Skip to content

Commit

Permalink
Merge pull request #204 from arcana261/master
Browse files Browse the repository at this point in the history
stronger checking for functions in client.js
  • Loading branch information
murgatroid99 authored Mar 6, 2018
2 parents ed2a048 + 232ff02 commit 227c095
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/grpc-native-core/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ exports.Client = Client;
Client.prototype.makeUnaryRequest = function(path, serialize, deserialize,
argument, metadata, options,
callback) {
if (options instanceof Function) {
if (_.isFunction(options)) {
callback = options;
if (metadata instanceof Metadata) {
options = {};
} else {
options = metadata;
metadata = new Metadata();
}
} else if (metadata instanceof Function) {
} else if (_.isFunction(metadata)) {
callback = metadata;
metadata = new Metadata();
options = {};
Expand All @@ -450,7 +450,7 @@ Client.prototype.makeUnaryRequest = function(path, serialize, deserialize,
}
if (!((metadata instanceof Metadata) &&
(options instanceof Object) &&
(callback instanceof Function))) {
(_.isFunction(callback)))) {
throw new Error('Argument mismatch in makeUnaryRequest');
}

Expand Down Expand Up @@ -508,15 +508,15 @@ Client.prototype.makeUnaryRequest = function(path, serialize, deserialize,
Client.prototype.makeClientStreamRequest = function(path, serialize,
deserialize, metadata,
options, callback) {
if (options instanceof Function) {
if (_.isFunction(options)) {
callback = options;
if (metadata instanceof Metadata) {
options = {};
} else {
options = metadata;
metadata = new Metadata();
}
} else if (metadata instanceof Function) {
} else if (_.isFunction(metadata)) {
callback = metadata;
metadata = new Metadata();
options = {};
Expand All @@ -529,7 +529,7 @@ Client.prototype.makeClientStreamRequest = function(path, serialize,
}
if (!((metadata instanceof Metadata) &&
(options instanceof Object) &&
(callback instanceof Function))) {
(_.isFunction(callback)))) {
throw new Error('Argument mismatch in makeClientStreamRequest');
}

Expand Down

0 comments on commit 227c095

Please sign in to comment.