Path: blob/main/extensions/copilot/src/platform/diff/node/diffWorkerMain.ts
13401 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { parentPort } from 'worker_threads';6import * as diffWorker from '../common/diffWorker';78function main() {9const port = parentPort;10if (!port) {11throw new Error(`This module should only be used in a worker thread.`);12}1314port.on('message', async ({ id, fn, args }) => {15try {16const res = await (diffWorker as any)[fn](...args);17port.postMessage({ id, res });18} catch (err) {19port.postMessage({ id, err });20}21});22}2324main();252627