Answers for "js promisify in browser"

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language