coleccionista
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -7,4 +7,4 @@ "use strict"; | ||
var Coleccionista = function(files, options) { | ||
if(!files.length) { | ||
var Coleccionista = function(filesOrStreams, options) { | ||
if(!filesOrStreams.length) { | ||
throw new Error('Files argument required'); | ||
@@ -15,3 +15,3 @@ } | ||
this.files = files; | ||
this.files = filesOrStreams; | ||
this.fileIndex = 0; | ||
@@ -26,3 +26,4 @@ this.o = options; | ||
end = (this.fileIndex === this.files.length-1), | ||
file = fs.createReadStream(this.files[this.fileIndex++], this.o); | ||
f = this.files[this.fileIndex++], | ||
file = typeof f === 'string' ? fs.createReadStream(f, this.o) : f; | ||
@@ -29,0 +30,0 @@ file |
{ | ||
"name": "coleccionista", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Helper class that streams files one by one.", | ||
@@ -5,0 +5,0 @@ "keywords": ["stream", "files", "collect"], |
# Coleccionista # | ||
Helper stream class that streams files one by one in one stream. | ||
Helper stream class that streams files or other streams one by one in one stream. | ||
## Events ## | ||
__itemstart__ — triggers when new file open | ||
__itemend__ — triggers when file stream end | ||
### Usage ### | ||
```js | ||
var Coleccionista = require('coleccionista'); | ||
var stream = new Coleccionista(filesOrStreams, options); | ||
//filesOrStreams — array of pathes to files or array of streams | ||
//options — options for file streams | ||
// now we can use it like usual stream | ||
stream.pipe(otherStream); | ||
``` | ||
### Additional events ### | ||
* __itemstart__ — triggers when new file open | ||
* __itemend__ — triggers when file stream end |
1863
34
21