source: node_modules/ramda-adjunct/lib/seq.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6/* eslint-disable max-len */
7/**
8 * Runs the given list of functions in order with the supplied object, then returns the object.
9 * Also known as the normal order sequencing combinator.
10 *
11 * Acts as a transducer if a transformer is given as second parameter.
12 *
13 * @func seq
14 * @aliases sequencing
15 * @memberOf RA
16 * @since {@link https://char0n.github.io/ramda-adjunct/2.3.0|v2.3.0}
17 * @category Function
18 * @sig [(a -> *), (a -> *), ...] -> a -> a
19 * @param {Array} fns The list of functions to call in order with `x` whose return values will be thrown away
20 * @param {*} x
21 * @return {*} `x`
22 * @see {@link http://ramdajs.com/docs/#tap|R.tap}, {@link http://www.cs.rpi.edu/academics/courses/spring11/proglang/handouts/lambda-calculus-chapter.pdf|sequencing combinator explained}
23 * @example
24 *
25 * RA.seq([console.info, console.log])('foo'); //=> prints 'foo' via info then log
26 *
27 * // usage in composition
28 * R.pipe(
29 * R.concat('prefix '),
30 * RA.seq([
31 * console.info, //=> prints 'prefix test'
32 * console.log //=> prints 'prefix test'
33 * ]),
34 * R.toUpper
35 * )('test'); //=> 'PREFIX TEST'
36 */
37/* eslint-enable max-len */
38var seq = (0, _ramda.curry)(function (fns, x) {
39 return (0, _ramda.tap)(function (tx) {
40 return (0, _ramda.map)(function (fn) {
41 return fn(tx);
42 })(fns);
43 })(x);
44});
45var _default = seq;
46exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.