Functions

Math

sum

Signature

sum(items: list)

Description

Returns the sum of all items in the list.

Example
>>> sum([1, 2, 3, 5, 8])
19

avg

Signature

avg(items: list)

Description

Returns the average of all items in the list.

Example
>>> avg([1, 2, 3, 5, 8])
3.8

round

Signature

round(value: number, precision: number)

Description

Returns the value rounded to the specified precision.

Example
>>> round(3.1415, 2)
3.14

floor

Signature

floor(value: number, precision: number)

Description

Returns the value rounded down to the specified precision.

Example
>>> floor(3.1415, 2)
3.14

ceil

Signature

ceil(value: number, precision: number)

Description

Returns the value rounded up to the specified precision.

Example
>>> ceil(3.1415, 2)
3.15

max

Signature

max(items: list)

Description

Returns the maximum of all items in the list.

Example
>>> max([1, 2, 3, 5, 8])
8

min

Signature

min(items: list)

Description

Returns the minimum of all items in the list.

Example
>>> min([1, 2, 3, 5, 8])
1

sin

Signature

sin(value: number, precision: number)

Description

Returns the sine of the value as a number between -1 and 1.

Example
>>> sin(30, 5)
0.500

cos

Signature

cos(value: number, precision: number)

Example
>>> cos(30, 5)
0.866

exp

Signature

exp(value: number, precision: number)

Example
>>> exp(1, 5)
2.718

pow

Signature

pow(value: number, exponent: number)

Example
>>> pow(2, 3)
8

sqrt

Signature

sqrt(value: number, precision: number)

Example
>>> sqrt(9, 5)
3.0000

abs

Signature

abs(value: number)

Example
>>> abs(-3)
3

vector

Signature

vector(values: list)

Example
>>> vector([[1, 2, 3]])
Vector {
    [[1, 2, 3]]
}

rand

Signature

rand(start: number, end: number)

Example
>>> rand(1, 10)
6

String

len

Signature

len(value: string)

Example
>>> len("hello")
5

substr

Signature

substr(value: string, start: number, end: number)

Example
>>> substr("hello", 1, 3)
ell

contains

Signature

contains(value: string, search: string)

Example
>>> contains("hello", "ell")
true

toUpperCase

Signature

toUpperCase(value: string)

Example
>>> toUpperCase("hello")
HELLO

random.password(minLength, maxLength)

Signature

random.password(minLength: number, maxLength: number)

Example
>>> random.password(6, 8)
cR9mVzp6

Object

len

Signature

len(value: object)

Example
>>> len({"hello": "world", "foo": "bar"})
2

contains

Signature

contains(value: object, key: string)

Example
>>> contains({"hello": "world", "foo": "bar"}, "hello")
true

list

Signature

list(value: object)

Example
>>> list({"hello": "world", "foo": "bar"})
["hello", "foo"]

relation

Signature

relation(value: object)

Example
>>> relation({"hello": "world", "foo": "bar"})
<relation>
  <tuple>
    <key>hello</key>
    <value type="string">world</value>
  </tuple>
  <tuple>
    <key>foo</key>
    <value type="string">bar</value>
  </tuple>
</relation>

join

Signature

join(glue: string, pieces: list)

Example
>>> join(', ', ['a', 'b', 'c', 'd'])
'a, b, c, d'

Date

today

Signature

today()

Example
>>> today()
2018-09-12

now

Signature

now()

Example
>>> now()
2018-09-12T13:22:02-05:00

date

Signature

date(value: string, timezone: string)

Example
>>> date('2018-06-19')
Date {
    date: 2018-09-12 00:00:00.0 UTC (+00:00)
}

duration

Signature

duration(value: string)

Example
>>> duration("1h30m")
90m

User

user -> User

Returns the current user from local store. The user gets updated on every refresh.

Signature

user()

Example
>>> user()
User {
    id: 4,
    module_id: 1,
    email: "steffen@brezel.io",
    name: "Steffen"
}

hasRole

Signature

hasRole(role: string)

Example
>>> hasRole("ROLE_ADMIN")
true

JSON

json.decode

Signature

json.decode(value: string)

Example
>>> json.decode("[1, 2, 3]")
[1, 2, 3]

json.encode

Signature

json.encode(value: string)

Example
>>> json.encode("[1, 2, 3]")
[1, 2, 3]

Regex

regex.quote

Signature

regex.quote(value: string, delimiter: string)

Example
>>> regex.quote("-=hello world=-", "/")
\\-=hello\\ world\\=-

regex.matchAll

Signature

regex.matchAll(pattern: string, subject: string)

Example
>>> regex.matchAll("hello (\\w+)", "hello world")
[
  { "0": "hello world", "1": "world" }
]

Misc

env

Signature

env(name: string)

Example
>>> env("SERVICE_URL")
"https://api.my-service.com"
  • Math functions: sum, avg, round, floor, ceil, max, min, sin, cos, exp, pow, sqrt, abs, vector, rand
  • String functions: len, substr, contains, toUpperCase, random.password(minLength, maxLength)
  • Object functions: len, contains, list, relation, join
  • Date functions: today, now, date, duration
  • User functions: user, hasRole
  • JSON functions: json.decode, json.encode
  • Regex functions: regex.quote(string, delimiter), regex.matchAll(pattern, subject)
  • Misc functions: env