UNPKG
@extra-array/accumulate
Version:
latest (2.10.19)
2.10.19
2.10.18
2.10.17
2.10.16
2.10.15
2.10.14
2.10.13
2.10.12
2.10.11
2.10.10
2.10.9
2.10.8
2.10.7
2.10.6
2.10.5
2.10.4
2.10.2
2.10.1
2.10.0
2.9.64
2.9.63
2.9.62
2.9.61
2.9.60
2.9.59
2.9.58
2.9.57
2.9.56
2.9.55
2.9.54
2.9.53
2.9.52
2.9.51
2.9.50
2.9.49
2.9.48
2.9.47
2.9.46
2.9.45
2.9.44
2.9.43
2.9.42
2.9.41
2.9.40
2.9.39
2.9.38
2.9.37
2.9.36
2.9.12
2.9.11
2.9.10
2.9.9
2.9.8
2.9.7
2.9.6
2.9.5
2.9.4
2.9.3
2.9.2
2.9.1
2.9.0
2.8.76
2.8.75
2.8.74
2.8.73
2.8.72
2.8.71
2.8.70
2.8.69
2.8.67
2.8.66
2.8.65
2.8.64
2.8.63
2.8.62
2.8.61
2.8.60
2.8.59
2.8.58
2.8.57
2.8.56
2.8.55
2.8.54
2.8.53
2.8.52
2.8.51
2.8.50
2.8.49
2.8.48
2.8.47
2.8.46
2.8.45
2.8.44
2.8.43
2.8.42
2.8.41
2.8.40
2.8.39
2.8.38
2.8.37
2.8.36
2.8.35
2.8.34
2.8.33
2.8.32
2.8.31
2.8.30
2.8.29
2.8.28
2.8.27
2.8.26
2.8.25
2.8.23
2.8.22
2.8.21
2.8.20
2.8.19
2.8.18
2.8.17
2.8.16
2.8.15
2.8.14
2.8.13
2.8.12
2.8.11
2.8.10
2.8.9
2.8.8
2.8.7
2.8.6
2.8.5
2.8.4
Produces accumulating values.
github.com/nodef/extra-array
nodef/extra-array
@extra-array/accumulate
/
index.mjs
17 lines
(16 loc)
•
341 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function
accumulate
(
x, fr, acc
)
{
var
init
= arguments.length <=
2
;
var
a = [], i =
-1
;
for
(
var
v of x) {
if
(
init
) { acc = v; ++i;
init
=
false
; }
else
acc = fr(acc, v, ++i, x); a.push(acc); }
return
a; } export { accumulate
as
default
};