summaryrefslogtreecommitdiff
path: root/node_modules/gather-stream
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:58:02 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:58:02 +0800
commitfee47f6414cc3ae9a88f3ee0ed20f1d6f2d9f556 (patch)
tree2b99dd57fc676a3819ef3cc46ac43df0043c2bb3 /node_modules/gather-stream
parent0379526e20e1ff212df23e6326741aa9c06df204 (diff)
added plugin from postcss: postcss-fixes rucksack-css
Diffstat (limited to 'node_modules/gather-stream')
-rw-r--r--node_modules/gather-stream/README.md32
-rw-r--r--node_modules/gather-stream/index.js44
-rw-r--r--node_modules/gather-stream/package.json24
3 files changed, 100 insertions, 0 deletions
diff --git a/node_modules/gather-stream/README.md b/node_modules/gather-stream/README.md
new file mode 100644
index 00000000..c3142fec
--- /dev/null
+++ b/node_modules/gather-stream/README.md
@@ -0,0 +1,32 @@
+# gather-stream
+
+Basically [concat-stream](https://github.com/maxogden/concat-stream) but minimaller implementation, and/but also with error handling.
+
+
+## Usage
+
+Here's a simple example:
+
+ var concat2 = require('gather-stream'),
+ fs = require('fs');
+
+ fs.createReadStream('README.md').pipe(concat2(function (error,buffer) {
+ if (error) console.error(error);
+ else console.log("Read file, it was %s bytes long.", buffer.length);
+ });
+
+
+## API
+
+* `var concat2 = require('gather-stream')` — the module exports a single wrapper function
+* `concat2([opts, ]cb)` — returns a Writable stream you can pipe into. If an error occurs on this stream *or* its source, `cb(error)` will be called; otherwise `cb(null, buffer)` will get you. You can provide `{maxLength:someNumberOfBytes}` as `opts` to limit memory mayhem if you wish — if the limit is about to be exceeded, an error will be fired instead.
+* that's about it
+
+
+## License
+
+Copyright © 2014, Nathan Vander Wilt
+
+Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/gather-stream/index.js b/node_modules/gather-stream/index.js
new file mode 100644
index 00000000..cab8bda9
--- /dev/null
+++ b/node_modules/gather-stream/index.js
@@ -0,0 +1,44 @@
+var Writable = require('stream').Writable,
+ util = require('util');
+
+function Gatherer(opts) {
+ opts.decodeStrings = true;
+ Writable.call(this, opts);
+ this._length = 0;
+ this._chunks = [];
+ this._maxLength = ('maxLength' in opts) ? opts.maxLength : Infinity;
+}
+
+util.inherits(Gatherer, Writable);
+
+Gatherer.prototype._write = function (d, _enc, cb) {
+ if (this._length + d.length > this._maxLength) {
+ return cb(new Error("Maximum length exceeded!"));
+ }
+ this._chunks.push(d);
+ this._length += d.length;
+ cb();
+}
+
+Gatherer.prototype.getBuffer = function () {
+ return Buffer.concat(this._chunks, this._length);
+}
+
+module.exports = function (opts, cb) {
+ if (typeof opts === 'function') {
+ cb = opts;
+ opts = {};
+ }
+ var target = new Gatherer(opts);
+ target.on('error', cb);
+ target.on('pipe', function (source) {
+ source.on('error', cb);
+ });
+ target.on('unpipe', function (source) {
+ source.removeListener('error', cb);
+ });
+ target.on('finish', function () {
+ cb(null, target.getBuffer());
+ });
+ return target;
+}
diff --git a/node_modules/gather-stream/package.json b/node_modules/gather-stream/package.json
new file mode 100644
index 00000000..86bff1e2
--- /dev/null
+++ b/node_modules/gather-stream/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "gather-stream",
+ "version": "1.0.0",
+ "description": "Gather a stream, callback with buffer (or error) when done",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/natevw/gather-stream.git"
+ },
+ "keywords": [
+ "stream",
+ "buffer",
+ "pipe"
+ ],
+ "author": "Nathan Vander Wilt",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/natevw/gather-stream/issues"
+ },
+ "homepage": "https://github.com/natevw/gather-stream"
+}