allow passing a function to shard eval (#2193)

This commit is contained in:
Gus Caplan
2018-01-12 07:05:27 -06:00
committed by Crawl
parent 2249da464f
commit 8aafcd6cde
2 changed files with 5 additions and 3 deletions

View File

@@ -86,6 +86,7 @@ class ShardClientUtil {
*/
broadcastEval(script) {
return new Promise((resolve, reject) => {
script = typeof script !== 'function' ? `(${script})(this)` : script;
const listener = message => {
if (!message || message._sEval !== script) return;
process.removeListener('message', listener);