pax_global_header00006660000000000000000000000064134660554200014517gustar00rootroot0000000000000052 comment=5298bece5aba2cf4d2f5ec84c4fc128572c41cee node-combined-stream-1.0.8/000077500000000000000000000000001346605542000155215ustar00rootroot00000000000000node-combined-stream-1.0.8/.gitignore000066400000000000000000000001111346605542000175020ustar00rootroot00000000000000*.un~ *.log /node_modules /test/tmp yarn.lock Vim swap files .*.sw[a-z] node-combined-stream-1.0.8/.npmignore000066400000000000000000000001051346605542000175140ustar00rootroot00000000000000.gitignore .npmignore .travis.yml Makefile *.un~ /node_modules /test node-combined-stream-1.0.8/.travis.yml000066400000000000000000000001221346605542000176250ustar00rootroot00000000000000language: node_js node_js: - "0.10" - "0.12" - "4" - "6" - "8" - "10" node-combined-stream-1.0.8/License000066400000000000000000000020751346605542000170320ustar00rootroot00000000000000Copyright (c) 2011 Debuggable Limited Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-combined-stream-1.0.8/Makefile000066400000000000000000000000711346605542000171570ustar00rootroot00000000000000SHELL := /bin/bash test: @./test/run.js .PHONY: test node-combined-stream-1.0.8/Readme.md000066400000000000000000000107071346605542000172450ustar00rootroot00000000000000# combined-stream A stream that emits multiple other streams one after another. **NB** Currently `combined-stream` works with streams version 1 only. There is ongoing effort to switch this library to streams version 2. Any help is welcome. :) Meanwhile you can explore other libraries that provide streams2 support with more or less compatibility with `combined-stream`. - [combined-stream2](https://www.npmjs.com/package/combined-stream2): A drop-in streams2-compatible replacement for the combined-stream module. - [multistream](https://www.npmjs.com/package/multistream): A stream that emits multiple other streams one after another. ## Installation ``` bash npm install combined-stream ``` ## Usage Here is a simple example that shows how you can use combined-stream to combine two files into one: ``` javascript var CombinedStream = require('combined-stream'); var fs = require('fs'); var combinedStream = CombinedStream.create(); combinedStream.append(fs.createReadStream('file1.txt')); combinedStream.append(fs.createReadStream('file2.txt')); combinedStream.pipe(fs.createWriteStream('combined.txt')); ``` While the example above works great, it will pause all source streams until they are needed. If you don't want that to happen, you can set `pauseStreams` to `false`: ``` javascript var CombinedStream = require('combined-stream'); var fs = require('fs'); var combinedStream = CombinedStream.create({pauseStreams: false}); combinedStream.append(fs.createReadStream('file1.txt')); combinedStream.append(fs.createReadStream('file2.txt')); combinedStream.pipe(fs.createWriteStream('combined.txt')); ``` However, what if you don't have all the source streams yet, or you don't want to allocate the resources (file descriptors, memory, etc.) for them right away? Well, in that case you can simply provide a callback that supplies the stream by calling a `next()` function: ``` javascript var CombinedStream = require('combined-stream'); var fs = require('fs'); var combinedStream = CombinedStream.create(); combinedStream.append(function(next) { next(fs.createReadStream('file1.txt')); }); combinedStream.append(function(next) { next(fs.createReadStream('file2.txt')); }); combinedStream.pipe(fs.createWriteStream('combined.txt')); ``` ## API ### CombinedStream.create([options]) Returns a new combined stream object. Available options are: * `maxDataSize` * `pauseStreams` The effect of those options is described below. ### combinedStream.pauseStreams = `true` Whether to apply back pressure to the underlaying streams. If set to `false`, the underlaying streams will never be paused. If set to `true`, the underlaying streams will be paused right after being appended, as well as when `delayedStream.pipe()` wants to throttle. ### combinedStream.maxDataSize = `2 * 1024 * 1024` The maximum amount of bytes (or characters) to buffer for all source streams. If this value is exceeded, `combinedStream` emits an `'error'` event. ### combinedStream.dataSize = `0` The amount of bytes (or characters) currently buffered by `combinedStream`. ### combinedStream.append(stream) Appends the given `stream` to the combinedStream object. If `pauseStreams` is set to `true, this stream will also be paused right away. `streams` can also be a function that takes one parameter called `next`. `next` is a function that must be invoked in order to provide the `next` stream, see example above. Regardless of how the `stream` is appended, combined-stream always attaches an `'error'` listener to it, so you don't have to do that manually. Special case: `stream` can also be a String or Buffer. ### combinedStream.write(data) You should not call this, `combinedStream` takes care of piping the appended streams into itself for you. ### combinedStream.resume() Causes `combinedStream` to start drain the streams it manages. The function is idempotent, and also emits a `'resume'` event each time which usually goes to the stream that is currently being drained. ### combinedStream.pause(); If `combinedStream.pauseStreams` is set to `false`, this does nothing. Otherwise a `'pause'` event is emitted, this goes to the stream that is currently being drained, so you can use it to apply back pressure. ### combinedStream.end(); Sets `combinedStream.writable` to false, emits an `'end'` event, and removes all streams from the queue. ### combinedStream.destroy(); Same as `combinedStream.end()`, except it emits a `'close'` event instead of `'end'`. ## License combined-stream is licensed under the MIT license. node-combined-stream-1.0.8/lib/000077500000000000000000000000001346605542000162675ustar00rootroot00000000000000node-combined-stream-1.0.8/lib/combined_stream.js000066400000000000000000000111171346605542000217610ustar00rootroot00000000000000var util = require('util'); var Stream = require('stream').Stream; var DelayedStream = require('delayed-stream'); module.exports = CombinedStream; function CombinedStream() { this.writable = false; this.readable = true; this.dataSize = 0; this.maxDataSize = 2 * 1024 * 1024; this.pauseStreams = true; this._released = false; this._streams = []; this._currentStream = null; this._insideLoop = false; this._pendingNext = false; } util.inherits(CombinedStream, Stream); CombinedStream.create = function(options) { var combinedStream = new this(); options = options || {}; for (var option in options) { combinedStream[option] = options[option]; } return combinedStream; }; CombinedStream.isStreamLike = function(stream) { return (typeof stream !== 'function') && (typeof stream !== 'string') && (typeof stream !== 'boolean') && (typeof stream !== 'number') && (!Buffer.isBuffer(stream)); }; CombinedStream.prototype.append = function(stream) { var isStreamLike = CombinedStream.isStreamLike(stream); if (isStreamLike) { if (!(stream instanceof DelayedStream)) { var newStream = DelayedStream.create(stream, { maxDataSize: Infinity, pauseStream: this.pauseStreams, }); stream.on('data', this._checkDataSize.bind(this)); stream = newStream; } this._handleErrors(stream); if (this.pauseStreams) { stream.pause(); } } this._streams.push(stream); return this; }; CombinedStream.prototype.pipe = function(dest, options) { Stream.prototype.pipe.call(this, dest, options); this.resume(); return dest; }; CombinedStream.prototype._getNext = function() { this._currentStream = null; if (this._insideLoop) { this._pendingNext = true; return; // defer call } this._insideLoop = true; try { do { this._pendingNext = false; this._realGetNext(); } while (this._pendingNext); } finally { this._insideLoop = false; } }; CombinedStream.prototype._realGetNext = function() { var stream = this._streams.shift(); if (typeof stream == 'undefined') { this.end(); return; } if (typeof stream !== 'function') { this._pipeNext(stream); return; } var getStream = stream; getStream(function(stream) { var isStreamLike = CombinedStream.isStreamLike(stream); if (isStreamLike) { stream.on('data', this._checkDataSize.bind(this)); this._handleErrors(stream); } this._pipeNext(stream); }.bind(this)); }; CombinedStream.prototype._pipeNext = function(stream) { this._currentStream = stream; var isStreamLike = CombinedStream.isStreamLike(stream); if (isStreamLike) { stream.on('end', this._getNext.bind(this)); stream.pipe(this, {end: false}); return; } var value = stream; this.write(value); this._getNext(); }; CombinedStream.prototype._handleErrors = function(stream) { var self = this; stream.on('error', function(err) { self._emitError(err); }); }; CombinedStream.prototype.write = function(data) { this.emit('data', data); }; CombinedStream.prototype.pause = function() { if (!this.pauseStreams) { return; } if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause(); this.emit('pause'); }; CombinedStream.prototype.resume = function() { if (!this._released) { this._released = true; this.writable = true; this._getNext(); } if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume(); this.emit('resume'); }; CombinedStream.prototype.end = function() { this._reset(); this.emit('end'); }; CombinedStream.prototype.destroy = function() { this._reset(); this.emit('close'); }; CombinedStream.prototype._reset = function() { this.writable = false; this._streams = []; this._currentStream = null; }; CombinedStream.prototype._checkDataSize = function() { this._updateDataSize(); if (this.dataSize <= this.maxDataSize) { return; } var message = 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'; this._emitError(new Error(message)); }; CombinedStream.prototype._updateDataSize = function() { this.dataSize = 0; var self = this; this._streams.forEach(function(stream) { if (!stream.dataSize) { return; } self.dataSize += stream.dataSize; }); if (this._currentStream && this._currentStream.dataSize) { this.dataSize += this._currentStream.dataSize; } }; CombinedStream.prototype._emitError = function(err) { this._reset(); this.emit('error', err); }; node-combined-stream-1.0.8/package.json000066400000000000000000000012001346605542000200000ustar00rootroot00000000000000{ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "combined-stream", "description": "A stream that emits multiple other streams one after another.", "version": "1.0.8", "homepage": "https://github.com/felixge/node-combined-stream", "repository": { "type": "git", "url": "git://github.com/felixge/node-combined-stream.git" }, "main": "./lib/combined_stream", "scripts": { "test": "node test/run.js" }, "engines": { "node": ">= 0.8" }, "dependencies": { "delayed-stream": "~1.0.0" }, "devDependencies": { "far": "~0.0.7" }, "license": "MIT" } node-combined-stream-1.0.8/test/000077500000000000000000000000001346605542000165005ustar00rootroot00000000000000node-combined-stream-1.0.8/test/common.js000066400000000000000000000007511346605542000203310ustar00rootroot00000000000000var common = module.exports; var path = require('path'); var fs = require('fs'); var root = path.join(__dirname, '..'); common.dir = { fixture: root + '/test/fixture', tmp: root + '/test/tmp', }; // Create tmp directory if it does not exist // Not using fs.exists so as to be node 0.6.x compatible try { fs.statSync(common.dir.tmp); } catch (e) { // Dir does not exist fs.mkdirSync(common.dir.tmp); } common.CombinedStream = require(root); common.assert = require('assert'); node-combined-stream-1.0.8/test/fixture/000077500000000000000000000000001346605542000201665ustar00rootroot00000000000000node-combined-stream-1.0.8/test/fixture/file1.txt000066400000000000000000000504001346605542000217260ustar00rootroot0000000000000010101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 10101010101010101010101010101010101010101010101010101010101010101010101010101010 01010101010101010101010101010101010101010101010101010101010101010101010101010101 node-combined-stream-1.0.8/test/fixture/file2.txt000066400000000000000000000504001346605542000217270ustar00rootroot0000000000000020202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 20202020202020202020202020202020202020202020202020202020202020202020202020202020 02020202020202020202020202020202020202020202020202020202020202020202020202020202 node-combined-stream-1.0.8/test/integration/000077500000000000000000000000001346605542000210235ustar00rootroot00000000000000node-combined-stream-1.0.8/test/integration/test-callback-streams.js000066400000000000000000000015231346605542000255470ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var fs = require('fs'); var FILE1 = common.dir.fixture + '/file1.txt'; var FILE2 = common.dir.fixture + '/file2.txt'; var EXPECTED = fs.readFileSync(FILE1) + fs.readFileSync(FILE2); var written; (function testDelayedStreams() { var combinedStream = CombinedStream.create(); combinedStream.append(function(next) { next(fs.createReadStream(FILE1)); }); combinedStream.append(function(next) { next(fs.createReadStream(FILE2)); }); var tmpFile = common.dir.tmp + '/combined.txt'; var dest = fs.createWriteStream(tmpFile); combinedStream.pipe(dest); dest.on('close', function() { written = fs.readFileSync(tmpFile, 'utf8'); }); })(); process.on('exit', function () { assert.strictEqual(written, EXPECTED); }); node-combined-stream-1.0.8/test/integration/test-data-size.js000066400000000000000000000020331346605542000242150ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; (function testDataSizeGetter() { var combinedStream = CombinedStream.create(); assert.strictEqual(combinedStream.dataSize, 0); // Test one stream combinedStream._streams.push({dataSize: 10}); combinedStream._updateDataSize(); assert.strictEqual(combinedStream.dataSize, 10); // Test two streams combinedStream._streams.push({dataSize: 23}); combinedStream._updateDataSize(); assert.strictEqual(combinedStream.dataSize, 33); // Test currentStream combinedStream._currentStream = {dataSize: 20}; combinedStream._updateDataSize(); assert.strictEqual(combinedStream.dataSize, 53); // Test currentStream without dataSize combinedStream._currentStream = {}; combinedStream._updateDataSize(); assert.strictEqual(combinedStream.dataSize, 33); // Test stream function combinedStream._streams.push(function() {}); combinedStream._updateDataSize(); assert.strictEqual(combinedStream.dataSize, 33); })(); node-combined-stream-1.0.8/test/integration/test-delayed-streams-and-buffers-and-strings.js000066400000000000000000000017701346605542000320470ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var fs = require('fs'); var FILE1 = common.dir.fixture + '/file1.txt'; var BUFFER = new Buffer('Bacon is delicious'); var FILE2 = common.dir.fixture + '/file2.txt'; var STRING = 'The € kicks the $\'s ass!'; var EXPECTED = fs.readFileSync(FILE1) + BUFFER + fs.readFileSync(FILE2) + STRING; var GOT; (function testDelayedStreams() { var combinedStream = CombinedStream.create(); combinedStream.append(fs.createReadStream(FILE1)); combinedStream.append(BUFFER); combinedStream.append(fs.createReadStream(FILE2)); combinedStream.append(function(next) { next(STRING); }); var tmpFile = common.dir.tmp + '/combined-file1-buffer-file2-string.txt'; var dest = fs.createWriteStream(tmpFile); combinedStream.pipe(dest); dest.on('close', function() { GOT = fs.readFileSync(tmpFile, 'utf8'); }); })(); process.on('exit', function() { assert.strictEqual(GOT, EXPECTED); }); node-combined-stream-1.0.8/test/integration/test-delayed-streams.js000066400000000000000000000017341346605542000254260ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var fs = require('fs'); var FILE1 = common.dir.fixture + '/file1.txt'; var FILE2 = common.dir.fixture + '/file2.txt'; var EXPECTED = fs.readFileSync(FILE1) + fs.readFileSync(FILE2); var GOT; (function testDelayedStreams() { var combinedStream = CombinedStream.create(); combinedStream.append(fs.createReadStream(FILE1)); combinedStream.append(fs.createReadStream(FILE2)); var stream1 = combinedStream._streams[0]; var stream2 = combinedStream._streams[1]; stream1.on('end', function() { assert.equal(stream2.dataSize, 0); }); var tmpFile = common.dir.tmp + '/combined.txt'; var dest = fs.createWriteStream(tmpFile); combinedStream.pipe(dest); dest.on('close', function() { GOT = fs.readFileSync(tmpFile, 'utf8'); }); })(); process.on('exit', function() { console.error(GOT.length, EXPECTED.length); assert.strictEqual(GOT, EXPECTED); }); node-combined-stream-1.0.8/test/integration/test-empty-string.js000066400000000000000000000013101346605542000247730ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var util = require('util'); var Stream = require('stream').Stream; var s = CombinedStream.create(); function StringStream(){ this.writable=true; this.str="" } util.inherits(StringStream,Stream); StringStream.prototype.write=function(chunk,encoding){ this.str+=chunk.toString(); this.emit('data',chunk); } StringStream.prototype.end=function(chunk,encoding){ this.emit('end'); } StringStream.prototype.toString=function(){ return this.str; } s.append("foo."); s.append(""); s.append("bar"); var ss = new StringStream(); s.pipe(ss); s.resume(); assert.equal(ss.toString(),"foo.bar"); node-combined-stream-1.0.8/test/integration/test-is-stream-like.js000066400000000000000000000010241346605542000251610ustar00rootroot00000000000000var fs = require('fs'); var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var FILE1 = common.dir.fixture + '/file1.txt'; var fileStream = fs.createReadStream(FILE1); var foo = function(){}; (function testIsStreamLike() { assert(! CombinedStream.isStreamLike(true)); assert(! CombinedStream.isStreamLike("I am a string")); assert(! CombinedStream.isStreamLike(7)); assert(! CombinedStream.isStreamLike(foo)); assert(CombinedStream.isStreamLike(fileStream)); })();node-combined-stream-1.0.8/test/integration/test-max-data-size.js000066400000000000000000000013261346605542000250040ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var fs = require('fs'); var FILE1 = common.dir.fixture + '/file1.txt'; var FILE2 = common.dir.fixture + '/file2.txt'; var EXPECTED = fs.readFileSync(FILE1) + fs.readFileSync(FILE2); (function testDelayedStreams() { var combinedStream = CombinedStream.create({pauseStreams: false, maxDataSize: 20736}); combinedStream.append(fs.createReadStream(FILE1)); combinedStream.append(fs.createReadStream(FILE2)); var gotErr = null; combinedStream.on('error', function(err) { gotErr = err; }); process.on('exit', function() { assert.ok(gotErr); assert.ok(gotErr.message.match(/bytes/)); }); })(); node-combined-stream-1.0.8/test/integration/test-pipe-memory-leak.js000066400000000000000000000021131346605542000255100ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var fs = require('fs'); var LARGE = common.dir.fixture + '/large.txt'; var FILE1 = common.dir.fixture + '/file1.txt'; var Readable = require('stream').Readable; var Writable = require('stream').Writable; var rss = process.memoryUsage().rss; var ws = Writable(); ws._write = function (chunk, enc, next) { setTimeout(function() { var rssDiff = process.memoryUsage().rss - rss; fs.unlink(LARGE, function(){}); assert.ok(rssDiff < totalSize); process.exit(); next(); }, 5000); return false; }; var rs = Readable(); var totalSize = 1024 * 1024 * 500; // 500MB var readBytes = 0; rs._read = function(n) { var buff = new Buffer(n); this.push(buff); readBytes += n; if (readBytes > totalSize) this.push(null); }; rs.pipe(fs.createWriteStream(LARGE)).on('finish', function() { var combinedStream = CombinedStream.create(); combinedStream.append(fs.createReadStream(FILE1)); combinedStream.append(fs.createReadStream(LARGE)); combinedStream.pipe(ws); });node-combined-stream-1.0.8/test/integration/test-recursion-append.js000066400000000000000000000004211346605542000256110ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var s = CombinedStream.create(); for (var i = 0; i < 1e4; i++) s.append('test'); // Shouldn't throw "RangeError: Maximum call stack size exceeded" s.resume(); node-combined-stream-1.0.8/test/integration/test-recursion-callback.js000066400000000000000000000004671346605542000261100ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var s = CombinedStream.create(); for (var i = 0; i < 1e4; i++) s.append(function (next) { next('test') }); // Shouldn't throw "RangeError: Maximum call stack size exceeded" s.resume(); node-combined-stream-1.0.8/test/integration/test-unpaused-streams.js000066400000000000000000000016371346605542000256450ustar00rootroot00000000000000var common = require('../common'); var assert = common.assert; var CombinedStream = common.CombinedStream; var fs = require('fs'); var FILE1 = common.dir.fixture + '/file1.txt'; var FILE2 = common.dir.fixture + '/file2.txt'; var EXPECTED = fs.readFileSync(FILE1) + fs.readFileSync(FILE2); (function testDelayedStreams() { var combinedStream = CombinedStream.create({pauseStreams: false}); combinedStream.append(fs.createReadStream(FILE1)); combinedStream.append(fs.createReadStream(FILE2)); var stream1 = combinedStream._streams[0]; var stream2 = combinedStream._streams[1]; stream1.on('end', function() { assert.ok(stream2.dataSize > 0); }); var tmpFile = common.dir.tmp + '/combined.txt'; var dest = fs.createWriteStream(tmpFile); combinedStream.pipe(dest); dest.on('end', function() { var written = fs.readFileSync(tmpFile, 'utf8'); assert.strictEqual(written, EXPECTED); }); })(); node-combined-stream-1.0.8/test/run.js000077500000000000000000000001711346605542000176440ustar00rootroot00000000000000#!/usr/bin/env node var far = require('far').create(); far.add(__dirname); far.include(/test-.*\.js$/); far.execute();