numberField
const numberField: <Row>(input) => MemoryFieldSpec<Row>;Defined in: filters/memory.ts:124
Allow-list a public field as a number filter over a row value read by path (a key, a dot
path, or a getter). between matches >= from and <= to; a bigint row value compares
numerically.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Row |
any |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ path: MemoryAccessor<Row>; } |
input.path |
MemoryAccessor<Row> |
Returns
Section titled “Returns”MemoryFieldSpec<Row>
Example
Section titled “Example”import { buildFilterPredicate, numberField } from "@xtandard/lib/filters/memory";
const { predicate } = buildFilterPredicate({ spec: { total: numberField({ path: (order: { cents: number }) => order.cents / 100 }) }, filters: [{ field: "total", filter: { kind: "number", operator: "between", from: 10, to: 20 } }],});predicate({ cents: 1999 }); // → truepredicate({ cents: 2001 }); // → false