Socket
Socket
Sign inDemoInstall

filter-obj

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-obj

Filter object keys and values into a new object


Version published
Maintainers
1
Created

What is filter-obj?

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.

What are filter-obj's main functionalities?

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 }

Other packages similar to filter-obj

Keywords

FAQs

Package last updated on 23 Jul 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc