This commit is contained in:
Justin Beckwith 2018-11-14 16:43:55 -08:00
parent 7cba96910c
commit 889c2218da
1 changed files with 5 additions and 1 deletions

View File

@ -861,6 +861,10 @@ var defaultHandler = {
}
};
function isObject(thing) {
return (typeof thing === 'object' || typeof thing === 'function') && thing !== null;
}
/**
* Add a service to the server, with a corresponding implementation.
* @param {grpc~ServiceDefinition} service The service descriptor
@ -868,7 +872,7 @@ var defaultHandler = {
* names to method implementation for the provided service.
*/
Server.prototype.addService = function(service, implementation) {
if (typeof service !== 'object' || typeof implementation !== 'object') {
if (!isObject(service) || !isObject(implementation)) {
throw new Error('addService requires two objects as arguments');
}
if (_.keys(service).length === 0) {