new Enumerable()
Creates a new enumerable.
Methods
-
<static> empty()
-
Returns an empty Enumerable.
Returns:
- Type
- Enumerable
-
<static> from(source)
-
Creates an Enumerable from iterable collections.
Parameters:
Name Type Description source
iterable A iterable source. Returns:
- Type
- Enumerable
-
aggregate(aggregateFn, seed, resultSelector)
-
Applies an aggregate function over a sequence.
Parameters:
Name Type Argument Default Description aggregateFn
aggregator An aggregate function that will be invoked for each element. seed
* <optional>
First element in the sequence The specified seed value is used as the initial aggregate value. resultSelector
selector <optional>
SELF_SELECTOR The specified result selector is used to project the aggregated value. Returns:
The aggregated value.- Type
- *
-
all(predicate)
-
Determines whether all elements of a sequence satisfy a condition.
Parameters:
Name Type Argument Default Description predicate
predicate <optional>
ALWAYS TRUE A function to test each source element for a condition. Returns:
- Type
- boolean
-
any(predicate)
-
Determines whether any element of a sequence exists or satisfies a condition.
Parameters:
Name Type Description predicate
predicate A function to test each source element for a condition. Returns:
- Type
- boolean
-
contains(element, equalityComparer)
-
Determines if the sequence contains a specified element by using the equality comparer.
Parameters:
Name Type Argument Description element
* The element to compare with. equalityComparer
equalityComparer <optional>
A function to determine equality of each element with specified element. -
count(predicate)
-
Returns the number of elements in a sequence. If a condition is specified then returns a how many elements in the sequence satisfy it.
Parameters:
Name Type Argument Description predicate
predicate <optional>
A function to test each source element for a condition. Returns:
- Type
- Number
-
first(predicate)
-
Returns the first element in a sequence that satisfies a specified condition.
Parameters:
Name Type Argument Description predicate
predicate <optional>
A function to test each source element for a condition. Throws:
-
-
If the sequence is empty.
- Type
- Error
-
-
-
If the sequence contains no matching element.
- Type
- Error
-
Returns:
- Type
- *
-
-
firstOrDefault(predicate)
-
Returns the first element of the sequence that satisfies a condition or null if no such element is found.
Parameters:
Name Type Argument Description predicate
predicate <optional>
A function to test each source element for a condition. Returns:
- Type
- *
-
select(selector)
-
Projects each element of a sequence into a new form.
Parameters:
Name Type Description selector
selector A transform function to apply to each element. Returns:
- Type
- Enumerable
-
selectMany(collectionSelector, resultSelector)
-
Projects a collection in each element of a sequence, flattens it, and invokes a result selector function to project the resulting sequence.
Parameters:
Name Type Argument Description collectionSelector
selector A function to apply to each element to get the intermediate collection. resultSelector
selector <optional>
A transform function to apply to each element of final flattened sequence. Throws:
-
If the collection is not iterable.
- Type
- TypeError
Returns:
- Type
- Enumerable
-
-
single(predicate)
-
Returns the only element of a sequence that satisfies the specified condition.
Parameters:
Name Type Argument Description predicate
predicate <optional>
A function to test each source element for a condition. Throws:
-
-
If the sequence is empty.
- Type
- Error
-
-
-
If the sequence contains no matching element.
- Type
- Error
-
-
-
If the sequence contains more than one matching element.
- Type
- Error
-
Returns:
- Type
- *
-
-
singleOrDefault(predicate)
-
Returns the only element of a sequence that satisfies a specified condition or null if no such element exists.
Parameters:
Name Type Argument Description predicate
predicate <optional>
A function to test each source element for a condition. Throws:
-
If the sequence contains more than one matching element.
- Type
- Error
Returns:
- Type
- *
-
-
skip(count)
-
Skips the specified number of elements of a sequence.
Parameters:
Name Type Argument Default Description count
Number <optional>
0 The number of elements to skip. Returns:
- Type
- Enumerable
-
skipWhile(predicate)
-
Skips elements in a sequence as long as a specified condition is true and then returns the remaining elements.
Parameters:
Name Type Description predicate
predicate A function to test each source element for a condition. Returns:
- Type
- Enumerable
-
take(count)
-
Returns a specified number of elements from the begining of a sequence.
Parameters:
Name Type Argument Default Description count
Number <optional>
0 The number of elements to return. Returns:
- Type
- Enumerable
-
takeWhile(predicate)
-
Returns elements in a sequence as long as a specified condition is true.
Parameters:
Name Type Description predicate
predicate A function to test each source element for a condition. Returns:
- Type
- Enumerable
-
toArray()
-
Returns an array. This method forces immediate evaluation and returns an array that contains the results.
Returns:
- Type
- Array
-
where(predicate)
-
Filters a collection of values based on a predicate.
Parameters:
Name Type Description predicate
predicate A function to test each source element for a condition. Returns:
- Type
- Enumerable