Refactor
This commit is contained in:
parent
067d508270
commit
1d40c06843
|
@ -5,12 +5,8 @@
|
||||||
|
|
||||||
const displayLimit = 5
|
const displayLimit = 5
|
||||||
|
|
||||||
$: badges = isValidType() ? value?.slice(0, displayLimit) : []
|
$: badges = Array.isArray(value) ? value.slice(0, displayLimit) : []
|
||||||
$: leftover = (value?.length ?? 0) - badges.length
|
$: leftover = (value?.length ?? 0) - badges.length
|
||||||
|
|
||||||
function isValidType() {
|
|
||||||
return Array.isArray(value) || typeof value === "string"
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each badges as badge}
|
{#each badges as badge}
|
||||||
|
|
Loading…
Reference in New Issue