Files
notification-elements-demo/node_modules/htmlparser2/dist/esm/WritableStream.js
Giuliano Silvestro 5d0c9ec7eb Initial commit: notification-elements-demo app
Interactive Angular 19 demo for @sda/notification-elements-ui with
6 sections: Bell & Feed, Notification Center, Inbox, Comments &
Threads, Mention Input, and Full-Featured layout. Includes mock
data, dark mode toggle, and real-time event log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 21:49:19 +10:00

32 lines
1.0 KiB
JavaScript

import { Parser } from "./Parser.js";
/*
* NOTE: If either of these two imports produces a type error,
* please update your @types/node dependency!
*/
import { Writable } from "node:stream";
import { StringDecoder } from "node:string_decoder";
// Following the example in https://nodejs.org/api/stream.html#stream_decoding_buffers_in_a_writable_stream
function isBuffer(_chunk, encoding) {
return encoding === "buffer";
}
/**
* WritableStream makes the `Parser` interface available as a NodeJS stream.
*
* @see Parser
*/
export class WritableStream extends Writable {
constructor(cbs, options) {
super({ decodeStrings: false });
this._decoder = new StringDecoder();
this._parser = new Parser(cbs, options);
}
_write(chunk, encoding, callback) {
this._parser.write(isBuffer(chunk, encoding) ? this._decoder.write(chunk) : chunk);
callback();
}
_final(callback) {
this._parser.end(this._decoder.end());
callback();
}
}
//# sourceMappingURL=WritableStream.js.map