Do you have a lot of callbacks but you like Promises more?
Have you written the same one function into many projects?
Would you like to use Async
more?
Just defer your callbacks!
npm i just-defer
const justDefer = require('just-defer');
const { promise, resolve, reject } = justDefer();
fs.readFile('/etc/passwd', (err, res) => {
if(err) return reject(err);
resolve(res);
});
const passwd = await promise;
console.log('passwd contents', passwd);
const justDefer = require('just-defer');
const { promise, callback } = justDefer();
fs.readFile('/etc/passwd', callback);
const passwd = await promise;
console.log('passwd contents', passwd);
Copyright (c) 2021, Michael Szmadzinski. (MIT License)