UNPKG

@boringnode/transmit

Version:

A framework agnostic Server-Sent-Event library

21 lines (20 loc) 530 B
import { Writable } from 'node:stream'; export class Sink extends Writable { #chunks = []; constructor() { super({ objectMode: true }); } assertWriteHead(assertion) { // @ts-expect-error - Mocking the writeHead method this.writeHead = (statusCode, headers) => { assertion(statusCode, headers); }; } get content() { return this.#chunks.join(''); } _write(chunk, _encoding, callback) { this.#chunks.push(chunk); callback(); } }