Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Commit accdf0d

Browse files
author
devfd
committed
fix js api
1 parent 71898e3 commit accdf0d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

js/self.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
module.exports = (WorkerSelf, EventEmitter) => {
43

54
const self = {

js/worker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11

2-
32
module.exports = (WorkerModule, EventEmitter) => {
43

54
class Worker {
65
constructor(jsPath) {
7-
this.id = WorkerModule.startWorker(jsPath)
6+
if (!jsPath || !jsPath.endsWith('.js')) {
7+
throw new Error("Invalid worker path. Only js files are supported");
8+
}
9+
10+
this.id = WorkerModule.startWorker(jsPath.replace(".js", ""))
811
.then(id => {
912
EventEmitter.addListener(`Worker${id}`, (message) => {
1013
!!message && this.onmessage && this.onmessage(message);

0 commit comments

Comments
 (0)