MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/internal/streams/fast-utf8-stream.js:116–230  ·  view source on GitHub ↗

* @typedef {object} Utf8StreamOptions * @property {string} [dest] - path to the file to write to * @property {number} [fd] - file descriptor to write to * @property {number} [minLength] - minimum length of the internal buffer before a write is triggered * @property {number} [maxLength] -

(options = kNullPrototype)

Source from the content-addressed store, hash-verified

114 * @param {Utf8StreamOptions} [options]
115 */
116 constructor(options = kNullPrototype) {
117 validateObject(options, 'options');
118 let {
119 fd,
120 } = options;
121 const {
122 dest,
123 minLength,
124 maxLength,
125 maxWrite,
126 periodicFlush,
127 sync,
128 append = true,
129 mkdir,
130 retryEAGAIN,
131 fsync,
132 contentMode = kContentModeUtf8,
133 mode,
134 // Provides for a custom fs implementation. Mostly useful for testing.
135 fs: overrideFs = kEmptyObject,
136 } = options;
137
138 super();
139
140 fd ??= dest;
141
142 validateObject(overrideFs, 'options.fs');
143 this.#fs = { ...fs, ...overrideFs };
144 validateFunction(this.#fs.write, 'options.fs.write');
145 validateFunction(this.#fs.writeSync, 'options.fs.writeSync');
146 validateFunction(this.#fs.fsync, 'options.fs.fsync');
147 validateFunction(this.#fs.fsyncSync, 'options.fs.fsyncSync');
148 validateFunction(this.#fs.close, 'options.fs.close');
149 validateFunction(this.#fs.open, 'options.fs.open');
150 validateFunction(this.#fs.mkdir, 'options.fs.mkdir');
151 validateFunction(this.#fs.mkdirSync, 'options.fs.mkdirSync');
152
153 this.#hwm = MathMax(minLength || 0, this.#hwm);
154 this.#minLength = minLength || 0;
155 this.#maxLength = maxLength || 0;
156 this.#maxWrite = maxWrite || kMaxWrite;
157 this.#periodicFlush = periodicFlush || 0;
158 this.#sync = sync || false;
159 this.#fsync = fsync || false;
160 this.#append = append || false;
161 this.#mode = mode;
162 this.#retryEAGAIN = retryEAGAIN || (() => true);
163 this.#mkdir = mkdir || false;
164
165 validateUint32(this.#hwm, 'options.hwm');
166 validateUint32(this.#minLength, 'options.minLength');
167 validateUint32(this.#maxLength, 'options.maxLength');
168 validateUint32(this.#maxWrite, 'options.maxWrite');
169 validateUint32(this.#periodicFlush, 'options.periodicFlush');
170 validateBoolean(this.#sync, 'options.sync');
171 validateBoolean(this.#fsync, 'options.fsync');
172 validateBoolean(this.#append, 'options.append');
173 validateBoolean(this.#mkdir, 'options.mkdir');

Callers

nothing calls this directly

Calls 15

#writeBufferMethod · 0.95
#flushBufferMethod · 0.95
#flushBufferSyncMethod · 0.95
#actualWriteBufferMethod · 0.95
#releaseMethod · 0.95
#writeUtf8Method · 0.95
#flushUtf8Method · 0.95
#flushSyncUtf8Method · 0.95
#actualWriteUtf8Method · 0.95
#openFileMethod · 0.95
flushMethod · 0.95
setIntervalFunction · 0.50

Tested by

no test coverage detected