@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.
15 lines (12 loc) • 348 B
text/typescript
type AtOptions<TRecord> = {
index: number;
records: Array<TRecord>;
};
/**
* @description
* Use this helper to retrieve the record at the specified index, or null if out of bounds.
*/
export const at = <TRecord>(options: AtOptions<TRecord>): TRecord | null => {
const { index, records } = options;
return records.at(index) ?? null;
};