Skip to content

Commit

Permalink
feat: add additional string expressions (#2517)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryce-seifert authored Jul 8, 2023
1 parent 31cdd5a commit 1087b33
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/4_secondary_admin_controls/expressions/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ substr() extracts characters from indexStart up to but not including indexEnd.

Tip: If you don't want the behaviour of negative numbers, you can use `max(0, index)` to limit the value to never be below 0.

**includes(val, find)**

Check if a string contains a specific value

eg `includes("Companion is great!", "great")` gives `true`

**toUpperCase(val)**

Coverts all characters in a string to uppercase

**toLowerCase(val)**

Coverts all characters in a string to lowercase

**replaceAll(val, find, replace)**

Searches a string for a specific value, and then replaces all instances of that value with a new string

eg `replaceAll("This is great!", "This", "Companion")` gives `Companion is great!`

**secondsToTimestamp(seconds, format)**

Convert a number of seconds into a timestamp of format 'HH:mm:ss'.
Expand Down
12 changes: 12 additions & 0 deletions lib/Shared/Expression/ExpressionFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ export const ExpressionFunctions = {
substr: (str, start, end) => {
return (str + '').slice(start, end)
},
includes: (str, arg) => {
return (str + '').includes(arg)
},
toUpperCase: (str) => {
return (str + '').toUpperCase()
},
toLowerCase: (str) => {
return (str + '').toLowerCase()
},
replaceAll: (str, find, replace) => {
return (str + '').replaceAll(find, replace)
},
secondsToTimestamp: (v, type) => {
v = Math.max(0, v)

Expand Down

0 comments on commit 1087b33

Please sign in to comment.