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

Callback parameters do not follow convention #21

Open
ryneo opened this issue Aug 30, 2016 · 3 comments
Open

Callback parameters do not follow convention #21

ryneo opened this issue Aug 30, 2016 · 3 comments

Comments

@ryneo
Copy link

ryneo commented Aug 30, 2016

Your callback function parameters are reversed when compared to conventional pattern of callback(err, data){}. Wrapping the init function into a Promise erroneously returns an error since the data is being passed as the first parameter.

license.init('/path/to/package', function(licenseMap, err){
    if (!err) {
        console.log(licenseMap);
    }
});
@anacronw
Copy link
Member

ahh, I suppose it would be nice to be able to be compatible.

Can you send me an example of how you're using it with Promises?

@ryneo ryneo changed the title Callback parameters does not follow convention Callback parameters do not follow convention Aug 30, 2016
@ryneo
Copy link
Author

ryneo commented Aug 30, 2016

Here is an example of how I was using it. I used the Q promise library to wrap the callback into a promise.

var bowerLicense = require('bower-license');
var Q = require('q');

var licenseInit = Q.denodeify(bowerLicense.init);
licenseInit('path')
  .done(function (licenses) {
    // Do stuff with licenses
  });

@anacronw
Copy link
Member

I see, I will accept a PR if you make one

Its not an original goal of this project, but supporting it doesn't seem difficult at all

Thanks!

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

2 participants