end

open override fun end(cb: () -> Unit = definedExternally)(source)

Calling the writable.end() method signals that no more data will be written to the Writable. The optional chunk and encoding arguments allow one final additional chunk of data to be written immediately before closing the stream.

Calling the {@link write} method after calling {@link end} will raise an error.

// Write 'hello, ' and then end with 'world!'.
import fs from 'node:fs';
const file = fs.createWriteStream('example.txt');
file.write('hello, ');
file.end('world!');
// Writing more now is not allowed!

Since

v0.9.4

Parameters

cb

Callback for when the stream is finished.


open fun end(chunk: Any?, cb: () -> Unit = definedExternally)(source)

Signals that no more data will be written, with one final chunk of data.

Since

v0.9.4

Parameters

chunk

Optional data to write. For streams not operating in object mode, chunk must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, chunk may be any JavaScript value other than null.

cb

Callback for when the stream is finished.

See also

{@link Writable.end} for full details.


open fun end(chunk: Any?, encoding: BufferEncoding, cb: () -> Unit = definedExternally)(source)

Signals that no more data will be written, with one final chunk of data.

Since

v0.9.4

Parameters

chunk

Optional data to write. For streams not operating in object mode, chunk must be a {string}, {Buffer}, {TypedArray} or {DataView}. For object mode streams, chunk may be any JavaScript value other than null.

encoding

The encoding if chunk is a string

cb

Callback for when the stream is finished.

See also

{@link Writable.end} for full details.


open override fun end(data: String, cb: () -> Unit = definedExternally)(source)
open override fun end(data: Uint8Array<*>, cb: () -> Unit = definedExternally)(source)
open override fun end(str: String, encoding: BufferEncoding = definedExternally, cb: () -> Unit = definedExternally)(source)