Allow to use promises along with callback #32
Description
Motivation
Suggestions from community:
Allow fh-sync-js to be promisified, by verifying and correcting api.
Provide promisified version of the api (separate for compatibility with the old one.
Quote from: #29
agree that we shouldn't mix promises in occasionally. The API should support one or the other, or both, but not a half-hearted mix. And for the record, promisify won't work with most sync (and other FH) functions, as they don't follow the standard single function (err, result) format.
That being said, my professional opinion is that you guys are going to be on the wrong side of history in callbacks vs promises. Most (popular, larger) libraries I see, if they support callbacks, generally support promises as well: if you provide a callback, it'll use that, otherwise it'll return a Promise. mongodb does this. It's really trivial if the inner workings of your library are promise-based, but mongodb also accomplishes it even though most of their internals are callback-based.
In my experience with people I've talked to, callbacks are generally deemed "legacy code" these days. There's a reason the mz library has nearly a million downloads per month. request-promise has double that. In addition to all the benefits of promises that Evan and I have probably stated ad nauseam, native async/await is just around the corner. Many shops have already been using them successfully with either Babel or TS, and callbacks-only API is completely incompatible with them."
Tasks
- Change callback definitions to in order to be promissified on demand.
- Provide promise based api