Skip to content

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 Parameter Default type
Row any
Parameter Type
input { path: MemoryAccessor<Row>; }
input.path MemoryAccessor<Row>

MemoryFieldSpec<Row>

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 }); // → true
predicate({ cents: 2001 }); // → false