Sha256: 0620a325ae38f0eeaf28c0ec789863e793973d89e71c70759aec771de5436865

Contents?: true

Size: 1.52 KB

Versions: 21

Compression:

Stored size: 1.52 KB

Contents

'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = compose;

var _seq = require('./seq');

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'];

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
appmap-0.72.2 ./node_modules/async/compose.js
appmap-0.72.1 ./node_modules/async/compose.js
appmap-0.72.0 ./node_modules/async/compose.js
appmap-0.71.0 ./node_modules/async/compose.js
appmap-0.70.2 ./node_modules/async/compose.js
appmap-0.70.1 ./node_modules/async/compose.js
appmap-0.70.0 ./node_modules/async/compose.js
appmap-0.69.0 ./node_modules/async/compose.js
appmap-0.68.2 ./node_modules/async/compose.js
appmap-0.68.1 ./node_modules/async/compose.js
appmap-0.68.0 ./node_modules/async/compose.js
appmap-0.67.1 ./node_modules/async/compose.js
appmap-0.67.0 ./node_modules/async/compose.js
appmap-0.66.2 ./node_modules/async/compose.js
appmap-0.66.1 ./node_modules/async/compose.js
appmap-0.66.0 ./node_modules/async/compose.js
appmap-0.65.1 ./node_modules/async/compose.js
appmap-0.65.0 ./node_modules/async/compose.js
appmap-0.64.0 ./node_modules/async/compose.js
appmap-0.63.0 ./node_modules/async/compose.js