@luvies/lazy
Version:
A linq-like lazy iteration module that aims to support deno, node & browser
1,001 lines • 35.4 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lazy = void 0;
const tslib_1 = require("tslib");
const aggregates = tslib_1.__importStar(require("./aggregates"));
const iterators = tslib_1.__importStar(require("./iterators"));
// Base lazy class.
/**
* The base class that all lazy iterable objects derive from.
* This can be extended with custom iterators if needed.
*/
class Lazy {
// ===================================== Base iterators =====================================
/**
* Creates an empty lazy iterable.
* @returns The empty lazy iterable object.
*/
static empty() {
return new LazyEmpty();
}
/**
* Creates a lazy iterable object from the given iterable object.
* @param iterable The object to source for lazy iteration.
* @returns The lazy iterable object with the given iterable as the source.
* @remarks If you pass in a lazy iterator, then it is returned without
* changes.
*/
static from(iterable) {
if (iterable instanceof Lazy) {
return iterable;
}
return new LazyIterator(iterable);
}
/**
* Creates a lazy iterable object that will produce a range of integers.
* @param start The starting number of the range (inclusive).
* @param end The ending number of the range (exclusive). If not given, then
* the value is assumed to be +Infinity.
* @returns The lazy iterable object with the range as the source.
* @remarks When creating an infinite interable, be very careful. If you do not
* include your own stop condition (e.g. with `.take(n)`), then it will lock
* up the thread until the process is aborted. You will also have to take into
* account that some lazy iterators *require* the interable to be finite to work.
* Check the remarks on the function you want to use to see which ones will work.
*/
static range(start, end) {
return new LazyRange(start, end);
}
/**
* Creates a lazy iterable object that will repeate the element a given number
* of times.
* @param element The value to repeat.
* @param count The number of times to repeat it. If not given, then the
* value is assumed to be +Infinity.
* @returns The lazy iterable object with the repeated value as the source.
* @throws {Error} If count < 0.
* @remarks When creating an infinite interable, be very careful. If you do not
* include your own stop condition (e.g. with `.take(n)`), then it will lock
* up the thread until the process is aborted. You will also have to take into
* account that some lazy iterators *require* the interable to be finite to work.
* Check the remarks on the function you want to use to see which ones will work.
*/
static repeat(element, count) {
return new LazyRepeat(element, count);
}
aggregate(agg, seed) {
if (arguments.length >= 2) {
return aggregates.aggregate(this, agg, seed);
}
else {
return aggregates.aggregate(this, agg);
}
}
/**
* Returns whether all elements satisfy the given condition.
* @param predicate The function to use to test each element.
* @returns Whether all elements satisfied the condition.
* @remarks This will iterate until the condition is false or until the iterable
* ends.
*/
all(predicate) {
return aggregates.all(this, predicate);
}
any(predicate) {
return aggregates.any(this, predicate);
}
average(selector) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
return aggregates.average(this, selector);
}
/**
* Determines whether the iterable has a given element.
* @param element The value to search for.
* @param comparer The function that compares 2 elements and returns a boolean on whether they
* are equal or not. If not given, defaults to strict equals (`===`).
* @returns Whether the element was in the iterable.
* @remarks This will iterable until the given value is found, or until the
* iterable ends.
*/
contains(element, comparer) {
return aggregates.contains(this, element, comparer);
}
count(predicate) {
return aggregates.count(this, predicate);
}
/**
* Returns the element at the given index of the iterable.
* @param index The index of the element to get.
* @returns The element at the given index.
* @throws {Error} If the index was < 0 or if it is >= the length of the iterable.
* @remarks The will iterate until the specified index, or until the iterable
* ends.
*/
elementAt(index) {
return aggregates.elementAt(this, index);
}
elementAtOrDefault(index, defaultValue) {
return aggregates.elementAtOrDefault(this, index, defaultValue);
}
first(predicate) {
return aggregates.first(this, predicate);
}
firstOrDefault(defaultValue, predicate) {
return aggregates.firstOrDefault(this, defaultValue, predicate);
}
/**
* Mimics the behaviour of `Array.prototype.forEach`, with the exception
* of not providing the entire array as the 3rd param of the callback.
* @param callbackFn The callback function that will be executed for each element
* in the iterable.
* @remarks This will cause a complete iteration of the iterable object.
*/
forEach(callbackFn) {
aggregates.forEach(this, callbackFn);
}
/**
* Determines whether 2 iterables are equal.
* @param second The iterable to compare against.
* @param comparer The function to perform the comparision of each pair of
* elements with. If not given, defaults to strict equals (`===`).
* @returns Whether the 2 iterables were both equal.
* @remarks This will check for both order and value, and will iterate
* both iterables completely.
*/
iterableEquals(second, comparer) {
return aggregates.iterableEquals(this, second, comparer);
}
last(predicate) {
return aggregates.last(this, predicate);
}
lastOrDefault(defaultValue, predicate) {
return aggregates.lastOrDefault(this, defaultValue, predicate);
}
max(selector) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
return aggregates.max(this, selector);
}
min(selector) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
return aggregates.min(this, selector);
}
/**
* Resolves all of the promises in the iterable, and returns a new Lazy
* iterable from the result.
* @returns A promise that will resolve to a lazy iterable object.
* @remarks This will cause a complete iteration of the iterable object.
* This will behave similar to [[cache]], in that the original lazy iterable
* will be resolved completely and then discarded, in favour of the resolved
* iterable.
*/
resolveAll() {
return aggregates
.resolveAll(this)
.then(iterable => Lazy.from(iterable));
}
/**
* Returns a single element from the iterable that matches the given
* condition.
* @param predicate The predicate function to test each element with.
* @returns The element that satisfies the condition.
* @throws {Error} If no element could be found that matched the condition.
* @remarks This will iterate until the condition is met or until the iterable
* ends.
*/
single(predicate) {
return aggregates.single(this, predicate);
}
singleOrDefault(predicate, defaultValue) {
return aggregates.singleOrDefault(this, predicate, defaultValue);
}
/**
* Joins all the elements in the iterable together into a single string,
* split by the given separator.
* @param separator The separator to split each element with in the string.
* Defaults to `''`.
* @param strFn The function to convert each element into a string.
* @remarks This will cause a complete iteration of the iterable object.
*/
stringJoin(separator, strFn) {
return aggregates.stringJoin(this, separator, strFn);
}
sum(selector) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
return aggregates.sum(this, selector);
}
/**
* Converts the iterable into a standard JavaScript `Array`.
* @remarks This will cause a complete iteration of the iterable object.
*/
toArray() {
return aggregates.toArray(this);
}
/**
* Converts the iterable to a JSON-serialisable array.
* @remarks This will cause a complete iteration of the iterable object.
* This will not do anything to the elements, meaning that you are
* responsible for ensuring that they are all JSON-serialisable.
*/
toJSON() {
return this.toArray();
}
/**
* Converts the iterable into a map using the key and value function.
* @param keyFn The function to use to derive the key of each map element.
* @param valueFn The function to use to derive the value of map value. If
* not given, then the value itself is used.
* @returns A `Map<TKey, TResult>` derived from the iterable.
* @remarks This will cause a complete iteration of the iterable object.
*/
toMap(keyFn, valueFn) {
return aggregates.toMap(this, keyFn, valueFn);
}
// ===================================== Iterators =====================================
/**
* Appends the element to the end of the iterable.
* @param element The element to append.
* @remarks Does not cause additional unexpected iteration.
*/
append(element) {
return new LazyAppendPrepend(this, element, false);
}
/**
* Applies the given lazy iterable implementation to the current object.
* This allows for using custom Lazy implementations using the standard
* chaining syntax.
* @param fn The function that will create the iterable instance using
* the current object.
* @returns The instantiated iterable object.
*/
apply(fn) {
return fn(this);
}
/**
* Batches elements in groups of the given batch size.
* @param batchSize The size of each batch.
* @param includeIncomplete Whether to include batches
* that are smaller than the target size. This only applies
* to the final batch of the iterable if the total size is
* not a multiple of the batch size.
* @remarks Does not cause additional unexpected iteration.
*/
batchIn(batchSize, includeIncomplete = true) {
return new LazyBatchIn(this, batchSize, includeIncomplete);
}
/**
* Resolves the underlaying iterable completely and returns a lazy
* of the result.
* @remarks This will completely iterate the underlaying iterable,
* and return a completely new lazy object of the result. This allows
* for some optimisation when a chain has become complex and iteration
* of it is needed multiple times (as the resulting iterable will only be
* calulated once, and then reused). This can also be used to ensure
* that side-effects of the chain are only done once, which can be useful
* in more complicated computations.
* Since this will return a completely new Lazy iterable, it means that,
* if no other references exist, then the previous chain (and even the
* original iterable) can be freed for garbage collection, potentially
* helping with memory.
*/
cache() {
return Lazy.from(this.toArray());
}
/**
* Concatinates multiple iterables in order.
* @param iterables The other iterables to concatinate with.
* @remarks Does not cause additional unexpected iteration.
*/
concat(...iterables) {
return new LazyConcat(this, ...iterables);
}
/**
* Returns the elements in the iterable, or the given default value
* as the only element if it contained none.
* @param defaultValue The value to use if the iterable was empty.
* @remarks Does not cause additional unexpected iteration.
*/
defaultIfEmpty(defaultValue) {
return new LazyDefaultIfEmpty(this, defaultValue);
}
/**
* Returns the distinct elements in the iterable.
* @param compareOn A mapping function to get the key to compare with. The result
* will be effectively compared using a strict equals (`===`) against the others.
* If not given, then each element will used directly.
* @remarks Does not cause additional unexpected iteration.
*/
distinct(compareOn) {
return new LazyDistinct(this, compareOn);
}
/**
* Returns the set difference between 2 iterables. This like doing an XOR
* over the 2 iterables.
* @param second The iterable to get the difference of.
* @param compareOn A mapping function to get the key to compare with. The value
* will be effectively compared using a strict equals (`===`) againt the others.
* If not given, then each element will used directly.
* @remarks This will iterate the second iterable completely once it has
* started iteration (not before). It will not cause additional unexpected iteration
* on the underlying iterable.
*/
except(second, compareOn) {
return new LazyExcept(this, second, compareOn);
}
groupBy(keyFn, elementSelector, resultSelector) {
return new LazyGroupBy(this, keyFn, elementSelector, resultSelector);
}
/**
* Joins 2 iterables on the given key and groups the results.
* @param second The other iterable to group join with.
* @param firstKeyFn The function that extracts the key from an element
* of the first iterable.
* @param secondKeyFn The function that extracts the key from an element
* of the second iterable.
* @param joinFn The function that takes an element from the first and an
* iterable of elements from the second, and outputs the resulting element.
* @remarks This will iterate the second iterable completely once it has
* started iteration (not before). It will not cause additional unexpected iteration
* on the underlying iterable.
*/
groupJoin(second, firstKeyFn, secondKeyFn, joinFn) {
return new LazyGroupJoin(this, second, firstKeyFn, secondKeyFn, joinFn);
}
/**
* Returns the set intersection between 2 iterables. This like doing an AND
* over the 2 iterables.
* @param second The iterable to get the intersection of.
* @param compareOn A mapping function to get the key to compare with. The value
* will be effectively compared using a strict equals (`===`) against the others.
* If not given, then each element will used directly.
* @remarks This will iterate the second iterable completely once it has
* started iteration (not before). It will not cause additional unexpected iteration
* on the underlying iterable.
*/
intersect(second, compareOn) {
return new LazyIntersect(this, second, compareOn);
}
/**
* Joins 2 iterables on the given matching keys. This is similar to a JOIN in
* SQL.
* @param second The iterable to join.
* @param firstKeyFn The function that extracts the key from the first iterable.
* @param secondKeyFn The function that extracts the key from the second iterable.
* @param joinFn The function that takes in a single element from the from each of
* the first and second iterables, and outputs the resulting element.
* @remarks This will iterate the second iterable completely once it has
* started iteration (not before). It will not cause additional unexpected iteration
* on the underlying iterable.
*/
join(second, firstKeyFn, secondKeyFn, joinFn) {
return new LazyJoin(this, second, firstKeyFn, secondKeyFn, joinFn);
}
/**
* Sorts the iterable in ascending order.
* @param keyFn The function used to get the key from a given element.
* @param compareFn The function that is passed to `Array.prototype.sort` to
* compare values and return the comparison number. If not given, a default
* sorting function will be used. This sorting function will match the
* behaviour of the standard sort comparison function.
* @remarks When this is iterated (not before), the underlying iterator is walked through
* completely in order to allow sorting.
*/
orderBy(keyFn, compareFn) {
return new LazyOrderBy(this, keyFn, compareFn, false);
}
/**
* Sorts the iterable in descending order.
* @param keyFn The function used to get the key from a given element.
* @param compareFn The function that is passed to `Array.prototype.sort` to
* compare values and return the comparison number. If not given, a default
* sorting function will be used. This sorting function will match the
* behaviour of the standard sort comparison function.
* @remarks When this is iterated (not before), the underlying iterator is walked through
* completely in order to allow sorting.
*/
orderByDecending(keyFn, compareFn) {
return new LazyOrderBy(this, keyFn, compareFn, true);
}
/**
* Sorts the iterable in acending order according to the numeric
* result of the key function.
* @param keyFn The function user to get the key from the given element.
* @remarks When this is iterated (not before), the underlying iterator is walked through
* completely in order to allow sorting.
* This function is equivalent to [[orderBy]] with a numeric comparison
* compare function.
*/
orderNumericallyBy(keyFn) {
return this.orderBy(keyFn, iterators.numericComparer);
}
/**
* Sorts the iterable in descending order according to the numeric
* result of the key function.
* @param keyFn The function used to get the key from a given element.
* @remarks When this is iterated (not before), the underlying iterator is walked through
* completely in order to allow sorting.
* This function is equivalent to [[orderByDecending]] with a numeric comparison
* compare function.
*/
orderNumericallyByDecending(keyFn) {
return this.orderByDecending(keyFn, iterators.numericComparer);
}
/**
* Prepends the element to the beginning of the iterable.
* @param element The element to prepend.
* @remarks Does not cause additional unexpected iteration.
*/
prepend(element) {
return new LazyAppendPrepend(this, element, true);
}
/**
* Reverses the order of the iterable.
* @remarks When this is iterated (not before), the underlying iterator is walked through
* completely in order to allow starting from the end.
*/
reverse() {
return new LazyReverse(this);
}
/**
* Projects the elements of the iterable into a new form.
* @param selector The transformation function to use for each element.
* @remarks Does not cause additional unexpected iteration.
*/
select(selector) {
return new LazySelect(this, selector);
}
/**
* Projects the elements of the iterable into a new form, and flattens the iterable of iterables
* into a single iterable.
* @param selector The transformation function to use for each element. The index parameter
* is the index that the element was at in the source iterable, *not* the resulting one.
* @remarks Does not cause additional unexpected iteration.
*/
selectMany(selector) {
return new LazySelectMany(this, selector);
}
/**
* Skips the given number of elements from the start of the iterable and returns
* the rest.
* @param count The number of elements to skip.
* @remarks Does not cause additional unexpected iteration.
*/
skip(count) {
return new LazySkip(this, count);
}
/**
* Skips the given number of elements from the end of the iterable, returning the rest.
* @param count The number of elements to skip from the end.
* @remarks This iterator requires the iterable to be finite in length. It will iterate
* slightly ahead of the resulting iterable.
*/
skipLast(count) {
return new LazySkipLast(this, count);
}
/**
* Skips all elements in the iterable until the condition returns true, after which all
* elements are returned regardless.
* @param predicate The predicate function to check the condition with.
* @remarks Does not cause additional unexpected iteration.
*/
skipWhile(predicate) {
return new LazySkipWhile(this, predicate);
}
/**
* Returns the given number of elements from the start of the iterable, ignoring
* the rest.
* @param count The number of elements to take from the start.
* @remarks Does not cause additional unexpected iteration.
*/
take(count) {
return new LazyTake(this, count);
}
/**
* Returns the given number of elements from the end of the iterable, ignore the
* elements before.
* @remarks This iterator requires the iterable to be finite in length. It will iterate
* until the end.
*/
takeLast(count) {
return new LazyTakeLast(this, count);
}
/**
* Takes all elements in the iterable until the condition returns true, after which
* the iterable is considered to have ended.
* @param predicate The predicate function to check the condition with.
* @remarks Does not cause additional unexpected iteration.
*/
takeWhile(predicate) {
return new LazyTakeWhile(this, predicate);
}
/**
* Returns the set union between 2 iterables. This like doing an OR
* over the 2 iterables.
* @param second The iterable to get the union of.
* @param compareOn A mapping function to get the key to compare with. The value
* will be effectively compared using a strict equals (`===`) against the others.
* If not given, then the element will used directly.
* @remarks This will iterate the second iterable completely once it has
* started iteration (not before). It will not cause additional unexpected iteration
* on the underlying iterable.
*/
union(second, compareOn) {
return new LazyUnion(this, second, compareOn);
}
where(predicate) {
return new LazyWhere(this, predicate);
}
zip(second, selector) {
return new LazyZip(this, second, selector);
}
}
exports.Lazy = Lazy;
// Base iterators.
/**
* @hidden
*/
class LazyEmpty extends Lazy {
[Symbol.iterator]() {
return {
next() {
return {
done: true,
value: undefined,
};
},
};
}
}
/**
* @hidden
*/
class LazyIterator extends Lazy {
constructor(_iterable) {
super();
this._iterable = _iterable;
}
count(predicate) {
if (predicate) {
return super.count(predicate);
}
// Use shortcut if we are directly on an array.
if (Array.isArray(this._iterable)) {
return this._iterable.length;
}
return super.count();
}
elementAt(index) {
// Use shortcut if we are directly on an array.
if (Array.isArray(this._iterable)) {
if (index >= 0 && index < this._iterable.length) {
return this._iterable[index];
}
else {
throw new Error('Index out of array bounds');
}
}
return super.elementAt(index);
}
elementAtOrDefault(index, defaultValue) {
// Use shortcut if we are directly on an array.
if (Array.isArray(this._iterable)) {
if (index >= 0 && index < this._iterable.length) {
return this._iterable[index];
}
else {
return defaultValue;
}
}
return super.elementAtOrDefault(index, defaultValue);
}
first(predicate) {
if (predicate) {
return super.first(predicate);
}
// Use shortcut if we are directly on an array.
if (Array.isArray(this._iterable)) {
if (this._iterable.length > 0) {
return this._iterable[0];
}
else {
throw new Error(aggregates.Errors.Empty);
}
}
return super.first();
}
firstOrDefault(defaultValue, predicate) {
if (predicate) {
return super.firstOrDefault(defaultValue, predicate);
}
// Use shortcut if we are directly on an array.
if (Array.isArray(this._iterable)) {
if (this._iterable.length > 0) {
return this._iterable[0];
}
else {
return defaultValue;
}
}
return super.firstOrDefault(defaultValue);
}
last(predicate) {
if (predicate) {
return super.last(predicate);
}
// Use shortcut if we are directly on an array.
if (Array.isArray(this._iterable)) {
if (this._iterable.length > 0) {
return this._iterable[this._iterable.length - 1];
}
else {
throw new Error(aggregates.Errors.Empty);
}
}
return super.last();
}
lastOrDefault(defaultValue, predicate) {
if (predicate) {
return super.lastOrDefault(defaultValue, predicate);
}
// Use shortcut if we are directly on an array.
if (Array.isArray(this._iterable)) {
if (this._iterable.length > 0) {
return this._iterable[this._iterable.length - 1];
}
else {
return defaultValue;
}
}
return super.lastOrDefault(defaultValue);
}
[Symbol.iterator]() {
return this._iterable[Symbol.iterator]();
}
}
/**
* @hidden
*/
class LazyRange extends Lazy {
constructor(_start, _end = +Infinity) {
super();
this._start = _start;
this._end = _end;
}
[Symbol.iterator]() {
return new iterators.LazyRangeIterator(this._start, this._end);
}
}
/**
* @hidden
*/
class LazyRepeat extends Lazy {
constructor(_element, _count = +Infinity) {
super();
this._element = _element;
this._count = _count;
if (_count < 0) {
throw new Error('Count cannot be < 0');
}
}
[Symbol.iterator]() {
return new iterators.LazyRepeatIterator(this._element, this._count);
}
}
/*
Iterator implementations.
Each of these will apply some form of transformation on an iterable,
but *only* while it is being iterated.
*/
/**
* @hidden
*/
class LazyAppendPrepend extends Lazy {
constructor(_iterable, _element, _atStart) {
super();
this._iterable = _iterable;
this._element = _element;
this._atStart = _atStart;
}
[Symbol.iterator]() {
return new iterators.LazyAppendPrependIterator(this._iterable, this._element, this._atStart);
}
}
/**
* @hidden
*/
class LazyBatchIn extends Lazy {
constructor(_iterable, _batchSize, _includeComplete) {
super();
this._iterable = _iterable;
this._batchSize = _batchSize;
this._includeComplete = _includeComplete;
}
[Symbol.iterator]() {
return new iterators.LazyBatchInIterator(this._iterable, this._batchSize, this._includeComplete);
}
}
/**
* @hidden
*/
class LazyConcat extends Lazy {
constructor(..._iterables) {
super();
this._iterables = _iterables;
}
[Symbol.iterator]() {
return new iterators.LazyConcatIterator(this._iterables);
}
}
/**
* @hidden
*/
class LazyDefaultIfEmpty extends Lazy {
constructor(_iterable, _defaultValue) {
super();
this._iterable = _iterable;
this._defaultValue = _defaultValue;
}
[Symbol.iterator]() {
return new iterators.LazyDefaultIfEmptyIterator(this._iterable, this._defaultValue);
}
}
/**
* @hidden
*/
class LazyDistinct extends Lazy {
constructor(_iterable, _compareOn) {
super();
this._iterable = _iterable;
this._compareOn = _compareOn;
}
[Symbol.iterator]() {
return new iterators.LazyDistinctIterator(this._iterable, this._compareOn);
}
}
/**
* @hidden
*/
class LazyExcept extends Lazy {
constructor(_firstIterable, _secondIterable, _compareOn) {
super();
this._firstIterable = _firstIterable;
this._secondIterable = _secondIterable;
this._compareOn = _compareOn;
}
[Symbol.iterator]() {
return new iterators.LazyExceptIterator(this._firstIterable, this._secondIterable, this._compareOn);
}
}
/**
* @hidden
*/
class LazyGroupBy extends Lazy {
constructor(_iterable, _keyFn, _elementSelector, _resultSelector) {
super();
this._iterable = _iterable;
this._keyFn = _keyFn;
this._elementSelector = _elementSelector;
this._resultSelector = _resultSelector;
}
[Symbol.iterator]() {
return new iterators.LazyGroupByIterator(this._iterable, this._keyFn, this._elementSelector, this._resultSelector);
}
}
/**
* @hidden
*/
class LazyGroupJoin extends Lazy {
constructor(_firstIterable, _secondIterable, _firstKeyFn, _secondKeyFn, _joinFn) {
super();
this._firstIterable = _firstIterable;
this._secondIterable = _secondIterable;
this._firstKeyFn = _firstKeyFn;
this._secondKeyFn = _secondKeyFn;
this._joinFn = _joinFn;
}
[Symbol.iterator]() {
return new iterators.LazyGroupJoinIterator(this._firstIterable, this._secondIterable, this._firstKeyFn, this._secondKeyFn, this._joinFn);
}
}
/**
* @hidden
*/
class LazyIntersect extends Lazy {
constructor(_firstIterable, _secondIterable, _compareOn) {
super();
this._firstIterable = _firstIterable;
this._secondIterable = _secondIterable;
this._compareOn = _compareOn;
}
[Symbol.iterator]() {
return new iterators.LazyIntersectIterator(this._firstIterable, this._secondIterable, this._compareOn);
}
}
/**
* @hidden
*/
class LazyJoin extends Lazy {
constructor(_firstIterable, _secondIterable, _firstKeyFn, _secondKeyFn, _joinFn) {
super();
this._firstIterable = _firstIterable;
this._secondIterable = _secondIterable;
this._firstKeyFn = _firstKeyFn;
this._secondKeyFn = _secondKeyFn;
this._joinFn = _joinFn;
}
[Symbol.iterator]() {
return new iterators.LazyJoinIterator(this._firstIterable, this._secondIterable, this._firstKeyFn, this._secondKeyFn, this._joinFn);
}
}
/**
* @hidden
*/
class LazyOrderBy extends Lazy {
constructor(_iterable, _keyFn, _compareFn, _decending) {
super();
this._iterable = _iterable;
this._keyFn = _keyFn;
this._compareFn = _compareFn;
this._decending = _decending;
}
[Symbol.iterator]() {
return iterators.lazyOrderBy(this._iterable, this._keyFn, this._compareFn, this._decending);
}
}
/**
* @hidden
*/
class LazyReverse extends Lazy {
constructor(_iterable) {
super();
this._iterable = _iterable;
}
[Symbol.iterator]() {
return new iterators.LazyReverseIterator(this._iterable);
}
}
/**
* @hidden
*/
class LazySelect extends Lazy {
constructor(_iterable, _selector) {
super();
this._iterable = _iterable;
this._selector = _selector;
}
[Symbol.iterator]() {
return new iterators.LazySelectIterator(this._iterable, this._selector);
}
}
/**
* @hidden
*/
class LazySelectMany extends Lazy {
constructor(_iterable, _selector) {
super();
this._iterable = _iterable;
this._selector = _selector;
}
[Symbol.iterator]() {
return new iterators.LazySelectManyIterator(this._iterable, this._selector);
}
}
/**
* @hidden
*/
class LazySkip extends Lazy {
constructor(_iterable, _count) {
super();
this._iterable = _iterable;
this._count = _count;
}
[Symbol.iterator]() {
return new iterators.LazySkipIterator(this._iterable, this._count);
}
}
/**
* @hidden
*/
class LazySkipLast extends Lazy {
constructor(_iterable, _count) {
super();
this._iterable = _iterable;
this._count = _count;
}
[Symbol.iterator]() {
return new iterators.LazySkipLastIterator(this._iterable, this._count);
}
}
/**
* @hidden
*/
class LazySkipWhile extends Lazy {
constructor(_iterable, _predicate) {
super();
this._iterable = _iterable;
this._predicate = _predicate;
}
[Symbol.iterator]() {
return new iterators.LazySkipWhile(this._iterable, this._predicate);
}
}
/**
* @hidden
*/
class LazyTake extends Lazy {
constructor(_iterable, _count) {
super();
this._iterable = _iterable;
this._count = _count;
}
[Symbol.iterator]() {
return new iterators.LazyTakeIterator(this._iterable, this._count);
}
}
/**
* @hidden
*/
class LazyTakeLast extends Lazy {
constructor(_iterable, _count) {
super();
this._iterable = _iterable;
this._count = _count;
}
[Symbol.iterator]() {
return new iterators.LazyTakeLastIterator(this._iterable, this._count);
}
}
/**
* @hidden
*/
class LazyTakeWhile extends Lazy {
constructor(_iterable, _predicate) {
super();
this._iterable = _iterable;
this._predicate = _predicate;
}
[Symbol.iterator]() {
return new iterators.LazyTakeWhileIterator(this._iterable, this._predicate);
}
}
/**
* @hidden
*/
class LazyUnion extends Lazy {
constructor(_firstIterable, _secondIterable, _compareOn) {
super();
this._firstIterable = _firstIterable;
this._secondIterable = _secondIterable;
this._compareOn = _compareOn;
}
[Symbol.iterator]() {
return new iterators.LazyUnionIterator(this._firstIterable, this._secondIterable, this._compareOn);
}
}
/**
* @hidden
*/
class LazyWhere extends Lazy {
constructor(_iterable, _predicate) {
super();
this._iterable = _iterable;
this._predicate = _predicate;
}
[Symbol.iterator]() {
return new iterators.LazyWhereIterator(this._iterable, this._predicate);
}
}
/**
* @hidden
*/
class LazyZip extends Lazy {
constructor(_firstIterable, _secondIterable, _selector) {
super();
this._firstIterable = _firstIterable;
this._secondIterable = _secondIterable;
this._selector = _selector;
}
[Symbol.iterator]() {
return new iterators.LazyZipIterator(this._firstIterable, this._secondIterable, this._selector);
}
}
//# sourceMappingURL=lazy.js.map