D (Dict)
Dict<A> is Record<string, A>.
Non-dual
Section titled “Non-dual”keys<A>(d: Dict<A>): string[]values<A>(d: Dict<A>): A[]toEntries<A>(d: Dict<A>): [string, A][]fromEntries<A>(entries: [string, A][]): Dict<A>isEmpty<A>(d: Dict<A>): booleanget<A>(d: Dict<A>, key: string): A | undefinedmap<A, B>(d: Dict<A>, f: (a: A, key: string) => B): Dict<B>filter<A>(d: Dict<A>, pred: (a: A, key: string) => boolean): Dict<A>merge<A>(a: Dict<A>, b: Dict<A>): Dict<A>Examples
Section titled “Examples”import { pipe, A, D } from '@stopcock/fp'
// count items per categoryconst counts = pipe( A.groupBy(products, p => p.category), D.map(items => items.length),)// { electronics: 12, clothing: 8 }
// merge config layersconst config = pipe( defaults, D.merge(envOverrides), D.merge(cliFlags),)
// filter out empty groupspipe( grouped, D.filter(items => items.length > 0),)
// build lookup tableconst byId = D.fromEntries( users.map(u => [u.id, u]),)