nodemw
nodemw copied to clipboard
support promises
every function could return a Promise if no callback are passed :
const promise = bot.getCategories('foo')
@MathieuDerelle you can use bluebird's promisifyAll, I am using it and works like a charm, for example:
var clientEs = new bot({
protocol: 'https', // Wikipedia now enforces HTTPS
server: lang + '.wikipedia.org', // host name of MediaWiki-powered site
path: '/w', // path to api.php script
debug: false // is more verbose when set to true
});
Promise.promisifyAll( clientEs );
clientEs.getPagesInCategoryAsync(category)
.then(function(data) {
console.log(JSON.stringify(data.map(function(el) {
return el.title;
})));
});
I'm on it
@KilianKilmister, welcome on board :) Looking forward to your commits.