瀏覽代碼

use for in instead of for of loops

Sebastián Katzer 8 年之前
父節點
當前提交
e483eee1d9
共有 2 個文件被更改,包括 9 次插入7 次删除
  1. 4 3
      www/local-notification-core.js
  2. 5 4
      www/local-notification-util.js

+ 4 - 3
www/local-notification-core.js

@@ -68,7 +68,8 @@ exports.schedule = function (msgs, callback, scope, args) {
             return;
         }
 
-        for (var toast of toasts) {
+        for (var i = 0, len = toasts.length; i < len; i++) {
+            var toast = toasts[i];
             this.mergeWithDefaults(toast);
             this.convertProperties(toast);
         }
@@ -102,8 +103,8 @@ exports.update = function (msgs, callback, scope, args) {
             return;
         }
 
-        for (var toast of toasts) {
-            this.convertProperties(toast);
+        for (var i = 0, len = toasts.length; i < len; i++) {
+            this.convertProperties(toasts[i]);
         }
 
         this.exec('update', toasts, callback, scope);

+ 5 - 4
www/local-notification-util.js

@@ -173,7 +173,8 @@ exports.convertActions = function (options) {
     if (!options.actions)
         return null;
 
-    for (var action of options.actions) {
+    for (var i = 0, len = options.actions.length; i < len; i++) {
+        var action = options.actions[i];
 
         if (!action.id) {
             console.warn('Action with title ' + action.title + ' ' +
@@ -335,8 +336,8 @@ exports.createCallbackFn = function (fn, scope) {
 exports.convertIds = function (ids) {
     var convertedIds = [];
 
-    for (var id of ids) {
-        convertedIds.push(Number(id));
+    for (var i = 0, len = ids.length; i < len; i++) {
+        convertedIds.push(Number(ids[i]));
     }
 
     return convertedIds;
@@ -353,7 +354,7 @@ exports.convertIds = function (ids) {
 exports.getValueFor = function (options) {
     var keys = Array.apply(null, arguments).slice(1);
 
-    for (var key of keys) {
+    for (var i = 0, key = keys[i], len = keys.length; i < len; key = keys[++i]) {
         if (options.hasOwnProperty(key)) {
             return options[key];
         }