callbag-pluck

1.0.0 • Public • Published

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)
  }),
)

Alternatives

Readme

Keywords

Package Sidebar

Install

npm i callbag-pluck

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.43 kB

Total Files

4

Last publish

Collaborators

  • andarist