From 7df9594a040516f9f027b2357eb3d4aceb5016bd Mon Sep 17 00:00:00 2001 From: zinsserzh Date: Wed, 9 Aug 2017 19:07:00 -0700 Subject: [PATCH] Add isEmpty function to ItemList (#1218) * Add isEmpty function to ItemList * Fix coding style to be consistent. * Recompiled app.js for both js/admin/ and js/forum/ --- js/admin/dist/app.js | 15 +++++++++++++-- js/forum/dist/app.js | 15 +++++++++++++-- js/lib/utils/ItemList.js | 16 ++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/js/admin/dist/app.js b/js/admin/dist/app.js index eb2e3fcc1..16a08b91b 100644 --- a/js/admin/dist/app.js +++ b/js/admin/dist/app.js @@ -23425,14 +23425,25 @@ System.register("flarum/utils/ItemList", [], function (_export, _context) { } /** - * Check whether an item is present in the list. + * Check whether the list is empty. * - * @param key * @returns {boolean} + * @public */ babelHelpers.createClass(ItemList, [{ + key: "isEmpty", + value: function isEmpty() { + for (var i in this.items) { + if (this.items.hasOwnProperty(i)) { + return false; + } + } + + return true; + } + }, { key: "has", value: function has(key) { return !!this.items[key]; diff --git a/js/forum/dist/app.js b/js/forum/dist/app.js index 4bcdd072e..16374dc0b 100644 --- a/js/forum/dist/app.js +++ b/js/forum/dist/app.js @@ -31837,14 +31837,25 @@ System.register("flarum/utils/ItemList", [], function (_export, _context) { } /** - * Check whether an item is present in the list. + * Check whether the list is empty. * - * @param key * @returns {boolean} + * @public */ babelHelpers.createClass(ItemList, [{ + key: "isEmpty", + value: function isEmpty() { + for (var i in this.items) { + if (this.items.hasOwnProperty(i)) { + return false; + } + } + + return true; + } + }, { key: "has", value: function has(key) { return !!this.items[key]; diff --git a/js/lib/utils/ItemList.js b/js/lib/utils/ItemList.js index 042315dfd..1a08890aa 100644 --- a/js/lib/utils/ItemList.js +++ b/js/lib/utils/ItemList.js @@ -20,6 +20,22 @@ export default class ItemList { this.items = {}; } + /** + * Check whether the list is empty. + * + * @returns {boolean} + * @public + */ + isEmpty() { + for (const i in this.items) { + if(this.items.hasOwnProperty(i)) { + return false; + } + } + + return true; + } + /** * Check whether an item is present in the list. *