Skip to content

Commit e2146cf

Browse files
authored
Merge pull request #39 from rezo-labs/feature/new_ops
Add more ops
2 parents 0f714ce + a062a1a commit e2146cf

File tree

4 files changed

+341
-167
lines changed

4 files changed

+341
-167
lines changed

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Operator | Description
8989
--- | ---
9090
`DATE_ISO(a)` | transform date or date-like object to ISO string
9191
`DATE_UTC(a)` | transform date or date-like object to UTC string
92+
`DATE_STR(a)` | transform date or date-like object to string with format "YYYY-MM-DD"
93+
`TIME_STR(a)` | transform date or date-like object to string with format "HH:mm:ss"
9294
`YEAR(a)` | get year of a date object, similar to `getFullYear`
9395
`MONTH(a)` | get month of a date object, similar to `getMonth`
9496
`GET_DATE(a)` | get date of a date object, similar to `getDate`
@@ -111,22 +113,37 @@ Operator | Description
111113
`MULTIPLY(a, b)` | a * b
112114
`DIVIDE(a, b)` | a / b
113115
`REMAINDER(a, b)` | a % b
114-
`ROUND(a, n)` | round number `a` to `n` number of decimals, similar to `toFixed`
115-
`MAX(a, b)` | max value
116-
`MIN(a, b)` | min value
116+
`CEIL(a)` | returns the smallest integer greater than or equal to `a`.
117+
`FLOOR(a)` | returns the largest integer less than or equal to `a`.
118+
`ROUND(a)` | rounds to the nearest integer.
119+
`ROUND(a, n)` | rounds number `a` to `n` number of decimals, (`ROUND(1.23, 1) = 1.2`).
120+
`MAX(a, b)` | max value between `a` and `b`.
121+
`MAX(arr)` | max value of an array of numbers.
122+
`MIN(a, b)` | min value between `a` and `b`.
123+
`MIN(arr)` | min value of an array of numbers.
117124
`POWER(a, b)` | a^b
125+
`EXP(a)` | returns `e^a`, where `e` is Euler's number.
126+
`LOG(a)` | returns the natural logarithm (base `e`) of `a`.
118127

119128
### String
120129

121130
Operator | Description
122131
--- | ---
123-
`STR_LEN(a)` | length of string
124-
`LOWER(a)` | to lower case
125-
`UPPER(a)` | to upper case
126-
`TRIM(a)` | removes whitespace at the beginning and end of string.
127-
`CONCAT(a, b)` | concat 2 strings `a` and `b`.
128-
`LEFT(a, b)` | extract `b` characters from the beginning of the string `a`.
129-
`RIGHT(a, b)` | extract `b` characters from the end of the string `a`.
132+
`STR_LEN(str)` | length of string
133+
`LOWER(str)` | to lower case
134+
`UPPER(str)` | to upper case
135+
`TRIM(str)` | removes whitespace at the beginning and end of string.
136+
`CONCAT(strA, strB)` | concat 2 strings `strA` and `strB`.
137+
`LEFT(str, count)` | extract `count` characters from the beginning of the string `str`.
138+
`RIGHT(str, count)` | extract `count` characters from the end of the string `str`.
139+
`MID(str, startAt, count)` | extract `count` characters from `startAt` position of the string `str`.
140+
`ENCODE_URL_COMPONENT(str)` | encode string to URL component.
141+
`REPT(str, count)` | repeat string `count` times.
142+
`JOIN(arr, separator)` | join an array of strings with `separator`.
143+
`SPLIT(str, separator)` | split string `str` by `separator` to an array of strings.
144+
`SEARCH(str, keyword)` | search `keyword` in `str` and return the position of the first occurrence. Return -1 if not found.
145+
`SEARCH(str, keyword, startAt)` | search `keyword` in `str` and return the position of the first occurrence after `startAt`. Return -1 if not found.
146+
`SUBSTITUTE(str, old, new)` | replace all occurrences of `old` in `str` with `new`.
130147

131148
### Boolean
132149

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"scripts": {
2626
"build": "directus-extension build",
2727
"dev": "directus-extension build -w --no-minify",
28-
"test": "jest"
28+
"test": "TZ=UTC jest"
2929
},
3030
"devDependencies": {
3131
"@babel/core": "^7.19.3",

0 commit comments

Comments
 (0)