Constructor
new Linq(iterable, thisArg)
- Description:
- Initialize a new instance of Linq object and wrap the specified iterable within it.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
iterable |
Iterable.<any> | An iterable object (e.g. Array, string, Map, Set...) |
thisArg |
any | A "this" pointer to be applied when calling user's callbacks. |
Throws:
-
`iterable` argument must be iterable
- Type
- Error
Members
(static) Version
- Description:
- Returns the version of this LINQ library. This is a read-only property used for diagnostics or compatibility checks.
- Source:
Returns the version of this LINQ library.
This is a read-only property used for diagnostics or compatibility checks.
Methods
aggregate(seed, accumulator, resultSelectoropt) → {any}
- Description:
- Applies an accumulator function over the sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
seed |
any | The initial accumulator value. The first parameter is the current sequence item. The second parameter is the value accumulated so far. The third parameter is the index of the current item (the first parameter) in the sequence. | |
accumulator |
function | An accumulator function to be invoked on each element. | |
resultSelector |
function |
<optional> |
An optional function to transform the final accumulator value into the result value. |
Throws:
-
`accumulator` must be a function
-
`resultSelector` must be a function or nullish
Returns:
The transformed final accumulator value.
- Type
- any
all(predicate) → {boolean}
- Description:
- Determines whether all elements of the sequence satisfy a condition.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
predicate |
function | A function to test each source element for a condition; The first parameter is a source element, the second parameter represents the index of the source element in the sequence. |
Throws:
`predicate` must be a function.
Returns:
true if every element of the sequence passes the test in the specified predicate, or if the sequence is empty; otherwise, false.
- Type
- boolean
any(predicateopt) → {boolean}
- Description:
- Determines whether any element of the sequence exists or satisfies a condition.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
predicate |
function |
<optional> |
A function to test each source element for a condition; The first parameter is a source element, the second parameter represents the index of the source element in the sequence. |
Throws:
`predicate` must be a function or nullish.
Returns:
true if the sequence contains any elements; otherwise, false. BUT In case that a predicate was specified: true if the sequence is not empty and at least one of its elements passes the test in the specified predicate; otherwise, false.
- Type
- boolean
append(value) → {Linq}
- Description:
- Appends a value to the end of the sequence. The original sequence (the current) is not changed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to be appended to the returned sequence. |
Returns:
A sequence consist of the current sequence plus the specified value.
- Type
- Linq
average() → {number|undefined}
- Description:
- Computes the average of the sequence of numeric values. If the sequence is empty or at least one element of the sequence is not a number, the return value is undefined.
- Source:
Returns:
The numeric average of the sequence,or undefined if the sequence contains at least oneitem that is not a number.
- Type
- number | undefined
concat(…withIterables) → {Linq}
- Description:
- Concatenates the current sequence with the specified sequences. Note that the current sequence is not modified.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
withIterables |
Iterable |
<repeatable> |
Iterable sequences be appended to the endof this sequence to form a single sequence. |
Returns:
An iterable that contains the concatenated elements of the current sequence with all input sequences.
- Type
- Linq
contains(value, equalityCompareropt) → {boolean}
- Description:
- Determines whether the sequence contains the specified element using strict equality comparison (===) or the specified equality comparer.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to locate in the sequence. | ||
equalityComparer |
function |
<optional> |
null
|
An optional equality comparer to compare values. The first parameter to the comparer is the specified value. The second parameter is an item from the sequence. The third parameter is the index of the item in the sequence. |
Throws:
`equalityComparer` must be a function or nullish.
Returns:
true if the sequence contains the specified value using strict equality comparison (===) or the specified equality comparer; otherwise, false.
- Type
- boolean
count() → {number}
Returns:
The number of elements in a sequence.
- Type
- number
defaultIfEmpty(defaultSingletonValue) → {Iterable}
- Description:
- Returns the elements of the sequence, or a default valued singleton collection if the sequence is empty.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
defaultSingletonValue |
any | A default value to be used as a singleton in the returned sequence if the current sequence is empty. |
Returns:
The elements of the sequence, or a default valued singleton collection if the sequence is empty.
- Type
- Iterable
distinct(equalityCompareropt) → {Linq}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
equalityComparer |
function |
<optional> |
An equality comparer to compare values. |
Throws:
`equalityComparer` must be a function or nullish
Returns:
Distinct elements from a sequence.
- Type
- Linq
duplicate(factor, inplaceopt) → {Linq}
- Description:
- Duplicate the sequence number of times as specified `factor` parameter. If the factor is non integral number, the integer value less than or equal to the factor is used. If factor is less than 1, an empty sequence returns. This function does not modify the current sequence.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
factor |
number | The number of times to duplicate the | |
inplace |
boolean |
<optional> |
If set to true, duplicate each element and places the duplication right after this element, instead of duplicating the whole sequence and return them one after the other. The default is false. |
Throws:
`factor` must be a non negative integer
Returns:
A sequence consist of duplication of the current sequence.
- Type
- Linq
elementAt(index) → {any}
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The zero-based index of the element to retrieve. |
Throws:
-
`index` must be a non negative integer
-
The sequence is empty
-
`index` is out of range
Returns:
The element at a specified index in a sequence.
- Type
- any
elementAtOrDefault(index, defaultValue) → {any}
- Description:
- Returns the element at a specified index in the sequence, or the specified default value if the specified index is negative or out of range.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The zero-based index of the element to retrieve. |
defaultValue |
any | The default value to be returned. |
Throws:
`index` must be a non negative integer
Returns:
The element at a specified index in the sequence, or the default value if the specified index is negative or out of range.
- Type
- any
except(secondIterable, equalityCompareropt) → {Linq}
- Description:
- Produces a set of unique items from the current sequence that do not appear in the specified scond sequence.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secondIterable |
Iterable | The second sequence. | |
equalityComparer |
function |
<optional> |
An equality comparer to be used to compare two items. |
Throws:
-
`secondIterable` must be iterable
-
`equalityComparer` must be a function or nullish
Returns:
A set of unique items from the current sequence that do not appear in the specified scond sequence.
- Type
- Linq
first(predicateopt) → {any}
- Description:
- Returns the first element in the sequence, or the first element in the sequence that meets the specified condition, if such one was specified.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
predicate |
function |
<optional> |
An optional function to test each element of the sequence for a condition; The first parameter is a source element, the second parameter is the index of the source element within the sequence. |
Throws:
-
`predicate` must be a function, null or undefined.
-
The sequence is empty.
-
No element satisfies the condition in predicate.
Returns:
The first element in the sequence, or the first element in the sequence that satisfies a specified condition, if such one was specified.
- Type
- any
firstOrDefault(defaultValue, predicateopt) → {any}
- Description:
- Returns the first element of the sequence, or the first one that meets the specified condition, if such one was specified. A default value is returned if the sequence is empty or no element was found.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
defaultValue |
any | The default value to return in case that sequence is empty, or none of the sequence items meets the specified condition. | |
predicate |
function |
<optional> |
A function to test each source element for a condition; The first parameter is a source element, the second parameter of the function represents the index of the source element. |
Throws:
`predicate` must be a function, null or undefined.
Returns:
The first element of the sequence, or the first one that meets the specified condition, if such one was specified. Or the specified default value if the sequence is empty or no element was found.
- Type
- any
forEach(callback)
- Description:
- Iterates through all elements in the sequence, and call the specified function for each.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | A callback function to be called for each element of the sequence until all elements of the sequence processed, or until a boolean false value was returned by the function; The first parameter to the callback is an element of the sequence, the second parameter represents the index of the element within the sequence. The callback might return false to stop the iteration. |
Throws:
`callback` must be a function
groupBy(keySelector, elementSelectoropt, resultSelectoropt, keyEqualityCompareropt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keySelector |
any | key creator | |
elementSelector |
any |
<optional> |
source element to group element: groupElementType func (sourceElementType) |
resultSelector |
any |
<optional> |
resultType func(key, groupElementType) |
keyEqualityComparer |
any |
<optional> |
bool (a, b) |
groupJoin(rightIterable, leftKeySelectoropt, rightKeySelectoropt, resultSelectoropt, keyEqualityCompareropt) → {Linq}
- Description:
- Correlates the elements of two sequences based on matching keys: this sequence (which considered to be the left one) and the specified sequence (the right). The result sequence contains each and every element from the left sequence along with its matched-key elements, group together, from the right. The order of the result sequence keeps the order of the left sequence (this sequence), and for each match from the right sequence the order is also maintained. It is possible to control the returned object by specifying a result selector which accepts the element from the left (this sequence) and its matched element from the right grouped as a single Linq object.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
rightIterable |
Iterable | The right side sequence to group-join to the left sequence (this one). | |
leftKeySelector |
function |
<optional> |
An optional function to extract the join key from each element of the left sequence (this one). By default the element itself is used as both key and value. |
rightKeySelector |
function |
<optional> |
An optional function to extract the join key from each element of the right sequence. By default the element itself is used as both key and value. |
resultSelector |
function |
<optional> |
An optional function to create a result element from matching elements, a single element from the left (this sequence) and a group of elements from the right (the specified sequence). By default, the result element is an array of these two. |
keyEqualityComparer |
function |
<optional> |
An optional function to check the equality of two keys. By default a strict comparison is made (===). |
Throws:
-
`rightIterable` must be iterable.
-
`leftKeySelector` must be a function or nullish.
-
`rightKeySelector` must be a function or nullish
-
`resultSelector` must be a function or nullish
-
`keyEqualityComparer` must be a function or nullish
Returns:
An iterable object that has elements that are obtained by performing an group join on the two sequences.
- Type
- Linq
intersect(secondIterable, equalityCompareropt) → {Linq}
- Description:
- Produces a sequence of UNIQUE items that appear in this sequence as well as the specified sequence. The order of the items remains the same as it was in this sequence.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secondIterable |
Iterable | The second sequence. | |
equalityComparer |
function |
<optional> |
An equality comparer to be used to compare two items. |
Throws:
-
`secondIterable` must be iterable
-
`equalityComparer` must be a function or nullish
Returns:
A sequence of UNIQUE items that ALSO appear in the specified sequence. The order of the items remains the same as it was in this sequence.
- Type
- Linq
join(rightIterable, leftKeySelectoropt, rightKeySelectoropt, resultSelectoropt, keyEqualityCompareropt) → {Linq}
- Description:
- Correlates the elements of two sequences based on matching keys: this sequence (which considered to be the left one) and the specified sequence (the right). The result sequence contains each element from the left sequence along with its matched-key element from the right - and only these. The order of the result sequence keeps the order of the left sequence (this sequence), and for each match from the right sequence the order is also maintained.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
rightIterable |
Iterable | The right side sequence to join to the left sequence (this one). | |
leftKeySelector |
function |
<optional> |
An optional function to extract the join key from each element of the left sequence (this one). By default the element itself is used as both key and value. |
rightKeySelector |
function |
<optional> |
An optional function to extract the join key from each element of the right sequence. By default the element itself is used as both key and value. |
resultSelector |
function |
<optional> |
An optional function to create a result element from two matching elements. By default, the result element is an array of the two matched elements. |
keyEqualityComparer |
function |
<optional> |
An optional function to check the equality of two keys. By default a strict comparison is made (===). |
Throws:
-
`rightIterable` must be iterable.
-
`leftKeySelector` must be a function or nullish.
-
`rightKeySelector` must be a function or nullish
-
`resultSelector` must be a function or nullish
-
`keyEqualityComparer` must be a function or nullish
Returns:
An iterable object that has elements that are obtained by performing an inner join on the two sequences.
- Type
- Linq
last(predicateopt) → {any}
- Description:
- Returns the last element in a sequence, or the last element in the sequence that meets the specified condition, if specified.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
predicate |
function |
<optional> |
A function to test each source element for a condition; The first parameter is a source element, the second parameter of the function represents the index of the source element. |
Throws:
-
`predicate` must be a function or nullish
-
The sequence is empty
-
No element satisfies the condition in predicate
Returns:
The last element in the specified sequence, or the last element in the sequence that satisfies a specified condition, if specified.
- Type
- any
lastOrDefault(defaultValue, predicateopt) → {any}
- Description:
- Returns the last element of the sequence, or the last one that meets the specified condition, if such one was specified. A default value is returned if the sequence is empty or no element was found.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
defaultValue |
any | The default value to return in case that sequence is empty, or none of the sequence items meets the specified condition. | |
predicate |
function |
<optional> |
A function to test each source element for a condition; The first parameter is a source element, the second parameter of the function represents the index of the source element. |
Throws:
`predicate` must be a function or nullish
Returns:
The last element of the sequence, or the last one that meets the specified condition, if such one was specified. Or the specified default value if the sequence is empty or no element was found.
- Type
- any
max(compareropt) → {any}
- Description:
- Returns the maximum value in the sequence. If the sequence is empty, the return value is undefined. If it contains a single value, it will be the maximum value, no matter what it is.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
comparer |
function |
<optional> |
An optional function to compare two items from the sequence. The first parameter to this function is the first item, the second parameter is the second item, and the third parameter is the index of the SECOND item in the sequence. If no compare function is passed, a default compare is used (>= operator). In this default compare, if one of the arguments is null or undefined, the result is undefined. |
Throws:
`compare` must be a function or nullish
Returns:
The maximum value of the sequence.
- Type
- any
min(compareropt) → {any}
- Description:
- Returns the minimum value in the sequence. If the sequence is empty, the return value is undefined. If it contains a single value, it will be the minimum value, no matter what it is.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
comparer |
function |
<optional> |
An optional function to compare two items from the sequence. The first parameter to this function is the first item, the second parameter is the second item, and the third parameter is the index of the SECOND item in the sequence. If no compare function is passed, a default compare is used (>= operator). In this default compare, if one of the arguments is null or undefined, the result is undefined. |
Throws:
`compare` must be a function or nullish
Returns:
The minimum value of the sequence.
- Type
- any
orderBy(keySelectoropt, compareropt) → {Linq}
- Description:
- Sorts the elements of the sequence in ascending order, optionally by using the specified keySelector and comparer. This method performs a stable sort; that is, if the keys of two elements are equal, the order of the elements is preserved. In contrast, an unstable sort does not preserve the order of elements that have the same key.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keySelector |
function |
<optional> |
An optional function to extract a key from an element. My default the element is used as the key. |
comparer |
function |
<optional> |
An optional comparer to compare keys. By default a simple comparison is made. |
Throws:
-
`keySelector` must be a function or nullish
-
`comparer` must be a function or nullish
Returns:
The elements of the sequence in ascending order, optionally by using the specified keySelector and comparer.
- Type
- Linq
orderByDescending(keySelectoropt, compareropt) → {Linq}
- Description:
- Sorts the elements of the sequence in descending order, optionally by using the specified keySelector and comparer. This method performs a stable sort; that is, if the keys of two elements are equal, the order of the elements is preserved. In contrast, an unstable sort does not preserve the order of elements that have the same key.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keySelector |
function |
<optional> |
An optional function to extract a key from an element. Ny default the element is used as the key. |
comparer |
function |
<optional> |
An optional comparer to compare keys. By default a simple comparison is made. |
Throws:
-
`keySelector` must be a function or nullish
-
`comparer` must be a function or nullish
Returns:
The elements of the sequence in descending order, optionally by using the specified keySelector and comparer.
- Type
- Linq
prepend(value) → {Linq}
- Description:
- Adds a value to the beginning of the sequence. The original sequence (the current) is not changed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to be added to the beginning of the returned sequence. |
Returns:
A sequence consist of the specified element, and then the items from the current sequence.
- Type
- Linq
removeNullishes() → {Linq}
- Description:
- Return a copy of this sequence without the nullish values (null or undefined).
- Source:
Returns:
A copy of this sequence without the nullish values (null or undefined).
- Type
- Linq
reverse() → {Linq}
Returns:
A copy of this sequence in reserve order.
- Type
- Linq
select(selectoropt) → {Linq}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
selector |
function |
<optional> |
A n optional transform function to apply to each source element; The first parameter is the element, the second parameter represents the index of the source element. The default selector simply return the item that passed as parameter. |
Throws:
`selector` must be a function or nullish
Returns:
A new sequence whose elements are the result of invoking the transform function on each element this sequence.
- Type
- Linq
selectMany(collectionSelectoropt, resultSelectoropt) → {Linq}
- Description:
- Projects each element as inner sequence, then flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
collectionSelector |
function |
<optional> |
A transform function to apply to each source element and SHOULD return an iterable object (the inner sequence). In this function: The first parameter is the source element from this sequence. The second parameter represents the index of the source element within this sequence. The default selector simply returns the source element that passed as the first parameter. |
resultSelector |
function |
<optional> |
A transform function to apply to each item of each inner sequence. In this function: The first parameter is a item itself. The second parameter represents the index of this item within the inner sequence which is currently scanned. The third parameter is a reference to the inner sequence which is currently scanned. The forth parameter represents the index of the this inner sequence within the current sequence.* By default the selector simply returns the item that passed as parameter. |
Throws:
-
`collectionSelector` must be a function or nullish
-
`resultSelector` must be a function or nullish
Returns:
A sequence whose elements are the result of invoking the transform functions on each inner sequence and on each element of each inner sequence.
- Type
- Linq
sequenceEqual(secondIterable, equalityCompareropt) → {boolean}
- Description:
- Determines whether the current sequence is equal to the specified, according to an equality comparer.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secondIterable |
Iterable | The second sequence to compare to. | |
equalityComparer |
function |
<optional> |
An equality comparer to compare two items. The first parameter is the first item, the second parameter is the second item, and the third is the index of these items within the sequences. |
Throws:
-
`secondIterable` must be iterable
-
`equalityComparer` must be a function or nullish
Returns:
true if the two sequences are of equal length and their corresponding elements are equal according to the equality comparer; otherwise, false.
- Type
- boolean
single(predicateopt) → {any}
- Description:
- Returns the only element of the sequence, and throws an exception if there is not exactly one element in the sequence. OR Returns the only element of the sequence that satisfies a specified condition, and throws an exception if more than one such element exists.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
predicate |
function |
<optional> |
An optional function to test each source element for a condition; The first parameter is a source element, the second parameter of the function represents the index of the source element. |
Throws:
-
`predicate` must be a function or nullish
-
The input sequence contains more than one element
-
More than one element satisfies the condition in predicate
-
The sequence is empty
-
No element satisfies the condition in predicate
Returns:
The single element of the input sequence OR The single element of the input sequence that satisfies the specified predicate.
- Type
- any
singleOrDefault(defaultValue, predicateopt) → {any}
- Description:
- Returns the only element of the sequence. If there is no element in the sequence, the specified defaultValue is returned. If the sequence contains more that a single element, an error is thrown. OR Returns the only element of the sequence, using the specified predicate to match the value. If no element matched, the specified defaultValue is returned. If more than a single element matched, an error is thrown.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
defaultValue |
any | The defaultValue. | |
predicate |
function |
<optional> |
An optional function to test each source element for a condition; The first parameter is a source element, the second parameter of the function represents the index of the source element. |
Throws:
-
predicate must be a function or nullish
-
The input sequence contains more than one element
-
More than one element satisfies the condition in predicate
Returns:
The single element of the input sequence OR The single element of the input sequence that satisfies the specified predicate, or the defaultValue.
- Type
- any
skip(count) → {Linq}
- Description:
- Bypasses a specified number of elements in the sequence and then returns the remaining elements.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
count |
number | The number of elements to skip before returning the remaining elements. |
Throws:
`count` must be an integer
Returns:
A new sequence that contains the elements that occur after the specified index in the sequence.
- Type
- Linq
skipLast(count) → {Linq}
- Description:
- Returns a new sequence that contains the elements from the current sequence with the last count elements omitted.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
count |
number | Number of element from the end of this sequence to omit. |
Throws:
`count` must be an integer
Returns:
A new sequence that contains the elements from the current sequence with the last count elements omitted.
- Type
- Linq
skipWhile(predicate) → {Linq}
- Description:
- Bypasses elements in the sequence as long as a specified condition is true and then returns the remaining elements.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
predicate |
function | A function to test each source element for a condition; The first parameter to this predicate is the source element, the second parameter represents the index of the source element. |
Throws:
`predicate` must be a function
Returns:
A new sequence that contains the elements from the sequence starting at the first element in the sequence that does not pass the test specified by predicate.
- Type
- Linq
statistics(extended) → {Linq.Statistics}
- Description:
- Calculates the following statistic measurements for the sequence of numbers: - count: The count numbers. - minimum: The minimal number in the sequence. - maximum: The maximal number in the sequence. - range: The range of the sequence, that is the difference between the maximal value and the minimal value. - average: The average number of the sequence. - summary: The summary of the sequence. - variance: The variance of the sequence - standard deviation: The standard deviation of the sequence (which is a square root of the variance). If extended was set to true, or more specifically extended.median and/or extended.mode were set to true. - mode: The value that appears most frequently in the sequence. If more than a single value have the same maximum repetition count, an array of all "modes" returns. If all items have the same repetition count, `undefined` is returned. - median: A numeric value that "splits" the sequence to two, so half of the elements comes before it, and half of the elements comes after it.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
extended |
boolean | Object | Determines whether to calculates extended (additional) statistic values: mode, median, variance, standard. |
Returns:
- The statistics result.
- Type
- Linq.Statistics
sum() → {number|undefined}
- Description:
- Computes the sum of the sequence of numeric values. If at least one element of the sequence is not a number, the return value is undefined. If the sequence is empty, the returned value is undefined.
- Source:
Returns:
- Type
- number | undefined
take(count) → {Linq}
- Description:
- Returns a specified number of contiguous elements from the start of this sequence.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
count |
number | The number of elements to return. |
Throws:
`count` must be an integer
Returns:
A new sequence that contains the specified number of elements from the start of this sequence.
- Type
- Linq
takeLast(count) → {Linq}
- Description:
- Returns a new sequence that contains the last count elements from this sequence.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
count |
number | The number of last elements to return. |
Throws:
`count` must be an integer
Returns:
A new sequence that contains the specified number of last elements from this sequence.
- Type
- Linq
takeWhile(predicate) → {Linq}
- Description:
- Returns elements from this sequence as long as a specified condition is true, and then skips the remaining elements.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
predicate |
function | A function to test each source element for a condition; The first parameter is the element, the second parameter represents the index of the element within this sequence. |
Throws:
`predicate` must be a function
Returns:
A new sequence that contains the elements from this sequence that occur before the element at which the test no longer passes.
- Type
- Linq
toArray() → {Array}
Returns:
An array that contains the elements from of the current sequence.
- Type
- Array
toDictionary(keySelectoropt, valueSelectoropt) → {Map}
- Description:
- Creates a map from the current sequence according to a specified key selector function, and an element selector function. This function is an alias to `toMap`.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keySelector |
function |
<optional> |
An optional function to extract out of each element in th sequence the key for each corresponding element in the map. The first parameter to the function is the elemnt in the sequence, and the second parameter represents the index of the element in the sequence. |
valueSelector |
function |
<optional> |
An optional function to extract out of each element in th sequence the value for each corresponding element in the map. The first parameter to the function is the elemnt in the sequence, and the second parameter represents the index of the element in the sequence. |
Throws:
-
`keySelector` must be a function or nullish
-
`valueSelector` must be a function or nullish
-
`keySelector` produces duplicate keys
Returns:
A map from the current sequence according to a specified key selector function, and the value selector function.
- Type
- Map
toMap(keySelectoropt, valueSelectoropt) → {Map}
- Description:
- Creates a map from the current sequence according to a specified key selector function, and an element selector function.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keySelector |
function |
<optional> |
An optional function to extract out of each element in th sequence the key for each corresponding element in the map. The first parameter to the function is the elemnt in the sequence, and the second parameter represents the index of the element in the sequence. |
valueSelector |
function |
<optional> |
An optional function to extract out of each element in th sequence the value for each corresponding element in the map. The first parameter to the function is the elemnt in the sequence, and the second parameter represents the index of the element in the sequence. |
Throws:
-
`keySelector` must be a function or nullish
-
`valueSelector` must be a function or nullish
-
`keySelector` produces duplicate keys
Returns:
A map from the current sequence according to a specified key selector function, and the value selector function.
- Type
- Map
toSet(keySelectoropt) → {Set}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keySelector |
function |
<optional> |
An optional function to extract out of each element in th sequence the key (which is also the value) for each corresponding element in the set. The first parameter to the function is the elemnt in the sequence, and the second parameter represents the index of the element in the sequence. |
Throws:
-
`keySelector` must be a function or nullish
-
`keySelector` produces duplicate keys
Returns:
A set from the current sequence according to a specified key selector.
- Type
- Set
union(secondIterable, equalityCompareropt) → {Linq}
- Description:
- Produces a set union of the current sequence with the specified sequences. The sequence contains only the UNIQUE items.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secondIterable |
Iterable | The second sequence. | |
equalityComparer |
function |
<optional> |
An equality comparer to be used to compare two items. |
Throws:
-
`secondIterable` must be iterable
-
`equalityComparer` must be a function or nullish
Returns:
A set union of the current sequence with the specified sequences.
- Type
- Linq
where(predicate) → {Linq}
Parameters:
Name | Type | Description |
---|---|---|
predicate |
function | A function to test each source element for a condition; The first parameter to this test function is a source element, the second parameter of the function represents the index of the source element. |
Throws:
`predicate` must be a function
Returns:
An enumerable that contains elements from the sequence that satisfy the condition.
- Type
- Linq
(static) empty(thisArg) → {Linq}
Parameters:
Name | Type | Description |
---|---|---|
thisArg |
any | Optional object to be used as this argument in any call in the returned sequence. |
Returns:
An empty sequence.
- Type
- Linq
(static) from(iterable, thisArgopt) → {Linq}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
iterable |
Iterable | An iterable object. | |
thisArg |
any |
<optional> |
An object to be used as `this` pointer in callback calls. |
Returns:
- A LINQ query from the specified iterable.
- Type
- Linq
(static) range(start, count, thisArgopt) → {Linq}
- Description:
- Generates a sequence of integral numbers within a specified range.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
start |
number | The value of the first integer in the sequence. | |
count |
number | The number of sequential integers to generate. | |
thisArg |
any |
<optional> |
The object to be used as this pointer for subsequent LINQ calls. |
Throws:
-
`start` must be an integer
-
`count` must be a non negative integer
Returns:
A sequence of integral numbers within a specified range.
- Type
- Linq
(static) repeat(value, count, thisArgopt) → {Linq}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
any | The value to be repeated. | |
count |
number | The number of times to repeat the value in the generated sequence. | |
thisArg |
any |
<optional> |
The object to be used as this pointer for subsequent LINQ calls. |
Throws:
`count` must be a non negative integer
Returns:
A sequence consist of the specified value repeated the specified count of times.
- Type
- Linq
(static) zip(iterable1, iterable2, transform, thisArg) → {Linq}
- Description:
- Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results. The iteration stops when right after the last item of one of the sequences has reached.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
iterable1 |
Iterable | The first sequence |
iterable2 |
Iterable | The second sequence. |
transform |
function | The transform function. The first parameter is the item from the first sequence, The second parameter is the item from the second sequence. The third parameter is the index of these items within the sequences. |
thisArg |
any | Th object that will be used as this pointer in the transform function. |
Throws:
-
`iterable1` must be iterable
-
`iterable2` must be iterable
-
`transform` must be a function
Returns:
A result sequence.
- Type
- Linq