Registry / testing / arrayfilter

arrayfilter

JSON →
library1.1.2jsnpmunverified

A lightweight Node.js utility for filtering arrays by type, regex/string pattern, empty values, or duplicates. Version 1.1.2 (last updated in 2016) is the latest stable release. It provides functions like typeAccept, patternAccept, emptyReject, duplicateReject, and patternReject. Compared to lodash or ramda, it is minimal and focused on filtering only, but is no longer actively maintained. Suitable for small projects or legacy codebases running Node >=4.

npm install arrayfilter
INSTALL
IMPORT
SIG · ARRAYFILTER
A
arrayfilter
testingjavascriptv1.1.2
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.

arrayfilter
import arrayfilter from 'arrayfilter'
const { arrayfilter } = require('arrayfilter')
Default import is the only way; named imports are not supported.
typeAccept
const { typeAccept } = require('arrayfilter')
import { typeAccept } from 'arrayfilter'
In CommonJS, destructure from the exported object. ESM usage is not documented.
emptyReject
const emptyReject = require('arrayfilter').emptyReject
import emptyReject from 'arrayfilter'
The function is a method on the default export, not a default export itself.

Demonstrates creating filter functions with arrayfilter and applying them to an array.

const arrayfilter = require('arrayfilter'); // Creating filtering functions const acceptString = arrayfilter.typeAccept('string'); const rejectEmpty = arrayfilter.emptyReject(); const rejectDuplicates = arrayfilter.duplicateReject(); const acceptFo = arrayfilter.patternAccept(/^fo/); // Example array const data = ['foo', '', 123, 'bar', 'foo', null, 'foobar']; // Apply filters const filtered = data .filter(acceptString) .filter(rejectEmpty) .filter(rejectDuplicates) .filter(acceptFo); console.log(filtered); // Output: ['foobar']
Debug
Known issues
deprecatedProject is no longer actively maintained; last update in 2016.
fix
Consider using lodash's filter or native Array.filter with custom logic.
affects: >=1.0.0
gotchatypeAccept('number') will not filter NaN because typeof NaN === 'number' in JavaScript.
fix
Use patternAccept(/^[0-9]+$/) or additional NaN check if needed.
affects: >=1.0.0
gotchaduplicateReject uses strict equality (===) for comparison; objects and arrays are compared by reference, not deep equality.
fix
Use a deduplication library like lodash.uniqWith for deep comparison.
affects: >=1.0.0
gotchapatternAccept and patternReject treat string patterns as literal strings, not regex; pass a RegExp object for regex matching.
fix
Use arrayfilter.patternAccept(new RegExp('fo')) or /fo/.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: arrayfilter.typeAccept is not a function
Importing as a named export from an ESM context when the package exports a CommonJS default.
fix
Use const arrayfilter = require('arrayfilter'); then arrayfilter.typeAccept.
Cannot find module 'arrayfilter'
Package not installed or not in node_modules.
fix
Run 'npm install arrayfilter' in your project directory.
arrayfilter.duplicateReject is not a function
Typo: the correct name is 'duplicateReject' (duplicate vs duplicate).
fix
Use arrayfilter.duplicateReject() (note the 'c' in 'duplicate').
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
arrayfilter — npm install arrayfilter · libregistry