Skip to content

👜 Callbag operator that maps to object properties.

Notifications You must be signed in to change notification settings

Andarist/callbag-pluck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

👜 Callbag operator that maps to object properties.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published