Skip to content

ecrmnn/get-only

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-only

Filter keys in an array of objects

travis npm version npm downloads npm license prs Welcome eslint

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

Releases

No releases published

Packages

No packages published