Merge pull request #643 from JustinBeckwith/each

refactor: drop usage of _.each
This commit is contained in:
Michael Lumish 2018-11-19 14:31:37 -08:00 committed by GitHub
commit 4071bf85a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -378,7 +378,8 @@ function Client(address, credentials, options) {
} }
self.$interceptors = options.interceptors || []; self.$interceptors = options.interceptors || [];
self.$interceptor_providers = options.interceptor_providers || []; self.$interceptor_providers = options.interceptor_providers || [];
_.each(self.$method_definitions, function(method_definition, method_name) { Object.keys(self.$method_definitions).forEach(method_name => {
const method_definition = self.$method_definitions[method_name];
self[method_name].interceptors = client_interceptors self[method_name].interceptors = client_interceptors
.resolveInterceptorProviders(self.$interceptor_providers, method_definition) .resolveInterceptorProviders(self.$interceptor_providers, method_definition)
.concat(self.$interceptors); .concat(self.$interceptors);
@ -934,7 +935,8 @@ exports.makeClientConstructor = function(methods, serviceName,
ServiceClient.prototype.$method_definitions = methods; ServiceClient.prototype.$method_definitions = methods;
ServiceClient.prototype.$method_names = {}; ServiceClient.prototype.$method_names = {};
_.each(methods, function(attrs, name) { Object.keys(methods).forEach(name => {
const attrs = methods[name];
if (name.indexOf('$') === 0) { if (name.indexOf('$') === 0) {
throw new Error('Method names cannot start with $'); throw new Error('Method names cannot start with $');
} }

View File

@ -144,7 +144,8 @@ exports.loadObject = function loadObject(value, options) {
return loadObject(value.ns, options); return loadObject(value.ns, options);
} }
if (value.className === 'Namespace') { if (value.className === 'Namespace') {
_.each(value.children, function(child) { Object.keys(value.children).forEach(key => {
const child = value.children[key];
result[child.name] = loadObject(child, options); result[child.name] = loadObject(child, options);
}); });
return result; return result;

View File

@ -137,7 +137,8 @@ exports.loadObject = function loadObject(value, options) {
if (value.hasOwnProperty('nested')) { if (value.hasOwnProperty('nested')) {
// It's a namespace or root object // It's a namespace or root object
_.each(value.nested, function(nested, name) { Object.keys(value.nested).forEach(name => {
const nested = value.nested[name];
result[name] = loadObject(nested, options); result[name] = loadObject(nested, options);
}); });
return result; return result;