Travis build: 1402
This commit is contained in:
24
README.md
24
README.md
@ -134,6 +134,7 @@ average(1, 2, 3);
|
||||
* [`pullAtIndex`](#pullatindex)
|
||||
* [`pullAtValue`](#pullatvalue)
|
||||
* [`reducedFilter`](#reducedfilter)
|
||||
* [`reduceSuccessive`](#reducesuccessive)
|
||||
* [`remove`](#remove)
|
||||
* [`sample`](#sample)
|
||||
* [`sampleSize`](#samplesize)
|
||||
@ -1693,6 +1694,29 @@ reducedFilter(data, ['id', 'name'], item => item.age > 24); // [{ id: 2, name: '
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### reduceSuccessive
|
||||
|
||||
Applies a function against an accumulator and each element in the array (from left to right), returning an array of successively reduced values.
|
||||
|
||||
Use `Array.reduce()` to apply the given function to the given array, storing each new result.
|
||||
|
||||
```js
|
||||
const reduceSuccessive = (arr, fn, acc) =>
|
||||
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
reduceSuccessive([1, 2, 3, 4, 5, 6], (acc, val) => acc + val, 0); // [0, 1, 3, 6, 10, 15, 21]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### remove
|
||||
|
||||
Removes elements from an array for which the given function returns `false`.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -6,9 +6,7 @@ Use `Array.reduce()` to apply the given function to the given array, storing eac
|
||||
|
||||
```js
|
||||
const reduceSuccessive = (arr, fn, acc) =>
|
||||
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)),res), [
|
||||
acc,
|
||||
]);
|
||||
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user