Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem if the first argument of a callback is not error #13

Closed
clarkf opened this issue Mar 21, 2011 · 2 comments
Closed

Problem if the first argument of a callback is not error #13

clarkf opened this issue Mar 21, 2011 · 2 comments

Comments

@clarkf
Copy link

clarkf commented Mar 21, 2011

I recently tried using Step with path.exists, which doesn't pass an error argument as the first argument to the callback. Here's the script I tested:

var Step = require('step'),
    path = require('path');
var stuff = ['file1', 'file2', 'file3', 'file4'];
Step(
    function () {
        var group = this.group();
        stuff.forEach(function (item) {
            path.exists(item, group());
        });
    },
    function (err, list) {
        console.log(err);
        console.log(list);
    }
);

This should output null (or some other falsy value) for error, and an array containing false: [false, false, false, false]. Instead, we get:

$ node stepissue.js 
undefined
[ undefined, undefined, undefined, undefined ]

I don't think this is a version compatibility issue, but for good measure, I'm running Step 0.0.4, node 0.4.1 on Ubuntu 10.10.

@creationix
Copy link
Owner

Step explicitly only supports node style callbacks where it's (err, value). For some reason path.exists is an inconsistency in node that doesn't follow it's own pattern. You can wrap it in a new function that follows the pattern and use that wrapped function.

function pathExists(path, callback) {
  Path.exists(path, function (exists) {
    callback(null, exists);
  });
}

@olecom
Copy link

olecom commented Aug 29, 2014

Fix for EventEmitters: #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants