Skip to content

tyneq


tyneq / TyneqOrderedSequence

Interface: TyneqOrderedSequence<TSource>

Defined in: src/types/core.ts:991

A TyneqSequence with additional secondary sort keys applied.

Remarks

Produced by orderBy / orderByDescending. Chain thenBy / thenByDescending to add secondary sort criteria.

Extends

Type Parameters

Type ParameterDescription
TSourceElement type.

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
[tyneqQueryNode]readonlyNullable<IQueryNode>The query plan node for this sequence, or null if no plan is available. Remarks Use QueryPlanPrinter to render this as a string. Sequences created via pipe() always have null here.TyneqSequence.[tyneqQueryNode]src/types/core.ts:113

Methods

getEnumerator()

getEnumerator(): Enumerator<TSource>

Defined in: src/types/core.ts:39

Returns a new, independent enumerator starting at the beginning of the sequence.

Returns

Enumerator<TSource>

Inherited from

TyneqSequence.getEnumerator


[iterator]()

[iterator](): Enumerator<TSource>

Defined in: src/types/core.ts:73

Returns

Enumerator<TSource>

Inherited from

TyneqSequence.[iterator]


any()

any(predicate): boolean

Defined in: src/types/core.ts:130

Returns true if any element satisfies the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

boolean

Remarks

Returns false for an empty sequence. The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.any


all()

all(predicate): boolean

Defined in: src/types/core.ts:142

Returns true if all elements satisfy the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

boolean

Remarks

Returns true for an empty sequence (vacuous truth). The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.all


contains()

contains(value, equalityComparer?): boolean

Defined in: src/types/core.ts:154

Returns true if the source sequence contains value.

Parameters

ParameterType
valueTSource
equalityComparer?EqualityComparer<TSource>

Returns

boolean

Remarks

Uses equalityComparer for element comparison, or === when omitted. Returns false for an empty sequence. Enumerates the source until a match is found or the sequence is exhausted.

Throws

When equalityComparer is null (undefined is allowed).

Inherited from

TyneqSequence.contains


count()

count(): number

Defined in: src/types/core.ts:162

Returns the number of elements.

Returns

number

Remarks

Returns 0 for an empty sequence.

Inherited from

TyneqSequence.count


countBy()

countBy(predicate): number

Defined in: src/types/core.ts:174

Returns the number of elements that satisfy the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

number

Remarks

Returns 0 if no elements match or the sequence is empty. The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.countBy


consume()

consume(): void

Defined in: src/types/core.ts:182

Iterates the entire sequence and discards all elements.

Returns

void

Remarks

Useful for triggering side effects (e.g., after tap).

Inherited from

TyneqSequence.consume


isNullOrEmpty()

isNullOrEmpty(): boolean

Defined in: src/types/core.ts:187

Returns true if the sequence is empty or if the first element is null or undefined.

Returns

boolean

Inherited from

TyneqSequence.isNullOrEmpty


elementAt()

elementAt(index): TSource

Defined in: src/types/core.ts:195

Returns the element at index.

Parameters

ParameterType
indexnumber

Returns

TSource

Throws

When index is not a safe integer.

Throws

When index is negative or greater than or equal to the sequence length.

Inherited from

TyneqSequence.elementAt


elementAtOrDefault()

elementAtOrDefault(index, defaultValue): TSource

Defined in: src/types/core.ts:203

Returns the element at index, or defaultValue if the index is out of range.

Parameters

ParameterType
indexnumber
defaultValueTSource

Returns

TSource

Throws

When index is not a safe integer.

Throws

When index is negative.

Inherited from

TyneqSequence.elementAtOrDefault


first()

first(predicate): TSource

Defined in: src/types/core.ts:215

Returns the first element that satisfies the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TSource

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Throws

When no element satisfies the predicate.

Inherited from

TyneqSequence.first


firstOrDefault()

firstOrDefault(predicate, defaultValue): TSource

Defined in: src/types/core.ts:226

Returns the first element that satisfies the predicate, or defaultValue if none does.

Parameters

ParameterType
predicateItemPredicate<TSource>
defaultValueTSource

Returns

TSource

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.firstOrDefault


indexOf()

indexOf(predicate, startIndex?): number

Defined in: src/types/core.ts:240

Returns the zero-based index of the first element that satisfies the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>
startIndex?number

Returns

number

Remarks

Returns -1 if no element satisfies the predicate. When startIndex is provided, the search starts at that index. The predicate receives each element and its zero-based index within the full sequence.

Throws

When predicate is null.

Throws

When predicate is undefined.

Throws

When startIndex is negative.

Inherited from

TyneqSequence.indexOf


last()

last(predicate): TSource

Defined in: src/types/core.ts:252

Returns the last element that satisfies the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TSource

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Throws

When no element satisfies the predicate.

Inherited from

TyneqSequence.last


lastOrDefault()

lastOrDefault(predicate, defaultValue): TSource

Defined in: src/types/core.ts:263

Returns the last element that satisfies the predicate, or defaultValue if none does.

Parameters

ParameterType
predicateItemPredicate<TSource>
defaultValueTSource

Returns

TSource

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.lastOrDefault


max()

max(comparer?): TSource

Defined in: src/types/core.ts:273

Returns the maximum element according to the comparer.

Parameters

ParameterType
comparer?Comparer<TSource>

Returns

TSource

Remarks

Uses the natural > operator when no comparer is provided.

Throws

When the sequence is empty.

Inherited from

TyneqSequence.max


maxBy()

maxBy<TKey>(keySelector, comparer?): TSource

Defined in: src/types/core.ts:282

Returns the element with the maximum key.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
keySelector(element) => TKey
comparer?Comparer<TKey>

Returns

TSource

Throws

When the sequence is empty.

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.maxBy


min()

min(comparer?): TSource

Defined in: src/types/core.ts:292

Returns the minimum element according to the comparer.

Parameters

ParameterType
comparer?Comparer<TSource>

Returns

TSource

Remarks

Uses the natural < operator when no comparer is provided.

Throws

When the sequence is empty.

Inherited from

TyneqSequence.min


minBy()

minBy<TKey>(keySelector, comparer?): TSource

Defined in: src/types/core.ts:301

Returns the element with the minimum key.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
keySelector(element) => TKey
comparer?Comparer<TKey>

Returns

TSource

Throws

When the sequence is empty.

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.minBy


sequenceEqual()

sequenceEqual(other, equalityComparer?): boolean

Defined in: src/types/core.ts:310

Returns true if this sequence and other have the same elements in the same order.

Parameters

ParameterType
otherIterable<TSource>
equalityComparer?EqualityComparer<TSource>

Returns

boolean

Remarks

Uses equalityComparer for element comparison, or === when omitted. Returns true if both sequences are empty.

Inherited from

TyneqSequence.sequenceEqual


single()

single(predicate): TSource

Defined in: src/types/core.ts:322

Returns the only element that satisfies the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TSource

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Throws

When no element satisfies the predicate, or when more than one does.

Inherited from

TyneqSequence.single


singleOrDefault()

singleOrDefault(predicate, defaultValue): TSource

Defined in: src/types/core.ts:334

Returns the only element that satisfies the predicate, or defaultValue if none does.

Parameters

ParameterType
predicateItemPredicate<TSource>
defaultValueTSource

Returns

TSource

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Throws

When more than one element satisfies the predicate.

Inherited from

TyneqSequence.singleOrDefault


endsWith()

endsWith(sequence, equalityComparer?): boolean

Defined in: src/types/core.ts:363

Returns true if this sequence ends with all elements of sequence in order.

Parameters

ParameterType
sequenceIterable<TSource>
equalityComparer?EqualityComparer<TSource>

Returns

boolean

Remarks

Uses equalityComparer for element comparison, or === when omitted. Returns true when sequence is empty (vacuous truth). Returns false when sequence is longer than the source.

Example

ts
Tyneq.from([1, 2, 3, 4, 5]).endsWith([4, 5]);        // true
Tyneq.from([1, 2, 3, 4, 5]).endsWith([3, 5]);        // false
Tyneq.from([1, 2, 3]).endsWith([]);                   // true
Tyneq.from([1, 2]).endsWith([1, 2, 3]);               // false

// Custom equality
Tyneq.from(["A", "B", "C"]).endsWith(
  ["b", "c"],
  (a, b) => a.toLowerCase() === b.toLowerCase()
); // true

Throws

When sequence is null.

Throws

When sequence is undefined.

Throws

When sequence is not iterable.

Throws

When equalityComparer is null (undefined is allowed).

Inherited from

TyneqSequence.endsWith


startsWith()

startsWith(sequence, equalityComparer?): boolean

Defined in: src/types/core.ts:378

Returns true if this sequence starts with all elements of sequence in order.

Parameters

ParameterType
sequenceIterable<TSource>
equalityComparer?EqualityComparer<TSource>

Returns

boolean

Remarks

Uses equalityComparer for element comparison, or === when omitted. Returns true when sequence is empty (vacuous truth). Returns false when sequence is longer than the source.

Throws

When sequence is null.

Throws

When sequence is undefined.

Throws

When sequence is not iterable.

Throws

When equalityComparer is null (undefined is allowed).

Inherited from

TyneqSequence.startsWith


sum()

sum(selector): number

Defined in: src/types/core.ts:389

Returns the sum of selector applied to each element.

Parameters

ParameterType
selector(item) => number

Returns

number

Remarks

Returns 0 for an empty sequence.

Throws

When selector is null.

Throws

When selector is undefined.

Inherited from

TyneqSequence.sum


toArray()

toArray(): TSource[]

Defined in: src/types/core.ts:397

Materializes the sequence into an array.

Returns

TSource[]

Remarks

Returns [] for an empty sequence.

Inherited from

TyneqSequence.toArray


toAsync()

toAsync(): AsyncIterable<TSource>

Defined in: src/types/core.ts:405

Returns an AsyncIterable that iterates this sequence asynchronously.

Returns

AsyncIterable<TSource>

Remarks

Deferred - each for await...of loop produces a fresh traversal of the source.

Inherited from

TyneqSequence.toAsync


toMap()

toMap<TKey, TValue>(selector): Map<TKey, TValue>

Defined in: src/types/core.ts:413

Materializes the sequence into a Map.

Type Parameters

Type Parameter
TKey
TValue

Parameters

ParameterType
selector(item) => KeyValuePair<TKey, TValue>

Returns

Map<TKey, TValue>

Throws

When selector is null.

Throws

When selector is undefined.

Inherited from

TyneqSequence.toMap


toRecord()

toRecord<TKey, TValue>(selector): Record<TKey, TValue>

Defined in: src/types/core.ts:421

Materializes the sequence into a plain object record.

Type Parameters

Type Parameter
TKey extends string | number | symbol
TValue

Parameters

ParameterType
selector(item) => KeyValuePair<TKey, TValue>

Returns

Record<TKey, TValue>

Throws

When selector is null.

Throws

When selector is undefined.

Inherited from

TyneqSequence.toRecord


toSet()

toSet(): Set<TSource>

Defined in: src/types/core.ts:429

Materializes the sequence into a Set.

Returns

Set<TSource>

Remarks

Duplicate elements are deduplicated using Set identity semantics.

Inherited from

TyneqSequence.toSet


average()

average(selector): number

Defined in: src/types/core.ts:438

Returns the arithmetic mean of selector applied to each element.

Parameters

ParameterType
selector(item) => number

Returns

number

Throws

When the sequence is empty.

Throws

When selector is null.

Throws

When selector is undefined.

Inherited from

TyneqSequence.average


aggregate()

aggregate<UAccumulate, VResult>(seed, func, resultSelector): VResult

Defined in: src/types/core.ts:449

Folds the sequence into a single result value.

Type Parameters

Type Parameter
UAccumulate
VResult

Parameters

ParameterType
seedUAccumulate
func(accumulate, item) => UAccumulate
resultSelector(accumulate) => VResult

Returns

VResult

Remarks

Applies func to each element in order, starting from seed. Returns resultSelector(seed) for an empty sequence.

Throws

When func or resultSelector is null.

Throws

When func or resultSelector is undefined.

Inherited from

TyneqSequence.aggregate


append()

append(item): TyneqSequence<TSource>

Defined in: src/types/core.ts:462

Returns a new sequence with item appended after all source elements.

Parameters

ParameterType
itemTSource

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.append


chunk()

chunk(size): TyneqSequence<TSource[]>

Defined in: src/types/core.ts:473

Partitions the sequence into non-overlapping arrays of length size.

Parameters

ParameterType
sizenumber

Returns

TyneqSequence<TSource[]>

Remarks

The last chunk may be shorter than size if the sequence length is not divisible by size.

Throws

When size is not a safe integer.

Throws

When size is less than or equal to 0.

Inherited from

TyneqSequence.chunk


concat()

concat(other): TyneqSequence<TSource>

Defined in: src/types/core.ts:476

Returns a new sequence with the elements of other appended after the source.

Parameters

ParameterType
otherIterable<TSource>

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.concat


defaultIfEmpty()

defaultIfEmpty(defaultValue): TyneqSequence<TSource>

Defined in: src/types/core.ts:484

Returns a sequence that yields defaultValue when the source is empty.

Parameters

ParameterType
defaultValueTSource

Returns

TyneqSequence<TSource>

Remarks

Passes source elements through unchanged when the source is non-empty.

Inherited from

TyneqSequence.defaultIfEmpty


flatten()

flatten<TInner>(this): TyneqSequence<TInner>

Defined in: src/types/core.ts:503

Flattens one level of nesting from a sequence of iterables.

Type Parameters

Type Parameter
TInner

Parameters

ParameterType
thisTyneqSequence<Iterable<TInner, any, any>>

Returns

TyneqSequence<TInner>

Remarks

Deferred. Each inner iterable is consumed lazily as the outer sequence advances. Returns an empty sequence when the source is empty. Equivalent to selectMany(x => x) but without requiring a selector.

Example

ts
Tyneq.from([[1, 2], [3, 4], [5]]).flatten().toArray();
// [1, 2, 3, 4, 5]

Tyneq.from(["hello", "world"]).flatten().toArray();
// ["h", "e", "l", "l", "o", "w", "o", "r", "l", "d"]

Inherited from

TyneqSequence.flatten


pairwise()

pairwise(): TyneqSequence<[TSource, TSource]>

Defined in: src/types/core.ts:511

Returns consecutive overlapping pairs of elements: [e0,e1], [e1,e2], ...

Returns

TyneqSequence<[TSource, TSource]>

Remarks

Returns an empty sequence when the source has fewer than two elements.

Inherited from

TyneqSequence.pairwise


ofType()

ofType<U>(guard): TyneqSequence<U>

Defined in: src/types/core.ts:519

Filters elements to those for which guard returns true, narrowing the type to U.

Type Parameters

Type Parameter
U

Parameters

ParameterType
guard(value) => value is U

Returns

TyneqSequence<U>

Throws

When guard is null.

Throws

When guard is undefined.

Inherited from

TyneqSequence.ofType


prepend()

prepend(item): TyneqSequence<TSource>

Defined in: src/types/core.ts:522

Returns a new sequence with item prepended before all source elements.

Parameters

ParameterType
itemTSource

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.prepend


repeat()

repeat(count): TyneqSequence<TSource>

Defined in: src/types/core.ts:543

Repeats the source sequence count times.

Parameters

ParameterType
countnumber

Returns

TyneqSequence<TSource>

Remarks

Deferred. Re-enumerates the source from the beginning for each repetition. Returns an empty sequence when count is 0.

Example

ts
Tyneq.from([1, 2]).repeat(3).toArray();
// [1, 2, 1, 2, 1, 2]

Tyneq.from([1, 2]).repeat(0).toArray();
// []

Throws

When count is negative.

Throws

When count is not an integer.

Inherited from

TyneqSequence.repeat


populate()

populate<TValue>(value): TyneqSequence<TValue>

Defined in: src/types/core.ts:551

Replaces each element with value, keeping the same sequence length.

Type Parameters

Type Parameter
TValue

Parameters

ParameterType
valueTValue

Returns

TyneqSequence<TValue>

Remarks

Useful for generating a sequence of a fixed value with a known length derived from the source.

Inherited from

TyneqSequence.populate


select()

select<TResult>(selector): TyneqSequence<TResult>

Defined in: src/types/core.ts:562

Projects each element through selector.

Type Parameters

Type Parameter
TResult

Parameters

ParameterType
selectorItemSelector<TSource, TResult>

Returns

TyneqSequence<TResult>

Remarks

The selector receives each element and its zero-based index.

Throws

When selector is null.

Throws

When selector is undefined.

Inherited from

TyneqSequence.select


selectMany()

selectMany<TResult>(selector): TyneqSequence<TResult>

Defined in: src/types/core.ts:570

Projects each element to an iterable and flattens the results into a single sequence.

Type Parameters

Type Parameter
TResult

Parameters

ParameterType
selector(item) => Iterable<TResult>

Returns

TyneqSequence<TResult>

Throws

When selector is null.

Throws

When selector is undefined.

Inherited from

TyneqSequence.selectMany


window()

window(size, step?): TyneqSequence<TSource[]>

Defined in: src/types/core.ts:598

Yields fixed-size windows (sub-arrays) over the source sequence.

Parameters

ParameterType
sizenumber
step?number

Returns

TyneqSequence<TSource[]>

Remarks

Deferred. O(size) memory - only the current window is held in memory. When step is 1 (the default), windows slide one element at a time (overlapping). When step equals size, windows are non-overlapping (tumbling). When step exceeds size, elements between windows are skipped (gaps). Yields no windows when the source has fewer than size elements. Each yielded array is a snapshot - mutating it does not affect subsequent windows.

Example

ts
// Sliding (default step = 1)
Tyneq.range(1, 5).window(3).toArray();
// [[1,2,3], [2,3,4], [3,4,5]]

// Tumbling (step = size)
Tyneq.range(1, 6).window(2, 2).toArray();
// [[1,2], [3,4], [5,6]]

Throws

When size or step is not a safe integer.

Throws

When size is less than 1.

Throws

When step is less than 1.

Inherited from

TyneqSequence.window


skip()

skip(count): TyneqSequence<TSource>

Defined in: src/types/core.ts:610

Skips the first count elements.

Parameters

ParameterType
countnumber

Returns

TyneqSequence<TSource>

Remarks

Returns an empty sequence when count exceeds the sequence length. count must be non-negative.

Throws

When count is not a safe integer.

Throws

When count is negative.

Inherited from

TyneqSequence.skip


skipLast()

skipLast(count): TyneqSequence<TSource>

Defined in: src/types/core.ts:621

Skips the last count elements.

Parameters

ParameterType
countnumber

Returns

TyneqSequence<TSource>

Remarks

Buffers count elements to determine the cutoff.

Throws

When count is not a safe integer.

Throws

When count is negative.

Inherited from

TyneqSequence.skipLast


skipUntil()

skipUntil(predicate): TyneqSequence<TSource>

Defined in: src/types/core.ts:634

Skips elements until predicate returns true, then yields all remaining elements including the one that triggered the predicate.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TyneqSequence<TSource>

Remarks

The predicate receives each element and its zero-based index. Once the predicate returns true it is never called again.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.skipUntil


skipWhile()

skipWhile(predicate): TyneqSequence<TSource>

Defined in: src/types/core.ts:645

Skips elements while predicate returns true, then yields the rest.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TyneqSequence<TSource>

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.skipWhile


slice()

slice(start, end?): TyneqSequence<TSource>

Defined in: src/types/core.ts:667

Yields elements between start (inclusive) and end (exclusive) by index.

Parameters

ParameterType
startnumber
end?number

Returns

TyneqSequence<TSource>

Remarks

Deferred. Enumerates only as far as end. When end is omitted, yields all elements from start to the end of the sequence. Returns an empty sequence when start is beyond the sequence length.

Example

ts
Tyneq.from([0, 1, 2, 3, 4]).slice(1, 4).toArray();
// [1, 2, 3]

Tyneq.from([0, 1, 2, 3, 4]).slice(2).toArray();
// [2, 3, 4]

Throws

When start is negative.

Throws

When end is negative or less than start.

Inherited from

TyneqSequence.slice


split()

split(splitOn): TyneqSequence<TSource[]>

Defined in: src/types/core.ts:678

Splits the sequence at elements where splitOn returns true.

Parameters

ParameterType
splitOn(item) => boolean

Returns

TyneqSequence<TSource[]>

Remarks

The delimiter elements are consumed and not included in any sub-array.

Throws

When splitOn is null.

Throws

When splitOn is undefined.

Inherited from

TyneqSequence.split


take()

take(count): TyneqSequence<TSource>

Defined in: src/types/core.ts:686

Takes at most the first count elements.

Parameters

ParameterType
countnumber

Returns

TyneqSequence<TSource>

Throws

When count is not a safe integer.

Throws

When count is negative.

Inherited from

TyneqSequence.take


takeUntil()

takeUntil(predicate): TyneqSequence<TSource>

Defined in: src/types/core.ts:699

Yields elements until predicate returns true, then stops. The element that triggered the predicate is not included.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TyneqSequence<TSource>

Remarks

The predicate receives each element and its zero-based index. Once the predicate returns true the sequence ends immediately.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.takeUntil


takeWhile()

takeWhile(predicate): TyneqSequence<TSource>

Defined in: src/types/core.ts:710

Takes elements while predicate returns true, then stops.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TyneqSequence<TSource>

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.takeWhile


tap()

tap(action): TyneqSequence<TSource>

Defined in: src/types/core.ts:721

Executes action for each element as it passes through the pipeline, then yields it unchanged.

Parameters

ParameterType
actionItemAction<TSource>

Returns

TyneqSequence<TSource>

Remarks

The action receives each element and its zero-based index.

Throws

When action is null.

Throws

When action is undefined.

Inherited from

TyneqSequence.tap


tapIf()

tapIf(action, predicate): TyneqSequence<TSource>

Defined in: src/types/core.ts:732

Executes action for each element only while predicate() returns true.

Parameters

ParameterType
actionItemAction<TSource>
predicate() => boolean

Returns

TyneqSequence<TSource>

Remarks

The action receives each element and its zero-based index.

Throws

When action or predicate is null.

Throws

When action or predicate is undefined.

Inherited from

TyneqSequence.tapIf


throttle()

throttle(count): TyneqSequence<TSource>

Defined in: src/types/core.ts:740

Yields every count-th element (i.e. elements at indices 0, count, 2*count, ...).

Parameters

ParameterType
countnumber

Returns

TyneqSequence<TSource>

Throws

When count is not a safe integer.

Throws

When count is less than or equal to 0.

Inherited from

TyneqSequence.throttle


where()

where(predicate): TyneqSequence<TSource>

Defined in: src/types/core.ts:751

Yields only elements for which predicate returns true.

Parameters

ParameterType
predicateItemPredicate<TSource>

Returns

TyneqSequence<TSource>

Remarks

The predicate receives each element and its zero-based index.

Throws

When predicate is null.

Throws

When predicate is undefined.

Inherited from

TyneqSequence.where


zip()

zip<TOther, TResult>(other, selector): TyneqSequence<TResult>

Defined in: src/types/core.ts:763

Pairs each element with the corresponding element from other using selector.

Type Parameters

Type Parameter
TOther
TResult

Parameters

ParameterType
otherIterable<TOther>
selector(first, second) => TResult

Returns

TyneqSequence<TResult>

Remarks

Stops at the shorter of the two sequences.

Throws

When other or selector is null.

Throws

When other or selector is undefined.

Throws

When other is not iterable.

Inherited from

TyneqSequence.zip


distinct()

distinct(): TyneqSequence<TSource>

Defined in: src/types/core.ts:772

Returns the sequence without duplicate elements, using SameValueZero (Set) equality.

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.distinct


distinctBy()

distinctBy<TKey>(keySelector): TyneqSequence<TSource>

Defined in: src/types/core.ts:780

Returns the sequence without duplicate elements, comparing by the result of keySelector.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
keySelector(item) => TKey

Returns

TyneqSequence<TSource>

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.distinctBy


except()

except(excludedValues): TyneqSequence<TSource>

Defined in: src/types/core.ts:783

Returns elements not present in excludedValues, using SameValueZero (Set) equality.

Parameters

ParameterType
excludedValuesIterable<TSource>

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.except


exceptBy()

exceptBy<TKey>(excludedKeys, keySelector): TyneqSequence<TSource>

Defined in: src/types/core.ts:791

Returns elements whose key (via keySelector) is not found in excludedKeys.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
excludedKeysIterable<TKey>
keySelector(item) => TKey

Returns

TyneqSequence<TSource>

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.exceptBy


groupBy()

groupBy<TKey, TValue, TResult>(keySelector, valueSelector, resultSelector): TyneqSequence<TResult>

Defined in: src/types/core.ts:799

Groups elements by key and projects each group with resultSelector.

Type Parameters

Type Parameter
TKey
TValue
TResult

Parameters

ParameterType
keySelector(item) => TKey
valueSelector(item) => TValue
resultSelector(key, values) => TResult

Returns

TyneqSequence<TResult>

Throws

When keySelector, valueSelector, or resultSelector is null.

Throws

