get-only
v1.0.0
Published
Filter keys in an array of objects
Downloads
2
Readme
get-only
Filter keys in an array of objects
Installation
npm install get-only --save
Usage
const only = require('get-only');
const players = [{
firstname: 'Sadio',
lastname: 'Mané',
number: 19,
}, {
firstname: 'Mohamed',
lastname: 'Salah',
number: 11,
}, {
firstname: 'Roberto',
lastname: 'Firmino',
number: 9,
}];
only(players, ['lastname', 'number']);
//=> [{
//=> lastname: 'Mané',
//=> number: 19,
//=> }, {
//=> lastname: 'Salah',
//=> number: 11,
//=> }, {
//=> lastname: 'Firmino',
//=> number: 9,
//=> }];
Related
- collect.js - Dependency free wrapper for working with arrays and objects
License
MIT © Daniel Eckermann