Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 2x 2x 2x 2x 2x 2x | "use strict"; /** * Calls a callback caller that calls a callback call for async instead of using promises. * * @param {Function} fn function to call * @param [args] arguments to call function with * @return {Promise} It returns a promise which resolves on callback call. */ function callback(fn, ...args) { return new Promise(function (resolve, reject) { function handler(err, result) { Iif (err) { reject(new Error(err)); } else { resolve(result); } } args.push(handler); fn(...args); }); } module.exports = callback; |