Just passed all tests for the changes I've done to node.js -- I have
to say the code is now much cleaner just by these simple changes.
http://github.com/rsms/node/tree/callbacks
Basically, what's happening is this:
function someFunction(arg0, arg1) {
return someCall(arg0, arg1).addCallback(function(arg) {
// continue on success branch
}).addErrback(function(err) {
// continue on error branch
});
}
becomes
function someFunction(arg0, arg1, callback) {
return someCall(arg0, arg1, function(err, arg) {
if (err) // continue on error branch
else // continue on success branch
});
}
I've already ported the module loading code (and some of the fs
functions, naturally).
--
Rasmus Andersson
Sorry, I've already done it. The one remaining piece is the multipart
library. I would like help with that.
What is the return value of "someCall"?
Kris Kowal
Yikes. So, 4 hours spend in vain :(
Have you deprecated *Sync methods?
IMHO there's no longer any need for them, as an absent callback would
indicate sync operation (as per the process.fs C++ implementation).
// truncate(fd, [mode=(0777^umask)], [callback])
exports.mkdir = function (path, mode, callback) {
if (typeof mode === 'function') {
callback = mode;
mode = undefined;
}
if (mode === undefined)
mode = 0777 ^ process.umask();
return process.fs.mkdir(path, mode, callback);
};
debug("looking for " + JSON.stringify(id) + " in " + JSON.stringify(paths));
become:
if (debugLevel > 0)
debug("looking for " + JSON.stringify(id) + " in " + JSON.stringify(paths));
--
Rasmus Andersson
- Micheil
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
It's in ry/master
>
> - Micheil
>
> On 20/02/2010, at 12:31 PM, r...@tinyclouds.org wrote:
>
>> On Fri, Feb 19, 2010 at 5:26 PM, Rasmus Andersson <ras...@notion.se> wrote:
>>> I've spend my Friday night starting to clean promises out of node (got
>>> a life? what's that? :P).
>>
>> Sorry, I've already done it. The one remaining piece is the multipart
>> library. I would like help with that.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "nodejs" group.
>> To post to this group, send email to nod...@googlegroups.com.
>> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>
--
Rasmus Andersson
What would you like done with the multipart lib? We talked about
making it a bit more SAXy, and removing the stream/http coupling,
which I'd definitely be willing to do.
--i
I already stripped out the promises. As a first step, it'd be great to
decouple it from HTTP so that the interface was
var p = new multipart.Parser();
req.addListener('data', function (d) { p.execute(d); }
req.addListener('end', function () { p.finish(); }
Because many people (myself included) only want a low-level interface
to file system operations that does not necessitate creating an
object, while many other people want something like promises but
different in one way or another. So instead of promises we'll use last
argument callbacks and consign the task of building better abstraction
layers to user libraries.
See http://groups.google.com/group/nodejs/msg/0c483b891c56fea2