Helpers
Small functions for text, lists and time.
Functions
util.trim(s)
The text without spaces at either end.
s:string
Returns string
util.starts_with(s, prefix)
Does the text begin with prefix?
s:stringprefix:string
Returns boolean
util.ends_with(s, suffix)
Does the text end with suffix?
s:stringsuffix:string
Returns boolean
util.split(s, sep)
Split on a plain separator (default ",").
s:stringsep:string, optional
Returns string[]
util.contains(list, value)
Is the value in the list?
list:any[]value:any
Returns boolean
util.index_of(list, value)
Where the value is in the list (1 is the first), or nil.
list:any[]value:any
Returns integer|nil
util.remove_value(list, value)
Remove the first matching value; true if it was there.
list:any[]value:any
Returns boolean
util.shuffle(list)
Shuffle a list in place.
list:T[]
Returns T[]
util.pick(list)
A random item of a list, or nil if it is empty.
list:T[]
Returns T
util.keys(t)
The keys of a table, sorted.
t:table
Returns any[]
util.clock(ms)
"12:30:05"
ms:integer, optional
Returns string
util.ago(ms)
"5s ago", "3m ago", "2h ago".
ms:integer
Returns string

