mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 05:35:05 +08:00
DISABLE_THIRD_PARTY_CHECK=new npm module causes package-lock change We can get rid of a custom script and use ESLint for these rules. Additionally this means editors will highlight the issue in the editor. Change-Id: I552b52e7f07b4e7430b3f685dbc3b5fad36ffff2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2052167 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
import _curry2 from './internal/_curry2.js';
|
|
import _dispatchable from './internal/_dispatchable.js';
|
|
import _makeFlat from './internal/_makeFlat.js';
|
|
import _xchain from './internal/_xchain.js';
|
|
import map from './map.js';
|
|
|
|
/**
|
|
* `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));
|
|
}));
|
|
export default chain; |