namespace sap.ui.vtm.ArrayUtilities

Control sample: sap.ui.vtm.ArrayUtilities
Visiblity: public
Available since: N/A
Module: sap/ui/vtm/ArrayUtilities
Application Component:

A set of utility functions for working with arrays.


Nodes Overview

Node Description

Methods Overview

Method Description
sap.ui.vtm.ArrayUtilities.areEqual

Returns true if a group of arrays are equal.

sap.ui.vtm.ArrayUtilities.deepClone

Creates a copy of an array in which the items are cloned.

sap.ui.vtm.ArrayUtilities.find

Returns the first item in an array that matches the supplied predicate or returns undefined if no match is found.

sap.ui.vtm.ArrayUtilities.findIndex

Returns the index of the first item in an array that matches the supplied predicate or returns -1 if no match is found.

sap.ui.vtm.ArrayUtilities.flatten

Flattens an array of arrays down to an array.

sap.ui.vtm.ArrayUtilities.fromArrayLike

Converts from an array-like object (an object that supports indexing and has a length) to an array.

sap.ui.vtm.ArrayUtilities.fromSet

Converts an ES6 Set to an array.

sap.ui.vtm.ArrayUtilities.haveIntersection

Returns whether a group of arrays have a non empty set intersection.

sap.ui.vtm.ArrayUtilities.intersect

Returns the set intersection of a group of arrays.

sap.ui.vtm.ArrayUtilities.shallowClone

Creates a copy of an array in which the items are copied by reference rather than being cloned.

sap.ui.vtm.ArrayUtilities.toSet

Converts an array to an ES6 Set.

sap.ui.vtm.ArrayUtilities.union

Returns the set union (as an array) of a group of arrays.

sap.ui.vtm.ArrayUtilities.unwrap

The inverse of sap.ui.vtm.ArrayUtilities.wrap.

  • If the parameter is not an array, the parameter is returned.
  • If the parameter is an array of length 0, undefined is returned.
  • If the parameter is an array of length 1, the first element of the array is returned.
  • Otherwise if the parameter is an array of length > 1, the parameter is returned (as an array).

sap.ui.vtm.ArrayUtilities.wrap

Wraps an item in an array if it is not already an array.

  • If the parameter is an array, the parameter is returned.
  • If the parameter is undefined an empty array is returned.
  • Otherwise a single element array containing the parameter value is returned.

sap.ui.vtm.ArrayUtilities.areEqual

Returns true if a group of arrays are equal.

Param Type DefaultValue Description
arrayOfArrays Array

The array of arrays to compare.

equalityFunc function

A function that takes two parameters and returns a boolean value indicating whether the parameter values are equal.

sap.ui.vtm.ArrayUtilities.deepClone

Creates a copy of an array in which the items are cloned.

Param Type DefaultValue Description
array Array

The array to clone.

itemCloneFunc function

A function used to clone an item of the array. The function has an argument that takes an item of the type stored in the array and returns an item of the same type.

sap.ui.vtm.ArrayUtilities.find

Returns the first item in an array that matches the supplied predicate or returns undefined if no match is found.

Param Type DefaultValue Description
array Array

The array to search.

predicate function

A function that takes a value of the type stored in the array and returns a boolean value (true if the item is a match.

sap.ui.vtm.ArrayUtilities.findIndex

Returns the index of the first item in an array that matches the supplied predicate or returns -1 if no match is found.

Param Type DefaultValue Description
array Array

The array to search.

predicate function

A function that takes a value of the type stored in the array and returns a boolean value (true if the item is a match.

sap.ui.vtm.ArrayUtilities.flatten

Flattens an array of arrays down to an array.

Param Type DefaultValue Description
arrayOfArrays Array

An array of arrays.

sap.ui.vtm.ArrayUtilities.fromArrayLike

Converts from an array-like object (an object that supports indexing and has a length) to an array.

Param Type DefaultValue Description
arrayLike object

The array-like object to convert to an array.

sap.ui.vtm.ArrayUtilities.fromSet

Converts an ES6 Set to an array.

Param Type DefaultValue Description
set Set

The Set to convert to an array.

sap.ui.vtm.ArrayUtilities.haveIntersection

Returns whether a group of arrays have a non empty set intersection.

Param Type DefaultValue Description
arrayOfArrays Array

An array of arrays to check for the existence of a set intersection.

equalityFunction function

A function that returns a Boolean value to compare values within arrays. When not specified, strict equality (===) is used to compare values.

sap.ui.vtm.ArrayUtilities.intersect

Returns the set intersection of a group of arrays.

Param Type DefaultValue Description
arrayOfArrays Array

An array of arrays to to find the set intersection of.

equalityFunction function

A function that returns a Boolean value to compare values within arrays. When not specified, strict equality (===) is used to compare values.

sap.ui.vtm.ArrayUtilities.shallowClone

Creates a copy of an array in which the items are copied by reference rather than being cloned.

Param Type DefaultValue Description
array Array

The array to clone.

sap.ui.vtm.ArrayUtilities.toSet

Converts an array to an ES6 Set.

Param Type DefaultValue Description
array Array

The array to convert to a Set.

sap.ui.vtm.ArrayUtilities.union

Returns the set union (as an array) of a group of arrays.

Param Type DefaultValue Description
arrayOfArrays Array

An array of arrays to find the set union of.

equalityFunction function

A function that returns a Boolean value to compare values within arrays. When not specified, strict equality (===) is used to compare values.

sap.ui.vtm.ArrayUtilities.unwrap

The inverse of sap.ui.vtm.ArrayUtilities.wrap.

Param Type DefaultValue Description
item any

The item to unwrap.

sap.ui.vtm.ArrayUtilities.wrap

Wraps an item in an array if it is not already an array.

Param Type DefaultValue Description
item any

The item to wrap as an array if it is not already an array.