
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
filter-obj
Advanced tools
The filter-obj npm package allows users to filter the properties of an object based on specific criteria. This can be useful for creating subsets of an object, removing unwanted properties, or selectively copying properties based on dynamic conditions.
Filtering based on property names
This feature allows you to filter an object by specifying which property names to keep. It is useful for extracting specific properties from an object.
const filterObj = require('filter-obj');
const obj = { a: 1, b: '2', c: 3 };
const filtered = filterObj(obj, ['a', 'c']);
console.log(filtered); // Output: { a: 1, c: 3 }Filtering using a function
This feature enables filtering based on a function that takes key and value as arguments. It allows for more dynamic and condition-based filtering, such as filtering out properties based on their types or values.
const filterObj = require('filter-obj');
const obj = { a: 1, b: '2', c: 3 };
const filtered = filterObj(obj, (key, value) => typeof value === 'number');
console.log(filtered); // Output: { a: 1, c: 3 }lodash.pick is a method from the Lodash library that creates an object composed of the picked object properties. It is similar to filter-obj but is part of a larger utility library, which might be preferable for users who need other utility functions.
object-filter is another npm package that provides similar functionality to filter-obj, allowing filtering of object properties based on a predicate function. It compares to filter-obj in terms of functionality but might have different implementation details or additional options.
Filter object keys and values into a new object
npm install filter-obj
import {includeKeys, excludeKeys} from 'filter-obj';
const object = {
foo: true,
bar: false
};
const newObject = includeKeys(object, (key, value) => value === true);
//=> {foo: true}
const newObject2 = includeKeys(object, ['bar']);
//=> {bar: false}
const newObject = excludeKeys(object, (key, value) => value === true);
//=> {bar: false}
const newObject3 = excludeKeys(object, ['bar']);
//=> {foo: true}
Type: object
The source object to filter properties from.
Type: (sourceKey: string | symbol, sourceValue: unknown, source: object) => boolean
A predicate function that determines whether a property should be filtered.
Type: Array<string | symbol> | Set<string | symbol>
An array or Set of property keys to be filtered.
FAQs
Filter object keys and values into a new object
The npm package filter-obj receives a total of 8,144,001 weekly downloads. As such, filter-obj popularity was classified as popular.
We found that filter-obj 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.

Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.

Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.

Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.