MCPcopy Create free account
hub / github.com/Snapchat/Valdi / read

Method read

valdi/vscode_debugger/src/targets/valdi/callback-file.ts:31–61  ·  view source on GitHub ↗

* Reads the file, returnings its contants after they're written, or returns * undefined if the file was disposed of before the read completed.

(pollInterval = CallbackFile.pollInterval)

Source from the content-addressed store, hash-verified

29 * undefined if the file was disposed of before the read completed.
30 */
31 public read(pollInterval = CallbackFile.pollInterval) {
32 if (this.readPromise) {
33 return this.readPromise;
34 }
35
36 this.readPromise = new Promise<T>((resolve, reject) => {
37 const interval = setInterval(() => {
38 if (this.disposed) {
39 clearInterval(interval);
40 resolve(undefined);
41 return;
42 }
43
44 if (!existsSync(this.path)) {
45 return;
46 }
47
48 try {
49 resolve(JSON.parse(readFileSync(this.path, 'utf-8')));
50 } catch (e) {
51 reject(e);
52 } finally {
53 this.dispose();
54 }
55
56 clearInterval(interval);
57 }, pollInterval);
58 });
59
60 return this.readPromise;
61 }
62
63 /**
64 * Diposes of the callback file.

Callers 1

doLaunchMethod · 0.95

Calls 7

disposeMethod · 0.95
readFileSyncFunction · 0.85
rejectFunction · 0.85
setIntervalFunction · 0.50
clearIntervalFunction · 0.50
resolveFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected