Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

node promisify without err

function promisify(func, callbackPos) {
  return (...args) => {
    return new Promise((resolve) => {
      const cb = (...args) => {
        resolve(args);
      };
      args.splice(callbackPos ? callbackPos : args.length, 0, cb);
      func(...args);
    });
  };
};
 
PREVIOUS NEXT
Tagged: #node #promisify #err
ADD COMMENT
Topic
Name
6+6 =