diff --git a/canary-checker/docs/scripting/cel.mdx b/canary-checker/docs/scripting/cel.mdx index 7462bd14..d60b02e7 100644 --- a/canary-checker/docs/scripting/cel.mdx +++ b/canary-checker/docs/scripting/cel.mdx @@ -110,6 +110,124 @@ base64.decode("aGVsbG8=") // return b'hello' ## collections +### .keys + +The `keys` method on a map returns a list of keys.. + +Syntax: + +```javascript +e.keys() + +// Where: +// `e` is a map . +``` + +Examples: + +```javascript +{"first": "John", "last": "Doe"}.keys() // ["first", "last"] +``` + +### .merge + +The `merge` method on a map takes in a second map to merge with. + +Syntax: + +```javascript +e.merge(x) + +// Where: +// `e` is the map you want to merge to. +// `x` is the second map to merge from. +``` + +Examples: + +```javascript +{"first": "John"}.merge({"last": "Doe"}) // {"first": "John", "last": "Doe"} +``` + +### .omit + +The `omit` method on a map takes a list of keys to omit from the map. + +Syntax: + +```javascript +e.omit(x) + +// Where: +// `e` is a list . +// `x` is a list of keys to omit. +``` + +Examples: + +```javascript +{"first": "John", "last": "Doe"}.omit(["first"]) // {"last": "Doe"} +``` + +### .sort + +The `sort` method on a list returns the reversed list. + +Syntax: + +```javascript +e.sort() + +// Where: +// `e` is a list . +``` + +Examples: + +```javascript +[3, 2, 1].sort() // [1, 2, 3] +['c', 'b', 'a'].sort() // ['a', 'b', 'c'] +``` + +### .uniq + +The `uniq` method on a list returns a list of the unique elements. + +Syntax: + +```javascript +e.uniq() + +// Where: +// `e` is a list . +``` + +Examples: + +```javascript +[1,2,3,3,3,].uniq().sum() // 10 +["a", "b", "b"].uniq().join() // "ab" +``` + +### .values + +The `values` method on a map returns a list of values. + +Syntax: + +```javascript +e.values() + +// Where: +// `e` is a map . +``` + +Examples: + +```javascript +{'a': 1, 'b': 2}.values().sum() // 3 +``` + ### all The `all` macro tests whether a predicate holds for **all** elements of a list `e` or keys of a map `e`. It returns a boolean value based on the evaluation.