Context

Context manipulation library

context(entries)

returns a new context that includes all specified entries

Parameters
Name Required Type Description

entries

Yes

context

Examples
context([{key: "key1", value: 1}, {key: "key2", value: 2}]) => {key1: 1, key2:2}

context merge(contexts)

return a new context that includes all entries from the given contexts merged together

Parameters
Name Required Type Description

contexts

Yes

context

Examples
context merge([{key1: 1}, {key2:2}]) => {key1:1, key2:2}

context merge([{key1: 1, key2: 2}, {key2: 0, key3:3}]) => {key1:1, key2:0, key3:3}

context put(context, key, value)

return a new context that includes all entries from context with the addition of the new entry composed of key and value. If the key already exist it is overwritten

Parameters
Name Required Type Description

context

Yes

context

key

Yes

Text

value

Yes

Any

Examples
context put({key1: 1}, "key2", 2) => {key1:1, key2:2}

context put({key1: 1, key2:2}, "key2", 7) => {key1:1, key2:7}

context put(context, keys, value)

return a new context that includes all entries from context with the addition of the new entry composed of keys and value. If the key already exist it is overwritten

Parameters
Name Required Type Description

context

Yes

context

keys

Yes

Collection of Text

value

Yes

Any

Examples
context put({key1: 1}, ["key2"], 2) => {key1:1, key2:2}

context put({key1: 1, key2: {sub: "V"}}, ["key2", "sub"], "N") => {key1:1, key2:{sub:"N"}}

get entries(m)

produces a list of key,value pairs from a context m

Parameters
Name Required Type Description

m

Yes

context

Examples
get entries({key1 : "value1", key2 : "value2"}) =>  [ { key : "key1", value : "value1" }, {key : "key2", value : "value2"} ]

get value(m, key)

selects the value of the entry named key from the context m

Parameters
Name Required Type Description

m

Yes

context

key

Yes

Text

Examples
get value({key1 : "value1"}, "key1") => "value1"

get value({key1 : "value1"}, "unexistent-key") => null