apr-asyncify
v3.0.3
Published
Take a sync function and make it async. This is useful for plugging sync functions into a waterfall, series, or other async functions.
Downloads
12
Maintainers
Readme
asyncify
Take a sync function and make it async. This is useful for plugging sync functions into a waterfall
, series
, or other async functions.
Parameters
function
Function
Examples
import awaitify from 'apr-awaitify';
import asyncify from 'apr-asyncify';
import waterfall from 'apr-waterfall';
import apply from 'apr-apply';
const readFile = awaitify(require('fs').readFile);
const pkgPath = path.join(__dirname, './package.json');
const pkg = await waterfall([
apply(readFile, pkgPath, 'utf8'),
asyncify(JSON.parse)
]);
Returns Function