{“ast”:null,“code”:“// Copyright Joyent, Inc. and other Node contributors.n//n// Permission is hereby granted, free of charge, to any person obtaining an// copy of this software and associated documentation files (then// "Software"), to deal in the Software without restriction, includingn// without limitation the rights to use, copy, modify, merge, publish,n// distribute, sublicense, and/or sell copies of the Software, and to permitn// persons to whom the Software is furnished to do so, subject to then// following conditions:n//n// The above copyright notice and this permission notice shall be includedn// in all copies or substantial portions of the Software.n//n// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSn// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFn// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INn// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT ORn// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THEn// USE OR OTHER DEALINGS IN THE SOFTWARE.n// a duplex stream is just a stream that is both readable and writable.n// Since JS doesn't have multiple prototypal inheritance, this classn// prototypally inherits from Readable, and then parasitically fromn// Writable.n'use strict';n/*<replacement>*/nnvar pna = require('process-nextick-args');n/*</replacement>*/nn/*<replacement>*/nnnvar objectKeys = Object.keys || function (obj) {n var keys = [];nn for (var key in obj) {n keys.push(key);n }nn return keys;n};n/*</replacement>*/nnnmodule.exports = Duplex;n/*<replacement>*/nnvar util = require('core-util-is');nnutil.inherits = require('inherits');n/*</replacement>*/nnvar Readable = require('./_stream_readable');nnvar Writable = require('./_stream_writable');nnutil.inherits(Duplex, Readable);n{n // avoid scope creep, the keys array can then be collectedn var keys = objectKeys(Writable.prototype);nn for (var v = 0; v < keys.length; v++) {n var method = keys;n if (!Duplex.prototype) Duplex.prototype = Writable.prototype;n }n}nnfunction Duplex(options) {n if (!(this instanceof Duplex)) return new Duplex(options);n Readable.call(this, options);n Writable.call(this, options);n if (options && options.readable === false) this.readable = false;n if (options && options.writable === false) this.writable = false;n this.allowHalfOpen = true;n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;n this.once('end', onend);n}nnObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {n // making it explicit this property is not enumerablen // because otherwise some prototype manipulation inn // userland will failn enumerable: false,n get: function get() {n return this._writableState.highWaterMark;n }n}); // the no-half-open enforcernnfunction onend() {n // if we allow half-open state, or if the writable side ended,n // then we're ok.n if (this.allowHalfOpen || this._writableState.ended) return; // no more data can be written.n // But allow more writes to happen in this tick.nn pna.nextTick(onEndNT, this);n}nnfunction onEndNT(self) {n self.end();n}nnObject.defineProperty(Duplex.prototype, 'destroyed', {n get: function get() {n if (this._readableState === undefined || this._writableState === undefined) {n return false;n }nn return this._readableState.destroyed && this._writableState.destroyed;n },n set: function set(value) {n // we ignore the value if the streamn // has not been initialized yetn if (this._readableState === undefined || this._writableState === undefined) {n return;n } // backward compatibility, the user is explicitlyn // managing destroyednnn this._readableState.destroyed = value;n this._writableState.destroyed = value;n }n});nnDuplex.prototype._destroy = function (err, cb) {n this.push(null);n this.end();n pna.nextTick(cb, err);n};”,“map”:null,“metadata”:{},“sourceType”:“module”}