Modernize for;;-loops
Change-Id: Ic6f86af0d674cc6643fc9eef2aa7431cfdf514f2
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index af49191..47f3a96 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -30,13 +30,13 @@
},
newAfter : function (obj) {
- for (var i = 0; i < this._operands.length; i++) {
- if (this._operands[i] === obj) {
+ this._operands.forEach(function (op, i) {
+ if (op === obj) {
var operand = unspecClass.create(this);
this._operands.splice(i + 1, 0, operand);
return this.update();
};
- };
+ }, this);
},
// The doc is already set in the group
@@ -48,15 +48,17 @@
if (operand.ldType() !== 'doc')
return null;
- for (var i = 0; i < this._operands.length; i++) {
- var op = this.getOperand(i);
- if (op.ldType() === 'doc'
- && operand.key() === op.key()
- && operand.matchop() === op.matchop()
- && operand.value() === op.value()) {
- return op;
- };
- };
+ const f = this._operands.find(
+ op =>
+ op.ldType() === 'doc'
+ && operand.key() === op.key()
+ && operand.matchop() === op.matchop()
+ && operand.value() === op.value()
+ );
+
+ if (f)
+ return f;
+
return null;
},
@@ -194,11 +196,9 @@
_removeChildren(group);
// Append operands
- for (var i = 0; i < this._operands.length; i++) {
- group.appendChild(
- this.getOperand(i).element()
- );
- };
+ this._operands.forEach(
+ op => group.appendChild(op.element())
+ );
// Set operators
var op = this.operators(
@@ -342,10 +342,10 @@
toJson : function () {
var opArray = new Array();
- for (var i = 0; i < this._operands.length; i++) {
- if (this._operands[i].ldType() !== 'non')
- opArray.push(this._operands[i].toJson());
- };
+ this._operands.forEach(function(op) {
+ if (op.ldType() !== 'non')
+ opArray.push(op.toJson());
+ });
return {
"@type" : "koral:" + this.ldType(),
"operation" : "operation:" + this.operation(),
diff --git a/dev/js/src/vc/jsonld.js b/dev/js/src/vc/jsonld.js
index 21260d4..cfa0acc 100644
--- a/dev/js/src/vc/jsonld.js
+++ b/dev/js/src/vc/jsonld.js
@@ -52,8 +52,7 @@
// In case of a group, destroy all operands
if (this._operands !== undefined) {
- for (var i = 0; i < this._operands.length; i++)
- this.getOperand(i).destroy();
+ this._operands.forEach(i => i.destroy());
this._operands = [];
};
},
diff --git a/dev/js/src/vc/rewritelist.js b/dev/js/src/vc/rewritelist.js
index 75f3d27..d6885c9 100644
--- a/dev/js/src/vc/rewritelist.js
+++ b/dev/js/src/vc/rewritelist.js
@@ -15,11 +15,12 @@
*/
fromJson : function (json) {
this._list = new Array();
- for (var i = 0; i < json.length; i++) {
- this._list.push(
- rewriteClass.create(json[i])
- );
- };
+ json.forEach(
+ i =>
+ this._list.push(
+ rewriteClass.create(i)
+ )
+ );
return this;
},
diff --git a/dev/js/src/vc/statistic.js b/dev/js/src/vc/statistic.js
index cd8d0ce..0c3c6ca 100644
--- a/dev/js/src/vc/statistic.js
+++ b/dev/js/src/vc/statistic.js
@@ -44,16 +44,14 @@
statDL.classList.add("flex");
var statistic = this._statistic;
- var keys = Object.keys(statistic);
- for (i = 0; i < keys.length; i++) {
+ Object.keys(statistic).forEach(function(k) {
statSp = statDL.addE('div')
statDT = statSp.addE('dt');
- var k = keys[i];
statDT.addT(k);
statDT.setAttribute('title', k);
statDD = statSp.addE('dd');
statDD.addT(new Number(statistic[k]).toLocaleString());
- }
+ });
this._element = statDL;
return this._element;