Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Pool.prototype.exec = function (method, params, options) {
return resolver.promise;
} else if (typeof method === "function") {
// send stringified function and function arguments to worker
return this.exec("run", [String(method), params], options);
return this.exec("run", [String(method), params, method.name], options);
} else {
throw new TypeError('Function or string expected as argument "method"');
}
Expand Down
7 changes: 6 additions & 1 deletion src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,14 @@ worker.methods = {};
* @param {Array} [args] Function arguments
* @returns {*}
*/
worker.methods.run = function run(fn, args) {
worker.methods.run = function run(fn, args, fnName) {
var f = new Function('return (' + fn + ').apply(this, arguments);');
f.worker = publicWorker;
Object.defineProperty(f, "name", {
value: fnName || "user defined function",
configurable: true,
});

return f.apply(f, args);
};

Expand Down