Adaptive Utility
ai.util
Functions
Method |
Parameters |
Returns |
Description |
---|---|---|---|
apply( obj, config ) |
|
Object |
Copies all the properties of config to obj and returns obj. |
decodeHtml( encodedHtml ) available in 2018.3 |
Hello <b> [there] >words<! |
String |
Returns a string as raw HTML. 'Hello <b> [there] >words<!' |
decodeUrl( encodedUrl ) available in 2018.3 |
https%3a%2f%2fwww.example.com%2ffings%2f%3fid%3d123%26more%3dwords%23hash |
String |
Returns a string with a raw URL. https://www.example.com/fings/?id=123&more=words#hash |
decodeBase64( encodedBase64 ) available in 2018.3 |
A string encoded as Base64. E.g. |
String |
Returns a decoded Base64 string. Text |
encodeHtml( rawHtml ) available in 2018.3 |
'Hello <b> [there] >words<!' |
String |
Returns a string with reserved characters translated in order to be used in HTML literals. Hello <b> [there] >words<! |
encodeUrl( rawUrl ) available in 2018.3 |
https://www.example.com/fings/?id=123&more=words#hash |
String |
Returns a raw URL as an encoded HTML. https%3a%2f%2fwww.example.com%2ffings%2f%3fid%3d123%26more%3dwords%23hash |
encodeBase64( rawBase64 ) available in 2018.3 |
Text |
String |
encodes text as Base64. dGV4dA== |
format ( formatString, arg1, arg2....argN) |
|
String |
Used to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc. |
isDate( value ) |
|
Boolean |
Returns true if the passed value is a JavaScript Date object. |
isUndefined( value ) |
|
Boolean |
Returns true if the passed value is 'undefined'. |
isDefined( value ) |
|
Boolean |
Returns true if the passed value is not 'undefined'. |
isArray( value ) |
|
Boolean |
Returns true if the passed value is a JavaScript array, otherwise false. |
isString( value ) |
|
Boolean |
Returns true if the passed value is a string. |
isNumber( value ) |
|
Boolean |
Returns true if the passed value is a number and is finite. |
isBoolean( value ) |
|
Boolean |
Returns true if the passed value is true or false. |
toArray( a, i, j ) |
Array |
||
isPrimitive( value ) |
|
Boolean |
Returns true if the passed value is a String, Number or Boolean. |
Examples
var rawHtml = "Hello <b> [there] >words<!"; var encodedHtml = "Hello <b> [there] >words<!"; var rawUrl = "https://www.blah-blah-blah.com/fings/?id=123&more=words#hash"; var encodedUrl = "https%3a%2f%2fwww.blah-blah-blah.com%2ffings%2f%3fid%3d123%26more%3dwords%23hash"; var rawBase64 = "Please don't encode me :("; var encodedBase64 = "UGxlYXNlIGRvbid0IGVuY29kZSBtZSA6KA=="; ai.log.logInfo(ai.util.encodeHtml(rawHtml), ai.util.decodeHtml(encodedHtml)); ai.log.logInfo(ai.util.encodeUrl(rawUrl), ai.util.decodeUrl(encodedUrl)); ai.log.logInfo(ai.util.encodeBase64(rawBase64, ""), ai.util.decodeBase64(encodedBase64, ""));