diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /node_modules/@jet-app/app-store/tmp/src/common/util/page-common.js | |
init commit
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.js | 25 |
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 |
