+
+ _run (fn, value) {
+ try {
+ const res = fn(value.data)
+ this.parent.postMessage({ data: res, _id: value._id })
+ this.lastTask = Date.now()
+ } catch (e) {
+ this.parent.postMessage({ error: e, _id: value._id })
+ this.lastTask = Date.now()
+ }
+ }
+
+ _runAsync (fn, value) {
+ fn(value.data)
+ .then(res => {
+ this.parent.postMessage({ data: res, _id: value._id })
+ this.lastTask = Date.now()
+ })
+ .catch(e => {
+ this.parent.postMessage({ error: e, _id: value._id })
+ this.lastTask = Date.now()
+ })
+ }