summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/util/page-common.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/common/util/page-common.js')
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/common/util/page-common.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/util/page-common.js b/node_modules/@jet-app/app-store/tmp/src/common/util/page-common.js
new file mode 100644
index 0000000..706fa9e
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/common/util/page-common.js
@@ -0,0 +1,25 @@
+/**
+ * Created by ls on 6/19/2019.
+ */
+/**
+ * On different platforms, different shelves are expected to be in certain multiples to not appear like there is a "gap"
+ * This function is used to truncate an array of models to fit given expected multiple.
+ * Note that ideally we want to request the exact number of items needed, but this accounts for cases where some data fails to build into full UI elements.
+ * @param items Array of items to truncate
+ * @param mod Modulo to apply.
+ */
+export function truncateItems(items, mod) {
+ if (!items) {
+ return null;
+ }
+ const length = items.length;
+ const remainder = length % mod;
+ // If we have less than mod items, we should return them all instead of 0 (because i - (i % mod)=0 when i < mod)
+ if (length >= mod) {
+ return items.slice(0, length - remainder);
+ }
+ else {
+ return items;
+ }
+}
+//# sourceMappingURL=page-common.js.map \ No newline at end of file