Only call slice if Array or string

This commit is contained in:
Mel O'Hagan 2022-06-28 13:44:33 +01:00
parent ed9a54e197
commit de30ebb60d
3 changed files with 23 additions and 19 deletions

View File

@ -5,8 +5,12 @@
const displayLimit = 5 const displayLimit = 5
$: badges = value?.slice(0, displayLimit) ?? [] $: badges = isValidType() ? 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}

View File

@ -1028,10 +1028,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.209": "@budibase/backend-core@1.0.212":
version "1.0.209" version "1.0.212"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.209.tgz#23f752d52027baf22995b1eb2ea7ea024f16a027" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212.tgz#7ce8bfa8c968f4aa7558bd2dd13ad3e1e3e40c8f"
integrity sha512-JBXdi/U8kXwulG2cerF8B/ijTo5N3tNItXAODy/rkNPbAef9sSpdPrduvUiGH6DKoVnovq2feSSfT0t/Iztwfw== integrity sha512-pCrAHr54d2onSbaUoCWP83LMJnm28PNIpBAmAhi2kNdSfaGTFY/Iw1sbGOE3G/9vNaB+RRXeibKEEPFjToOgAg==
dependencies: dependencies:
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
@ -1109,12 +1109,12 @@
svelte-flatpickr "^3.2.3" svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0" svelte-portal "^1.0.0"
"@budibase/pro@1.0.209": "@budibase/pro@1.0.212":
version "1.0.209" version "1.0.212"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.209.tgz#a27175fc2f4da4d065c13bd5d3552cc5f197693a" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212.tgz#d6d2528b9ec2ec47e79d3360d04feeb5d2900d1e"
integrity sha512-/mEr8O1UpmF1V17sKTzjUrrG7M5g/ofKw7ROT9wEv0sQGE2D2eZtPrjwSHSC0vYHHsTFf/4aQnu+WY9UAdgQdA== integrity sha512-RcbDmz3pkReUHXAJDPzvgTYy0CBksw55XLbW0wNtDu2HVWP0ZXoiMMJjOxNDwMfL3q4eZitWgISa7QUDisDtMA==
dependencies: dependencies:
"@budibase/backend-core" "1.0.209" "@budibase/backend-core" "1.0.212"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@budibase/standard-components@^0.9.139": "@budibase/standard-components@^0.9.139":

View File

@ -291,10 +291,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.209": "@budibase/backend-core@1.0.212":
version "1.0.209" version "1.0.212"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.209.tgz#23f752d52027baf22995b1eb2ea7ea024f16a027" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212.tgz#7ce8bfa8c968f4aa7558bd2dd13ad3e1e3e40c8f"
integrity sha512-JBXdi/U8kXwulG2cerF8B/ijTo5N3tNItXAODy/rkNPbAef9sSpdPrduvUiGH6DKoVnovq2feSSfT0t/Iztwfw== integrity sha512-pCrAHr54d2onSbaUoCWP83LMJnm28PNIpBAmAhi2kNdSfaGTFY/Iw1sbGOE3G/9vNaB+RRXeibKEEPFjToOgAg==
dependencies: dependencies:
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
@ -322,12 +322,12 @@
uuid "8.3.2" uuid "8.3.2"
zlib "1.0.5" zlib "1.0.5"
"@budibase/pro@1.0.209": "@budibase/pro@1.0.212":
version "1.0.209" version "1.0.212"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.209.tgz#a27175fc2f4da4d065c13bd5d3552cc5f197693a" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212.tgz#d6d2528b9ec2ec47e79d3360d04feeb5d2900d1e"
integrity sha512-/mEr8O1UpmF1V17sKTzjUrrG7M5g/ofKw7ROT9wEv0sQGE2D2eZtPrjwSHSC0vYHHsTFf/4aQnu+WY9UAdgQdA== integrity sha512-RcbDmz3pkReUHXAJDPzvgTYy0CBksw55XLbW0wNtDu2HVWP0ZXoiMMJjOxNDwMfL3q4eZitWgISa7QUDisDtMA==
dependencies: dependencies:
"@budibase/backend-core" "1.0.209" "@budibase/backend-core" "1.0.212"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@cspotcode/source-map-consumer@0.8.0": "@cspotcode/source-map-consumer@0.8.0":