MCPcopy Create free account
hub / github.com/TruthHun/BookStack / WritableState

Function WritableState

static/word2md/mammoth.browser.js:25340–25434  ·  view source on GitHub ↗
(options, stream)

Source from the content-addressed store, hash-verified

25338}
25339
25340function WritableState(options, stream) {
25341 Duplex = Duplex || require('./_stream_duplex');
25342
25343 options = options || {};
25344
25345 // object stream flag to indicate whether or not this stream
25346 // contains buffers or objects.
25347 this.objectMode = !!options.objectMode;
25348
25349 if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
25350
25351 // the point at which write() starts returning false
25352 // Note: 0 is a valid value, means that we always return false if
25353 // the entire buffer is not flushed immediately on write()
25354 var hwm = options.highWaterMark;
25355 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
25356 this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
25357
25358 // cast to ints.
25359 this.highWaterMark = ~~this.highWaterMark;
25360
25361 // drain event flag.
25362 this.needDrain = false;
25363 // at the start of calling end()
25364 this.ending = false;
25365 // when end() has been called, and returned
25366 this.ended = false;
25367 // when 'finish' is emitted
25368 this.finished = false;
25369
25370 // should we decode strings into buffers before passing to _write?
25371 // this is here so that some node-core streams can optimize string
25372 // handling at a lower level.
25373 var noDecode = options.decodeStrings === false;
25374 this.decodeStrings = !noDecode;
25375
25376 // Crypto is kind of old and crusty. Historically, its default string
25377 // encoding is 'binary' so we have to make this configurable.
25378 // Everything else in the universe uses 'utf8', though.
25379 this.defaultEncoding = options.defaultEncoding || 'utf8';
25380
25381 // not an actual buffer we keep track of, but a measurement
25382 // of how much we're waiting to get pushed to some underlying
25383 // socket or file.
25384 this.length = 0;
25385
25386 // a flag to see when we're in the middle of a write.
25387 this.writing = false;
25388
25389 // when true all writes will be buffered until .uncork() call
25390 this.corked = 0;
25391
25392 // a flag to be able to tell if the onwrite cb is called immediately,
25393 // or on a later tick. We set this to true at first, because any
25394 // actions that shouldn't happen until "later" should generally also
25395 // not happen before the first write call.
25396 this.sync = true;
25397

Callers

nothing calls this directly

Calls 1

onwriteFunction · 0.70

Tested by

no test coverage detected