Caplin Trader 4.7.1

Class: module:br/util/ArrayUtility

module:br/util/ArrayUtility

Utility class that provides methods for array manipulation.

Constructor

new module:br/util/ArrayUtility()

This is a static class that never needs to be instantiated.

Methods

(static) inArray(arrayToSearch, valueToFind) → {Boolean}

Return true if the input array contains the input value, false otherwise.
Parameters:
Name Type Description
arrayToSearch Array The Array to test for the presence of the input variant. May not be null or undefined.
valueToFind Variant Variant whose presence in the input array is to be tested. Works with null, undefined and NaN.
Returns:
true if the specified value was found in the array, false otherwise.
Type
Boolean

(static) removeItem(arrayToRemoveFrom, valueToRemove) → {Array}

Removes the first example of the specified item in the specified array, or does nothing if the item is not found.

Since this method uses the built-in indexOf which does work with NaN, it will not work if called with NaN and will throw an InvalidParametersError. If you need to remove NaN, you'll have to loop over the array and then splice it out.

Parameters:
Name Type Description
arrayToRemoveFrom Array The Array from which to remove the specified item. May not be null or undefined.
valueToRemove Variant The Variant to be removed from the specified array. May not be NaN.
Returns:
The input array with the specified item removed, or the original array if the item was not found.
Type
Array