MCPcopy
hub / github.com/idank/explainshell / map

Function map

explainshell/web/static/js/d3.v3.js:254–277  ·  view source on GitHub ↗
(mapType, array, depth)

Source from the content-addressed store, hash-verified

252 d3.nest = function() {
253 var nest = {}, keys = [], sortKeys = [], sortValues, rollup;
254 function map(mapType, array, depth) {
255 if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;
256 var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;
257 while (++i < n) {
258 if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
259 values.push(object);
260 } else {
261 valuesByKey.set(keyValue, [ object ]);
262 }
263 }
264 if (mapType) {
265 object = mapType();
266 setter = function(keyValue, values) {
267 object.set(keyValue, map(mapType, values, depth));
268 };
269 } else {
270 object = {};
271 setter = function(keyValue, values) {
272 object[keyValue] = map(mapType, values, depth);
273 };
274 }
275 valuesByKey.forEach(setter);
276 return object;
277 }
278 function entries(map, depth) {
279 if (depth >= keys.length) return map;
280 var array = [], sortKey = sortKeys[depth++];

Callers 2

group_continuousFunction · 0.85
d3.v3.jsFile · 0.85

Calls 1

callMethod · 0.45

Tested by

no test coverage detected