Method | Defined by | ||
---|---|---|---|
ArrayPeer Static Constructor
| ArrayPeer | ||
find(array:Array, conditions:Object, options:Object = null):*
[static]
Searches an array using simple or complex conditions.
| ArrayPeer | ||
findAll(array:Array, conditions:Object):Array
[static]
Shortcut for searching by a single property
| ArrayPeer | ||
findBy(array:Array, property:String, value:Object, options:* = null):*
[static]
Shortcut for searching by a single property
| ArrayPeer | ||
findFirst(array:Array, conditions:Object):*
[static]
Shortcut for retrieving the first matching item
| ArrayPeer | ||
findLast(array:Array, conditions:Object):*
[static]
Shortcut for retrieving the last matching item
| ArrayPeer |
Constant | Defined by | ||
---|---|---|---|
ALL : String = "all" [static]
| ArrayPeer | ||
FIRST : String = "first" [static]
| ArrayPeer | ||
LAST : String = "last" [static]
| ArrayPeer |
ArrayPeer | () | constructor |
public function ArrayPeer()
ArrayPeer Static Constructor
find | () | method |
public static function find(array:Array, conditions:Object, options:Object = null):*
Searches an array using simple or complex conditions.
The conditons are evaluated and compared strictly equal and the item must match all conditions to be in the returned array.
Conditions with Class, Function or RegExp as the expected values are subject to some additional rules regarding matches.
is
of the Class type.var condtions:Object = { someProperty: function(item: actual::Boolean { return actual != null; } }
All other expected value are compared with ===
Parametersarray:Array |
|
conditions:Object |
|
options:Object (default = null )
|
* |
var movies:Array = []; // retrieve from some datasource // find with simple property value condition var moviesByMichaelBay:Array = ArrayPeer.find( movies, { director: 'Michael Bay' } ); // find with property chain condition (assuming the 'released' property returns a Date instance) var moviesByMichaelByReleasedIn2007:Array = ArrayPeer.find( moviesByMichaelBay, { 'released.fullYear': 2007 } // find with Class condition // todo: add example // find with Function condition var moviesWithAverageRatings:Array = ArrayPeer.find( movies, { rating: function(item:Movie, actual:Number):Boolean { return actual > 2.4 && actual < 3.7; } }) // find with RegExp var moviesTheBeginWithTr:Array = ArrayPeer.find( movies, { name: new RegExp('^Tr.) }); // find with sub-array query (assuming the 'cast' property returns an Array of Actors with the property 'name') var moviesWithMeganFox:Array = ArrayPeer.find( movies, { 'cast.name': 'Megan Fox' })
findAll | () | method |
public static function findAll(array:Array, conditions:Object):Array
Shortcut for searching by a single property
Parametersarray:Array |
|
conditions:Object |
Array |
findBy | () | method |
public static function findBy(array:Array, property:String, value:Object, options:* = null):*
Shortcut for searching by a single property
Parametersarray:Array |
|
property:String |
|
value:Object |
|
options:* (default = null )
|
* |
findFirst | () | method |
public static function findFirst(array:Array, conditions:Object):*
Shortcut for retrieving the first matching item
Parametersarray:Array |
|
conditions:Object |
* |
findLast | () | method |
public static function findLast(array:Array, conditions:Object):*
Shortcut for retrieving the last matching item
Parametersarray:Array |
|
conditions:Object |
* |
ALL | constant |
public static const ALL:String = "all"
FIRST | constant |
public static const FIRST:String = "first"
LAST | constant |
public static const LAST:String = "last"