@future-widget-lab/record-set
Version:
A dedicated data structure for in-memory record collections, offering fluent, immutable APIs for MongoDB-like querying, sorting, and transformation.
18 lines (17 loc) • 630 B
TypeScript
type SelectOptions<TRecord> = {
spec: string | string[] | Record<string, 0 | 1>;
records: Array<TRecord>;
};
/**
* @description
* Use this helper to project each record to include or exclude fields, returning a new record set of records with only those keys:
* - String: `'a b -c +d'`.
* - Array of strings: `['a', '-b']`.
* - Object notation: `{ a: 1, b: 1 }` or `{ c: 0 }`.
*
* Inclusive if any field is positively specified (no `-` or `0`).
*
* Exclusive if only negatives (`-`) or zeros (`0`).
*/
export declare const select: <TRecord>(options: SelectOptions<TRecord>) => Array<Partial<TRecord>>;
export {};