Editor
Ready
Output
A composable TypeScript filter system for querying and evaluating in-memory data. Provides a structured way to build complex query conditions that can be evaluated against entities.
npm install tsfiltor
This package is built with dual module support (ESM + CommonJS) for maximum compatibility:
The package automatically serves the correct format:
import { ... } from 'tsfiltor' → ESM (browsers, modern Node.js, bundlers)const { ... } = require('tsfiltor') → CommonJS (React Native, older tools)The package works in browsers via CDN. Use esm.sh or similar CDN:
<script type="module">
import { eq, gt, filterEntities } from 'https://esm.sh/tsfiltor@latest';
// Use the library...
</script>
Edit the code below and click "Run" to see the results. The package is loaded from npm via esm.sh CDN.
eq(field, value) - Equalityne(field, value) - Not equallt(field, value) - Less thanlte(field, value) - Less than or equalgt(field, value) - Greater thangte(field, value) - Greater than or equalcontains(field, value) - String/array containsstartsWith(field, value) - String starts withendsWith(field, value) - String ends withmatches(field, pattern) - Regex pattern matchanyOf(field, values[]) - Value is in arrayminLength(field, n) - Minimum lengthmaxLength(field, n) - Maximum lengthisRecord(field) - Is plain object/RecordmatchesZodSchema(field, schema) - Matches Zod schemaand(...conditions) - All conditions must matchor(...conditions) - Any condition must matchnot(condition) - Negate conditionevaluateCondition(entity, condition) - Evaluate condition against entityfilterEntities(entities, filter?) - Filter array of entitiesfindFirst(entities, filter?) - Find first matching entitymatchExists(entities, filter?) - Check if any entity matchescountWhere(entities, filter?) - Count matching entitiesfindWhere(entities, options?) - Find with pagination supportenableArrayExtensions(options?) - Enable Array prototype extensionsdisableArrayExtensions() - Disable Array prototype extensionsregisterOperator(operator, evaluator) - Register custom operatorUnlicense - This is free and unencumbered software released into the public domain.
For more information, see unlicense.org