1.0.0 • Published 6 years ago
callbag-pluck v1.0.0
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
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
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)
}),
)