Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cotyhamilton/fly-worker
Pass a function to a web worker
https://github.com/cotyhamilton/fly-worker
Last synced: about 2 months ago
JSON representation
Pass a function to a web worker
- Host: GitHub
- URL: https://github.com/cotyhamilton/fly-worker
- Owner: cotyhamilton
- License: mit
- Created: 2020-10-02T18:06:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-04T01:46:36.000Z (over 4 years ago)
- Last Synced: 2024-11-07T14:44:39.726Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fly-worker
[![npm version](https://img.shields.io/npm/v/fly-worker.svg)](https://www.npmjs.org/package/fly-worker)
[![npm version](https://img.shields.io/npm/dt/fly-worker.svg)](https://www.npmjs.org/package/fly-worker)## Pass a function to a web worker
(or worker on the fly, or generic web worker)
### Installation
```
yarn add fly-worker
```### Usage
Pass your function as the first argument and function parameters as additional arguments
```
import FlyWorker from 'fly-worker'const add = (a, b) => (a + b);
const worker = new FlyWorker();
(async () => {
console.log('3 + 9 = ', await worker.exec(add,3,9));
})();```
Live example here
https://cotyhamilton.github.io/fly-worker/example/