Skip to content

Instantly share code, notes, and snippets.

@oneshadab
Created February 10, 2024 19:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oneshadab/f224b281b6b8fecedb5b484bd4c5335a to your computer and use it in GitHub Desktop.
Save oneshadab/f224b281b6b8fecedb5b484bd4c5335a to your computer and use it in GitHub Desktop.
// > file-sync-blocking.test.mjs
import test from 'node:test';
import assert from 'node:assert';
import fs from "node:fs";
test('reading file 10,000 times with callback blocking', (t) => {
for (let i = 0; i < 10000; i++ ) {
const data = fs.readFileSync("./text.txt", { encoding: 'utf-8'})
assert.strictEqual(data, "Hello, world")
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment