@hydra-cg/heracles.ts > FilterableCollection
Provides a base functionality of a collection that filters itself with given predicates.
abstract:
class:
FilterableCollection
↳ ResourceFilterableCollection
<Protected> constructor⊕ new FilterableCollection(items?: Iterable<T>): FilterableCollection
Defined in DataModel/Collections/FilterableCollection.ts:13
Initializes a new instance of the {@link FilterableCollection} class with initial collections of items to filter.
Parameters:
| Name | Type |
|---|---|
Optional items |
Iterable<T> |
Returns: FilterableCollection
<Private> filters● filters: IDictionary<any>
Defined in DataModel/Collections/FilterableCollection.ts:13
<Private> items● items: Iterable<T>
Defined in DataModel/Collections/FilterableCollection.ts:12
get length(): number
Defined in DataModel/Collections/FilterableCollection.ts:38
Gets the number of items in this collection.
readonly:
Returns: number
▸ __@iterator(): Iterator<T>
Defined in DataModel/Collections/FilterableCollection.ts:111
inheritdoc:
Returns: Iterator<T>
▸ any(): boolean
Defined in DataModel/Collections/FilterableCollection.ts:52
Checks whether this collection has any items fitlered.
Returns: boolean
<Protected><Abstract> createInstance▸ createInstance(items: Iterable<T>): FilterableCollection<T>
Defined in DataModel/Collections/FilterableCollection.ts:121
Creates a new instance of the collection.
abstract:
Parameters:
| Name | Type | Description |
|---|---|---|
| items | Iterable<T> |
Initial collection of items to filter. |
Returns: FilterableCollection<T>
▸ first(): T
Defined in DataModel/Collections/FilterableCollection.ts:60
Gets the first item of the collection or null if there are no items matching the criteria.
Returns: T
▸ last(): T
Defined in DataModel/Collections/FilterableCollection.ts:69
Gets the last item of the collection or null if there are no items matching the criteria.
Returns: T
<Protected> narrowFiltersWith▸ narrowFiltersWith<TValue>(predicate: string, matchEvaluator: function): FilterableCollection<T>
▸ narrowFiltersWith(predicate: string, value: string | RegExp): FilterableCollection<T>
Defined in DataModel/Collections/FilterableCollection.ts:129
Creates a new instance of the FilterableCollection with filter made narrower with given predicate.
Type parameters:
Parameters:
| Name | Type | Description |
|---|---|---|
| predicate | string |
Predicate of the filter. |
| matchEvaluator | function |
Match evaluator of the predicate to filter. |
Returns: FilterableCollection<T>
Defined in DataModel/Collections/FilterableCollection.ts:140
Creates a new instance of the FilterableCollection with filter made narrower with given predicate.
Parameters:
| Name | Type | Description |
|---|---|---|
| predicate | string |
Predicate of the filter. |
| value | string | RegExp |
Either value or regular expression to match the value of the predicate to filter. |
Returns: FilterableCollection<T>
▸ toArray(): T[]
Defined in DataModel/Collections/FilterableCollection.ts:101
Flattens this collection to a standard array.
Returns: T[]
▸ where(matchEvaluator: function): FilterableCollection<T>
Defined in DataModel/Collections/FilterableCollection.ts:83
Filters the collection with a generic match evaluator.
Parameters:
| Name | Type | Description |
|---|---|---|
| matchEvaluator | function |
Match evaluation delegate. |
Returns: FilterableCollection<T>