Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/parser/node/parserWorker.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { parentPort } from 'worker_threads';
7
import * as parser from './parserImpl';
8
9
function main() {
10
const port = parentPort;
11
if (!port) {
12
throw new Error(`This module should only be used in a worker thread.`);
13
}
14
15
port.on('message', async ({ id, fn, args }) => {
16
try {
17
const res = await (parser as any)[fn](...args);
18
port.postMessage({ id, res });
19
} catch (err) {
20
port.postMessage({ id, err });
21
}
22
});
23
}
24
25
main();
26
27