MCPcopy
hub / github.com/rollup/rollup / nest

Function nest

cli/run/batchWarnings.ts:289–306  ·  view source on GitHub ↗
(array: readonly T[], property: string)

Source from the content-addressed store, hash-verified

287}
288
289function nest<T extends Record<string, any>>(array: readonly T[], property: string): Nested<T>[] {
290 const nested: Nested<T>[] = [];
291 const lookup = new Map<string, Nested<T>>();
292
293 for (const item of array) {
294 const key = item[property];
295 getOrCreate(lookup, key, () => {
296 const items = {
297 items: [],
298 key
299 };
300 nested.push(items);
301 return items;
302 }).items.push(item);
303 }
304
305 return nested;
306}
307
308function showTruncatedWarnings(warnings: readonly RollupLog[]): void {
309 const nestedByModule = nest(warnings, 'id');

Callers 2

PLUGIN_WARNINGFunction · 0.85
showTruncatedWarningsFunction · 0.85

Calls 2

getOrCreateFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…