diff options
| author | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
|---|---|---|
| committer | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
| commit | 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch) | |
| tree | 360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/combined-stream | |
| parent | b500a50f1b97d93c98b36ed9a980f8188d648147 (diff) | |
| download | LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip  | |
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/combined-stream')
| -rw-r--r-- | node_modules/combined-stream/License | 19 | ||||
| -rw-r--r-- | node_modules/combined-stream/Readme.md | 138 | ||||
| -rw-r--r-- | node_modules/combined-stream/lib/combined_stream.js | 208 | ||||
| -rw-r--r-- | node_modules/combined-stream/package.json | 25 | ||||
| -rw-r--r-- | node_modules/combined-stream/yarn.lock | 17 | 
5 files changed, 407 insertions, 0 deletions
diff --git a/node_modules/combined-stream/License b/node_modules/combined-stream/License new file mode 100644 index 0000000..4804b7a --- /dev/null +++ b/node_modules/combined-stream/License @@ -0,0 +1,19 @@ +Copyright (c) 2011 Debuggable Limited <felix@debuggable.com> + +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. diff --git a/node_modules/combined-stream/Readme.md b/node_modules/combined-stream/Readme.md new file mode 100644 index 0000000..9e367b5 --- /dev/null +++ b/node_modules/combined-stream/Readme.md @@ -0,0 +1,138 @@ +# 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. diff --git a/node_modules/combined-stream/lib/combined_stream.js b/node_modules/combined-stream/lib/combined_stream.js new file mode 100644 index 0000000..125f097 --- /dev/null +++ b/node_modules/combined-stream/lib/combined_stream.js @@ -0,0 +1,208 @@ +var 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); +}; diff --git a/node_modules/combined-stream/package.json b/node_modules/combined-stream/package.json new file mode 100644 index 0000000..6982b6d --- /dev/null +++ b/node_modules/combined-stream/package.json @@ -0,0 +1,25 @@ +{ +  "author": "Felix Geisendörfer <felix@debuggable.com> (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" +} diff --git a/node_modules/combined-stream/yarn.lock b/node_modules/combined-stream/yarn.lock new file mode 100644 index 0000000..7edf418 --- /dev/null +++ b/node_modules/combined-stream/yarn.lock @@ -0,0 +1,17 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +delayed-stream@~1.0.0: +  version "1.0.0" +  resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +far@~0.0.7: +  version "0.0.7" +  resolved "https://registry.yarnpkg.com/far/-/far-0.0.7.tgz#01c1fd362bcd26ce9cf161af3938aa34619f79a7" +  dependencies: +    oop "0.0.3" + +oop@0.0.3: +  version "0.0.3" +  resolved "https://registry.yarnpkg.com/oop/-/oop-0.0.3.tgz#70fa405a5650891a194fdc82ca68dad6dabf4401"  | 
