MCPcopy Index your code
hub / github.com/nodejs/node / testBinaryData

Function testBinaryData

test/parallel/test-fs-promises-file-handle-pullsync.js:64–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62// =============================================================================
63
64async function testBinaryData() {
65 const filePath = path.join(tmpDir, 'pullsync-binary.bin');
66 const input = Buffer.alloc(200000);
67 for (let i = 0; i < input.length; i++) input[i] = i & 0xff;
68 fs.writeFileSync(filePath, input);
69
70 const fh = await open(filePath, 'r');
71 try {
72 const data = bytesSync(fh.pullSync());
73 assert.deepStrictEqual(Buffer.from(data), input);
74 } finally {
75 await fh.close();
76 }
77}
78
79// =============================================================================
80// pullSync with sync compression transform round-trip

Calls 7

bytesSyncFunction · 0.85
allocMethod · 0.80
openFunction · 0.70
closeMethod · 0.65
joinMethod · 0.45
writeFileSyncMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected