https://github.com/ecrmnn/get-only
Filter keys in an array of objects
https://github.com/ecrmnn/get-only
array filter keys objects pluck
Last synced: about 2 months ago
JSON representation
Filter keys in an array of objects
- Host: GitHub
- URL: https://github.com/ecrmnn/get-only
- Owner: ecrmnn
- License: mit
- Created: 2018-03-03T19:07:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-03T19:11:40.000Z (about 7 years ago)
- Last Synced: 2025-02-09T06:27:35.890Z (4 months ago)
- Topics: array, filter, keys, objects, pluck
- Language: JavaScript
- Homepage: https://npmjs.com/get-only
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# get-only
> Filter keys in an array of objects[](https://travis-ci.org/ecrmnn/get-only/builds)
[](http://badge.fury.io/js/get-only)
[](http://badge.fury.io/js/get-only)
[](http://badge.fury.io/js/get-only)
[](http://makeapullrequest.com)
[](https://github.com/airbnb/javascript)### Installation
```bash
npm install get-only --save
```### Usage
```javascript
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](https://github.com/ecrmnn/collect.js) - Dependency free wrapper for working with arrays and objects### License
MIT © [Daniel Eckermann](http://danieleckermann.com)