Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172'use strict';
/*<replacement>*/
var processNextTick = require('process-nextick-args');/*</replacement>*/
// undocumented cb() API, needed for core, not for public APIfunction 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};