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

Method groupIn

src/api/data-array.ts:350–363  ·  view source on GitHub ↗
(key: ArrayFunc<LowestKey<T>, U>, comparator?: ArrayComparator<U>)

Source from the content-addressed store, hash-verified

348 }
349
350 public groupIn<U>(key: ArrayFunc<LowestKey<T>, U>, comparator?: ArrayComparator<U>): DataArray<Ingrouped<U, T>> {
351 if (Groupings.isGrouping(this.values)) {
352 return this.map((v) => {
353 return {
354 key: (v as GroupElement<unknown>).key,
355 rows: this.lwrap((v as GroupElement<unknown>).rows)
356 .groupIn(key as ArrayFunc<unknown, unknown>)
357 .array(),
358 } as Ingrouped<U, T>;
359 });
360 } else {
361 return this.groupBy(key as ArrayFunc<T, U>, comparator) as DataArray<Ingrouped<U, T>>;
362 }
363 }
364
365 public distinct<U>(key?: ArrayFunc<T, U>, comparator?: ArrayComparator<U>): DataArray<T> {
366 if (this.values.length == 0) return this;

Callers

nothing calls this directly

Calls 5

mapMethod · 0.95
lwrapMethod · 0.95
groupByMethod · 0.95
arrayMethod · 0.65
groupInMethod · 0.65

Tested by

no test coverage detected