diff options
author | Tim Emiola <tbetbetbe@users.noreply.github.com> | 2015-01-26 11:26:05 -0800 |
---|---|---|
committer | Tim Emiola <tbetbetbe@users.noreply.github.com> | 2015-01-26 11:26:05 -0800 |
commit | 8a089291b155fde35f3251202bbdab5123ed3442 (patch) | |
tree | e577c22790d76c7ba273700c161f10303d86513f | |
parent | 52e271563ee0ed4f7c553844b4cfd7d57b75be96 (diff) | |
parent | c3969d5e3f6cae08a6ea0932c388d0b3caddfecd (diff) |
Merge pull request #207 from murgatroid99/node_remove_implicit_type_coersion
Node remove implicit type coersion
-rw-r--r-- | src/node/examples/math_server.js | 7 | ||||
-rw-r--r-- | src/node/interop/interop_client.js | 2 | ||||
-rw-r--r-- | src/node/server.js | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/node/examples/math_server.js b/src/node/examples/math_server.js index d649b4fd6d..e65cfe3002 100644 --- a/src/node/examples/math_server.js +++ b/src/node/examples/math_server.js @@ -52,7 +52,8 @@ var Server = grpc.buildServer([math.Math.service]); */ function mathDiv(call, cb) { var req = call.request; - if (req.divisor == 0) { + // Unary + is explicit coersion to integer + if (+req.divisor === 0) { cb(new Error('cannot divide by zero')); } cb(null, { @@ -89,7 +90,7 @@ function mathSum(call, cb) { // Here, call is a standard readable Node object Stream var sum = 0; call.on('data', function(data) { - sum += data.num | 0; + sum += (+data.num); }); call.on('end', function() { cb(null, {num: sum}); @@ -104,7 +105,7 @@ function mathDivMany(stream) { Transform.call(this, options); } DivTransform.prototype._transform = function(div_args, encoding, callback) { - if (div_args.divisor == 0) { + if (+div_args.divisor === 0) { callback(new Error('cannot divide by zero')); } callback(null, { diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js index cf75b9a77a..9306317b68 100644 --- a/src/node/interop/interop_client.js +++ b/src/node/interop/interop_client.js @@ -183,7 +183,7 @@ function pingPong(client, done) { assert.equal(response.payload.body.limit - response.payload.body.offset, response_sizes[index]); index += 1; - if (index == 4) { + if (index === 4) { call.end(); } else { call.write({ diff --git a/src/node/server.js b/src/node/server.js index fc7144a9c1..fe50acb5a1 100644 --- a/src/node/server.js +++ b/src/node/server.js @@ -233,7 +233,7 @@ function Server(options) { function handleNewCall(event) { var call = event.call; var data = event.data; - if (data == null) { + if (data === null) { return; } server.requestCall(handleNewCall); |