pax_global_header00006660000000000000000000000064121456755540014530gustar00rootroot0000000000000052 comment=66e8f5fa4927bfea7d187563d1b6b4900ca7dc75 node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/000077500000000000000000000000001214567555400226275ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/.gitignore000066400000000000000000000000361214567555400246160ustar00rootroot00000000000000*.un~ /node_modules /test/tmp node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/.npmignore000066400000000000000000000000061214567555400246220ustar00rootroot00000000000000/test node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/License000066400000000000000000000020751214567555400241400ustar00rootroot00000000000000Copyright (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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/Makefile000066400000000000000000000000711214567555400242650ustar00rootroot00000000000000SHELL := /bin/bash test: @./test/run.js .PHONY: test node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/Readme.md000066400000000000000000000076211214567555400243540ustar00rootroot00000000000000# combined-stream 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/lib/000077500000000000000000000000001214567555400233755ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/lib/combined_stream.js000066400000000000000000000076561214567555400271040ustar00rootroot00000000000000var 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; } 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)) { stream.on('data', this._checkDataSize.bind(this)); stream = DelayedStream.create(stream, { maxDataSize: Infinity, pauseStream: this.pauseStreams, }); } 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; 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; } this.emit('pause'); }; CombinedStream.prototype.resume = function() { if (!this._released) { this._released = true; this.writable = true; this._getNext(); } 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/package.json000066400000000000000000000010621214567555400251140ustar00rootroot00000000000000{ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "combined-stream", "description": "A stream that emits multiple other streams one after another.", "version": "0.0.4", "homepage": "https://github.com/felixge/node-combined-stream", "repository": { "type": "git", "url": "git://github.com/felixge/node-combined-stream.git" }, "main": "./lib/combined_stream", "engines": { "node": "*" }, "dependencies": { "delayed-stream": "0.0.5" }, "devDependencies": { "far": "0.0.1" } } node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/000077500000000000000000000000001214567555400236065ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/common.js000066400000000000000000000007511214567555400254370ustar00rootroot00000000000000var 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/fixture/000077500000000000000000000000001214567555400252745ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/fixture/file1.txt000066400000000000000000000504001214567555400270340ustar00rootroot0000000000000010101010101010101010101010101010101010101010101010101010101010101010101010101010 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/fixture/file2.txt000066400000000000000000000504001214567555400270350ustar00rootroot0000000000000020202020202020202020202020202020202020202020202020202020202020202020202020202020 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integration/000077500000000000000000000000001214567555400261315ustar00rootroot00000000000000test-callback-streams.js000066400000000000000000000014441214567555400326000ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integrationvar 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(); 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('end', function() { var written = fs.readFileSync(tmpFile, 'utf8'); assert.strictEqual(written, EXPECTED); }); })(); node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integration/test-data-size.js000066400000000000000000000020331214567555400313230ustar00rootroot00000000000000var 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); })(); test-delayed-streams-and-buffers-and-strings.js000066400000000000000000000017701214567555400370760ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integrationvar 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); }); test-delayed-streams.js000066400000000000000000000017341214567555400324550ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integrationvar 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integration/test-empty-string.js000066400000000000000000000013101214567555400321010ustar00rootroot00000000000000var 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"); test-is-stream-like.js000066400000000000000000000010241214567555400322100ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integrationvar 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integration/test-max-data-size.js000066400000000000000000000013261214567555400321120ustar00rootroot00000000000000var 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/)); }); })(); test-unpaused-streams.js000066400000000000000000000016371214567555400326740ustar00rootroot00000000000000node-combined-stream-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/integrationvar 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-66e8f5fa4927bfea7d187563d1b6b4900ca7dc75/test/run.js000077500000000000000000000001711214567555400247520ustar00rootroot00000000000000#!/usr/bin/env node var far = require('far').create(); far.add(__dirname); far.include(/test-.*\.js$/); far.execute();