Skip to content

Conversation

@wraugh
Copy link
Contributor

@wraugh wraugh commented Mar 16, 2019

I want to use split2 in pipelines where I can pass each transform the
same options object, e.g.

class MyTransform extends Transform {
    _transform (chunk, encoding, callback) {
    // ...
    }
}
var options = { highWaterMark: 1024 }
pump(split2(options), new MyTransform(options), process.stdout)

If split2 adds transform and flush properties to options, then
MyTransform will also set those options, and it won't behave as
expected.

To avoid this, we can use a shallow copy of options instead of
operating on the object directly.

I want to use split2 in pipelines where I can pass each transform the
same options object, e.g.

    class MyTransform extends Transform {
        _transform (chunk, encoding, callback) {
            // ...
        }
    }
    var options = { highWaterMark: 1024 }
    pump(split2(options), new MyTransform(options), process.stdout)

If split2 adds `transform` and `flush` properties to `options`, then
`MyTransform` will also set those options, and it won't behave as
expected.

To avoid this, we can use a shallow copy of `options` instead of
operating on the object directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants