mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
Major update breaking changes: - ESLint 7.0.0 (https://eslint.org/docs/user-guide/migrating-to-7.0.0) now includes .eslint.rc.js in its list, which is fine for us. Other changes are not applicable for us. - eslint-plugin-mocha (https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/CHANGELOG.md#700-may-13-2020) drops support for ESLint <7, but this CL updates to 7+. Other changes are not applicable for us. DISABLE_THIRD_PARTY_CHECK=Updating ESLint R=petermarshall@chromium.org Change-Id: I7760e084ef87f73a92f9ea4e075fb4c065047f5a Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2534873 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import _curry2 from "./internal/_curry2.js";
|
|
/**
|
|
* Builds a list from a seed value. Accepts an iterator function, which returns
|
|
* either false to stop iteration or an array of length 2 containing the value
|
|
* to add to the resulting list and the seed to be used in the next call to the
|
|
* iterator function.
|
|
*
|
|
* The iterator function receives one argument: *(seed)*.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.10.0
|
|
* @category List
|
|
* @sig (a -> [b]) -> * -> [b]
|
|
* @param {Function} fn The iterator function. receives one argument, `seed`, and returns
|
|
* either false to quit iteration or an array of length two to proceed. The element
|
|
* at index 0 of this array will be added to the resulting array, and the element
|
|
* at index 1 will be passed to the next call to `fn`.
|
|
* @param {*} seed The seed value.
|
|
* @return {Array} The final list.
|
|
* @example
|
|
*
|
|
* const f = n => n > 50 ? false : [-n, n + 10];
|
|
* R.unfold(f, 10); //=> [-10, -20, -30, -40, -50]
|
|
* @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...]
|
|
*/
|
|
|
|
var unfold =
|
|
/*#__PURE__*/
|
|
_curry2(function unfold(fn, seed) {
|
|
var pair = fn(seed);
|
|
var result = [];
|
|
|
|
while (pair && pair.length) {
|
|
result[result.length] = pair[0];
|
|
pair = fn(pair[1]);
|
|
}
|
|
|
|
return result;
|
|
});
|
|
|
|
export default unfold; |