When keySelector, valueSelector, or resultSelector is undefined.

Inherited from

TyneqSequence.groupBy


groupJoin()

groupJoin<TInner, TKey, TResult>(inner, outerKeySelector, innerKeySelector, resultSelector): TyneqSequence<TResult>

Defined in: src/types/core.ts:815

Performs a left outer join: each outer element is paired with its matching inner group.

Type Parameters

Type Parameter
TInner
TKey
TResult

Parameters

ParameterType
innerIterable<TInner>
outerKeySelector(outer) => TKey
innerKeySelector(inner) => TKey
resultSelector(outer, group) => TResult

Returns

TyneqSequence<TResult>

Remarks

Elements with no match in inner receive an empty group.

Throws

When any selector is null.

Throws

When any selector is undefined.

Throws

When inner is not iterable.

Inherited from

TyneqSequence.groupJoin


intersect()

intersect(intersectedValues): TyneqSequence<TSource>

Defined in: src/types/core.ts:823

Returns elements that are also present in intersectedValues, using SameValueZero (Set) equality.

Parameters

ParameterType
intersectedValuesIterable<TSource>

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.intersect


intersectBy()

intersectBy<TKey>(intersectedKeys, keySelector): TyneqSequence<TSource>

Defined in: src/types/core.ts:831

Returns elements whose key (via keySelector) is found in intersectedKeys.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
intersectedKeysIterable<TKey>
keySelector(item) => TKey

Returns

TyneqSequence<TSource>

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.intersectBy


join()

join<TInner, TKey, TResult>(inner, outerKeySelector, innerKeySelector, resultSelector): TyneqSequence<TResult>

Defined in: src/types/core.ts:839

Performs an inner join: produces one result for each matching pair of outer and inner elements.

Type Parameters

Type Parameter
TInner
TKey
TResult

Parameters

ParameterType
innerIterable<TInner>
outerKeySelector(outer) => TKey
innerKeySelector(inner) => TKey
resultSelector(outer, inner) => TResult

Returns

TyneqSequence<TResult>

Throws

When any selector is null.

Throws

When any selector is undefined.

Inherited from

TyneqSequence.join


memoize()

memoize(): TyneqCachedSequence<TSource>

Defined in: src/types/core.ts:853

Returns a sequence that caches elements incrementally as they are iterated.

Returns

TyneqCachedSequence<TSource>

Remarks

Subsequent iterations replay the cache; the source is only iterated once. Call refresh() on the returned sequence to clear the cache and re-enumerate the source.

Inherited from

TyneqSequence.memoize


orderBy()

orderBy<TKey>(keySelector, comparer?): TyneqOrderedSequence<TSource>

Defined in: src/types/core.ts:864

Returns the sequence sorted in ascending order by keySelector.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
keySelector(item) => TKey
comparer?Comparer<TKey>

Returns

TyneqOrderedSequence<TSource>

Remarks

Stable sort. Append thenBy/thenByDescending for multi-key sorting.

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.orderBy


orderByDescending()

orderByDescending<TKey>(keySelector, comparer?): TyneqOrderedSequence<TSource>

Defined in: src/types/core.ts:878

Returns the sequence sorted in descending order by keySelector.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
keySelector(item) => TKey
comparer?Comparer<TKey>

Returns

TyneqOrderedSequence<TSource>

Remarks

Stable sort. Append thenBy/thenByDescending for multi-key sorting.

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.orderByDescending


permutations()

permutations(): TyneqSequence<TSource[]>

Defined in: src/types/core.ts:890

Returns all possible permutations of the sequence.

Returns

TyneqSequence<TSource[]>

Remarks

O(n!) time and O(n) auxiliary memory. Use only on short sequences. For a sequence of length n, produces n! result arrays, each of length n.

Inherited from

TyneqSequence.permutations


reverse()

reverse(): TyneqSequence<TSource>

Defined in: src/types/core.ts:893

Returns the sequence in reverse order.

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.reverse


shuffle()

shuffle(): TyneqSequence<TSource>

Defined in: src/types/core.ts:901

Returns the sequence in random order using Math.random().

Returns

TyneqSequence<TSource>

Remarks

Uses the Fisher-Yates shuffle. Not cryptographically secure.

Inherited from

TyneqSequence.shuffle


backsert()

backsert(index, other): TyneqSequence<TSource>

