Skip to content
Snippets Groups Projects
Commit fbce2b7f authored by Daniel Di Sarli's avatar Daniel Di Sarli Committed by GitHub
Browse files

Merge pull request #20 from danieleds/patch-1

Fix crash with minified functions
parents 58182859 0cf0a529
No related branches found
No related tags found
No related merge requests found
...@@ -6,19 +6,11 @@ var fs = require("fs"), ...@@ -6,19 +6,11 @@ var fs = require("fs"),
noop = require(path.join(__dirname, "noop.js")), noop = require(path.join(__dirname, "noop.js")),
events = /^(error|message)$/; events = /^(error|message)$/;
function trim(arg) {
return arg.replace(/^(\s+|\t+|\n+)|(\s+|\t+|\n+)$/g, "");
}
function explode(arg) {
return trim(arg).split(new RegExp("\\s*,\\s*"));
}
function toFunction(arg) { function toFunction(arg) {
var args = trim(arg.replace(/^.*\(/, "").replace(/[\t|\r|\n|\"|\']+/g, "").replace(/\).*/, "")), var __worker_evaluated_function_ = null;
body = trim(arg.replace(/^.*\{/, "").replace(/\}$/, "")); eval("__worker_evaluated_function_ = (" + arg + ")"); // eslint-disable-line no-eval
return Function.apply(Function, explode(args).concat([body])); return __worker_evaluated_function_;
} }
// Bootstraps the Worker // Bootstraps the Worker
......
...@@ -4,19 +4,11 @@ const fs = require("fs"), ...@@ -4,19 +4,11 @@ const fs = require("fs"),
noop = require(path.join(__dirname, "noop.js")), noop = require(path.join(__dirname, "noop.js")),
events = /^(error|message)$/; events = /^(error|message)$/;
function trim (arg) {
return arg.replace(/^(\s+|\t+|\n+)|(\s+|\t+|\n+)$/g, "");
}
function explode (arg) {
return trim(arg).split(new RegExp("\\s*,\\s*"));
}
function toFunction (arg) { function toFunction (arg) {
const args = trim(arg.replace(/^.*\(/, "").replace(/[\t|\r|\n|\"|\']+/g, "").replace(/\).*/, "")), var __worker_evaluated_function_ = null;
body = trim(arg.replace(/^.*\{/, "").replace(/\}$/, "")); eval("__worker_evaluated_function_ = (" + arg + ")"); // eslint-disable-line no-eval
return Function.apply(Function, explode(args).concat([body])); return __worker_evaluated_function_;
} }
// Bootstraps the Worker // Bootstraps the Worker
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment