Maps and Values
Functions over maps, and functions that inspect any value. Keys are listed in JavaScript property order: integer-like keys first, ascending, then the other keys in the order they were added.
Every function can be called as f(x, ...) or as a method, x.f(...). In the signatures, T and U stand for any type, T[] is a list, ? marks an optional parameter, and (T, number) => boolean is a lambda parameter.
| Function | Description |
|---|---|
keys | The keys of a map. |
values | The values of a map. |
entries | The entries of a map, as a list of { key, value } maps (not [key, value] pairs as in JavaScript), e.g. m.entries().map(.key + "=" + .value). |
isEmpty | Whether a list, text, or map has no items; null is empty. |
type | The kind of a value: "null", "boolean", "number", "string", "list", "map", "timestamp", "duration", or "opaque". |
toString | Renders a value as text, as a template would. |
keys
The keys of a map.
keys({ [key: string]: any }): string[]
{ a: 1, b: 2 }.keys() // => ["a", "b"]values
The values of a map.
values({ [key: string]: T }): T[]
{ a: 1, b: 2 }.values() // => [1, 2]entries
The entries of a map, as a list of { key, value } maps (not [key, value] pairs as in JavaScript), e.g. m.entries().map(.key + "=" + .value).
entries({ [key: string]: T }): { key: string, value: T }[]
{ a: 1, b: 2 }.entries() // => [{ key: "a", value: 1 }, { key: "b", value: 2 }]
{ a: 1, b: 2 }.entries().map(`${.key}=${.value}`).join("&") // => "a=1&b=2"isEmpty
Whether a list, text, or map has no items; null is empty.
isEmpty(any[] | string | { [key: string]: any } | null): boolean
{}.isEmpty() // => true
isEmpty("") // => truetype
The kind of a value: "null", "boolean", "number", "string", "list", "map", "timestamp", "duration", or "opaque".
type(any): string
type(1) // => "number"
type("a") // => "string"
type([]) // => "list"
type({}) // => "map"
type(null) // => "null"
type(now()) // => "timestamp"
type(days(1)) // => "duration"toString
Renders a value as text, as a template would.
toString(string | number | boolean | null | timestamp | duration): string
toString(true) // => "true"
`${1.5}` == toString(1.5) // => true