Refactor
This commit is contained in:
parent
de30ebb60d
commit
fbf9997805
|
@ -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