MCPcopy Create free account
hub / github.com/blacksmithgu/datacore / expand

Method expand

src/api/data-array.ts:429–446  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

427 }
428
429 public expand(key: string): DataArray<unknown> {
430 let result = [];
431 let queue: unknown[] = ([] as unknown[]).concat(this.values);
432
433 while (queue.length > 0) {
434 let next = queue.pop();
435 let value = (next as Record<string, unknown>)[key];
436
437 if (value === undefined || value === null) continue;
438 if (Array.isArray(value)) value.forEach((v) => queue.push(v));
439 else if (value instanceof DataArrayImpl) value.forEach((v) => queue.push(v));
440 else queue.push(value);
441
442 result.push(next);
443 }
444
445 return this.lwrap(result);
446 }
447
448 public forEach(f: ArrayFunc<T, void>) {
449 for (let index = 0; index < this.values.length; index++) {

Callers

nothing calls this directly

Calls 3

lwrapMethod · 0.95
concatMethod · 0.65
forEachMethod · 0.65

Tested by

no test coverage detected