Exhibit/API/2.2.0/Util/Util

= Exhibit.Util =

A rounding utility function and extensions to the native Array type are included.

Code: http://api.simile-widgets.org/exhibit/2.2.0/scripts/util/util.js

Back to Exhibit API

Exhibit.Util.round

 * Arguments:
 * n: Number, Original number.
 * precision: Number, Optional; rounding bucket, by default 1.
 * Returns: String, Formatted number rounded into the nearest bucket.
 * Description: Round a number n to the nearest multiple of precision (any positive value), such as 5000, 0.1 (one decimal), 1e-12 (twelve decimals), or 1024 (if you'd want "to the nearest kilobyte" -- so round(66000, 1024) == "65536"). You are also guaranteed to get the precision you ask for, so round(0, 0.1) == "0.0".

Array.prototype.indexOf

 * Arguments:
 * elt: Object, Object to search for (must be a simple type like a string, number, or boolean).
 * from: Number, Starting index
 * Returns: Number
 * Description: Returns the index of an element in an array based on strict equality. Returns -1 if not found in the array.

Array.prototype.filter

 * Arguments:
 * fun: Function, A filtering function of the form function(value, index, array) that returns a boolean value.
 * thisp: Object, Optional, What 'this' should refer to inside of fun.
 * Returns: Array
 * Description: Filter out elements of an array with a filtering function in order to build a new array.

Array.prototype.map

 * Arguments:
 * f: Function, A mapping function of the form function(value, index, array) that returns an object suitable for the new array.
 * thisp: Object, Optional, What 'this' should refer to inside of f.
 * Returns: Array
 * Description: Run a function over every entry in an array, building a new array with the function's output values.

Array.prototype.forEach

 * Arguments:
 * fun: Function, A mapping function of the form function(value, index, array).
 * thisp: Object, Optional, What 'this' should refer to inside fun.
 * Returns: Nothing
 * Description: Run a function over every value in an array, doing something with the values, but not building a result array. Returns nothing.

Back to Exhibit API