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
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