Skip to main content
Adaptive Insights
Knowledge and Support - Adaptive Insights

Adaptive Utility

ai.util

Functions

Method

Parameters

Returns

Description

apply( obj, config )

  • obj : Object
    The receiver of the properties
  • config : Object
    The source of the properties

 

Object

Copies all the properties of config to obj and returns obj.

decodeHtml( encodedHtml )

available in 2018.3

  • encodedHtml: String
A string with reserved characters translated in order to be used in HTML literals.
Hello <b> [there] >words<!
String

Returns a string as raw HTML.

'Hello <b> [there] >words<!'

decodeUrl( encodedUrl )

available in 2018.3

  • encodedUrl: String
A string with an HTML encoded URL. E.g.
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

  • encodedBase64: String

A string encoded as Base64. E.g.
dGV4dA==

String

Returns a decoded Base64 string.

Text

encodeHtml( rawHtml )

available in 2018.3

  • rawHtml: String
A string with raw HTML. E.g.
'Hello <b> [there] >words<!'
 
String

Returns a string with reserved characters translated in order to be used in HTML literals.

Hello &lt;b&gt; [there] &gt;words&lt;!

encodeUrl( rawUrl )

available in 2018.3

  • rawUrl: String
A string with a raw URL. E.g.
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

  • rawBase64: String
A string with text. E.g.
Text
String

encodes text as Base64.

dGV4dA==

format ( formatString, arg1, arg2....argN)

  • formatString : String
    A string with replace tokens. E.g 'There are {0} things'
  • arg1 : String The value to replace token {0}
  • arg2 : String Etc...

 

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 )

  • value : Mixed
    The value to test

 

Boolean

Returns true if the passed value is a JavaScript Date object.

isUndefined( value )

  • value : Mixed
    The value to test

 

Boolean

Returns true if the passed value is 'undefined'.

isDefined( value )

  • value : Mixed
    The value to test

 

Boolean

Returns true if the passed value is not 'undefined'.

isArray( value )

  • value : Mixed 
  • The value to test

 

Boolean

Returns true if the passed value is a JavaScript array, otherwise false.

isString( value )

  • value : Mixed
    The value to test

 

Boolean

Returns true if the passed value is a string.

isNumber( value )

  • value : Mixed
    The value to test

 

Boolean

Returns true if the passed value is a number and is finite.

isBoolean( value )

  • value : Mixed The value to test

 

Boolean

Returns true if the passed value is true or false.

toArray( a, i, j )

 

Array

 

isPrimitive( value )

  • value : Mixed
    The value to test

 

Boolean

Returns true if the passed value is a String, Number or Boolean.

Examples

		var rawHtml = "Hello <b> [there] >words<!";
		var encodedHtml = "Hello &lt;b&gt; [there] &gt;words&lt;!";

		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, ""));
  • Was this article helpful?