diff options
-rw-r--r-- | js/build/app.js | 30 | ||||
-rw-r--r-- | js/service/Resource.js | 9 | ||||
-rw-r--r-- | js/utility/Iterators.js (renamed from js/utility/iterators.js) | 5 |
3 files changed, 8 insertions, 36 deletions
diff --git a/js/build/app.js b/js/build/app.js index 8f09b44d1..31ad58c70 100644 --- a/js/build/app.js +++ b/js/build/app.js @@ -399,32 +399,10 @@ var $__build_47_app__ = function () { return this.hashMap[$traceurRuntime.toProperty(id)]; }, delete: function (id) { - var deleteAtIndex; - for (var $__3 = enumerate(this.values)[$traceurRuntime.toProperty(Symbol.iterator)](), $__4; !($__4 = $__3.next()).done;) { - try { - throw undefined; - } catch (value) { - try { - throw undefined; - } catch (index) { - try { - throw undefined; - } catch ($__8) { - { - $__8 = $traceurRuntime.assertObject($__4.value); - index = $__8[0]; - value = $__8[1]; - } - { - if (value[$traceurRuntime.toProperty(this.id)] === id) { - deleteAtIndex = index; - break; - } - } - } - } - } - } + var $__0 = this; + var deleteAtIndex = this.values.findIndex(function (e) { + return e[$traceurRuntime.toProperty($__0.id)] === id; + }); if (deleteAtIndex !== undefined) { this.values.splice(deleteAtIndex, 1); } diff --git a/js/service/Resource.js b/js/service/Resource.js index 44a7277b6..f71126f02 100644 --- a/js/service/Resource.js +++ b/js/service/Resource.js @@ -49,14 +49,7 @@ app.factory('Resource', () => { delete (id) { // find index of object that should be deleted - let deleteAtIndex; - - for (let [index, value] of enumerate(this.values)) { - if (value[this.id] === id) { - deleteAtIndex = index; - break; - } - } + let deleteAtIndex = this.values.findIndex(e => e[this.id] === id); if (deleteAtIndex !== undefined) { this.values.splice(deleteAtIndex, 1); diff --git a/js/utility/iterators.js b/js/utility/Iterators.js index b83e5de82..3c5e34b18 100644 --- a/js/utility/iterators.js +++ b/js/utility/Iterators.js @@ -13,7 +13,8 @@ const hasOwn = Object.prototype.hasOwnProperty; /** * From http://wiki.ecmascript.org/doku.php?id=harmony:iterators#standard_api - * Allows to iterate over objects like for (let [key, value] of objects) + * Allows to iterate over objects + * like: for (let [key, value] of objects) */ window.items = function (obj) { 'use strict'; @@ -32,7 +33,7 @@ window.items = function (obj) { /** * Iterates over a list and returns the item and index - * like: (let [index, value] of list) + * like: for (let [index, value] of enumerate(list)) * Similar to Pythons enumerate() iterator function */ window.enumerate = function (list) { |