diff options
Diffstat (limited to 'desktop/node_modules/axios/lib/helpers/callbackify.js')
-rw-r--r-- | desktop/node_modules/axios/lib/helpers/callbackify.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/desktop/node_modules/axios/lib/helpers/callbackify.js b/desktop/node_modules/axios/lib/helpers/callbackify.js new file mode 100644 index 0000000..4603bad --- /dev/null +++ b/desktop/node_modules/axios/lib/helpers/callbackify.js @@ -0,0 +1,16 @@ +import utils from "../utils.js"; + +const callbackify = (fn, reducer) => { + return utils.isAsyncFn(fn) ? function (...args) { + const cb = args.pop(); + fn.apply(this, args).then((value) => { + try { + reducer ? cb(null, ...reducer(value)) : cb(null, value); + } catch (err) { + cb(err); + } + }, cb); + } : fn; +} + +export default callbackify; |