|
|
|
@ -38,22 +38,22 @@ module.exports = function (theModule, ignoreKeys) {
|
|
|
|
|
|
|
|
|
|
function wrapCallback(origFn, callbackFn) {
|
|
|
|
|
return async function wrapperCallback(...args) {
|
|
|
|
|
if (arguments.length && typeof arguments[arguments.length - 1] === 'function') {
|
|
|
|
|
if (args.length && typeof args[args.length - 1] === 'function') {
|
|
|
|
|
const cb = args.pop();
|
|
|
|
|
args.push((err, res) => (res !== undefined ? cb(err, res) : cb(err)));
|
|
|
|
|
return callbackFn.apply(null, args);
|
|
|
|
|
return callbackFn(...args);
|
|
|
|
|
}
|
|
|
|
|
return origFn.apply(null, arguments);
|
|
|
|
|
return origFn(...args);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function wrapPromise(origFn, promiseFn) {
|
|
|
|
|
return function wrapperPromise(...args) {
|
|
|
|
|
if (arguments.length && typeof arguments[arguments.length - 1] === 'function') {
|
|
|
|
|
return origFn.apply(null, args);
|
|
|
|
|
if (args.length && typeof args[args.length - 1] === 'function') {
|
|
|
|
|
return origFn(...args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return promiseFn.apply(null, arguments);
|
|
|
|
|
return promiseFn(...args);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|