Total Complexity | 2 |
Complexity/F | 0 |
Lines of Code | 26 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {createReadStream, readFileSync} from 'fs' |
||
2 | import {createInterface} from 'readline' |
||
3 | |||
4 | it("last empty", async () => { |
||
5 | const filename = `${__dirname}/readline.last--empty.txt` |
||
6 | , {length} = readFileSync(filename).toString().split("\n") |
||
7 | , lineReader = createInterface(createReadStream(filename)) |
||
8 | |||
9 | let i = 0 |
||
10 | for await (const _ of lineReader) |
||
11 | i++ |
||
12 | |||
13 | expect(i).toBe(length - 1) |
||
14 | }) |
||
15 | |||
16 | it("last not empty", async () => { |
||
17 | const filename = `${__dirname}/readline.last--not_empty.txt` |
||
18 | , {length} = readFileSync(filename).toString().split("\n") |
||
19 | , lineReader = createInterface(createReadStream(filename)) |
||
20 | |||
21 | let i = 0 |
||
22 | for await (const _ of lineReader) |
||
23 | i++ |
||
24 | |||
25 | expect(i).toBe(length) |
||
26 | }) |