summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/readable-stream/lib/internal
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/readable-stream/lib/internal')
-rw-r--r--tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/BufferList.js74
-rw-r--r--tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/destroy.js72
-rw-r--r--tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream-browser.js1
-rw-r--r--tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream.js1
4 files changed, 148 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/BufferList.js b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/BufferList.js
new file mode 100644
index 0000000000..d467615978
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/BufferList.js
@@ -0,0 +1,74 @@
+'use strict';
+
+/*<replacement>*/
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Buffer = require('safe-buffer').Buffer;
+/*</replacement>*/
+
+function copyBuffer(src, target, offset) {
+ src.copy(target, offset);
+}
+
+module.exports = function () {
+ function BufferList() {
+ _classCallCheck(this, BufferList);
+
+ this.head = null;
+ this.tail = null;
+ this.length = 0;
+ }
+
+ BufferList.prototype.push = function push(v) {
+ var entry = { data: v, next: null };
+ if (this.length > 0) this.tail.next = entry;else this.head = entry;
+ this.tail = entry;
+ ++this.length;
+ };
+
+ BufferList.prototype.unshift = function unshift(v) {
+ var entry = { data: v, next: this.head };
+ if (this.length === 0) this.tail = entry;
+ this.head = entry;
+ ++this.length;
+ };
+
+ BufferList.prototype.shift = function shift() {
+ if (this.length === 0) return;
+ var ret = this.head.data;
+ if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
+ --this.length;
+ return ret;
+ };
+
+ BufferList.prototype.clear = function clear() {
+ this.head = this.tail = null;
+ this.length = 0;
+ };
+
+ BufferList.prototype.join = function join(s) {
+ if (this.length === 0) return '';
+ var p = this.head;
+ var ret = '' + p.data;
+ while (p = p.next) {
+ ret += s + p.data;
+ }return ret;
+ };
+
+ BufferList.prototype.concat = function concat(n) {
+ if (this.length === 0) return Buffer.alloc(0);
+ if (this.length === 1) return this.head.data;
+ var ret = Buffer.allocUnsafe(n >>> 0);
+ var p = this.head;
+ var i = 0;
+ while (p) {
+ copyBuffer(p.data, ret, i);
+ i += p.data.length;
+ p = p.next;
+ }
+ return ret;
+ };
+
+ return BufferList;
+}(); \ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/destroy.js b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/destroy.js
new file mode 100644
index 0000000000..b3e58c33bc
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/destroy.js
@@ -0,0 +1,72 @@
+'use strict';
+
+/*<replacement>*/
+
+var processNextTick = require('process-nextick-args');
+/*</replacement>*/
+
+// undocumented cb() API, needed for core, not for public API
+function destroy(err, cb) {
+ var _this = this;
+
+ var readableDestroyed = this._readableState && this._readableState.destroyed;
+ var writableDestroyed = this._writableState && this._writableState.destroyed;
+
+ if (readableDestroyed || writableDestroyed) {
+ if (cb) {
+ cb(err);
+ } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
+ processNextTick(emitErrorNT, this, err);
+ }
+ return;
+ }
+
+ // we set destroyed to true before firing error callbacks in order
+ // to make it re-entrance safe in case destroy() is called within callbacks
+
+ if (this._readableState) {
+ this._readableState.destroyed = true;
+ }
+
+ // if this is a duplex stream mark the writable part as destroyed as well
+ if (this._writableState) {
+ this._writableState.destroyed = true;
+ }
+
+ this._destroy(err || null, function (err) {
+ if (!cb && err) {
+ processNextTick(emitErrorNT, _this, err);
+ if (_this._writableState) {
+ _this._writableState.errorEmitted = true;
+ }
+ } else if (cb) {
+ cb(err);
+ }
+ });
+}
+
+function undestroy() {
+ if (this._readableState) {
+ this._readableState.destroyed = false;
+ this._readableState.reading = false;
+ this._readableState.ended = false;
+ this._readableState.endEmitted = false;
+ }
+
+ if (this._writableState) {
+ this._writableState.destroyed = false;
+ this._writableState.ended = false;
+ this._writableState.ending = false;
+ this._writableState.finished = false;
+ this._writableState.errorEmitted = false;
+ }
+}
+
+function emitErrorNT(self, err) {
+ self.emit('error', err);
+}
+
+module.exports = {
+ destroy: destroy,
+ undestroy: undestroy
+}; \ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream-browser.js b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream-browser.js
new file mode 100644
index 0000000000..9332a3fdae
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream-browser.js
@@ -0,0 +1 @@
+module.exports = require('events').EventEmitter;
diff --git a/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream.js b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream.js
new file mode 100644
index 0000000000..ce2ad5b6ee
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/readable-stream/lib/internal/streams/stream.js
@@ -0,0 +1 @@
+module.exports = require('stream');