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 => {
// ...
})
)
npm install --save pull-property
# with yarn
yarn add pull-property
A through stream that takes and gives objects, replacing a certain property on them.
name
: The property you are mapping (resolved byobject-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)