![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
object-recursive-filter
Advanced tools
Module to recursively filter-in or filter-out object properties based on the provided predicate.
This module can be used to recursively perform filter-in or filter-out operations on object properties based on the provided predicate. The module returns a new copy of the object so the original is not mutated.
The module doesn't have any external dependencies (only tape to run the tests).
You can install with [npm]:
$ npm install --save object-recursive-filter
The module provides two self described functions: filterOutBy and filterInBy. Both require two parameters:
A common use case might be to remove the undefined or null values in an object:
// Example1: Remove the undefined or null values
const orf = require('object-recursive-filter')
const countries = {
Colombia: { code: 'co', area: 1197411 },
Argentina: { code: 'ar', area: 2766890 },
canada: { code: 'ca', area: 9984670 },
NonExistingCountry: undefined,
Brasil: { code: 'br', area: 8511965 },
anotherNonExisting: null,
europe: {
France: {code: 'fr', area: 551394},
NonEuropeanCountry: null
}
}
orf.filterOutBy(countries, x => !x);
// Returns
// { Colombia: { code: 'co', area: 1197411 },
// Argentina: { code: 'ar', area: 2766890 },
// canada: { code: 'ca', area: 9984670 },
// Brasil: { code: 'br', area: 8511965 },
// europe: { France: { code: 'fr', area: 551394 } } }
You can run the tests and check the functionality of this module using:
$ npm install && npm test
Copyright © 2018, Juan Convers. Released under the MIT License.
FAQs
Module to recursively filter-in or filter-out object properties based on the provided predicate.
The npm package object-recursive-filter receives a total of 1 weekly downloads. As such, object-recursive-filter popularity was classified as not popular.
We found that object-recursive-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.