# Legato.Lang.CollectionUtils

Some common utils for collections

Summary

Legato.Lang.CollectionUtils | Some common utils for collections
Functions |
Legato.Lang.CollectionUtils.filter | Filters given array based on given evaluate method.
Legato.Lang.CollectionUtils.filterObject | Filters given object based on given evaluate method.
Legato.Lang.CollectionUtils.transform | Transforms given array based on given transformer method.
Legato.Lang.CollectionUtils.each | Calls a given function on each element of an array
copyIfExists | Copies 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

source | source object
destination | destination object
properties | array 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