Registry / database / filtr
library0.3.0jsnpmunverified

Array filtering for Node.js and the browser with a MongoDB-inspired query language. Version 0.3.0 (last stable). Provides comparators ($gt, $gte, $lt, $lte, $all, $exists, $mod, $eq, $ne, $in, $nin, $size) and traversables ($or, $nor, $and). Supports deep path matching, multiple output types (subset, boolean, index) and input modes (array, single). No dependencies. Early development stage with minimal maintenance.

npm install filtr
INSTALL
IMPORT
SIG · FILTR
F
filtr
databasejavascriptv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

filtr
import filtr from 'filtr'
const filtr = require('filtr')
Package is ESM-only? Actually it's CommonJS. Default export via require works.
filtr.getPathValue
import filtr from 'filtr'; filtr.getPathValue('d[0].e', data)
import { getPathValue } from 'filtr'
getPathValue is a method on the default export, not a named export.
filtr.comparators
import filtr from 'filtr'; filtr.comparators
import { comparators } from 'filtr'
comparators is a property on the default object.

Shows basic filtering with comparators, deep path matching, and getPathValue helper.

const filtr = require('filtr'); const query = filtr({ $gt: 15, $lt: 25 }); const results = query.test([5, 10, 17, 19, 25]); console.log(results); // [17, 19] // Deep path matching const data = [ { a: { b: 100 }, c: 'testC', d: [{ e: 'world' }] }, { a: { b: 50 }, c: 'testC', d: [{ e: 'universe' }, { e: 'galaxy' }] } ]; const query2 = filtr({ 'a.b': { $gt: 25, $lt: 75 }, 'd[0].e': { $eq: 'universe' } }); const res = query2.test(data); console.log(res); // [ second item ] // Get nested value const hello = filtr.getPathValue('d[0].e', data[1]); console.log(hello); // 'universe'
Debug
Known issues
gotchaThe `test` method's second argument is an options object; spec 'subset' returns matched items, 'boolean' returns booleans, 'index' returns indices. Default spec is 'subset'.
fix
Review options documentation and choose appropriate spec.
affects: >=0.0.0
gotchaDeep path matching uses dot notation for nested objects and bracket notation with index for arrays (e.g., 'd[0].e'). Ensure path strings match exactly.
fix
Use correct path syntax; e.g., 'a.b' for {a: {b: ...}}, 'arr[0].prop' for arrays.
affects: >=0.0.0
deprecatedPackage has not been updated since 2014. It's in maintenance mode with no active development.
fix
Consider alternatives like MongoDB's query engine or lodash's filter for modern applications.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'filtr'
filtr is not installed or not in node_modules.
fix
npm install filtr
filtr is not a function
Incorrect import: using default import instead of require.
fix
const filtr = require('filtr'); or import filtr from 'filtr';
Object doesn't support property or method 'test'
Using a non-function value as query; ensure filtr() returns an object with .test method.
fix
const query = filtr({ $gt: 15 }); query.test([1,20]);
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
packagefiltr
filtr — npm install filtr · libregistry