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

Function validate

test/parallel/test-fs-promises-file-handle-sync.js:9–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7const { access, copyFile, open } = require('fs').promises;
8
9async function validate() {
10 tmpdir.refresh();
11 const dest = tmpdir.resolve('baz.js');
12 await assert.rejects(
13 copyFile(fixtures.path('baz.js'), dest, 'r'),
14 {
15 code: 'ERR_INVALID_ARG_TYPE',
16 }
17 );
18 await copyFile(fixtures.path('baz.js'), dest);
19 await assert.rejects(
20 access(dest, 'r'),
21 { code: 'ERR_INVALID_ARG_TYPE', message: /mode/ }
22 );
23 await access(dest);
24 const handle = await open(dest, 'r+');
25 await handle.datasync();
26 await handle.sync();
27 const buf = Buffer.from('hello world');
28 await handle.write(buf);
29 const ret = await handle.read(Buffer.alloc(11), 0, 11, 0);
30 assert.strictEqual(ret.bytesRead, 11);
31 assert.deepStrictEqual(ret.buffer, buf);
32 await handle.close();
33}
34
35validate();

Calls 13

allocMethod · 0.80
accessFunction · 0.70
openFunction · 0.70
closeMethod · 0.65
copyFileFunction · 0.50
refreshMethod · 0.45
resolveMethod · 0.45
pathMethod · 0.45
datasyncMethod · 0.45
syncMethod · 0.45
fromMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…