• File: callbackify.js
  • Full Path: /var/www/nodejs/simo_meps_file_script/node_modules/axios/lib/helpers/callbackify.js
  • Date Modified: 02/28/2025 8:55 PM
  • File size: 372 bytes
  • MIME-type: text/x-java
  • Charset: utf-8
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;