Standard node.js best practices are to have the callback be the last parameter. This is especially important when using modified control flow (as is used by co or koa).
When using koa, having the final parameter be the callback allows us to promisify the library:
global.Promise = require('bluebird').Promise;
var Bing = Promise.promisifyAll(require('node-bing-api')({
'accKey': config.bingAccKey
}));
This then lets us yield the function call:
var results = yield Bing.imagesAsync(args.query, {'adult': 'Moderate'});
var body = results[1];
As this is a fairly significant breaking change, this will likely have to go out as a 2.0.0 release.
I also added a jsbeautify grunt task to help with code readability and consistency.
Standard node.js best practices are to have the callback be the last parameter. This is especially important when using modified control flow (as is used by co or koa).
When using koa, having the final parameter be the callback allows us to promisify the library:
This then lets us
yield
the function call:As this is a fairly significant breaking change, this will likely have to go out as a 2.0.0 release.
I also added a jsbeautify grunt task to help with code readability and consistency.