monaco-worker-manager
Version:
Easily deal with monaco workers
12 lines (11 loc) • 347 B
JavaScript
import { initialize as initializeWorker } from 'monaco-editor/esm/vs/editor/editor.worker.js';
/**
* Create a web worker proxy.
*
* @param fn - The function that creates the web worker.
*/
export function initialize(fn) {
self.onmessage = () => {
initializeWorker((ctx, createData) => Object.create(fn(ctx, createData)));
};
}