Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using readline to optimize performance #3

Open
cweijan opened this issue Jun 8, 2022 · 0 comments
Open

Using readline to optimize performance #3

cweijan opened this issue Jun 8, 2022 · 0 comments

Comments

@cweijan
Copy link

cweijan commented Jun 8, 2022

I tried ndjson to improve performance, but using this library is slower than JSON.parse(arrayString), I changed to readline to improve the speed, consider code like the following:

const readline = require('readline');
const fileStream = fs.createReadStream('data.txt');
const rl = readline.createInterface({
    input: fileStream,
    crlfDelay: Infinity
});
for await (const line of rl) {
    JSON.parse(line)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant