Slide 11
Slide 11 text
const LF = '\n'.codePointAt(0);
const CR = '\r'.codePointAt(0);
const GT = '>'.codePointAt(0);
async function parse(file) {
const reader = file.stream().getReader();
let done, value;
let entriesCount = 0;
let isBOL = true;
while (({done, value} = await reader.read()), !done) {
for (const byte of value) {
if (isBOL && byte === GT) {
entriesCount++;
isBOL = false;
} else {
isBOL = byte === LF || byte === CR;
}
}
}
return {entriesCount};
}