webworker-shim
A tiny shim for WebWorker (data URI only) that works in Node.
Last updated 3 years ago by fabiospampinato .
Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install webworker-shim 
SYNC missed versions from official npm registry.

WebWorker Shim

A tiny shim for WebWorker (data URI only) that works in Node.

Install

npm install --save webworker-shim

Usage

Only WebWorkers encoded as a data:text/javascript;charset=utf-8,* string are supported.

import WebWorker from 'webworker-shim';

const worker = new Worker ( `data:text/javascript;charset=utf-8,${encodeURIComponent (`
  addEventListener ( 'message', event => {
    if ( event.data === 'ping' ) {
      postMessage ( 'pong' );
    }
  });
`)}`);

worker.addEventListener ( 'message', event => {
  console.log ( event.data ); // => 'pong'
});

worker.postMessage ( 'ping' );

License

MIT © Fabio Spampinato

Current Tags

  • 1.1.0                                ...           latest (3 years ago)

2 Versions

  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |