Follow standard node callback style and include `err` parameter.
chrisfosterelli opened this issue · comments
Since this is an asynchronous operation, this:
ls('grunt', '0.1.0', true, function(obj) { /* ... */ });
Should be:
ls('grunt', '0.1.0', true, function(err, obj) { /* ... */ });
If there is a network error, npm is down, there is no internet, or any other failure then there is no way to communicate that to the calling code. The calling code simply gets an empty list back, which it can't differentiate from a package with no dependencies. This module appears to sometimes print error messages directly to the console, which isn't an OK way to report errors.
Additionally, it's not possible to use anything like bluebird to promisify this library since bluebird expects callback-based code to follow standard node callbacks.
I recognize this would be a breaking change unfortunately, but is much more "node-y" and would improve the library to behave like most of the node ecosystem expects :)