Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Andarist/callbag-pluck
👜 Callbag operator that maps to object properties.
https://github.com/Andarist/callbag-pluck
callbag callbags
Last synced: 3 months ago
JSON representation
👜 Callbag operator that maps to object properties.
- Host: GitHub
- URL: https://github.com/Andarist/callbag-pluck
- Owner: Andarist
- Created: 2018-04-30T08:43:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-11T20:29:06.000Z (over 6 years ago)
- Last Synced: 2024-10-20T06:23:08.303Z (3 months ago)
- Topics: callbag, callbags
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-callbags - pluck
README
# callbag-pluck
Callbag operator that maps to object properties. It intentionally doesn't support default values and expects that path exists (nested property access is not "safe").
## Examples
### Single prop
```js
import fromIter from 'callbag-from-iter'
import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import pluck from 'callbag-pluck'pipe(
fromIter([{ name: 'Jurek' }, { name: 'John' }, { name: 'Sherlock' }]),
pluck('name'),
forEach(data => {
// will log 'Jurek', 'John', 'Sherlock'
console.log(data)
}),
)
```### Multiple nested properties
```js
import fromIter from 'callbag-from-iter'
import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import pluck from 'callbag-pluck'pipe(
fromIter([
{ some: { nested: { path: 'Apple' } } },
{ some: { nested: { path: 'Banana' } } },
{ some: { nested: { path: 'Orange' } } },
]),
pluck(['some', 'nested', 'path']),
forEach(data => {
// will log 'Apple', 'Banana', 'Orange'
console.log(data)
}),
)
```## Alternatives
* [callbag-map-delve](https://github.com/jaw977/callbag-map-delve)