Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/node/stream.ts>Writable#end

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
method Writable.prototype.end
Re-export
import { Writable } from "https://deno.land/std@0.161.0/node/stream.ts";

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 write method after calling end will raise an error.

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

Parameters

optional
cb: () => void

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

Parameters

chunk: any
optional
cb: () => void

Parameters

chunk: any
encoding: BufferEncoding
optional
cb: () => void