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

Function writeAndWaitForChanges

test/parallel/test-watch-mode-files_watcher.mjs:37–45  ·  view source on GitHub ↗
(watcher, file)

Source from the content-addressed store, hash-verified

35
36 let counter = 0;
37 function writeAndWaitForChanges(watcher, file) {
38 return new Promise((resolve) => {
39 const interval = setInterval(() => writeFileSync(file, `write ${counter++}`), 100);
40 watcher.once('changed', () => {
41 clearInterval(interval);
42 resolve();
43 });
44 });
45 }
46
47 it('should watch changed files', async () => {
48 const file = tmpdir.resolve('file1');

Calls 5

writeFileSyncFunction · 0.85
clearIntervalFunction · 0.85
setIntervalFunction · 0.50
resolveFunction · 0.50
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…