[nodejs] Request for Feedback: asyncscript

2012-12-11 Thread Jonathan Dickinson
Hi All, I just started my first foray into javascript beyond the usual minimal glue I was used with browsers. After looking at some node tutorials the first thing I noticed was the CPS hell (honestly, no way in hell I am dealing with that ;)). I present an extremely rough draft of asyncscript;

Re: [nodejs] Request for Feedback: asyncscript

2012-12-11 Thread Jonathan Dickinson
> maintaining code that looks different from more idiomatic JS) to the table. > > F > > On Monday, December 10, 2012, Jonathan Dickinson wrote: > >> Hi All, >> >> I just started my first foray into javascript beyond the usual minimal >> glue I was used with b

Re: [nodejs] "this" and that

2012-12-11 Thread Jonathan Dickinson
'that' would also introduce a closure, where the exclusive use of 'this' wouldn't - at least naively (compilers may optimize this). It's nit-picking but it makes the GCs job ever so slightly easier. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/

Re: [nodejs] Re: A simple implementation of fs.write(fd, buffer, offset, length, position, [callback])

2012-12-11 Thread Jonathan Dickinson
Superior alternative being this I assume: http://blog.marksoper.net/Server-side-DOM-manipulation-in-Nodejs-with-JSDOM-JQuery-and-Mustache-Templates-April-25-2011.html - just to make sure this thread gets closed off with a real answer. Newbies also make the mistake of thinking that structured da

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Jonathan Dickinson
You can do it with .bind(). I assume that the 1...n arguments of .bind() are often overlooked. var fs = require('fs'); function onStat(file, err, stat) { if (stat.isFile()) { //fs.readFile(...)... WHICH FILE console.log(file); // This file } } var files = [ "E:\\site

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Jonathan Dickinson
t's what leads to the 'if') > parameters given to it for that purpose, and since the API functions > are possibly called millions of times per second, the decision was > made to burden the code using node.js instead of node.js. > > > > > On Wed, De

[nodejs] Re: Good error messages: Method's file location without stacktrace

2012-12-13 Thread Jonathan Dickinson
It looks like you can only do it with errors: (new Error()).stack Taking require() as an example (if you were in control of it) you would make require() add the stack trace to the module before any code in the module executes. Now within the context of the B load you find out that it is a cycl

Re: [nodejs] preferred license for node modules?

2012-12-14 Thread Jonathan Dickinson
On Saturday, 15 December 2012 06:38:14 UTC+2, Raynos wrote: > I have zero dependencies on GPL modules for that reason and won't use any > npm modules that are under the GPL licence. > > This brings up a good point: we should maybe be able to blacklist licenses in the NPM client. If you want to w

[nodejs] Re: How would you do this: schedule events

2012-12-16 Thread Jonathan Dickinson
If you care about failure resilience at all: 1. You will need a pseudoqueue in SQL (or whatever) with a datetime field indicating when the event needs to fire. 2. Every, say, 5 minutes (settimeout) query SQL for anything that needs to happen in the next, say, 6 minutes. 3. Calculate the differen