aboutsummaryrefslogtreecommitdiff
path: root/node_modules/readable-stream/lib/_stream_writable.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-16 01:59:39 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-16 02:00:31 +0100
commitbd65bb67e25a79b019d745b7262b2008ce2adb15 (patch)
tree89e1b032103a63737f1a703e6a943832ef261704 /node_modules/readable-stream/lib/_stream_writable.js
parentf91466595b651721690133f58ab37f977539e95b (diff)
downloadwallet-core-bd65bb67e25a79b019d745b7262b2008ce2adb15.tar.xz
incrementally verify denoms
The denominations are not stored in a separate object store.
Diffstat (limited to 'node_modules/readable-stream/lib/_stream_writable.js')
-rw-r--r--node_modules/readable-stream/lib/_stream_writable.js42
1 files changed, 35 insertions, 7 deletions
diff --git a/node_modules/readable-stream/lib/_stream_writable.js b/node_modules/readable-stream/lib/_stream_writable.js
index ed5efcbd2..4d9c62ba6 100644
--- a/node_modules/readable-stream/lib/_stream_writable.js
+++ b/node_modules/readable-stream/lib/_stream_writable.js
@@ -14,6 +14,10 @@ var processNextTick = require('process-nextick-args');
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
/*</replacement>*/
+/*<replacement>*/
+var Duplex;
+/*</replacement>*/
+
Writable.WritableState = WritableState;
/*<replacement>*/
@@ -54,7 +58,6 @@ function WriteReq(chunk, encoding, cb) {
this.next = null;
}
-var Duplex;
function WritableState(options, stream) {
Duplex = Duplex || require('./_stream_duplex');
@@ -76,6 +79,7 @@ function WritableState(options, stream) {
// cast to ints.
this.highWaterMark = ~ ~this.highWaterMark;
+ // drain event flag.
this.needDrain = false;
// at the start of calling end()
this.ending = false;
@@ -150,7 +154,7 @@ function WritableState(options, stream) {
this.corkedRequestsFree = new CorkedRequest(this);
}
-WritableState.prototype.getBuffer = function writableStateGetBuffer() {
+WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest;
var out = [];
while (current) {
@@ -170,13 +174,37 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
} catch (_) {}
})();
-var Duplex;
+// Test _writableState for inheritance to account for Duplex streams,
+// whose prototype chain only points to Readable.
+var realHasInstance;
+if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
+ realHasInstance = Function.prototype[Symbol.hasInstance];
+ Object.defineProperty(Writable, Symbol.hasInstance, {
+ value: function (object) {
+ if (realHasInstance.call(this, object)) return true;
+
+ return object && object._writableState instanceof WritableState;
+ }
+ });
+} else {
+ realHasInstance = function (object) {
+ return object instanceof this;
+ };
+}
+
function Writable(options) {
Duplex = Duplex || require('./_stream_duplex');
- // Writable ctor is applied to Duplexes, though they're not
- // instanceof Writable, they're instanceof Readable.
- if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
+ // Writable ctor is applied to Duplexes, too.
+ // `realHasInstance` is necessary because using plain `instanceof`
+ // would return false, as no `_writableState` property is attached.
+
+ // Trying to use the custom `instanceof` for Writable here will also break the
+ // Node.js LazyTransform implementation, which has a non-trivial getter for
+ // `_writableState` that would lead to infinite recursion.
+ if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
+ return new Writable(options);
+ }
this._writableState = new WritableState(options, this);
@@ -436,7 +464,7 @@ function clearBuffer(stream, state) {
}
Writable.prototype._write = function (chunk, encoding, cb) {
- cb(new Error('not implemented'));
+ cb(new Error('_write() is not implemented'));
};
Writable.prototype._writev = null;