mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
26 lines
575 B
TypeScript
26 lines
575 B
TypeScript
/// <reference types="node" />
|
|
|
|
import fs = require("fs");
|
|
import readlines = require("gen-readlines");
|
|
|
|
const fd = fs.openSync('./somefile.txt', 'r');
|
|
const stats = fs.fstatSync(fd);
|
|
|
|
let buff: Buffer;
|
|
|
|
for (const line of readlines(fd, stats.size)) {
|
|
buff = line;
|
|
console.log(line.toString());
|
|
}
|
|
|
|
fs.closeSync(fd);
|
|
|
|
fs.open('./test_data/hipster.txt', 'r', (err, fd) => {
|
|
fs.fstat(fd, (err, stats) => {
|
|
for (const line of readlines(fd, stats.size, 64 * 0x400, 0)) {
|
|
buff = line;
|
|
console.log(line.toString());
|
|
}
|
|
});
|
|
});
|