package
Changes interface of asynchronous functions to Promises
npm install promisify-apiGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Changes interface of asynchronous functions to Promises. Functions should be designed using error-first callback pattern.
$ npm install promisify-apipromisify(fn, ctx, _)Creates a wrapper function, which returns Promises.
const fs = require('fs');
const resolve = require('path').resolve;
const promisify = require('promisify-api');
// the second argument (which is context) is optional
const readFile = promisify(fs.readFile, fs);
readFile(resolve('index.js'), 'utf8')
.then(console.log)
.catch(console.error);Arguments:
fn (function): The original function.ctx (*): Predefines execution context of the original function...._ (*): Possibility to provide additional arguments, that will be prepended to the function.The MIT License