browserify / browserify/stream-splicer

splice(index, howMany) doesn't pipe the remaining streams correctly, splice(index, howMany, through) does

Open
#3 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
56
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Based on how Array.splice works, I expected to be able to just call `splice(index, howMany)` to remove an entry from the pipeline. However, if you don't pass a stream the splice fails to correctly call pipe on the remaining streams. Example case:

``` js
var through = require('through2'),
splicer = require('labeled-stream-splicer');

function log() {
return through.obj(function(o, enc, onDone) {
console.log(o);
this.push(o);
onDone();
});
}

console.log('splice(label, 1)');

var s1 = splicer.obj([
log(),
'foo', log(),
log()
]);

s1.splice('foo', 1);

s1.write('hello 1');

console.log('splice(label, 1, through)');

var s2 = splicer.obj([
log(),
'foo', log(),
log()
]);

s2.splice('foo', 1, through.obj());

s2.write('hello 2');
```

Output:

```
splice(label)
hello 1
splice(label, through)
hello 2
hello 2
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.