Defined in: src/types/core.ts:921

Inserts elements from other into the sequence at index.

Parameters

ParameterType
indexnumber
otherIterable<TSource>

Returns

TyneqSequence<TSource>

Remarks

index is zero-based and counts from the end of the sequence. Use 0 to append after the last element, 1 to insert before the last element.

Example

ts
Tyneq.from([1, 2, 3]).backsert(0, [4, 5]).toArray();
// [1, 2, 3, 4, 5]  (appended)

Tyneq.from([1, 2, 3]).backsert(1, [99]).toArray();
// [1, 2, 99, 3]  (inserted before the last element)

Throws

When index is negative.

Inherited from

TyneqSequence.backsert


union()

union(otherValues): TyneqSequence<TSource>

Defined in: src/types/core.ts:924

Returns the distinct elements from both this sequence and otherValues, using SameValueZero (Set) equality.

Parameters

ParameterType
otherValuesIterable<TSource>

Returns

TyneqSequence<TSource>

Inherited from

TyneqSequence.union


unionBy()

unionBy<TKey>(otherValues, keySelector): TyneqSequence<TSource>

Defined in: src/types/core.ts:932

Returns the elements from both sequences whose keys are distinct.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
otherValuesIterable<TSource>
keySelector(item) => TKey

Returns

TyneqSequence<TSource>

Throws

When keySelector is null.

Throws

When keySelector is undefined.

Inherited from

TyneqSequence.unionBy


pipe()

pipe<TResult>(factory): TyneqSequence<TResult>

Defined in: src/types/core.ts:950

Passes this sequence through a custom factory function and wraps the result.

Type Parameters

Type Parameter
TResult

Parameters

ParameterType
factory(source) => Enumerator<TResult> | IterableIterator<TResult, any, any>

Returns

TyneqSequence<TResult>

Remarks

The returned sequence tracks a "pipe" node in the query plan, with factory recorded as the argument. Use this for one-off operator compositions that do not need to be registered via the plugin API.

Throws

When factory is null.

Throws

When factory is undefined.

Inherited from

TyneqSequence.pipe


scan()

scan<TResult>(seed, accumulator): TyneqSequence<TResult>

Defined in: src/types/core.ts:969

Returns a sequence of running aggregates.

Type Parameters

Type Parameter
TResult

Parameters

ParameterType
seedTResult
accumulator(acc, item) => TResult

Returns

TyneqSequence<TResult>

Remarks

The first element of the output is accumulator(seed, source[0]). Returns an empty sequence when the source is empty.

Throws

When accumulator is null.

Throws

When accumulator is undefined.

Inherited from

TyneqSequence.scan


minMax()

minMax(comparer?): MinMaxResult<TSource>

Defined in: src/types/core.ts:979

Returns the minimum and maximum element in one pass.

Parameters

ParameterType
comparer?Comparer<TSource>

Returns

MinMaxResult<TSource>

Remarks

Uses the natural < / > operators when no comparer is provided.

Throws

When the sequence is empty.

Inherited from

TyneqSequence.minMax


thenBy()

thenBy<TKey>(keySelector, comparer?): TyneqOrderedSequence<TSource>

Defined in: src/types/core.ts:998

Adds an ascending secondary sort key.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
keySelector(item) => TKey
comparer?Comparer<TKey>

Returns

TyneqOrderedSequence<TSource>

Throws

When keySelector is null.

Throws

When keySelector is undefined.


thenByDescending()

thenByDescending<TKey>(keySelector, comparer?): TyneqOrderedSequence<TSource>

Defined in: src/types/core.ts:1006

Adds a descending secondary sort key.

Type Parameters

Type Parameter
TKey

Parameters

ParameterType
keySelector(item) => TKey
comparer?Comparer<TKey>

Returns

TyneqOrderedSequence<TSource>

Throws

When keySelector is null.

Throws

When keySelector is undefined.


asc()

asc(): TyneqOrderedSequence<TSource>

Defined in: src/types/core.ts:1009

Sets the ordering to ascending according to the current sort keys.

Returns

TyneqOrderedSequence<TSource>


desc()

desc(): TyneqOrderedSequence<TSource>

Defined in: src/types/core.ts:1012

Sets the ordering to descending according to the current sort keys.

Returns

TyneqOrderedSequence<TSource>