pull-prop

0.3.0 • Public • Published

pull-prop

Map an object's property with a stream

pull(
  values([
    { foo: { bar: 123 } },
    { foo: { bar: 321 } },
    { foo: { bar: 333 } }
  ]),
  prop('foo.bar', () => pull(
    map(bar => bar * 3)
  ))
  drain(obj => {
    // ...
  })
)

Install

npm install --save pull-property
 
# with yarn 
yarn add pull-property

Usage

prop(name, transform)

A through stream that takes and gives objects, replacing a certain property on them.

  • name: The property you are mapping (resolved by object-path)
  • transform: A function that returns a through stream, which maps the property

An psuedo example with pull-files:

pull(
  read('lib/**/*.js'),
  // Map `data` with buf -> buf streams:
  prop('data', () => pull(
    map(babel.transformSync),
    map(uglify.compileSync),
    // ...
  )),
  write('out', err => {
    if (err) throw err
  })
)

Maintained by Jamen Marz (See on Twitter and GitHub for questions & updates)

Package Sidebar

Install

npm i pull-prop

Weekly Downloads

0

Version

0.3.0

License

none

Last publish

Collaborators

  • npm