Object Funcers

+

Combines the items of two objects into one.

TypeValue
InputObj<Any>an object
other (param #1)Obj<Any>another object
OutputObj<Any>an object with the items of the input and other

Where the input and other share keys, the values of other are used in the output.

Examples

ProgramTypeValueError
{a: 1} +{b: 2}Obj<>{a: 1, b: 2}
{a: 1, b: 2} +{b: 3}Obj<>{a: 1, b: 3}

get

Retrieves the value of a given property.

TypeValue
InputObj<<A Any>>an object
prop (param #1)Str|Numa property key
Output<A Any>the value associated in the input object with the given property key

Examples

ProgramTypeValueError
{} get("a")Void{"Code":"VoidProgram","Kind":"Type"}
{a: 1} get("a")Num1
{a: 1, b: "hey"} get("a")Num|Str1
{a: 1, b: "hey", c: false} get("a")Num|Str|Bool1
{1: "a"} get(1)Str"a"
{1.5: "a"} get(1.5)Str"a"
{b: 1} get("a")Num{"Code":"NoSuchProperty","GotValue":"\"a\"","Kind":"Value"}

has

Checks for the presence of a given property.

TypeValue
InputObj<<A Any>>an object
prop (param #1)Str|Numa property key
OutputBooltrue if the object has the given property, false if not

Examples

ProgramTypeValueError
{} has("a")Boolfalse
{a: 1} has("a")Booltrue

items

Iterates over the properties together with the values.

TypeValue
InputObj<<A Any>>an object
OutputArr<Arr<Str, <A Any>>...>an array of tuples of the properties and associated values of the input object

Examples

ProgramTypeValueError
{a: 1, b: 2} items sortBy(@0, <)Arr<Arr<Str, Num>...>[["a", 1], ["b", 2]]
{} itemsArr<Arr<Str, Void>...>[]

props

Lists the properties of an object.

TypeValue
InputObj<<A Any>>an object
OutputArr<Str...>all the property keys of the object, as an array

Examples

ProgramTypeValueError
{a: 1, b: 2} props sortArr<Str...>["a", "b"]
{} propsArr<Str...>[]

values

Lists the values of an object.

TypeValue
InputObj<<A Any>>an object
OutputArr<<A Any>...>all the property values of the object, as an array

Examples

ProgramTypeValueError
{a: 1, b: 2} values sortArr<Num...>[1, 2]
{} valuesArr<>[]

without

Removes a property from an object.

TypeValue
InputObj<<A Any>>an object
prop (param #1)Stra property key
OutputObj<<A Any>>the input object, but with the specified property removed

Examples

ProgramTypeValueError
{a: 1, b: 2} without("b")Obj<Num>{a: 1}
{a: 1, b: 2} without("c")Obj<Num>{a: 1, b: 2}