Skip to content

Commit

Permalink
add writable=false and remove the wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
F3n67u committed Jun 1, 2022
1 parent e4bd5f4 commit cb0ee5d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tools/license2rtf.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LineSplitter extends Stream {
if (this.buffer) {
this.emit('data', this.buffer);
}
this.writable = false;
this.emit('end');
}
}
Expand All @@ -52,6 +53,7 @@ class ParagraphParser extends Stream {
if (data)
this.parseLine(data + '');
this.flushParagraph();
this.writable = false;
this.emit('end');
}

Expand Down Expand Up @@ -211,6 +213,7 @@ class Unwrapper extends Stream {
end(data) {
if (data)
this.write(data);
this.writable = false;
this.emit('end');
}
}
Expand Down Expand Up @@ -272,6 +275,7 @@ class RtfGenerator extends Stream {
this.write(data);
if (this.didWriteAnything)
this.emitFooter();
this.writable = false;
this.emit('end');
}

Expand All @@ -289,15 +293,11 @@ class RtfGenerator extends Stream {
stdin.setEncoding('utf-8');
stdin.resume();

async function main() {
await pipeline(
stdin,
new LineSplitter(),
new ParagraphParser(),
new Unwrapper(),
new RtfGenerator(),
stdout,
);
}

main().catch(console.error);
await pipeline(
stdin,
new LineSplitter(),
new ParagraphParser(),
new Unwrapper(),
new RtfGenerator(),
stdout,
);

0 comments on commit cb0ee5d

Please sign in to comment.