!=(any a, any b) -> bool
Returns true if the two value are not equal
%(int a, int b) -> int
Returns the result of wrapping a around so that 0 <= res < b.
The modulus b must be 0 or negative.
Use
*(int a, int b) -> int
Multiplies two integers
+(int a, int b) -> int
Adds two integers together
++(string s1, string s2) -> string
Concatenates the two strings by appending s2 to s1 and
returns the joined string.
-(int a, int b) -> int
Subtracts two integers
/(float a, float b) -> float
Divide
<(int a, int b) -> bool
Returns true if a is less than b
<=(int a, int b) -> bool
Returns true if a is less than or equal to b
==(any a, any b) -> bool
Returns true if the two value are equal
>(int a, int b) -> bool
Returns true if a is greater than b
>=(int a, int b) -> bool
Returns true if a is greater than or equal to b
AWS::urlencode(string str) -> string
Url encode a string per AWS' requirements
Bool::and(bool a, bool b) -> bool
Returns true if both a and b are true
Bool::isNull(any check) -> bool
Returns true if the check parameter is null
Bool::not(bool b) -> bool
Returns the inverse of b: true if b is false and false if b is true
Bool::or(bool a, bool b) -> bool
Returns true if either a is true or b is true
Bool::xor(bool a, bool b) -> bool
Returns true if exactly one of a and b is true. Returns false if both are true or neither is true.
Bytes::base64Decode_v1(string s) -> result
Base64 decodes a string. Works with both the URL-safe and standard Base64
alphabets defined in [RFC 4648](https://www.rfc-editor.org/rfc/rfc4648.html)
sections [4](https://www.rfc-editor.org/rfc/rfc4648.html#section-4) and
[5](https://www.rfc-editor.org/rfc/rfc4648.html#section-5).
Bytes::base64Encode(bytes bytes) -> string
Base64URL encodes bytes with = padding. Uses URL-safe encoding
with - and _ instead of + and /, as defined in RFC 4648
section [5](https://www.rfc-editor.org/rfc/rfc4648.html#section-5).
Bytes::empty() -> bytes
Returns an empty list of bytes
Bytes::hexEncode(bytes bytes) -> string
Hex (Base16) encodes bytes using an uppercase alphabet. Complies
with [RFC 4648 section 8](https://www.rfc-editor.org/rfc/rfc4648.html#section-8).
Bytes::length(bytes bytes) -> int
Returns the number of bytes in bytes
Char::isASCII(character c) -> bool
Return whether c is a valid ASCII character
Char::isASCIILetter(character c) -> bool
Return whether c is an ASCII letter
Char::isDigit(character c) -> bool
Return whether c is a digit (that is, the digits 0-9)
Char::isLowercase(character c) -> bool
Return whether c is a lowercase character.
Char::isUppercase(character c) -> bool
Return whether c is an uppercase character.
Char::toLowercase_v1(character c) -> character
Return the lowercase value of c. If c does not have a lowercase value, returns c
Char::toUppercase_v1(character c) -> character
Return the uppercase value of c. If c does not have an uppercase value, returns c
Crypto::md5(bytes data) -> bytes
Computes the md5 digest of the given data. NOTE: There are multiple security problems with md5, see https://en.wikipedia.org/wiki/MD5#Security
Crypto::sha1hmac(bytes key, bytes data) -> bytes
Computes the SHA1-HMAC (hash-based message authentication code) digest of the given key and data.
Crypto::sha256(bytes data) -> bytes
Computes the SHA-256 digest of the given data
Crypto::sha256hmac(bytes key, bytes data) -> bytes
Computes the SHA-256 HMAC (hash-based message authentication code) digest of the given key and data.
Crypto::sha384(bytes data) -> bytes
Computes the SHA-384 digest of the given data
DB::count(datastore table) -> int
Return the number of items stored in table
DB::deleteAll_v1(datastore table) -> null
Delete everything from table
DB::delete_v1(string key, datastore table) -> null
Delete key from table
DB::generateKey() -> string
Returns a random key suitable for use as a DB key
DB::getAllWithKeys_v2(datastore table) -> dict
Fetch all the values in table. Returns an object with key: value. ie. {key : value, key2: value2}
DB::getAll_v3(datastore table) -> list
Fetch all the values in table
DB::getExisting(list keys, datastore table) -> list
Finds many values in table by keys (ignoring any missing items), returning a [value] list of values
DB::getManyWithKeys_v1(list keys, datastore table) -> dict
Finds many values in table by keys, returning a {key:{value}, key2: {value2} } object of keys and values
DB::getMany_v3(list keys, datastore table) -> option
Finds many values in table by keys. If all keys are found, returns Just a list of [values], otherwise returns Nothing (to ignore missing keys, use DB::getExisting)
DB::get_v2(string key, datastore table) -> option
Finds a value in table by key
DB::keys_v1(datastore table) -> list
Fetch all the keys of entries in table. Returns an list with strings
DB::queryCount(datastore table, block filter) -> int
Return the number of items from table for which filter returns true. Note that this does not check every value in table, but rather is optimized to find data with indexes. Errors at compile-time if Dark's compiler does not support the code in question.
DB::queryExactFields(dict spec, datastore table) -> list
Fetch all the values from table which have the same fields and values that spec has, returning a list of values. Previously called DB::query_v3
DB::queryExactFieldsWithKey(dict spec, datastore table) -> dict
Fetch all the values from table which have the same fields and values that spec has
, returning {key : value} as an object. Previous called DB::queryWithKey_v2
DB::queryOneWithExactFields(dict spec, datastore table) -> option
Fetch exactly one value from table which have the same fields and values that spec has. If there is exactly one value, it returns Just value and if there is none or more than 1 found, it returns Nothing. Previously called DB::queryOne_v2
DB::queryOneWithExactFieldsWithKey(dict spec, datastore table) -> option
Fetch exactly one value from table which have the same fields and values that spec has. If there is exactly one key/value pair, it returns Just {key: value} and if there is none or more than 1 found, it returns Nothing. Previously called DB::queryOnewithKey_v2
DB::queryOneWithKey_v3(datastore table, block filter) -> option
Fetch exactly one value from table for which filter returns true. Note that this does not check every value in table, but rather is optimized to find data with indexes. If there is exactly one key/value pair, it returns Just {key: value} and if there is none or more than 1 found, it returns Nothing. Errors at compile-time if Dark's compiler does not support the code in question.
DB::queryOne_v4(datastore table, block filter) -> option
Fetch exactly one value from table for which filter returns true. Note that this does not check every value in table, but rather is optimized to find data with indexes. If there is exactly one value, it returns Just value and if there is none or more than 1 found, it returns Nothing. Errors at compile-time if Dark's compiler does not support the code in question.
DB::queryWithKey_v3(datastore table, block filter) -> dict
Fetch all the values from table for which filter returns true, returning {key : value} as an object. Note that this does not check every value in table, but rather is optimized to find data with indexes. Errors at compile-time if Dark's compiler does not support the code in question.
DB::query_v4(datastore table, block filter) -> list
Fetch all the values from table for which filter returns true. Note that this does not check every value in table, but rather is optimized to find data with indexes. Errors at compile-time if Dark's compiler does not support the code in question.
DB::schemaFields_v1(datastore table) -> list
Fetch all the fieldNames in table
DB::schema_v1(datastore table) -> dict
Returns a
DB::set_v1(dict val, string key, datastore table) -> dict
Upsert val into table, accessible by key
Date::<(date d1, date d2) -> bool
Returns whether d1 < d2
Date::<=(date d1, date d2) -> bool
Returns whether d1 <= d2
Date::>(date d1, date d2) -> bool
Returns whether d1 d2
Date::>=(date d1, date d2) -> bool
Returns whether d1 = d2
Date::add(date d, int seconds) -> date
Returns a
Date::atStartOfDay(date date) -> date
Returns
Date::day(date date) -> int
Returns the day portion of date as an
Date::fromSeconds(int seconds) -> date
Converts an
Date::greaterThan(date d1, date d2) -> bool
Returns whether d1 d2
Date::greaterThanOrEqualTo(date d1, date d2) -> bool
Returns whether d1 = d2
Date::hour_v2(date date) -> int
Returns the hour portion of date as an
Date::lessThan(date d1, date d2) -> bool
Returns whether d1 < d2
Date::lessThanOrEqualTo(date d1, date d2) -> bool
Returns whether d1 <= d2
Date::minute_v1(date date) -> int
Returns the minute portion of date as an
Date::month(date date) -> int
Returns the month portion of date as an
Date::now() -> date
Returns the current time
Date::parse_v2(string s) -> result
Parses a string representing a date and time in the ISO 8601 format (for example: 2019-09-07T22:44:25Z) and returns the Date wrapped in a Result.
Date::second_v1(date date) -> int
Returns the second portion of date as an
Date::subtractSeconds(date d, int seconds) -> date
Returns a
Date::subtract_v1(date end, date start) -> int
Returns the difference of the two dates, in seconds
Date::toSeconds(date date) -> int
Converts date to an
Date::toString(date date) -> string
Stringify date to the ISO 8601 format YYYY-MM-DD'T'hh:mm:ss'Z'
Date::toStringISO8601BasicDate(date date) -> string
Stringify date to the ISO 8601 basic format YYYYMMDD
Date::toStringISO8601BasicDateTime(date date) -> string
Stringify date to the ISO 8601 basic format YYYYMMDD'T'hhmmss'Z'
Date::today() -> date
Returns the
Date::weekday(date date) -> int
Returns the weekday of date as an
Date::year(date date) -> int
Returns the year portion of date as an
Dict::empty() -> dict
Returns an empty dictionary
Dict::filterMap(dict dict, block fn) -> dict
Calls fn on every entry in dict, returning a
Dict::filter_v1(dict dict, block fn) -> dict
Evaluates fn key value on every entry in dict. Returns a
Dict::fromList(list entries) -> option
Each value in entries must be a [key, value] list, where is a
Dict::fromListOverwritingDuplicates(list entries) -> dict
Returns a
Dict::get_v2(dict dict, string key) -> option
If the dict contains key, returns the corresponding value,
wrapped in an
Dict::isEmpty(dict dict) -> bool
Returns true if the dict contains no entries
Dict::keys(dict dict) -> list
Returns dict's keys in a
Dict::map(dict dict, block fn) -> dict
Returns a new dictionary that contains the same keys as the original with values that have been transformed by fn, which operates on
each key-value pair.
Consider
Dict::member(dict dict, string key) -> bool
Returns true if the dict contains an entry with key, and
false otherwise
Dict::merge(dict left, dict right) -> dict
Returns a combined dictionary with both dictionaries' entries. If the same key exists in both left and right, it will have the value from right.
Dict::remove(dict dict, string key) -> dict
If the dict contains key, returns a copy of dict with key and its associated value removed. Otherwise, returns dict unchanged.
Dict::set(dict dict, string key, any val) -> dict
Returns a copy of dict with the key set to val
Dict::singleton(string key, any value) -> dict
Returns a dictionary with a single entry key: value
Dict::size(dict dict) -> int
Returns the number of entries in dict
Dict::toJSON(dict dict) -> string
Returns dict as a JSON string
Dict::toList(dict dict) -> list
Returns dict's entries as a list of [key, value] lists, in an arbitrary order. This function is the opposite of
Dict::values(dict dict) -> list
Returns dict's values in a
Float::absoluteValue(float a) -> float
Returns the absolute value of a (turning negative inputs into positive outputs)
Float::add(float a, float b) -> float
Add
Float::ceiling(float a) -> int
Round up to an integer value
Float::clamp(float value, float limitA, float limitB) -> float
If value is within the range given by limitA and , returns value.
If value is outside the range, returns limitA or , whichever is closer to value.
limitA and limitB can be provided in any order.
Float::divide(float a, float b) -> float
Divide
Float::floor(float a) -> int
Round down to an integer value.
Consider
Float::greaterThan(float a, float b) -> bool
Returns true if a is greater than b
Float::greaterThanOrEqualTo(float a, float b) -> bool
Returns true if a is greater than b
Float::lessThan(float a, float b) -> bool
Returns true if a is less than b
Float::lessThanOrEqualTo(float a, float b) -> bool
Returns true if a is less than b
Float::max(float a, float b) -> float
Returns the greater of
Float::min(float a, float b) -> float
Returns the lesser of
Float::multiply(float a, float b) -> float
Multiply
Float::negate(float a) -> float
Returns the negation of a, -a
Float::parse(string s) -> result
Returns the
Float::power(float base, float exponent) -> float
Returns base raised to the power of exponent
Float::round(float a) -> int
Round to the nearest integer value
Float::roundDown(float a) -> int
Round down to an integer value.
Consider
Float::roundTowardsZero(float a) -> int
Discard the fractional portion of
Float::roundUp(float a) -> int
Round up to an integer value
Float::sqrt(float a) -> float
Get the square root of a float
Float::subtract(float a, float b) -> float
Subtract
Float::sum(list a) -> float
Returns the sum of all the floats in the list
Float::truncate(float a) -> int
Discard the fractional portion of the float, rounding towards zero
Http::badRequest(string error) -> response
Returns a
Http::forbidden() -> response
Returns a
Http::notFound() -> response
Returns a
Http::redirectTo(string url) -> response
Returns a
Http::response(any response, int code) -> response
Returns a
Http::responseWithHeaders(any response, dict headers, int code) -> response
Returns a
Http::responseWithHtml(any response, int code) -> response
Returns a
Http::responseWithJson(any response, int code) -> response
Returns a
Http::responseWithText(any response, int code) -> response
Returns a
Http::setCookie_v2(string name, string value, dict params) -> dict
Returns an HTTP Set-Cookie header
Http::success(any response) -> response
Returns a
Http::unauthorized() -> response
Returns a
HttpBaseClient::request(string method, string uri, list headers, bytes body) -> result
Make blocking HTTP call to uri. Returns a
HttpClient::basicAuth_v1(string username, string password) -> dict
Returns a header
HttpClient::bearerToken_v1(string token) -> dict
Returns a header
HttpClient::delete_v5(string uri, dict query, dict headers) -> result
Make blocking HTTP DELETE call to uri. Returns a
HttpClient::formContentType() -> dict
Returns a header
HttpClient::get_v5(string uri, dict query, dict headers) -> result
Make blocking HTTP GET call to uri. Returns a
HttpClient::head_v5(string uri, dict query, dict headers) -> result
Make blocking HTTP HEAD call to uri. Returns a
HttpClient::htmlContentType() -> dict
Returns a header
HttpClient::jsonContentType() -> dict
Returns a header
HttpClient::options_v5(string uri, dict query, dict headers) -> result
Make blocking HTTP OPTIONS call to uri. Returns a
HttpClient::patch_v5(string uri, any body, dict query, dict headers) -> result
Make blocking HTTP PATCH call to uri. Returns a
HttpClient::plainTextContentType() -> dict
Returns a header
HttpClient::post_v5(string uri, any body, dict query, dict headers) -> result
Make blocking HTTP POST call to uri. Returns a
HttpClient::put_v5(string uri, any body, dict query, dict headers) -> result
Make blocking HTTP PUT call to uri. Returns a
Int::absoluteValue(int a) -> int
Returns the absolute value of a (turning negative inputs into positive outputs)
Int::add(int a, int b) -> int
Adds two integers together
Int::clamp(int value, int limitA, int limitB) -> int
If value is within the range given by limitA and , returns value.
If value is outside the range, returns limitA or , whichever is closer to value.
limitA and limitB can be provided in any order.
Int::divide(int a, int b) -> int
Divides two integers
Int::greaterThan(int a, int b) -> bool
Returns true if a is greater than b
Int::greaterThanOrEqualTo(int a, int b) -> bool
Returns true if a is greater than or equal to b
Int::lessThan(int a, int b) -> bool
Returns true if a is less than b
Int::lessThanOrEqualTo(int a, int b) -> bool
Returns true if a is less than or equal to b
Int::max(int a, int b) -> int
Returns the higher of a and b
Int::min(int a, int b) -> int
Returns the lower of a and b
Int::mod(int a, int b) -> int
Returns the result of wrapping a around so that 0 <= res < b.
The modulus b must be 0 or negative.
Use
Int::multiply(int a, int b) -> int
Multiplies two integers
Int::negate(int a) -> int
Returns the negation of a, -a
Int::parse(string s) -> result
Returns the
Int::power(int base, int exponent) -> int
Raise base to the power of exponent
Int::random_v1(int start, int end) -> int
Returns a random integer between start and end (inclusive)
Int::remainder(int value, int divisor) -> result
Returns the integer remainder left over after dividing value by
divisor, as a
Int::sqrt(int a) -> float
Get the square root of an
Int::subtract(int a, int b) -> int
Subtracts two integers
Int::sum(list a) -> int
Returns the sum of all the ints in the list
Int::toFloat(int a) -> float
Converts an
JSON::parse_v1(string json) -> result
Parses a json string and returns its value.
HTTPClient functions, and our request handler, automatically parse JSON into
the body and jsonBody fields, so you probably won't need this.
However, if you need to consume bad JSON, you can use string functions to
fix the JSON and then use this function to parse it.
JWT::signAndEncodeWithHeaders_v1(string pemPrivKey, dict headers, any payload) -> result
Sign and encode an rfc751J9 JSON Web Token, using the RS256 algorithm, with an extra header map. Takes an unencrypted RSA private key in PEM format.
JWT::signAndEncode_v1(string pemPrivKey, any payload) -> result
Sign and encode an rfc751J9 JSON Web Token, using the RS256 algorithm. Takes an unencrypted RSA private key in PEM format.
JWT::verifyAndExtract_v1(string pemPubKey, string token) -> result
Verify and extract the payload and headers from an rfc751J9 JSON Web Token that uses the RS256 algorithm. Takes an unencrypted RSA public key in PEM format.
List::all(list list, block fn) -> bool
Return true if all elements in the list meet the function's criteria, else false
List::append(list as, list bs) -> list
Returns a new list with all values in as followed by all values in bs,
preserving the order.
List::drop(list list, int count) -> list
Drops the first count values from list
List::dropWhile(list list, block fn) -> list
Drops the longest prefix of list which satisfies the predicate val
List::empty() -> list
Returns an empty list
List::filterMap(list list, block fn) -> list
Calls fn on every val in list, returning a list that
drops some values (filter) and transforms others (map).
If fn val returns Nothing, drops val from the list.
If fn val returns Just newValue, replaces val with newValue.
Preserves the order of values that were not dropped.
This function combines
List::filter_v2(list list, block fn) -> list
Calls f on every val in list, returning a list of only
those values for which fn val returns true.
Preserves the order of values that were not dropped. Consider
List::findFirst_v2(list list, block fn) -> option
Returns Just firstMatch where firstMatch is the first value of the
list for which fn returns true. Returns Nothing if no such
value exists
List::flatten(list list) -> list
Returns a single list containing the values of every list directly in (does not recursively flatten nested lists)
List::fold(list list, any init, block fn) -> any
Folds list into a single value, by repeatedly applying fn to
any two pairs.
List::getAt_v1(list list, int index) -> option
Returns Just value at index in list if index is
less than the length of the list otherwise returns Nothing.
List::head_v2(list list) -> option
Returns Just the head (first value) of a list. Returns Nothing if
the list is empty.
List::indexedMap(list list, block fn) -> list
Calls
List::interleave(list as, list bs) -> list
Returns a list with the first value from as then the first value
from bs, then the second value from as then the second value
other list.
List::interpose(list list, any sep) -> list
Returns a single list containing the values of list separated by sep
List::isEmpty(list list) -> bool
Returns true if list has no values
List::last_v2(list list) -> option
Returns the last value in list, wrapped in an option ( if the list is empty)
List::length(list list) -> int
Returns the number of values in list
List::map(list list, block fn) -> list
Calls fn on every val in list, returning a list of the
results of those calls.
Consider
List::map2(list as, list bs, block fn) -> option
If the lists are the same length, returns Just list formed by mapping
fn over as and bs in parallel, calling fn a b on
every pair of values from as and bs.
For example, if as is [1,2,3] and bs is
["x","y","z"], returns [(fn 1 "x"), (f 2 "y"), (f 3
"z")].
If the lists differ in length, returns Nothing (consider
List::map2shortest(list as, list bs, block fn) -> list
Maps fn over as and bs in parallel, calling fn a
b on every pair of values from as and bs.
If the lists differ in length, values from the longer list are dropped.
For example, if as is [1,2] and bs is
["x","y","z"], returns [(f 1 "x"), (f 2 "y")]
Use
List::member(list list, any val) -> bool
Returns true if val is in the list
List::partition(list list, block fn) -> tuple
Calls f on every val in list, splitting the list into
two - those values for which fn val returns true, and those that
return false.
Preserves the order of values.
List::push(list list, any val) -> list
Add element val to front of
List::pushBack(list list, any val) -> list
Add element val to back of
List::randomElement(list list) -> option
Returns Just randomValue, where randomValue is a randomly
selected value in list. Returns Nothing if list is
empty.
List::range(int lowest, int highest) -> list
Returns a list of numbers where each element is 1 larger than the
previous. You provide the lowest and highest numbers in the
list.
List::repeat(int times, any val) -> list
Returns a list containing val repeated times times
List::reverse(list list) -> list
Returns a reversed copy of list
List::singleton(any val) -> list
Returns a one-element list containing the given val
List::sort(list list) -> list
Returns a copy of list with every value sorted in ascending order.
Use this if the values have types Dark knows how to sort.
Consider
List::sortBy(list list, block fn) -> list
Returns a copy of list, sorted in ascending order, as if each value
evaluated to fn val.
For example, List::sortBy ["x","jkl","ab"] \val - String::length
val returns [ "x", "ab", "jkl" ].
Consider
List::sortByComparator(list list, block fn) -> result
Returns a copy of list, sorted using fn a b to compare values
a and b.
f must return -1 if a should appear before b, 1
if a should appear after b, and 0 if the order of a
and b doesn't matter.
Consider
List::tail(list list) -> option
If list contains at least one value, returns Just with a list of
every value other than the first. Otherwise, returns Nothing.
List::take(list list, int count) -> list
Drops all but the first count values from list
List::takeWhile(list list, block fn) -> list
Return the longest prefix of list which satisfies the predicate fn
List::uniqueBy(list list, block fn) -> list
Returns the passed list, with only unique values, where uniqueness is based
on the result of fn. Only one of each value will be returned, but the
order will not be maintained.
List::unzip(list pairs) -> list
Given a pairs list where each value is a list of two values (such
lists are constructed by
List::zip(list as, list bs) -> option
If the lists have the same length, returns Just list formed from
parallel pairs in as and bs.
For example, if as is [1,2,3] and bs is
["x","y","z"], returns [[1,"x"], [2,"y"], [3,"z"]].
See
List::zipShortest(list as, list bs) -> list
Returns a list of parallel pairs from as and bs.
If the lists differ in length, values from the longer list are dropped.
For example, if as is [1,2] and bs is
["x","y","z"], returns [[1,"x"], [2,"y"]].
Use
Math::acos(float ratio) -> option
Returns the arc cosine of ratio, as an
Math::asin(float ratio) -> option
Returns the arc sine of ratio, as an
Math::atan(float ratio) -> float
Returns the arc tangent of ratio. The result is in radians and is between
-Math::pi/2 and Math::pi/2.
This function is the inverse of
Math::atan2(float y, float x) -> float
Returns the arc tangent of y / x, using the signs of y and
x to determine the quadrant of the result.
The result is in radians and is between -Math::pi and Math::pi.
Consider
Math::cos(float angleInRadians) -> float
Returns the cosine of the given angleInRadians.
One interpretation of the result relates to a right triangle: the cosine is
the ratio of the lengths of the side adjacent to the angle and the
hypotenuse.
Math::cosh(float angleInRadians) -> float
Returns the hyperbolic cosine of angleInRadians
Math::degrees(float angleInDegrees) -> float
Returns the equivalent of angleInDegrees in radians, the unit used
by all of Dark's trigonometry functions.
There are 360 degrees in a circle.
Math::pi() -> float
Returns an approximation for the mathematical constant π, the ratio of a
circle's circumference to its diameter.
Math::radians(float angleInRadians) -> float
Returns angleInRadians in radians, the unit used by all of Dark's
trigonometry functions.
There are Float::multiply 2 Math::pi radians in a
circle.
Math::sin(float angleInRadians) -> float
Returns the sine of the given angleInRadians.
One interpretation of the result relates to a right triangle: the sine is
the ratio of the lengths of the side opposite the angle and the hypotenuse
Math::sinh(float angleInRadians) -> float
Returns the hyperbolic sine of angleInRadians
Math::tan(float angleInRadians) -> float
Returns the tangent of the given angleInRadians.
One interpretation of the result relates to a right triangle: the tangent is
the ratio of the lengths of the side opposite the angle and the side
adjacent to the angle.
Math::tanh(float angleInRadians) -> float
Returns the hyperbolic tangent of angleInRadians
Math::tau() -> float
Returns an approximation for the mathematical constant τ, the number of
radians in one turn. Equivalent to Float::multiply Math::pi 2.
Math::turns(float angleInTurns) -> float
Returns the equivalent of angleInTurns in radians, the unit used by all of
Dark's trigonometry functions.
There is 1 turn in a circle.
Option::andThen(option option, block fn) -> option
If option is Just input, returns fn input. Where
the lambda fn is applied to input and must return Just or Nothing. Otherwise if option is Nothing, returns
Nothing.
Option::map2(option option1, option option2, block fn) -> option
If both arguments are Just (option1 is Just v1 and
option2 is Just v2), then return Just (fn v1 ). The lambda fn should have two parameters, representing and v2. But if either option1 or option2 are
Nothing, returns Nothing without applying fn.
Option::map_v1(option option, block fn) -> option
If option is Just val, then return Just (f ). The lambda
Option::withDefault(option option, any default) -> any
If option is Just value, returns value. Returns
default otherwise.
Password::check(password password, string rawPassword) -> bool
Check whether a Password matches a raw password String safely. This uses libsodium's pwhash under the hood, which is based on argon2.
NOTE: This is not usable interactively, because we do not send Password values to the client for security reasons.
Password::hash(string password) -> password
Hash a password into a Password by salting and hashing it. This uses libsodium's crypto_pwhash_str under the hood, which is based on argon2.
NOTE: This is not usable interactively, because we do not send Password values to the client for security reasons.
Result::andThen_v1(result result, block fn) -> result
If result is Ok value, returns fn value. The
lambda fn is applied to value and must return Error or Ok newValue. If result is Error msg,
returns result unchanged.
Result::fromOption_v2(option option, any error) -> result
Turn an option into a result, using error as the error message for Error. Specifically, if option is Just value, returns Ok value. Returns Error error otherwise.
Result::map2(result result1, result result2, block fn) -> result
If both result1 is Ok v1 and result2 is Ok , returns Ok (fn v1 v2) -- the lambda fn is
applied to v1 and v2, and the result is wrapped in Ok.
Otherwise, returns the first of result1 and result2 that is
an error.
Result::mapError_v1(result result, block fn) -> result
If result is Error msg, returns Error (fn msg).
The lambda fn is applied to msg and the result is wrapped in
Error. If result is Ok value, returns result
unchanged.
Result::map_v1(result result, block fn) -> result
If result is Ok value, returns Ok (fn value).
The lambda fn is applied to value and the result is wrapped in
Ok. If result is Error msg, returns result
unchanged.
Result::toOption_v1(result result) -> option
Turn a
Result::withDefault(result result, any default) -> any
If result is Ok value, returns value. Returns otherwise.
StaticAssets::baseUrlFor(string deployHash) -> string
Return the baseUrl for the specified deploy hash
StaticAssets::baseUrlForLatest_v1() -> option
Return the baseUrl for the latest deploy, wrapped in an Option. If no deploys have been made, Nothing is returned.
StaticAssets::fetchBytes(string deployHash, string file) -> result
Return the bytes of the specified file from the deploy_hash
StaticAssets::fetchLatestBytes(string file) -> result
Return the bytes of the specified file from the latest deploy
StaticAssets::fetchLatest_v1(string file) -> result
Return the specified file from the latest deploy - only works on UTF8-safe files for now
StaticAssets::fetch_v1(string deployHash, string file) -> result
Return the specified file from the deploy_hash - only works on UTF8-safe files for now
StaticAssets::serveLatest_v1(string file) -> result
Return the specified file from the latest deploy
StaticAssets::serve_v1(string deployHash, string file) -> result
Return the specified file from the given deploy
StaticAssets::urlFor(string deployHash, string file) -> string
Return a url for the specified file and deploy hash
StaticAssets::urlForLatest(string file) -> string
Return a url for the specified file and latest deploy
String::append_v1(string s1, string s2) -> string
Concatenates the two strings by appending s2 to s1 and
returns the joined string.
String::base64Decode(string s) -> string
Base64 decodes a string. Works with both the URL-safe and standard Base64
alphabets defined in [RFC 4648
sections](https://www.rfc-editor.org/rfc/rfc4648.html)
[4](https://www.rfc-editor.org/rfc/rfc4648.html#section-4) and
[5](https://www.rfc-editor.org/rfc/rfc4648.html#section-5).
String::base64Encode(string s) -> string
URLBase64 encodes a string without padding. Uses URL-safe encoding with
- and _ instead of + and /, as defined in
[RFC 4648 section 5](https://www.rfc-editor.org/rfc/rfc4648.html#section-5)
String::contains(string lookingIn, string searchingFor) -> bool
Checks if lookingIn contains searchingFor
String::digest(string s) -> string
Take a string and hash it to a cryptographically-secure digest.
Don't rely on either the size or the algorithm.
String::dropFirst(string string, int characterCount) -> string
Returns all but the first characterCount characters of , as a
String::dropLast(string string, int characterCount) -> string
Returns all but the last characterCount characters of , as a String.
If characterCount is longer than string, returns the empty string.
If characterCount is negative, returns string.
String::endsWith(string subject, string suffix) -> bool
Checks if subject ends with suffix
String::first(string string, int characterCount) -> string
Returns the first characterCount characters of string, as a
String.
If characterCount is longer than string, returns .
If characterCount is negative, returns the empty string.
String::foreach_v1(string s, block fn) -> string
Iterate over each Character (EGC, not byte) in the string, performing the
operation in fn on each one.
String::fromChar_v1(character c) -> string
Converts a
String::fromList_v1(list l) -> string
Returns the list of characters as a string
String::htmlEscape(string html) -> string
Escape an untrusted string in order to include it safely in HTML output
String::isEmpty(string s) -> bool
Returns true if s is the empty string ""
String::join(list l, string separator) -> string
Combines a list of strings with the provided separator
String::last(string string, int characterCount) -> string
Returns the last characterCount characters of string, as a
String.
If characterCount is longer than string, returns .
If characterCount is negative, returns the empty string.
String::length_v1(string s) -> int
Returns the length of the string
String::newline() -> string
Returns a string containing a single '
'
String::padEnd(string string, string padWith, int goalLength) -> string
If string is shorter than goalLength characters, returns a
copy of string ending with enough copies of padWith for the
result have goalLength.
If the string is longer than goalLength, returns an unchanged copy of
string.
String::padStart(string string, string padWith, int goalLength) -> string
If string is shorter than goalLength characters, returns a
copy of string starting with enough copies of padWith for the
result have goalLength.
If the string is longer than goalLength, returns an unchanged copy of string
String::prepend(string s1, string s2) -> string
Concatenates the two strings by prepending s2 to s1 and
returns the joined string.
String::random_v2(int length) -> result
Generate a
String::replaceAll(string s, string searchFor, string replaceWith) -> string
Replace all instances on searchFor in s with
String::reverse(string string) -> string
Reverses string
String::slice(string string, int from, int to) -> string
Returns the substring of string between the from and indices.
Negative indices start counting from the end of string.
String::slugify_v2(string string) -> string
Turns a string into a prettified slug, including only lowercased
alphanumeric characters, joined by hyphens
String::split_v1(string s, string separator) -> list
Splits a string at the separator, returning a list of strings without the separator.
If the separator is not present, returns a list containing only the initial string.
String::startsWith(string subject, string prefix) -> bool
Checks if subject starts with prefix
String::toBytes(string str) -> bytes
Converts the given unicode string to a UTF8-encoded byte sequence.
String::toList_v1(string s) -> list
Returns the list of Characters (EGC, not byte) in the string
String::toLowercase_v1(string s) -> string
Returns the string, lowercased
String::toUppercase_v1(string s) -> string
Returns the string, uppercased
String::trim(string str) -> string
Returns a copy of str with all leading and trailing whitespace
removed. 'whitespace' here means all Unicode characters with the
White_Space property, which includes " ", "\t" and
"\n"
String::trimEnd(string str) -> string
Returns a copy of str with all trailing whitespace removed.
'whitespace' here means all Unicode characters with the White_Space
property, which includes " ", "\t" and "\n".
String::trimStart(string str) -> string
Returns a copy of str with all leading whitespace removed. 'whitespace'
here means all Unicode characters with the White_Space property, which
includes " ", "\t" and "\n"
Tuple2::create(any first, any second) -> tuple
Returns a pair with the given values
Tuple2::first(tuple tuple) -> any
Returns the first value of a pair
Tuple2::mapBoth(block fnFirst, block fnSecond, tuple tuple) -> tuple
Transform both values in a pair
Tuple2::mapFirst(block fn, tuple tuple) -> tuple
Transform the first value in a pair
Tuple2::mapSecond(block fn, tuple tuple) -> tuple
Transform the second value in a pair
Tuple2::second(tuple tuple) -> any
Returns the second value of a pair
Tuple2::swap(tuple tuple) -> tuple
Returns a pair with the elements swapped
Tuple3::create(any first, any second, any third) -> tuple
Returns a triple with the given values
Tuple3::first(tuple tuple) -> any
Returns the first value of a triple
Tuple3::mapAllThree(block fnFirst, block fnSecond, block fnThird, tuple tuple) -> tuple
Transform all values in a triple
Tuple3::mapFirst(block fn, tuple tuple) -> tuple
Transform the first value in a triple
Tuple3::mapSecond(block fn, tuple tuple) -> tuple
Transform the second value in a triple
Tuple3::mapThird(block fn, tuple tuple) -> tuple
Transform the third value in a triple
Tuple3::second(tuple tuple) -> any
Returns the second value of a triple
Tuple3::third(tuple tuple) -> any
Returns the third value of a triple
Twilio::sendText_v1(string accountSID, string authToken, string fromNumber, string toNumber, string body) -> dict
Send text with body to phone number toNumber from number fromNumber, authenticated via accountSID and authToken
Uuid::generate() -> uuid
Generate a new UUID v4 according to RFC 4122
Uuid::parse(string uuid) -> result
Parse a
X509::pemCertificatePublicKey(string pemCert) -> result
Extract the public key from a PEM encoded certificate and return the key in PEM format.
^(int base, int exponent) -> int
Raise base to the power of exponent
emit_v1(any event, string name) -> any
Emit a event to the name worker
equals(any a, any b) -> bool
Returns true if the two value are equal
notEquals(any a, any b) -> bool
Returns true if the two value are not equal
toString(any v) -> string
Returns a string representation of v, suitable for displaying to a
user. Redacts passwords.