Have ideas to improve npm?Join in the discussion! »

webworker-fileTypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

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

Install

npm i webworker-file

DownloadsWeekly Downloads

173

Version

0.2.0

License

MIT

Unpacked Size

9.99 kB

Total Files

13

Last publish

Collaborators

  • avatar