CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
callbackify.js17 linesDownload Raw Back to helpers
1import utils from "../utils.js";2 3const callbackify = (fn, reducer) => {4  return utils.isAsyncFn(fn) ? function (...args) {5    const cb = args.pop();6    fn.apply(this, args).then((value) => {7      try {8        reducer ? cb(null, ...reducer(value)) : cb(null, value);9      } catch (err) {10        cb(err);11      }12    }, cb);13  } : fn;14}15 16export default callbackify;17