MCPcopy
hub / github.com/axios/axios / callbackify

Function callbackify

lib/helpers/callbackify.js:3–16  ·  view source on GitHub ↗
(fn, reducer)

Source from the content-addressed store, hash-verified

1import utils from '../utils.js';
2
3const callbackify = (fn, reducer) => {
4 return utils.isAsyncFn(fn)
5 ? function (...args) {
6 const cb = args.pop();
7 fn.apply(this, args).then((value) => {
8 try {
9 reducer ? cb(null, ...reducer(value)) : cb(null, value);
10 } catch (err) {
11 cb(err);
12 }
13 }, cb);
14 }
15 : fn;
16};
17
18export default callbackify;

Callers 1

http.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected