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

Function nest

src/group.js:48–65  ·  view source on GitHub ↗
(values, map, reduce, keys)

Source from the content-addressed store, hash-verified

46}
47
48function nest(values, map, reduce, keys) {
49 return (function regroup(values, i) {
50 if (i >= keys.length) return reduce(values);
51 const groups = new InternMap();
52 const keyof = keys[i++];
53 let index = -1;
54 for (const value of values) {
55 const key = keyof(value, ++index, values);
56 const group = groups.get(key);
57 if (group) group.push(value);
58 else groups.set(key, [value]);
59 }
60 for (const [key, values] of groups) {
61 groups.set(key, regroup(values, i));
62 }
63 return map(groups);
64 })(values, 0);
65}

Callers 6

groupFunction · 0.85
groupsFunction · 0.85
rollupFunction · 0.85
rollupsFunction · 0.85
indexFunction · 0.85
indexesFunction · 0.85

Calls 2

reduceFunction · 0.85
mapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…