Registry / database / weiliddat-sift

weiliddat-sift

JSON →
library18.3.1jsnpmunverified

sift is a lightweight JavaScript library for performing MongoDB-style query filtering on arrays and individual values. Version 18.3.1 (current stable) is actively maintained, supports Node.js >= 18, and ships TypeScript definitions. Key differentiators: tiny bundle size, tree-shakable, supports all standard MongoDB query operators ($in, $regex, $elemMatch, etc.), works in browsers and Node.js, and allows custom operations. Unlike MongoDB drivers, sift runs client-side for filtering in-memory data. The library is ESM-first and has no dependencies.

npm install weiliddat-sift
INSTALL
IMPORT
SIG · WEILIDDAT-SIFT
W
weiliddat-sift
databasejavascriptv18.3.1
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.

sift
import sift from 'sift'
const sift = require('sift')
ESM-only since v18. If using CommonJS, use dynamic import or upgrade to Node >= 18.
createQueryTester
import { createQueryTester } from 'sift'
import { createQueryTester } from 'sift' (correct usage)
Named export for creating a query tester without built-in operations.
$eq, $in
import { $eq, $in } from 'sift'
const { $eq, $in } = require('sift');
Named exports for operators; require() will not work in ESM-only environment.

Demonstrates filtering arrays and objects using MongoDB-style $gt and $gte operators with ESM import.

import sift from 'sift'; const numbers = [1, 2, 3, 4, 5, 6]; const greaterThanThree = sift({ $gt: 3 }); const result = numbers.filter(greaterThanThree); console.log(result); // [4, 5, 6] // Filtering objects const data = [ { name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }, ]; const adults = data.filter(sift({ age: { $gte: 18 } })); console.log(adults); // [ { name: 'Alice', age: 30 }, { name: 'Bob', age: 25 } ]
Debug
Known issues
breakingsift v18 is ESM-only and requires Node >= 18.
fix
Update Node.js to >= 18 and use import instead of require(). For CommonJS projects, consider dynamic import() or stay on v16.x.
affects: >=18.0.0
deprecatedThe default export sift() now returns a function that operates on single values; earlier versions had different behavior.
fix
No change needed if using current API. Refer to docs for usage with arrays via .filter().
affects: >=16.0.0
gotchasift v18 ships TypeScript types, but some complex MongoDB queries (e.g., $expr) are not supported.
fix
Use only supported operators listed in documentation. For unsupported queries, consider using a different library or MongoDB aggregation.
affects: >=18.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Trying to require('sift') in a CommonJS project with Node >= 18.
fix
Use dynamic import: const sift = await import('sift'); or switch to import syntax in an ESM context.
TypeError: sift is not a function
Importing incorrectly, e.g., import { sift } from 'sift' instead of default import.
fix
Use default import: import sift from 'sift'; for the main filtering function.
Upgrade
Version history
18.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
20
Meta
2
OpenAI (training)
1
Resources
weiliddat-sift — npm install weiliddat-sift · libregistry