2.0.1 • Published 8 years ago

filter-obj-depth v2.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

filter-obj-depth Build Status

Filter object keys and values by depth into a new object

Install

$ npm install --save filter-obj-depth

Usage

const filterObjDepth = require('filter-obj-depth');

const obj = {
	a: {
		a: 'foo',
		b: {
			a: 'foo'
		}
	}
};

filterObjDepth(obj, 1);
//=> {a: {a: 'foo'}}

filterObjDepth(obj, (key, val, level, object) => level <= 1);
//=> {a: {a: 'foo'}}

License

MIT © Kevin Martensson