-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathlength.cue
69 lines (66 loc) · 1.23 KB
/
length.cue
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package metadata
remap: functions: length: {
category: "Enumerate"
description: """
Returns the length of the `value`.
"""
arguments: [
{
name: "value"
description: "The array or object"
required: true
type: ["array", "object", "string"]
},
]
internal_failure_reasons: []
return: {
types: ["integer"]
rules: [
"If `value` is an array, the size of the array is returned.",
"If `value` is a string, the size of the string is returned.",
"If `value` is a map, the number of map keys is returned (nested keys are ignored)",
]
}
examples: [
{
title: "Length (object)"
source: """
length({
"portland": "Trail Blazers"
"seattle": "Supersonics"
})
"""
return: 2
},
{
title: "Length (nested object)"
source: """
length({
"home": {
"city": "Portland"
"state": "Oregon"
}
"name": "Trail Blazers"
"mascot": {
"name": "Blaze the Trail Cat"
}
})
"""
return: 3
},
{
title: "Length (array)"
source: """
length(["Trail Blazers", "Supersonics", "Grizzlies"])
"""
return: 3
},
{
title: "Length (string)"
source: """
length("The Planet of the Apes Musical")
"""
return: 30
},
]
}