multijs
Version:
Multi.js is cross browsing JavaScript multithread library.
40 lines (29 loc) • 865 B
Markdown
Light weight, easy to use cross browsing JavaScript multithread module.
If the browser supports Web Worker and Blob, it uses Web Worker. But if not, use timer function instead.
Yes, it is not cross browsing 'multithread', but can use this module for old browsers with same code.
IE5.5-11 and all major browsers supported.
MIT.
1. Install module via NPM
> $ npm install --save multi.js
2. Include from browser script. You need Web bundler(Browserify/Webpack) and transpiler like Babel.
```javascript
import Thread from 'multijs';
var thread = new Thread(function() {
postData = Math.PI * postData;
return postData;
});
thread.start().execute(100, function(err, data) {
if(err) {
console.log(err);
return;
}
console.log(data);
thread.terminate();
});
```
3. Build and run.