Legato.Lang.CollectionUtils

Some common utils for collections

Summary
Legato.Lang.CollectionUtilsSome common utils for collections
Functions
Legato.Lang.CollectionUtils.filterFilters given array based on given evaluate method.
Legato.Lang.CollectionUtils.filterObjectFilters given object based on given evaluate method.
Legato.Lang.CollectionUtils.transformTransforms given array based on given transformer method.
Legato.Lang.CollectionUtils.eachCalls a given function on each element of an array
copyIfExistsCopies all Properties from source to destination if they exist in source

Functions

Legato.Lang.CollectionUtils.filter

Legato.Lang.CollectionUtils.filter = function(array,
evaluate)

Filters given array based on given evaluate method.  If evaluate method returns true, arrayelement will been keeped.  False otherwise.

Parameters

array{Object} The array to filter
evaluate{Function} the filter function

Returns

{Object} The filtered array

Legato.Lang.CollectionUtils.filterObject

Legato.Lang.CollectionUtils.filterObject = function(object,
evaluate)

Filters given object based on given evaluate method.  If key is in evaluate, object property will be keeped.  False otherwise.

Parameters

object{Object} The object to filter
evaluate{Array} the array of properties to keep

Returns

{Object} The filtered object

Legato.Lang.CollectionUtils.transform

Legato.Lang.CollectionUtils.transform = function(array,
transformer)

Transforms given array based on given transformer method.  The new build array will then been returned.

Parameters

array{Object} The array to filter
evaluate{Function} the filter function

Returns

{Object} The filtered array

Legato.Lang.CollectionUtils.each

Legato.Lang.CollectionUtils.each = function(array,
func)

Calls a given function on each element of an array

Parameters

array{Object} The array to iterate
func{Function} the function to call

Returns

nothing

copyIfExists

Legato.Lang.CollectionUtils.copyIfExists = function(source,
destination,
properties)

Copies all Properties from source to destination if they exist in source

Returns

nothing

Parameters

sourcesource object
destinationdestination object
propertiesarray with property names
Legato.Lang.CollectionUtils.filter = function(array,
evaluate)
Filters given array based on given evaluate method.
Legato.Lang.CollectionUtils.filterObject = function(object,
evaluate)
Filters given object based on given evaluate method.
Legato.Lang.CollectionUtils.transform = function(array,
transformer)
Transforms given array based on given transformer method.
Legato.Lang.CollectionUtils.each = function(array,
func)
Calls a given function on each element of an array
Legato.Lang.CollectionUtils.copyIfExists = function(source,
destination,
properties)
Copies all Properties from source to destination if they exist in source