Function: group()
group<
T,G>(predicates, …sources): { [K in string | number | symbol]: GroupValue<T, G[K]>[] }
Splits the concatenated sources into one array per named predicate. Consumes
the input once, routing each element to the FIRST predicate it satisfies (so
groups are disjoint); elements matching no predicate are dropped. Type-guard
predicates narrow their group’s element type (see GroupValue).
predicates leads so the sources can stay variadic.
Type Parameters
Section titled “Type Parameters”T
G extends GroupPredicates<T>
The map of group name -> predicate.
Parameters
Section titled “Parameters”predicates
Section titled “predicates”G
Named predicates; evaluated in declaration order.
sources
Section titled “sources”…readonly Source<T>[]
Containers to concatenate (nullish sources are skipped).
Returns
Section titled “Returns”{ [K in string | number | symbol]: GroupValue<T, G[K]>[] }
An object with the same keys, each an array of its group’s elements.
Example
Section titled “Example”const { strings, fns } = group({ strings: isString, fns: isFunction }, xs);