MCPcopy Create free account
hub / github.com/d3/d3-array / reduce

Function reduce

src/reduce.js:1–14  ·  view source on GitHub ↗
(values, reducer, value)

Source from the content-addressed store, hash-verified

1export default function reduce(values, reducer, value) {
2 if (typeof reducer !== "function") throw new TypeError("reducer is not a function");
3 const iterator = values[Symbol.iterator]();
4 let done, next, index = -1;
5 if (arguments.length < 3) {
6 ({done, value} = iterator.next());
7 if (done) return;
8 ++index;
9 }
10 while (({done, value: next} = iterator.next()), !done) {
11 value = reducer(value, next, ++index, values);
12 }
13 return value;
14}

Callers 4

reduce-test.jsFile · 0.90
reducerFunction · 0.85
nestFunction · 0.85
groupSortFunction · 0.85

Calls 1

reducerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…