This file provides guidance when working with code in this repository.
Boxfan is a serializable JSON filter predicate library built on Remeda. Filter descriptors use allPass, anyPass, and nonePass keys (matching Remeda's naming). Descriptors are plain JSON, designed to be sent over the wire or stored in a database.
- Run tests:
pnpm test(vitest) - Watch tests:
pnpm test:watch - Build:
pnpm build(tsc → dist/) - Type-check:
pnpm typecheck
Exports both TS source (source condition) and compiled JS (import). Build runs automatically on prepublishOnly.
- src/index.ts — Single-module library. Exports
filterBy(default),buildPredicate,buildMatcher,matchContext, and typesFilterDescriptor,FilterInput. Internally builds predicate functions from JSON descriptors using Remeda'sallPass/anyPass. - test/boxfan.test.ts — Vitest tests covering allPass/anyPass/nonePass, wildcards, dot-path access, grouped OR, pipelines, matchContext, buildMatcher, and serialization round-trips.
- Filter descriptors are plain JSON objects — no function references, classes, or non-serializable values.
allPass,anyPass,nonePassare reserved keys.*is a reserved value (wildcard).- Dot-notation keys (e.g.
"meta.role") resolved via Remeda'sprop+stringToPath. - If the filter object has no reserved key, it is implicitly treated as
allPass. buildPredicatecompiles a descriptor once into a reusable predicate function.buildMatcherpre-compiles a collection's embedded filters for repeated context matching.