mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
19 lines
443 B
TypeScript
19 lines
443 B
TypeScript
import writer = require("flush-write-stream");
|
|
|
|
const stream = writer(write, flush);
|
|
|
|
stream.on("finish", () => console.log("finished"));
|
|
|
|
stream.write("hello");
|
|
stream.write("world");
|
|
stream.end();
|
|
|
|
function write(data: any, encoding: string, callback: (error?: Error) => void): void {
|
|
console.log("Writing", data.toString());
|
|
callback();
|
|
}
|
|
|
|
function flush(callback: (error?: Error) => void): void {
|
|
setTimeout(callback, 1000);
|
|
}
|