Files
Inyeccion_Dashboard/node_modules/pipe-functions/lib/pipe.js
2025-11-20 15:27:34 -06:00

18 lines
428 B
JavaScript

'use strict';
const pipe = (...fns) => fns.length === 1 ? fns[0].constructor === Function ? fns[0]() : fns[0] : fns.reduce((v, f, i) => {
if (i === 1 && v && v.constructor === Function) {
let exec = v();
if (exec && exec.then) {
return exec.then(v => f(v));
} else {
return f(exec);
}
} else if (v && v.then) {
return v.then(v => f(v));
} else {
return f(v);
}
});
module.exports = pipe;