Answers for "js promisify"

0

promisify

const util = require('util');
const fs = require('fs');

const stat = util.promisify(fs.stat);
stat('.').then((stats) => {
  // Do something with `stats`
}).catch((error) => {
  // Handle the error.
});
Posted by: Guest on October-04-2020
0

js promisify in browser

function promisify(func, callbackPos=null) {
  return (...args) => {
    return new Promise((resolve) => {
      const cb = (...args) => {
        resolve(args);
      };
      args.splice(callbackPos != null ? callbackPos : args.length, 0, cb);
      func(...args);
    });
  };
};
Posted by: Guest on October-10-2020
0

js promisify function

return new Promise((resolve, reject) => {});
Posted by: Guest on September-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language