Skip to content

Commit e6dbad0

Browse files
committed
Switch from eval() to Function(). Fixes #6.
1 parent eb4148b commit e6dbad0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[{*.json,*.md,.*rc,*.yml,*.txt}]
11+
indent_style = space
12+
indent_size = 2
13+
insert_final_newline = false

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ global.Worker = function Worker(url) {
5858
outside.emit('message', { data });
5959
},
6060
fetch: global.fetch,
61-
importScripts(...urls) {}
61+
importScripts() {}
6262
},
6363
getScopeVar;
6464
inside.on('message', e => { let f = getScopeVar('onmessage'); if (f) f.call(scope, e); });
@@ -78,7 +78,9 @@ global.Worker = function Worker(url) {
7878
.then( code => {
7979
let vars = 'var self=this,global=self';
8080
for (let k in scope) vars += `,${k}=self.${k}`;
81-
getScopeVar = eval('(function() {'+vars+';\n'+code+'\nreturn function(__){return eval(__)}})').call(scope);
81+
getScopeVar = Function(
82+
vars + ';\n' + code + '\nreturn function(n){return n=="onmessage"?onmessage:null;}'
83+
).call(scope);
8284
let q = messageQueue;
8385
messageQueue = null;
8486
q.forEach(this.postMessage);

0 commit comments

Comments
 (0)