📜  js promisify 在浏览器中 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:41.112000             🧑  作者: Mango

代码示例1
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);
    });
  };
};