@okiba/worker-utils
v0.1.25
Published
Utils to work with WebWorker
Downloads
21
Readme
Okiba / worker-utils
Set of useful functions to ease WebWorkers development
__
Installation
npm i --save @okiba/worker-utils
Or import it directly in the browser
<script type="module" src="https://unpkg.com/@okiba/worker-utils/index.js"></script>
Usage
import worker-utils from '@okiba/worker-utils'
Untranspiled code 🛑
Okiba Core packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:
{
test: /\.js$/,
exclude: /node_modules\/(?!(@okiba)\/).*/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
createWorker(fn)
Creates a web worker starting from a function
Arguments
+ fn
: function
function to be included in the worker script, will be self-invoked
Returns
WebWorker
worker running the passed script