diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-12-21 22:46:53 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-12-21 22:46:53 +0800 |
| commit | f06956efd2dc4bf77244a9fcce2b883a00b925af (patch) | |
| tree | 0123cb73ce67f1f4b17e1d6cbabff076ee44e31b /node_modules/universalify/index.js | |
| parent | 8d980c13970c15b6d2312b6fc4ac51698dd0d220 (diff) | |
updated node modules
Diffstat (limited to 'node_modules/universalify/index.js')
| -rw-r--r-- | node_modules/universalify/index.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/node_modules/universalify/index.js b/node_modules/universalify/index.js index ba6c6626..233beac7 100644 --- a/node_modules/universalify/index.js +++ b/node_modules/universalify/index.js @@ -5,11 +5,8 @@ exports.fromCallback = function (fn) { if (typeof args[args.length - 1] === 'function') fn.apply(this, args) else { return new Promise((resolve, reject) => { - fn.call( - this, - ...args, - (err, res) => (err != null) ? reject(err) : resolve(res) - ) + args.push((err, res) => (err != null) ? reject(err) : resolve(res)) + fn.apply(this, args) }) } }, 'name', { value: fn.name }) @@ -19,6 +16,9 @@ exports.fromPromise = function (fn) { return Object.defineProperty(function (...args) { const cb = args[args.length - 1] if (typeof cb !== 'function') return fn.apply(this, args) - else fn.apply(this, args.slice(0, -1)).then(r => cb(null, r), cb) + else { + args.pop() + fn.apply(this, args).then(r => cb(null, r), cb) + } }, 'name', { value: fn.name }) } |
