-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from taylor1791/additional-examples
Add ES6 example
- Loading branch information
Showing
5 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import gamma from 'gamma'; | ||
|
||
export default function () { | ||
self.addEventListener('message',function (ev){ | ||
var startNum = parseInt(ev.data); // ev.data=4 from main.js | ||
|
||
setInterval(function () { | ||
var r = startNum / Math.random() - 1; | ||
self.postMessage([ startNum, r, gamma(r) ]); | ||
}, 500); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
var commonWorker = require('./common-js-worker.js'); | ||
import es6Worker from './es6-worker.js'; | ||
|
||
var work = require('../'); | ||
|
||
var w = work(require('./worker.js')); | ||
w.addEventListener('message', function (ev) { | ||
console.log(ev.data); | ||
|
||
var w1 = work(commonWorker); | ||
w1.addEventListener('message', function (ev) { | ||
console.log('CommonJS Worker:', ev.data); | ||
}); | ||
|
||
w1.postMessage(4); // send the worker a message | ||
|
||
var w2 = work(es6Worker); | ||
w2.addEventListener('message', function (ev) { | ||
console.log('ES6 Worker', ev.data); | ||
}); | ||
|
||
w.postMessage(4); // send the worker a message | ||
w2.postMessage(4); // send the worker a message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
entry: { | ||
app: ["./example/main.js"] | ||
}, | ||
output: { | ||
filename: "output.js" | ||
}, | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.jsx?$/, | ||
exclude: /(node_modules|bower_components)/, | ||
loader: 'babel', | ||
query: { | ||
presets: ['es2015'] | ||
} | ||
} | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters