sizeOf
A helpful utility to get size of the store which can be a String, Array, a Set or a Map of values.
Demo
List Size: 6
[1,2,3,4,5,6]
Set Size: 4
{1, 2, 3, 4}
Map Size: 2
{1 => 3, 2 => 4}
Usage
<script lang="ts">
import { sizeOf } from "svelte-legos";
import { writable } from "svelte/store";
const list = writable([1, 2, 3, 4, 5, 6]);
const set = writable(new Set([1, 2, 3, 4]));
const map = writable(
new Map([
[1, 3],
[2, 4],
])
);
const listSize = sizeOf(list); // $listSize => 4
const setSize = sizeOf(set); // $setSize => 4
const mapSize = sizeOf(map); // $mapSize => 2
</script>