@contrast/route-metrics
Version:
`route-metrics` allows server performance, exclusive of network time, to be compared on a route-by-route basis. It was created to compare server performance with and without `@contrast/agent` being loaded and active.
30 lines (21 loc) • 612 B
JavaScript
;
const readline = require('readline');
const fs = require('fs');
/**
* async generator that yields lines of a file. yields null on EOF. after the
* null the function returns the number of characters read which can be fetched
* via `(await iterator.next()).value`.
*/
async function* reader({file}) {
const readstream = fs.createReadStream(file, {encoding: 'utf8'});
const rl = readline.createInterface({
input: readstream,
crlfDelay: Infinity,
});
for await (const line of rl) {
yield line;
}
yield null;
return readstream.bytesRead;
}
module.exports = reader;