Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonkemp/pluck-util
Extract a list of property values from a collection
https://github.com/jonkemp/pluck-util
array map object pluck util utility
Last synced: 26 days ago
JSON representation
Extract a list of property values from a collection
- Host: GitHub
- URL: https://github.com/jonkemp/pluck-util
- Owner: jonkemp
- License: mit
- Created: 2020-02-17T15:03:44.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-24T03:42:18.000Z (over 2 years ago)
- Last Synced: 2024-04-10T14:07:59.444Z (7 months ago)
- Topics: array, map, object, pluck, util, utility
- Language: JavaScript
- Size: 153 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pluck-util ![Build Status](https://github.com/jonkemp/pluck-util/actions/workflows/main.yml/badge.svg?branch=master)
> Extract a list of property values from a collection.
A convenient version of what is perhaps the most common use-case for map.
Inspired by `_.pluck`. 😄
## Install
Install with [npm](https://npmjs.org/package/pluck-util)
```
$ npm install pluck-util
```Or [unpkg](https://unpkg.com/pluck-util/)
```
```
Check out the unit tests on [CodePen](https://codepen.io/jonkemp/full/KKpzYzz).
## Usage
```js
const pluck = require('pluck-util');const stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
pluck(stooges, 'name');
//=> ['moe', 'larry', 'curly']pluck(stooges, 'age');
//=> [40, 50, 60]
```---
| **Like us a lot?** Help others know why you like us! **Review this package on [pkgreview.dev](https://pkgreview.dev/npm/pluck-util)** | âž¡ | [![Review us on pkgreview.dev](https://i.ibb.co/McjVMfb/pkgreview-dev.jpg)](https://pkgreview.dev/npm/pluck-util) |
| ----------------------------------------------------------------------------------------------------------------------------------------- | --- | --------------------------------------------------------------------------------------------------------------------- |## API
### pluck(collection, propertyName)
#### collection
Type: `array`
Default: `none`The array to iterate over.
#### propertyName
Type: `string`
Default: `none`The property name to extract.
## License
MIT