blob: 706fa9ec67c61074a8600e8776db0496ee906ad0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
|