Skip to content

Commit 079f756

Browse files
committed
added writer-chaining section to readme + bumped version number
1 parent 9396dc7 commit 079f756

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,24 @@ ez.devices.file.text.reader('users.csv').transform(ez.transforms.csv.parser())
388388
}, ez.devices.file.text.writer('females.json'));
389389
```
390390
391+
<a name="writer-chaining"/>
392+
## Writer chaining
393+
394+
You can also chain operations on writers via a special `pre` property. For example:
395+
396+
``` javascript
397+
// create a binary file writer
398+
var rawWriter = ez.devices.file.binary.writer("data.gzip");
399+
// create another writer that applies a gzip transform before the file writer
400+
var zipWriter = rawWriter.pre.nodeTransform(zlib.createGzip());
401+
```
402+
403+
All the chainable operations available on readers (`map`, `filter`, `transform`, `nodeTransform`, ...)
404+
can also be applied to writers through this `pre` property.
405+
406+
Note: the `pre` property was introduced to stress the fact that the operation is applied _before_
407+
writing to the original writer, even though it appears _after_ in the chain.
408+
391409
<a name="backpressure"/>
392410
## Backpressure
393411

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ez-streams",
33
"description": "EZ streams for node.js",
4-
"version": "0.1.3",
4+
"version": "0.1.4",
55
"repository": {
66
"type": "git",
77
"url": "git://github.com/Sage/ez-streams.git"

0 commit comments

Comments
 (0)