restart portfolio

This commit is contained in:
Tutur33
2023-12-05 18:45:50 +01:00
parent de25e0072a
commit 40db853637
1174 changed files with 21145 additions and 107608 deletions
+6 -6
View File
@@ -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 })
}