Skip to content

Commit 227c095

Browse files
authored
Merge pull request #204 from arcana261/master
stronger checking for functions in client.js
2 parents ed2a048 + 232ff02 commit 227c095

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/grpc-native-core/src/client.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,15 @@ exports.Client = Client;
429429
Client.prototype.makeUnaryRequest = function(path, serialize, deserialize,
430430
argument, metadata, options,
431431
callback) {
432-
if (options instanceof Function) {
432+
if (_.isFunction(options)) {
433433
callback = options;
434434
if (metadata instanceof Metadata) {
435435
options = {};
436436
} else {
437437
options = metadata;
438438
metadata = new Metadata();
439439
}
440-
} else if (metadata instanceof Function) {
440+
} else if (_.isFunction(metadata)) {
441441
callback = metadata;
442442
metadata = new Metadata();
443443
options = {};
@@ -450,7 +450,7 @@ Client.prototype.makeUnaryRequest = function(path, serialize, deserialize,
450450
}
451451
if (!((metadata instanceof Metadata) &&
452452
(options instanceof Object) &&
453-
(callback instanceof Function))) {
453+
(_.isFunction(callback)))) {
454454
throw new Error('Argument mismatch in makeUnaryRequest');
455455
}
456456

@@ -508,15 +508,15 @@ Client.prototype.makeUnaryRequest = function(path, serialize, deserialize,
508508
Client.prototype.makeClientStreamRequest = function(path, serialize,
509509
deserialize, metadata,
510510
options, callback) {
511-
if (options instanceof Function) {
511+
if (_.isFunction(options)) {
512512
callback = options;
513513
if (metadata instanceof Metadata) {
514514
options = {};
515515
} else {
516516
options = metadata;
517517
metadata = new Metadata();
518518
}
519-
} else if (metadata instanceof Function) {
519+
} else if (_.isFunction(metadata)) {
520520
callback = metadata;
521521
metadata = new Metadata();
522522
options = {};
@@ -529,7 +529,7 @@ Client.prototype.makeClientStreamRequest = function(path, serialize,
529529
}
530530
if (!((metadata instanceof Metadata) &&
531531
(options instanceof Object) &&
532-
(callback instanceof Function))) {
532+
(_.isFunction(callback)))) {
533533
throw new Error('Argument mismatch in makeClientStreamRequest');
534534
}
535535

0 commit comments

Comments
 (0)