Skip to main content
Module

std/node/stream.ts>Writable#cork

Deno standard library
Go to Latest
method Writable.prototype.cork
import { Writable } from "https://deno.land/std@0.145.0/node/stream.ts";

The writable.cork() method forces all written data to be buffered in memory. The buffered data will be flushed when either the uncork or end methods are called.

The primary intent of writable.cork() is to accommodate a situation in which several small chunks are written to the stream in rapid succession. Instead of immediately forwarding them to the underlying destination, writable.cork()buffers all the chunks until writable.uncork() is called, which will pass them all to writable._writev(), if present. This prevents a head-of-line blocking situation where data is being buffered while waiting for the first small chunk to be processed. However, use of writable.cork() without implementingwritable._writev() may have an adverse effect on throughput.

See also: writable.uncork(), writable._writev().