MCPcopy Create free account
hub / github.com/nodejs/node / #flushUtf8

Method #flushUtf8

lib/internal/streams/fast-utf8-stream.js:766–797  ·  view source on GitHub ↗
(cb)

Source from the content-addressed store, hash-verified

764 }
765
766 #flushUtf8(cb) {
767 validateFunction(cb, 'cb');
768
769 if (this.#destroyed) {
770 const error = new ERR_INVALID_STATE('Utf8Stream is destroyed');
771 if (cb) {
772 cb(error);
773 return;
774 }
775
776 throw error;
777 }
778
779 if (this.#minLength <= 0) {
780 cb?.();
781 return;
782 }
783
784 if (cb) {
785 this.#callFlushCallbackOnDrain(cb);
786 }
787
788 if (this.#writing) {
789 return;
790 }
791
792 if (this.#bufs.length === 0) {
793 ArrayPrototypePush(this.#bufs, '');
794 }
795
796 this.#actualWrite();
797 }
798
799 #writeBuffer(data) {
800 if (this.#destroyed) {

Callers 1

constructorMethod · 0.95

Calls 2

cbFunction · 0.70

Tested by

no test coverage detected