2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

feat(dns): added support for a custom lookup function; (#5339)

This commit is contained in:
Dmitriy Mozgovoy
2023-04-26 02:04:59 +03:00
committed by GitHub
parent e6f7053bf1
commit 2701911260
8 changed files with 129 additions and 4 deletions
+16
View File
@@ -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;