webworker-file
v0.2.0
Published
Initialize imported web worker files with ease
Downloads
177
Maintainers
Readme
webworker-file
Initialize imported web worker files with ease
Installation
npm install --save webworker-file
or:
yarn add webworker-file
Usage
// workerFile.js
const worker = function() {
postMessage({ type: "ready" });
// File to import will be downloaded, ensure that the path is relative to the server address
const scriptPath = "https://archive.org/download/ffmpeg_asm/ffmpeg_asm.js";
importScripts(scriptPath);
onmessage = function(event) {
postMessage({ type: "stdout", data: {} });
};
};
export default worker;
import WorkerFile from "webworker-file";
import workerFile from "./workerFile";
const worker = new WorkerFile(workerFile);
worker.onmessage = function(e) {
// ...
console.log(e);
};
License
MIT