deep-filter-object
Return a deep copy of an object, recursively filtered to have only keys that match the given glob patterns.
Last updated 6 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install deep-filter-object 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

2 Versions

  • 1.0.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 8
This Month 8
Last Day 0
Last Week 14
Last Month 38
Dependencies (2)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |