Len
Is a function that returns the length of a value. The function is inspired from Python len function.
Usage
<script>
import {len} from "@sveu/shared"
const value = "Hello World"
</script>
<h1>Length of "{value}" is {len(value)}</h1>
<script>
import {len} from "@sveu/shared"
const value = "Hello World"
</script>
<h1>Length of "{value}" is {len(value)}</h1>
svelte
Example
Length of "Hello World" is 11
Length of map is 2
Length of dict is 2
Length of set is 3
Length of list is 3
<script lang="ts">
import { len } from "@sveu/shared"
const value = "Hello World"
const mapx = new Map()
const dict = {
a: 1,
b: 2,
}
const set = new Set([1, 2, 3])
const list = [1, 2, 3]
mapx.set("a", 1)
mapx.set("b", 2)
</script>
<h1>Length of "{value}" is {len(value)}</h1>
<h1>Length of map is {len(mapx)}</h1>
<h1>Length of dict is {len(dict)}</h1>
<h1>Length of set is {len(set)}</h1>
<h1>Length of list is {len(list)}</h1>
<script lang="ts">
import { len } from "@sveu/shared"
const value = "Hello World"
const mapx = new Map()
const dict = {
a: 1,
b: 2,
}
const set = new Set([1, 2, 3])
const list = [1, 2, 3]
mapx.set("a", 1)
mapx.set("b", 2)
</script>
<h1>Length of "{value}" is {len(value)}</h1>
<h1>Length of map is {len(mapx)}</h1>
<h1>Length of dict is {len(dict)}</h1>
<h1>Length of set is {len(set)}</h1>
<h1>Length of list is {len(list)}</h1>
svelte
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
26
27
28
29
30
Click fold/expand code
API
Arguments
Name | Description | Type | Required |
---|---|---|---|
item | The value to get the length from. | T | Yes |