mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-19 16:32:58 +00:00
27 lines
516 B
JavaScript
27 lines
516 B
JavaScript
/**
|
|
* @internal
|
|
*/
|
|
export class LineBreakTransformer {
|
|
_chunks = "";
|
|
|
|
/**
|
|
* @param chunk {string}
|
|
* @param controller {TransformStreamDefaultController}
|
|
*/
|
|
transform(chunk, controller) {
|
|
this.chunks += chunk;
|
|
const lines = this.chunks.split("\r\n");
|
|
this.chunks = lines.pop();
|
|
for (const line of lines) {
|
|
controller.enqueue(line);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param controller {TransformStreamDefaultController}
|
|
*/
|
|
flush(controller) {
|
|
controller.enqueue(this.chunks);
|
|
}
|
|
}
|