Launch Week Day 1:Rust Support in Socket Is Now Generally Available.Learn More
Socket
Book a DemoInstallSign in
Socket

deep-filter-object

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-filter-object

Return a deep copy of an object, recursively filtered to have only keys that match the given glob patterns.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

deep-filter-object NPM version

Return a deep copy of an object, recursively filtered to have only keys that match the given glob patterns.

Install with npm

npm i deep-filter-object --save

Usage

var deepFilter = require('deep-filter-object');

deepFilter({a: 'a', b: {a: 'a', b: {a: 'a', b: 'b', c: 'c'}}}, 'b');
//=> {b: {b: {b: 'b'}}}

Negation patterns:

deepFilter({foo: 'a', bar: {foo: 'a', bar: {foo: 'a', bar: 'b', baz: 'c'}}}, ['*', '!foo']);
//=> {bar: {bar: {bar: 'b', baz: 'c'}}}

Filter functions

deepFilter({a: 'a', b: 'b', c: 'c'}, function (value, key, obj, i) {
  return key === 'b';
});
//=> {b: 'b'}

deepFilter({a: 'a', b: {c: 'c', d: {e: {c: 'c', f: 'f'}}}, c: 'c'}, function (value, key, obj) {
  return key !== 'c';
});
//=> {a: 'a', b: {d: {e: {f: 'f'}}}}

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Run tests

Install dev dependencies:

npm i -d && npm test

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license

This file was generated by verb on January 19, 2015.

Keywords

filter

FAQs

Package last updated on 20 Jan 2015

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