MCPcopy Index your code
hub / github.com/developit/workerize

github.com/developit/workerize @0.1.8 sqlite

repository ↗ · DeepWiki ↗ · release 0.1.8 ↗
3 symbols 5 edges 2 files 0 documented · 0%
README

💖 Using Webpack? You want workerize-loader ➡️

workerize

Workerize npm travis

Moves a module into a Web Worker, automatically reflecting exported functions as asynchronous proxies.

  • Bundles a tiny, purpose-built RPC implementation into your app
  • If exported module methods are already async, signature is unchanged
  • Supports synchronous and asynchronous worker functions
  • Works beautifully with async/await
  • Just 800 bytes of gzipped ES3

Install

npm install --save workerize

Usage

Pass either a function or a string containing code.

worker.js:

let worker = workerize(`
    export function add(a, b) {
        // block for half a second to demonstrate asynchronicity
        let start = Date.now();
        while (Date.now()-start < 500);
        return a + b;
    }
`);

(async () => {
    console.log('3 + 9 = ', await worker.add(3, 9));
    console.log('1 + 2 = ', await worker.add(1, 2));
})();

License

MIT License © Jason Miller

Core symbols most depended-on inside this repo

setup
called by 1
src/index.js
toCjs
called by 1
src/index.js
workerize
called by 0
src/index.js

Shape

Function 3

Languages

TypeScript100%

Modules by API surface

src/index.js3 symbols

Dependencies from manifests, versioned

eslint4.16.0 · 1×
eslint-config-developit1.1.1 · 1×
microbundle0.4.3 · 1×

For agents

$ claude mcp add workerize \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact