Files
vscode/extensions/ipynb/src/notebookSerializerWorker.ts
2024-09-09 11:37:44 +10:00

20 lines
780 B
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { parentPort } from 'worker_threads';
import { serializeNotebookToString } from './serializers';
import type { NotebookData } from 'vscode';
if (parentPort) {
parentPort.on('message', ({ id, data }: { id: string; data: NotebookData }) => {
if (parentPort) {
const json = serializeNotebookToString(data);
const bytes = new TextEncoder().encode(json);
parentPort.postMessage({ id, data: bytes });
}
});
}