if (value && value.data && value._id) {
// here you will receive messages
// console.log('This is the main thread ' + isMainThread)
- this._run(fn, value)
+ this.runInAsyncScope(this._run.bind(this), this, fn, value)
} else if (value.parent) {
// save the port to communicate with the main thread
// this will be received once
_run (fn, value) {
try {
- const res = this.runInAsyncScope(fn, null, value.data)
+ const res = fn(value.data)
this.parent.postMessage({ data: res, _id: value._id })
this.lastTask = Date.now()
} catch (e) {
"scripts": {
"build": "npm install",
"test": "standard && nyc mocha --exit --timeout 20000 tests/*test.js ",
- "debug-test": "mocha --inspect-brk --experimental-worker --exit tests/*test.js ",
+ "debug-test": "mocha --inspect-brk --exit tests/*test.js ",
"demontest": "nodemon --exec \"npm test\"",
"coverage": "nyc report --reporter=text-lcov tests/*test.js | coveralls",
"standard-verbose": "npx standard --verbose",