Merge pull request #637 from JustinBeckwith/forown

refactor: drop usage of _.forOwn
This commit is contained in:
Michael Lumish 2018-11-15 16:03:44 -08:00 committed by GitHub
commit 06274d82f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -122,7 +122,8 @@ Metadata.prototype.get = function(key) {
*/ */
Metadata.prototype.getMap = function() { Metadata.prototype.getMap = function() {
var result = {}; var result = {};
_.forOwn(this._internal_repr, function(values, key) { Object.keys(this._internal_repr).forEach(key => {
const values = this._internal_repr[key];
if(values.length > 0) { if(values.length > 0) {
result[key] = values[0]; result[key] = values[0];
} }
@ -136,7 +137,8 @@ Metadata.prototype.getMap = function() {
*/ */
Metadata.prototype.clone = function() { Metadata.prototype.clone = function() {
var copy = new Metadata(); var copy = new Metadata();
_.forOwn(this._internal_repr, function(value, key) { Object.keys(this._internal_repr).forEach(key => {
const value = this._internal_repr[key];
copy._internal_repr[key] = _.clone(value); copy._internal_repr[key] = _.clone(value);
}); });
return copy; return copy;
@ -162,7 +164,8 @@ Metadata.prototype._getCoreRepresentation = function() {
Metadata._fromCoreRepresentation = function(metadata) { Metadata._fromCoreRepresentation = function(metadata) {
var newMetadata = new Metadata(); var newMetadata = new Metadata();
if (metadata) { if (metadata) {
_.forOwn(metadata, function(value, key) { Object.keys(metadata).forEach(key => {
const value = metadata[key];
newMetadata._internal_repr[key] = _.clone(value); newMetadata._internal_repr[key] = _.clone(value);
}); });
} }

View File

@ -882,7 +882,8 @@ Server.prototype.addService = function(service, implementation) {
throw new Error('Can\'t add a service to a started server.'); throw new Error('Can\'t add a service to a started server.');
} }
var self = this; var self = this;
_.forOwn(service, function(attrs, name) { Object.keys(service).forEach(name => {
const attrs = service[name];
var method_type; var method_type;
if (attrs.requestStream) { if (attrs.requestStream) {
if (attrs.responseStream) { if (attrs.responseStream) {