npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

filter-obj-depth

2.0.1

@kevva

npmHomeRepoSnykSocket
Downloads:548
$ npm install filter-obj-depth
DailyWeeklyMonthlyYearly

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