CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
compose.js55 linesDownload Raw Back to async
1'use strict';2 3Object.defineProperty(exports, "__esModule", {4    value: true5});6exports.default = compose;7 8var _seq = require('./seq.js');9 10var _seq2 = _interopRequireDefault(_seq);11 12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }13 14/**15 * Creates a function which is a composition of the passed asynchronous16 * functions. Each function consumes the return value of the function that17 * follows. Composing functions `f()`, `g()`, and `h()` would produce the result18 * of `f(g(h()))`, only this version uses callbacks to obtain the return values.19 *20 * If the last argument to the composed function is not a function, a promise21 * is returned when you call it.22 *23 * Each function is executed with the `this` binding of the composed function.24 *25 * @name compose26 * @static27 * @memberOf module:ControlFlow28 * @method29 * @category Control Flow30 * @param {...AsyncFunction} functions - the asynchronous functions to compose31 * @returns {Function} an asynchronous function that is the composed32 * asynchronous `functions`33 * @example34 *35 * function add1(n, callback) {36 *     setTimeout(function () {37 *         callback(null, n + 1);38 *     }, 10);39 * }40 *41 * function mul3(n, callback) {42 *     setTimeout(function () {43 *         callback(null, n * 3);44 *     }, 10);45 * }46 *47 * var add1mul3 = async.compose(mul3, add1);48 * add1mul3(4, function (err, result) {49 *     // result now equals 1550 * });51 */52function compose(...args) {53    return (0, _seq2.default)(...args.reverse());54}55module.exports = exports.default;
basant307/AI_Governance_Project · CoolFace