Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stronger checking for functions in client.js #204

Merged
merged 1 commit into from
Mar 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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