Create and execute tasks in real cpu threads other than the main one. (ES6 imports for now) Threadman doesn't use any dependencies. It's based on workers.
Installation
npm i threadman
Syntax
new Thread(fn, args, options).run(callback)
// Or
new Thread(fn, args, options).run().then(callback)
Basic usage
import { Thread } from 'threadman'
let number = 10
const fn = (number) => number + 20
const callback = (result) => number = result
const args = [number]
new Thread(fn, args).run(callback)
// Or a callback function can be passed as third argument like below
new Thread(fn, args).run().then(callback)
After you get the result you can access main scope again and reassign variables.
Top comments (0)