Use Object.values instead of _.each : 96ddb50

This commit is contained in:
Hongarc 2018-12-05 12:18:35 +07:00
parent e6d7edd130
commit 70b7a72bd7

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Q = require('q'); var Q = require('q');
var intl = require('../intl'); var intl = require('../intl');
@ -83,7 +82,7 @@ GitVisuals.prototype.resetAll = function() {
visTag.remove(); visTag.remove();
}, this); }, this);
_.each(this.visNodeMap, function(visNode) { Object.values(this.visNodeMap).forEach(function(visNode) {
visNode.remove(); visNode.remove();
}, this); }, this);
@ -207,7 +206,7 @@ GitVisuals.prototype.animateAllAttrKeys = function(keys, attr, speed, easing) {
this.visBranchCollection.each(animate); this.visBranchCollection.each(animate);
this.visEdgeCollection.each(animate); this.visEdgeCollection.each(animate);
this.visTagCollection.each(animate); this.visTagCollection.each(animate);
_.each(this.visNodeMap, animate); Object.values(this.visNodeMap).forEach(animate);
var time = (speed !== undefined) ? speed : GRAPHICS.defaultAnimationTime; var time = (speed !== undefined) ? speed : GRAPHICS.defaultAnimationTime;
setTimeout(function() { setTimeout(function() {
@ -322,7 +321,7 @@ GitVisuals.prototype.finishAnimation = function(speed) {
GitVisuals.prototype.explodeNodes = function(speed) { GitVisuals.prototype.explodeNodes = function(speed) {
var deferred = Q.defer(); var deferred = Q.defer();
var funcs = []; var funcs = [];
_.each(this.visNodeMap, function(visNode) { Object.values(this.visNodeMap).forEach(function(visNode) {
funcs.push(visNode.getExplodeStepFunc(speed)); funcs.push(visNode.getExplodeStepFunc(speed));
}); });
@ -369,7 +368,7 @@ GitVisuals.prototype.animateAllFromAttrToAttr = function(fromSnapshot, toSnapsho
this.visBranchCollection.each(animate); this.visBranchCollection.each(animate);
this.visEdgeCollection.each(animate); this.visEdgeCollection.each(animate);
this.visTagCollection.each(animate); this.visTagCollection.each(animate);
_.each(this.visNodeMap, animate); Object.values(this.visNodeMap).forEach(animate);
}; };
/*************************************** /***************************************
@ -393,7 +392,7 @@ GitVisuals.prototype.genSnapshot = function() {
this.fullCalc(); this.fullCalc();
var snapshot = {}; var snapshot = {};
_.each(this.visNodeMap, function(visNode) { Object.values(this.visNodeMap).forEach(function(visNode) {
snapshot[visNode.get('id')] = visNode.getAttributes(); snapshot[visNode.get('id')] = visNode.getAttributes();
}, this); }, this);
@ -633,7 +632,7 @@ GitVisuals.prototype.calcDepth = function() {
} }
var depthIncrement = this.getDepthIncrement(maxDepth); var depthIncrement = this.getDepthIncrement(maxDepth);
_.each(this.visNodeMap, function(visNode) { Object.values(this.visNodeMap).forEach(function(visNode) {
visNode.setDepthBasedOn(depthIncrement, this.getHeaderOffset()); visNode.setDepthBasedOn(depthIncrement, this.getHeaderOffset());
}, this); }, this);
}; };
@ -656,7 +655,7 @@ GitVisuals.prototype.calcDepth = function() {
**************************************/ **************************************/
GitVisuals.prototype.animateNodePositions = function(speed) { GitVisuals.prototype.animateNodePositions = function(speed) {
_.each(this.visNodeMap, function(visNode) { Object.values(this.visNodeMap).forEach(function(visNode) {
visNode.animateUpdatedPosition(speed); visNode.animateUpdatedPosition(speed);
}, this); }, this);
}; };
@ -854,7 +853,7 @@ GitVisuals.prototype.zIndexReflow = function() {
}; };
GitVisuals.prototype.visNodesFront = function() { GitVisuals.prototype.visNodesFront = function() {
_.each(this.visNodeMap, function(visNode) { Object.values(this.visNodeMap).forEach(function(visNode) {
visNode.toFront(); visNode.toFront();
}); });
}; };
@ -893,7 +892,7 @@ GitVisuals.prototype.drawTreeFirstTime = function() {
this.gitReady = true; this.gitReady = true;
this.calcTreeCoords(); this.calcTreeCoords();
_.each(this.visNodeMap, function(visNode) { Object.values(this.visNodeMap).forEach(function(visNode) {
visNode.genGraphics(this.paper); visNode.genGraphics(this.paper);
}, this); }, this);