Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zoubin/writable-stream-stack
make a node stream pipeline, new transforms can be pushed to apply before the data reaches the dest stream
https://github.com/zoubin/writable-stream-stack
Last synced: 8 days ago
JSON representation
make a node stream pipeline, new transforms can be pushed to apply before the data reaches the dest stream
- Host: GitHub
- URL: https://github.com/zoubin/writable-stream-stack
- Owner: zoubin
- Created: 2015-05-29T02:54:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-20T01:03:41.000Z (over 9 years ago)
- Last Synced: 2024-04-25T17:44:08.973Z (7 months ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# writable-stream-stack
Make a node stream pipeline. New transforms can be pushed to apply before the data reaches the dest stream## Usage
```javascript
var Stack = require('writable-stream-stack');
```### ws = Stack(dest)
### ws = Stack(tr1, tr2,..., dest)
### ws = Stack([tr1, tr2,..., dest])
`ws` is a `Writable` stream, and each chunk written in will reach the writable `dest`, before handled by the transform pipeline `tr1, tr2,...`### ws.on('done', cb)
`ws` fires `done` after `dest` has finished.### ws.push(tr)
Add transform `tr` to the very beginning of the pipeline.### ws.pop()
Delete the first transform from the pipeline.## Example
```javascript
var fs = require('fs');
var vfs = require('vinyl-fs');
var path = require('path');
var Stack = require('writable-stream-stack');
var source = require('vinyl-source-stream');var DEST = path.join(__dirname, 'files');
var dest = createDestStream('b.js', DEST)fs.createReadStream(path.join(__dirname, 'files/a.js'))
.pipe(dest);dest.on('done', function () {
fs.createReadStream(path.join(DEST, 'b.js'))
.pipe(process.stdout);
});function createDestStream(filename, dir) {
return Stack(
source(filename),
vfs.dest(dir)
);
}
```a.js:
```javascript
module.exports = function () {
console.log('a');
};
```output:
```
module.exports = function () {
console.log('a');
};
```