mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
17 lines
400 B
TypeScript
17 lines
400 B
TypeScript
import each = require("stream-each");
|
|
import { createReadStream } from "fs";
|
|
|
|
const stream = createReadStream(__filename);
|
|
|
|
each(stream,
|
|
(data, next) => {
|
|
if (typeof data === "string") {
|
|
console.log(data);
|
|
next();
|
|
} else {
|
|
const buffer: Buffer = data;
|
|
next(new Error("Buffer"));
|
|
}
|
|
},
|
|
error => console.error(error));
|