From 18efd30a263ec0d79a26a82cbd8c90c9f81056b7 Mon Sep 17 00:00:00 2001 From: Minteck Date: Mon, 28 Nov 2022 17:14:38 +0100 Subject: Open source --- node_modules/async/compose.js | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 node_modules/async/compose.js (limited to 'node_modules/async/compose.js') diff --git a/node_modules/async/compose.js b/node_modules/async/compose.js new file mode 100644 index 0000000..d4ce989 --- /dev/null +++ b/node_modules/async/compose.js @@ -0,0 +1,55 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = compose; + +var _seq = require('./seq.js'); + +var _seq2 = _interopRequireDefault(_seq); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Creates a function which is a composition of the passed asynchronous + * functions. Each function consumes the return value of the function that + * follows. Composing functions `f()`, `g()`, and `h()` would produce the result + * of `f(g(h()))`, only this version uses callbacks to obtain the return values. + * + * If the last argument to the composed function is not a function, a promise + * is returned when you call it. + * + * Each function is executed with the `this` binding of the composed function. + * + * @name compose + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {...AsyncFunction} functions - the asynchronous functions to compose + * @returns {Function} an asynchronous function that is the composed + * asynchronous `functions` + * @example + * + * function add1(n, callback) { + * setTimeout(function () { + * callback(null, n + 1); + * }, 10); + * } + * + * function mul3(n, callback) { + * setTimeout(function () { + * callback(null, n * 3); + * }, 10); + * } + * + * var add1mul3 = async.compose(mul3, add1); + * add1mul3(4, function (err, result) { + * // result now equals 15 + * }); + */ +function compose(...args) { + return (0, _seq2.default)(...args.reverse()); +} +module.exports = exports['default']; \ No newline at end of file -- cgit