update
This commit is contained in:
parent
d9becc67b6
commit
9308795b8b
964 changed files with 104265 additions and 16 deletions
62
node_modules/ramda/src/chain.js
generated
vendored
Normal file
62
node_modules/ramda/src/chain.js
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
var _curry2 =
|
||||
/*#__PURE__*/
|
||||
require("./internal/_curry2");
|
||||
|
||||
var _dispatchable =
|
||||
/*#__PURE__*/
|
||||
require("./internal/_dispatchable");
|
||||
|
||||
var _makeFlat =
|
||||
/*#__PURE__*/
|
||||
require("./internal/_makeFlat");
|
||||
|
||||
var _xchain =
|
||||
/*#__PURE__*/
|
||||
require("./internal/_xchain");
|
||||
|
||||
var map =
|
||||
/*#__PURE__*/
|
||||
require("./map");
|
||||
/**
|
||||
* `chain` maps a function over a list and concatenates the results. `chain`
|
||||
* is also known as `flatMap` in some libraries.
|
||||
*
|
||||
* Dispatches to the `chain` method of the second argument, if present,
|
||||
* according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain).
|
||||
*
|
||||
* If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`.
|
||||
*
|
||||
* Acts as a transducer if a transformer is given in list position.
|
||||
*
|
||||
* @func
|
||||
* @memberOf R
|
||||
* @since v0.3.0
|
||||
* @category List
|
||||
* @sig Chain m => (a -> m b) -> m a -> m b
|
||||
* @param {Function} fn The function to map with
|
||||
* @param {Array} list The list to map over
|
||||
* @return {Array} The result of flat-mapping `list` with `fn`
|
||||
* @example
|
||||
*
|
||||
* const duplicate = n => [n, n];
|
||||
* R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3]
|
||||
*
|
||||
* R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1]
|
||||
*/
|
||||
|
||||
|
||||
var chain =
|
||||
/*#__PURE__*/
|
||||
_curry2(
|
||||
/*#__PURE__*/
|
||||
_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) {
|
||||
if (typeof monad === 'function') {
|
||||
return function (x) {
|
||||
return fn(monad(x))(x);
|
||||
};
|
||||
}
|
||||
|
||||
return _makeFlat(false)(map(fn, monad));
|
||||
}));
|
||||
|
||||
module.exports = chain;
|
Loading…
Add table
Add a link
Reference in a new issue