diff --git a/lib/worker.js b/lib/worker.js index c8e5d688570740be47e4aa97bd3dc0605b8c9298..a704f231df95f1cdddb2b80277482830bda7ccc0 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -6,19 +6,11 @@ var fs = require("fs"), noop = require(path.join(__dirname, "noop.js")), 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) { - var args = trim(arg.replace(/^.*\(/, "").replace(/[\t|\r|\n|\"|\']+/g, "").replace(/\).*/, "")), - body = trim(arg.replace(/^.*\{/, "").replace(/\}$/, "")); + var __worker_evaluated_function_ = null; + 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