-
Notifications
You must be signed in to change notification settings - Fork 0
/
scratch.js
31 lines (27 loc) · 832 Bytes
/
scratch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs')
const path = require('path')
const tester = require('./index')
const readline = require('readline')
function fnToTest() {
const filePath = path.resolve(__dirname, './airports.csv')
const fileData = fs.readFileSync(filePath, { encoding: 'utf-8' });
const [headers] = fileData.split(/\r?\n/)
return headers.split(',')
}
async function getFirstLine() {
const filePath = path.resolve(__dirname, './airports.csv')
const readable = fs.createReadStream(filePath);
const reader = readline.createInterface({ input: readable });
const line = await new Promise((resolve) => {
reader.on('line', (line) => {
resolve(line);
reader.close();
});
});
readable.close();
return line.split(',')
}
(async () => await tester({
iterations: 100,
functionUnderTest: fnToTest,
}))()