object-filters
Filter object by keys. For node.js 6.x or higher
install
npm i --save object-filters
usage
// add filters as prototype to use in all objectsObjectprototypefilters = filters const obj = firstname: 'John' lastname: 'Snow' email: 'iknownothing@snow.com' address: castle: 'Black' region: 'North' // return a new object, without alter previous objconst filtered = obj // filtered is now firstname: 'John' lastname: 'Snow'
The method filters
works with:
// strings separated by spaceobj
// array of stringsobj
// negative stringsobj // or obj.filters(['-email', '-address'])
// nested objectobj