Merge pull request #620 from JustinBeckwith/noobj

refactor: drop usage of _.isObject
This commit is contained in:
Michael Lumish 2018-11-15 16:03:19 -08:00 committed by GitHub
commit b472dc30cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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. * Add a service to the server, with a corresponding implementation.
* @param {grpc~ServiceDefinition} service The service descriptor * @param {grpc~ServiceDefinition} service The service descriptor
@ -868,7 +872,7 @@ var defaultHandler = {
* names to method implementation for the provided service. * names to method implementation for the provided service.
*/ */
Server.prototype.addService = function(service, implementation) { Server.prototype.addService = function(service, implementation) {
if (!_.isObject(service) || !_.isObject(implementation)) { if (!isObject(service) || !isObject(implementation)) {
throw new Error('addService requires two objects as arguments'); throw new Error('addService requires two objects as arguments');
} }
if (Object.keys(service).length === 0) { if (Object.keys(service).length === 0) {