MCPcopy Create free account
hub / github.com/nodejs/node / reopen

Method reopen

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

* @param {string} [file]

(file)

Source from the content-addressed store, hash-verified

254 * @param {string} [file]
255 */
256 reopen(file) {
257 if (this.#destroyed) {
258 throw new ERR_INVALID_STATE('Utf8Stream is destroyed');
259 }
260
261 if (this.#opening) {
262 this.once('ready', () => this.reopen(file));
263 return;
264 }
265
266 if (this.#ending) {
267 return;
268 }
269
270 if (!this.#file) {
271 throw new ERR_OPERATION_FAILED(
272 'Unable to reopen a file descriptor, you must pass a file to SonicBoom');
273 }
274
275 if (file) {
276 this.#file = file;
277 }
278 this.#reopening = true;
279
280 if (this.#writing) {
281 return;
282 }
283
284 const fd = this.#fd;
285 this.once('ready', () => {
286 if (fd !== this.#fd) {
287 this.#fs.close(fd, (err) => {
288 if (err) {
289 return this.emit('error', err);
290 }
291 });
292 }
293 });
294
295 this.#openFile(this.#file);
296 }
297
298 end() {
299 if (this.#destroyed) {

Callers 3

#releaseMethod · 0.95
runTestsFunction · 0.95
runTestsFunction · 0.95

Calls 4

#openFileMethod · 0.95
closeMethod · 0.65
onceMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected