mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-20 17:03:42 +00:00
19 lines
486 B
TypeScript
19 lines
486 B
TypeScript
export class LineBreakTransformer {
|
|
private chunks = ""
|
|
|
|
// noinspection JSUnusedGlobalSymbols
|
|
transform(chunk: string, controller: TransformStreamDefaultController) {
|
|
this.chunks += chunk
|
|
const lines = this.chunks.split("\r\n")
|
|
this.chunks = lines.pop()!
|
|
for (const line of lines) {
|
|
controller.enqueue(line)
|
|
}
|
|
}
|
|
|
|
// noinspection JSUnusedGlobalSymbols
|
|
flush(controller: TransformStreamDefaultController) {
|
|
controller.enqueue(this.chunks)
|
|
}
|
|
}
|