diff options
author | Minwoo Jung <jmwsoft@gmail.com> | 2015-08-21 14:30:08 -0700 |
---|---|---|
committer | minwoojung <minwoojung@minwoojungs-MacBook-Pro.local> | 2015-12-17 19:45:57 +0900 |
commit | ae5bcf9528e49c612c36b9c72d1d5602ecc18827 (patch) | |
tree | 6f25f8f5fa737c7942953d5ce4198609a80c627c /lib/cluster.js | |
parent | 93d6b5fb68eae8b0912579980e17ebf0723ab2cc (diff) | |
download | android-node-v8-ae5bcf9528e49c612c36b9c72d1d5602ecc18827.tar.gz android-node-v8-ae5bcf9528e49c612c36b9c72d1d5602ecc18827.tar.bz2 android-node-v8-ae5bcf9528e49c612c36b9c72d1d5602ecc18827.zip |
lib: use arrow functions instead of bind
use `arrow functions` instead of `bind(this)` in order to improve
performance through optimizations.
PR-URL: https://github.com/nodejs/node/pull/3622
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'lib/cluster.js')
-rw-r--r-- | lib/cluster.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/cluster.js b/lib/cluster.js index f202f25cdd..6ab829de45 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -33,8 +33,12 @@ function Worker(options) { if (options.process) { this.process = options.process; - this.process.on('error', this.emit.bind(this, 'error')); - this.process.on('message', this.emit.bind(this, 'message')); + this.process.on('error', (code, signal) => + this.emit('error', code, signal) + ); + this.process.on('message', (message, handle) => + this.emit('message', message, handle) + ); } } util.inherits(Worker, EventEmitter); @@ -337,7 +341,9 @@ function masterInit() { process: workerProcess }); - worker.on('message', this.emit.bind(this, 'message')); + worker.on('message', (message, handle) => + this.emit('message', message, handle) + ); worker.process.once('exit', function(exitCode, signalCode) { /* |