Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit aa51fba

Browse files
committed
feat(parallel-transform): allow passing of default optinos to .create
1 parent 5a82490 commit aa51fba

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ They may implement `_parallelFlush`, although this is not required.
4949

5050
### API
5151

52-
**ParallelTransform.create(transform, flush = function(done) { done(); })**
52+
**ParallelTransform.create(transform, flush = function(done) { done(); }, defaultOptions = {})**
5353

5454
* `transform` `<Function>` The \_transform function of the stream. See below for more details
5555
* `flush` `<Function>` The \_flush function of the stream. See below for more details
56+
* `defaultOptions` `<Object>` Default options for the class constructor
5657

5758
### API for extending ParallelTransform
5859

src/parallel-transform.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ export default class ParallelTransform extends stream.Transform {
3838
_ondrain.set(this, null);
3939
}
4040

41-
static create(transform, flush = done => done()) {
41+
static create(transform, flush = done => done(), defaultOptions = {}) {
4242
class Transform extends ParallelTransform {
43+
constructor(options) {
44+
super(Object.assign({}, defaultOptions, options));
45+
}
46+
4347
_parallelTransform = transform;
4448
_parallelFlush = flush;
4549
}

0 commit comments

Comments
 (0)