tyneq 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +67 -1
  2. package/dist/{TyneqCachedTerminalOperator.d.ts → TyneqCachedTerminalOperator-BrW77zIy.d.ts} +328 -173
  3. package/dist/{TyneqCachedTerminalOperator.d.cts → TyneqCachedTerminalOperator-EaNiNt61.d.cts} +328 -173
  4. package/dist/chunk-5R4AALC7.js +680 -0
  5. package/dist/chunk-C5PBY3ZU.cjs +46 -0
  6. package/dist/chunk-OWKUE3AC.cjs +680 -0
  7. package/dist/chunk-PCBN5AFG.js +46 -0
  8. package/dist/chunk-VJAICXA6.cjs +3788 -0
  9. package/dist/chunk-ZP6WMZCK.js +3788 -0
  10. package/dist/core-C54TSmgW.d.cts +1390 -0
  11. package/dist/core-C54TSmgW.d.ts +1390 -0
  12. package/dist/index.cjs +638 -843
  13. package/dist/index.d.cts +405 -605
  14. package/dist/index.d.ts +405 -605
  15. package/dist/index.js +630 -781
  16. package/dist/plugin/index.cjs +51 -24
  17. package/dist/plugin/index.d.cts +35 -38
  18. package/dist/plugin/index.d.ts +35 -38
  19. package/dist/plugin/index.js +51 -2
  20. package/dist/utility/index.cjs +18 -9
  21. package/dist/utility/index.d.cts +312 -2
  22. package/dist/utility/index.d.ts +312 -2
  23. package/dist/utility/index.js +18 -3
  24. package/package.json +5 -5
  25. package/dist/Lazy.cjs +0 -762
  26. package/dist/Lazy.cjs.map +0 -1
  27. package/dist/Lazy.js +0 -691
  28. package/dist/Lazy.js.map +0 -1
  29. package/dist/TyneqCachedTerminalOperator.cjs +0 -4950
  30. package/dist/TyneqCachedTerminalOperator.cjs.map +0 -1
  31. package/dist/TyneqCachedTerminalOperator.d.cts.map +0 -1
  32. package/dist/TyneqCachedTerminalOperator.d.ts.map +0 -1
  33. package/dist/TyneqCachedTerminalOperator.js +0 -4741
  34. package/dist/TyneqCachedTerminalOperator.js.map +0 -1
  35. package/dist/ValidationBuilder.cjs +0 -80
  36. package/dist/ValidationBuilder.cjs.map +0 -1
  37. package/dist/ValidationBuilder.d.cts +0 -319
  38. package/dist/ValidationBuilder.d.cts.map +0 -1
  39. package/dist/ValidationBuilder.d.ts +0 -319
  40. package/dist/ValidationBuilder.d.ts.map +0 -1
  41. package/dist/ValidationBuilder.js +0 -69
  42. package/dist/ValidationBuilder.js.map +0 -1
  43. package/dist/core.d.cts +0 -1393
  44. package/dist/core.d.cts.map +0 -1
  45. package/dist/core.d.ts +0 -1393
  46. package/dist/core.d.ts.map +0 -1
  47. package/dist/index.cjs.map +0 -1
  48. package/dist/index.d.cts.map +0 -1
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/index.js.map +0 -1
  51. package/dist/plugin/index.d.cts.map +0 -1
  52. package/dist/plugin/index.d.ts.map +0 -1
@@ -0,0 +1,1390 @@
1
+ /**
2
+ * Abstract base for multi-key stable sorters used by the ordering infrastructure.
3
+ *
4
+ * @remarks
5
+ * `computeKeys()` pre-computes sort keys for each element; `compareKeys()` compares by index.
6
+ * Sorters chain together via the `next` field on {@link TyneqEnumerableSorter} to implement
7
+ * multi-key (thenBy) sorting.
8
+ *
9
+ * @internal
10
+ */
11
+ declare abstract class BaseEnumerableSorter<TSource> {
12
+ /** Pre-computes the sort key for each element in `source[0..count-1]`. */
13
+ abstract computeKeys(source: TSource[], count: number): void;
14
+ /** Compares the sort keys at indices `i` and `j`. Returns negative, zero, or positive. */
15
+ abstract compareKeys(i: number, j: number): number;
16
+ /**
17
+ * Returns a stable sorted index map for `source[0..count-1]`.
18
+ *
19
+ * @returns An array of indices sorted by the key order defined by this sorter chain.
20
+ */
21
+ sort(source: TSource[], count: number): number[];
22
+ }
23
+
24
+ /** `T | null` */
25
+ type Nullable<T> = T | null;
26
+ /** `T | undefined` */
27
+ type Maybe<T> = T | undefined;
28
+ /** `T | null | undefined` */
29
+ type Optional<T> = T | null | undefined;
30
+ /** Any object with a `length` property. */
31
+ type HasLength = {
32
+ length: number;
33
+ };
34
+ /** Any function with any number of arguments. */
35
+ type GenericFunction = (...x: never[]) => unknown;
36
+ /** A constructor type that can be instantiated with `new`. */
37
+ type Constructor<TInstance = unknown, TArgs extends readonly any[] = any[]> = new (...args: TArgs) => TInstance;
38
+ /** A type that extracts the instance type from a constructor. */
39
+ type InstanceOf<C> = C extends Constructor<infer TInstance> ? TInstance : never;
40
+ /** A type that prevents inference of `T` in generic functions. */
41
+ type NoInfer<T> = [T][T extends any ? 0 : never];
42
+ /** A function that takes arguments of type `TArgs` (tuple) and returns void. */
43
+ type Action<TArgs extends readonly unknown[] = []> = (...args: TArgs) => void;
44
+ /** A function that takes arguments of type `TArgs` (tuple) and returns a boolean. */
45
+ type Predicate<TArgs extends readonly unknown[] = []> = (...args: TArgs) => boolean;
46
+ /** A predicate over a sequence element and its zero-based index. */
47
+ type ItemPredicate<T> = (item: T, index: number) => boolean;
48
+ /** A projection over a sequence element and its zero-based index. */
49
+ type ItemSelector<T, TResult> = (item: T, index: number) => TResult;
50
+ /** A side-effect action over a sequence element and its zero-based index. */
51
+ type ItemAction<T> = (item: T, index: number) => void;
52
+ /** A function that takes arguments of type `TArgs` (tuple) and returns a value of type `TResult`. */
53
+ type Func<TArgs extends readonly unknown[] = [], TResult = unknown> = (...args: TArgs) => TResult;
54
+ /** A method callable on a specific `this` context, returning `TReturn`. */
55
+ type BoundMethod<TThis = unknown, TReturn = unknown> = (this: TThis, ...args: any[]) => TReturn;
56
+ /** A method callable on any `this` context with unknown arguments. */
57
+ type Method = BoundMethod<unknown>;
58
+ /** A factory function that creates an instance of type `TInstance` given arguments of type `TArgs`. */
59
+ type Factory<TInstance = unknown, TArgs extends readonly any[] = any[]> = (...args: TArgs) => TInstance;
60
+ /**
61
+ * Narrows `T` to `U` if `T extends U`; otherwise falls back to `U`.
62
+ *
63
+ * @remarks
64
+ * Use this when you have a type variable `T` that you know satisfies `U` in context
65
+ * but TypeScript cannot prove it statically. `Assume<T, U>` resolves to `T` when the
66
+ * constraint holds and to `U` as a safe fallback when it does not - avoiding `any`.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * // Generic return type constrained to the concrete key type:
71
+ * type ValueAt<T, K extends keyof T> = Assume<T[K], string>;
72
+ * // T[K] is string -> resolves to T[K] (the specific type is kept)
73
+ * // T[K] is number -> resolves to string (falls back to the bound)
74
+ * ```
75
+ *
76
+ * @group Types
77
+ */
78
+ type Assume<T, U> = T extends U ? T : U;
79
+ /**
80
+ * Identity type - preserves `T` as-is with no structural transformation.
81
+ *
82
+ * @remarks
83
+ * Use `Cast<T>` as an explicit annotation in generic contexts where inference would
84
+ * widen or lose the type, or where you want to document that a type is intentionally
85
+ * passed through unchanged. It is a zero-cost no-op at both compile time and runtime.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * // Annotate a computed property type without changing it:
90
+ * type Passthrough<T> = Cast<{ [K in keyof T]: T[K] }>;
91
+ *
92
+ * // Use as a readable annotation instead of a bare type parameter:
93
+ * function identity<T>(value: Cast<T>): T { return value; }
94
+ * ```
95
+ *
96
+ * @group Types
97
+ */
98
+ type Cast<T> = T;
99
+ /** A type representing an object with assignable properties. */
100
+ type WithProperties<K extends PropertyKey, V> = {
101
+ [P in K]?: V;
102
+ } & Record<PropertyKey, unknown>;
103
+ /**
104
+ * Extracts the keys of `T` whose value type extends `Function` (i.e. methods).
105
+ *
106
+ * @group Types
107
+ */
108
+ type MethodKeys<T> = {
109
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
110
+ }[keyof T];
111
+ /**
112
+ * Extracts the keys of `T` whose value type does NOT extend `Function` (i.e. data fields).
113
+ *
114
+ * @group Types
115
+ */
116
+ type FieldKeys<T> = {
117
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? never : K;
118
+ }[keyof T];
119
+
120
+ /**
121
+ * Symbol key used to access the {@link QueryPlanNode} on a `TyneqSequence`.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * import { tyneqQueryNode } from "tyneq";
126
+ * const node = seq[tyneqQueryNode]; // QueryPlanNode | null
127
+ * ```
128
+ *
129
+ * @group QueryPlan
130
+ */
131
+ declare const tyneqQueryNode: unique symbol;
132
+ /**
133
+ * Categories of operators.
134
+ *
135
+ * @remarks
136
+ * String literal types used to classify operator behaviour.
137
+ *
138
+ * @group QueryPlan
139
+ */
140
+ type OperatorCategory = "source" | "streaming" | "buffer" | "terminal";
141
+ /**
142
+ * The JavaScript collection type that backs a source node.
143
+ *
144
+ * @group QueryPlan
145
+ */
146
+ type SourceKind = "array" | "set" | "map" | "string" | "other";
147
+ /**
148
+ * A node in the query plan tree representing one operator in a pipeline.
149
+ *
150
+ * @remarks
151
+ * Nodes form a linked list via `source`. The head node has `source === null` and represents the data source.
152
+ *
153
+ * @group QueryPlan
154
+ */
155
+ interface QueryPlanNode {
156
+ /** The operator name as registered with the registry. */
157
+ readonly operatorName: string;
158
+ /** The arguments passed to the operator. Functions render as `<fn>` in printed output. */
159
+ readonly args: readonly unknown[];
160
+ /** The upstream node, or `null` for source nodes. */
161
+ readonly source: Nullable<QueryPlanNode>;
162
+ /**
163
+ * Operator category describing behaviour (`"source" | "streaming" | "buffer" | "terminal").
164
+ */
165
+ readonly category: OperatorCategory;
166
+ /**
167
+ * The backing JavaScript collection type for source nodes.
168
+ *
169
+ * @remarks
170
+ * Only meaningful when `category === "source"`. For all other categories this field is
171
+ * `undefined`. Use {@link isSourceNode} to narrow the type before reading this field.
172
+ */
173
+ readonly sourceKind?: SourceKind;
174
+ /**
175
+ * Accepts a visitor and returns its result.
176
+ *
177
+ * @param visitor - The visitor to invoke.
178
+ */
179
+ accept<T>(visitor: QueryPlanVisitor<T>): T;
180
+ }
181
+ /**
182
+ * Narrows a `QueryPlanNode` to one that is guaranteed to have a `sourceKind`.
183
+ *
184
+ * @remarks
185
+ * `sourceKind` is only present on source nodes (`category === "source"`). Reading it on any
186
+ * other node returns `undefined`. Use this guard before accessing `node.sourceKind` to get
187
+ * proper type narrowing and avoid ambiguous `undefined`.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * if (isSourceNode(node)) {
192
+ * console.log(node.sourceKind); // "array" | "set" | "map" | "string" | "other"
193
+ * }
194
+ * ```
195
+ *
196
+ * @group QueryPlan
197
+ */
198
+ declare function isSourceNode(node: QueryPlanNode): node is QueryPlanNode & {
199
+ sourceKind: SourceKind;
200
+ };
201
+ /**
202
+ * Traversal direction for {@link QueryPlanWalker}.
203
+ *
204
+ * - `"source-to-terminal"` - visits from the source node up to the terminal (bottom-up).
205
+ * `from` is visited before `where`, `where` before `select`. This is the default.
206
+ * - `"terminal-to-source"` - visits from the terminal node down to the source (top-down).
207
+ * `select` is visited before `where`, `where` before `from`.
208
+ *
209
+ * @group QueryPlan
210
+ */
211
+ type QueryPlanTraversalDirection = "source-to-terminal" | "terminal-to-source";
212
+ /**
213
+ * Options for {@link QueryPlanWalker}.
214
+ *
215
+ * @group QueryPlan
216
+ */
217
+ interface QueryPlanWalkerOptions {
218
+ /**
219
+ * Callback invoked by the default `visitNode` implementation for each node.
220
+ * Ignored when `visitNode` is overridden in a subclass without calling `super.visitNode`.
221
+ */
222
+ callback?: (node: QueryPlanNode) => void;
223
+ /**
224
+ * Traversal direction. Defaults to `"source-to-terminal"`.
225
+ */
226
+ direction?: QueryPlanTraversalDirection;
227
+ }
228
+ /**
229
+ * Visitor for traversing a query plan tree.
230
+ *
231
+ * @typeParam T - The value produced by visiting a node.
232
+ * @group QueryPlan
233
+ */
234
+ interface QueryPlanVisitor<T> {
235
+ /** Called for each node during traversal. */
236
+ visit(node: QueryPlanNode): T;
237
+ }
238
+ /**
239
+ * Options for {@link QueryPlanPrinter}.
240
+ *
241
+ * @group QueryPlan
242
+ */
243
+ interface QueryPlanPrinterOptions {
244
+ /** Indentation string per nesting level. Defaults to `" "` (two spaces). */
245
+ indent?: string;
246
+ /** Arrow string between levels. Defaults to `"->"`. */
247
+ arrow?: string;
248
+ /** Maximum number of array items to render inline. Defaults to `3`. */
249
+ maxInlineArrayItems?: number;
250
+ }
251
+
252
+ /**
253
+ * Concrete `QueryPlanNode` implementation.
254
+ * One node is created per operator call and linked to its upstream source node,
255
+ * forming a singly-linked list that represents the full query plan.
256
+ *
257
+ * @group QueryPlan
258
+ * @internal
259
+ */
260
+ declare class QueryNode implements QueryPlanNode {
261
+ readonly operatorName: string;
262
+ readonly args: readonly unknown[];
263
+ readonly source: Nullable<QueryPlanNode>;
264
+ readonly category: OperatorCategory;
265
+ readonly sourceKind?: SourceKind | undefined;
266
+ constructor(operatorName: string, args: readonly unknown[], source: Nullable<QueryPlanNode>, category: OperatorCategory, sourceKind?: SourceKind | undefined);
267
+ accept<T>(visitor: QueryPlanVisitor<T>): T;
268
+ }
269
+
270
+ /**
271
+ * Abstract base that adds `orderBy`, `orderByDescending`, `memoize`, and `pipe` to a sequence.
272
+ *
273
+ * @remarks
274
+ * All four methods build `QueryNode`s and delegate to abstract factory methods, allowing
275
+ * subclasses to control which concrete sequence types are produced.
276
+ *
277
+ * @internal
278
+ */
279
+ declare abstract class TyneqEnumerableCore<TSource> {
280
+ abstract readonly [tyneqQueryNode]: Nullable<QueryPlanNode>;
281
+ [Symbol.iterator](): Enumerator<TSource>;
282
+ abstract getEnumerator(): Enumerator<TSource>;
283
+ orderBy<TKey>(keySelector: (item: TSource) => TKey, comparer?: Comparer<TKey>): TyneqOrderedSequence<TSource>;
284
+ orderByDescending<TKey>(keySelector: (item: TSource) => TKey, comparer?: Comparer<TKey>): TyneqOrderedSequence<TSource>;
285
+ memoize(): TyneqCachedSequence<TSource>;
286
+ pipe<TResult>(factory: (source: Iterable<TSource>) => Enumerator<TResult> | IterableIterator<TResult>): TyneqSequence<TResult>;
287
+ /**
288
+ * Helper that creates a new sequence with the provided enumerator factory and query node.
289
+ * @param factory The factory function that produces an enumerator for the new sequence.
290
+ * @param node The query plan node associated with the new sequence.
291
+ * @returns A new TyneqSequence instance.
292
+ */
293
+ protected createSequence<TResult>(factory: () => Enumerator<TResult>, node: QueryPlanNode): TyneqSequence<TResult>;
294
+ /**
295
+ * Helper for creating a query node with the current sequence's node as its parent.
296
+ * @param name The name of the query node.
297
+ * @param category The category of the operator.
298
+ * @param args The arguments for the query node.
299
+ * @returns A new QueryNode instance.
300
+ */
301
+ protected createNode(name: string, category: OperatorCategory, args?: unknown[]): QueryNode;
302
+ protected abstract createEnumerable<TResult>(factory: EnumeratorFactory<TResult>, node: Nullable<QueryPlanNode>): TyneqSequence<TResult>;
303
+ protected abstract createOrderedEnumerable<TKey>(keySelector: (x: TSource) => TKey, comparer: Comparer<TKey>, descending: boolean, node: Nullable<QueryPlanNode>): TyneqOrderedSequence<TSource>;
304
+ protected abstract createCachedEnumerable(source: TyneqSequence<TSource>, node: Nullable<QueryPlanNode>): TyneqCachedSequence<TSource>;
305
+ }
306
+
307
+ /**
308
+ * Abstract base class that implements all {@link TyneqSequence} operator methods.
309
+ *
310
+ * @remarks
311
+ * All operator methods delegate to the corresponding operator class registered via
312
+ * `@operator`, `@terminal`, or the functional registration APIs.
313
+ * Subclasses implement `createEnumerable`, `createOrderedEnumerable`, and `createCachedEnumerable`
314
+ * to control which concrete sequence types are returned.
315
+ *
316
+ * @internal
317
+ */
318
+ declare abstract class TyneqEnumerableBase<TSource> extends TyneqEnumerableCore<TSource> implements TyneqSequence<TSource> {
319
+ aggregate<UAccumulate, VResult>(seed: UAccumulate, func: (accumulate: UAccumulate, item: TSource) => UAccumulate, resultSelector: (accumulate: UAccumulate) => VResult): VResult;
320
+ all(predicate: ItemPredicate<TSource>): boolean;
321
+ any(predicate: ItemPredicate<TSource>): boolean;
322
+ average(selector: (item: TSource) => number): number;
323
+ consume(): void;
324
+ contains(value: TSource, equalityComparer?: EqualityComparer<TSource>): boolean;
325
+ count(): number;
326
+ countBy(predicate: ItemPredicate<TSource>): number;
327
+ elementAt(index: number): TSource;
328
+ elementAtOrDefault(index: number, defaultValue: TSource): TSource;
329
+ first(predicate: ItemPredicate<TSource>): TSource;
330
+ firstOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource;
331
+ indexOf(predicate: ItemPredicate<TSource>, startIndex?: number): number;
332
+ isNullOrEmpty(): boolean;
333
+ last(predicate: ItemPredicate<TSource>): TSource;
334
+ lastOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource;
335
+ max(comparer?: Comparer<TSource>): TSource;
336
+ maxBy<TKey>(keySelector: (element: TSource) => TKey, comparer?: Comparer<TKey>): TSource;
337
+ min(comparer?: Comparer<TSource>): TSource;
338
+ minBy<TKey>(keySelector: (element: TSource) => TKey, comparer?: Comparer<TKey>): TSource;
339
+ minMax(comparer?: Comparer<TSource>): MinMaxResult<TSource>;
340
+ sequenceEqual(other: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean;
341
+ single(predicate: ItemPredicate<TSource>): TSource;
342
+ singleOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource;
343
+ endsWith(sequence: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean;
344
+ startsWith(sequence: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean;
345
+ sum(selector: (item: TSource) => number): number;
346
+ toArray(): TSource[];
347
+ toAsync(): AsyncIterable<TSource>;
348
+ toMap<TKey, TValue>(selector: (item: TSource) => KeyValuePair<TKey, TValue>): Map<TKey, TValue>;
349
+ toRecord<TKey extends string | number | symbol, TValue>(selector: (item: TSource) => KeyValuePair<TKey, TValue>): Record<TKey, TValue>;
350
+ toSet(): Set<TSource>;
351
+ ofType<U extends TSource>(guard: (value: TSource) => value is U): TyneqSequence<U>;
352
+ append(item: TSource): TyneqSequence<TSource>;
353
+ chunk(size: number): TyneqSequence<TSource[]>;
354
+ concat(other: Iterable<TSource>): TyneqSequence<TSource>;
355
+ defaultIfEmpty(defaultValue: TSource): TyneqSequence<TSource>;
356
+ flatten<TInner>(): TyneqSequence<TInner>;
357
+ pairwise(): TyneqSequence<[TSource, TSource]>;
358
+ populate<TValue>(value: TValue): TyneqSequence<TValue>;
359
+ prepend(item: TSource): TyneqSequence<TSource>;
360
+ scan<TResult>(seed: TResult, accumulator: (acc: TResult, item: TSource) => TResult): TyneqSequence<TResult>;
361
+ select<TResult>(selector: ItemSelector<TSource, TResult>): TyneqSequence<TResult>;
362
+ selectMany<TResult>(selector: (item: TSource) => Iterable<TResult>): TyneqSequence<TResult>;
363
+ window(size: number, step?: number): TyneqSequence<TSource[]>;
364
+ repeat(count: number): TyneqSequence<TSource>;
365
+ skip(count: number): TyneqSequence<TSource>;
366
+ skipLast(count: number): TyneqSequence<TSource>;
367
+ skipUntil(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
368
+ skipWhile(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
369
+ slice(start: number, end?: number): TyneqSequence<TSource>;
370
+ split(splitOn: (item: TSource) => boolean): TyneqSequence<TSource[]>;
371
+ take(count: number): TyneqSequence<TSource>;
372
+ takeUntil(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
373
+ takeWhile(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
374
+ tap(action: ItemAction<TSource>): TyneqSequence<TSource>;
375
+ tapIf(action: ItemAction<TSource>, predicate: () => boolean): TyneqSequence<TSource>;
376
+ throttle(count: number): TyneqSequence<TSource>;
377
+ where(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
378
+ zip<TOther, TResult>(other: Iterable<TOther>, selector: (first: TSource, second: TOther) => TResult): TyneqSequence<TResult>;
379
+ backsert(index: number, other: Iterable<TSource>): TyneqSequence<TSource>;
380
+ distinct(): TyneqSequence<TSource>;
381
+ distinctBy<TKey>(keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
382
+ except(excludedValues: Iterable<TSource>): TyneqSequence<TSource>;
383
+ exceptBy<TKey>(excludedKeys: Iterable<TKey>, keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
384
+ groupBy<TKey, TValue, TResult>(keySelector: (item: TSource) => TKey, valueSelector: (item: TSource) => TValue, resultSelector: (key: TKey, values: TyneqSequence<TValue>) => TResult): TyneqSequence<TResult>;
385
+ groupJoin<TInner, TKey, TResult>(inner: Iterable<TInner>, outerKeySelector: (outer: TSource) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: TSource, group: TyneqSequence<TInner>) => TResult): TyneqSequence<TResult>;
386
+ intersect(intersectedValues: Iterable<TSource>): TyneqSequence<TSource>;
387
+ intersectBy<TKey>(intersectedKeys: Iterable<TKey>, keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
388
+ join<TInner, TKey, TResult>(inner: Iterable<TInner>, outerKeySelector: (outer: TSource) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: TSource, inner: TInner) => TResult): TyneqSequence<TResult>;
389
+ permutations(): TyneqSequence<TSource[]>;
390
+ reverse(): TyneqSequence<TSource>;
391
+ shuffle(): TyneqSequence<TSource>;
392
+ union(otherValues: Iterable<TSource>): TyneqSequence<TSource>;
393
+ unionBy<TKey>(otherValues: Iterable<TSource>, keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
394
+ }
395
+
396
+ /**
397
+ * Metadata describing a registered operator.
398
+ *
399
+ * @group Classes
400
+ */
401
+ declare class OperatorMetadata {
402
+ readonly name: string;
403
+ readonly kind: OperatorKind;
404
+ readonly source: OperatorSource;
405
+ readonly targetClass: Maybe<SequenceConstructor>;
406
+ readonly extensions: Readonly<Record<string, unknown>>;
407
+ constructor(name: string, kind: OperatorKind, source?: OperatorSource, targetClass?: Maybe<SequenceConstructor>, extensions?: Readonly<Record<string, unknown>>);
408
+ /**
409
+ * Creates metadata for a source operator.
410
+ *
411
+ * @remarks
412
+ * `targetClass` is always `undefined` for source operators - they are static
413
+ * factories with no prototype and are never patched onto a class instance.
414
+ */
415
+ static source(name: string, src?: OperatorSource): OperatorMetadata;
416
+ /** Creates metadata for a streaming operator. Defaults targetClass to TyneqEnumerableBase. */
417
+ static streaming(name: string, targetClass?: SequenceConstructor, source?: OperatorSource, extensions?: Record<string, unknown>): OperatorMetadata;
418
+ /** Creates metadata for a buffering operator. Defaults targetClass to TyneqEnumerableBase. */
419
+ static buffer(name: string, targetClass?: SequenceConstructor, source?: OperatorSource, extensions?: Record<string, unknown>): OperatorMetadata;
420
+ /** Creates metadata for a terminal operator. Defaults targetClass to TyneqEnumerableBase. */
421
+ static terminal(name: string, targetClass?: SequenceConstructor, source?: OperatorSource, extensions?: Record<string, unknown>): OperatorMetadata;
422
+ /**
423
+ * Creates metadata for a streaming or buffer operator determined at runtime.
424
+ *
425
+ * @remarks
426
+ * Use when the category is a variable rather than a compile-time literal --
427
+ * for example in `@operator` and `@orderedOperator` whose `category` parameter
428
+ * is provided by the caller. For compile-time-known categories prefer the
429
+ * dedicated {@link streaming} / {@link buffer} / {@link terminal} statics.
430
+ *
431
+ * Only `"streaming"` and `"buffer"` are valid; passing `"terminal"` or `"source"` throws.
432
+ */
433
+ static forCategory(category: "streaming" | "buffer", name: string, targetClass?: SequenceConstructor, source?: OperatorSource, extensions?: Record<string, unknown>): OperatorMetadata;
434
+ }
435
+
436
+ /**
437
+ * A pull-based iterator over a sequence.
438
+ *
439
+ * @remarks
440
+ * Extends the native `Iterator<T>` protocol. `return()` disposes the iterator early;
441
+ * `throw()` is not supported and throws {@link NotSupportedError} if called.
442
+ *
443
+ * @typeParam T - Element type.
444
+ * @group Interfaces
445
+ */
446
+ interface Enumerator<T> extends Iterator<T> {
447
+ next(): IteratorResult<T>;
448
+ /**
449
+ * Terminates the iterator early and releases resources.
450
+ *
451
+ * @remarks
452
+ * Idempotent - safe to call multiple times. Calling `next()` after `return()` returns `{ done: true }`.
453
+ */
454
+ return?(value?: unknown): IteratorResult<T>;
455
+ }
456
+ /**
457
+ * A factory that produces a fresh {@link Enumerator} on demand.
458
+ *
459
+ * @typeParam T - Element type.
460
+ * @group Interfaces
461
+ */
462
+ interface EnumeratorFactory<T> {
463
+ /** Returns a new, independent enumerator starting at the beginning of the sequence. */
464
+ getEnumerator(): Enumerator<T>;
465
+ }
466
+ /**
467
+ * A function that compares two values for ordering.
468
+ *
469
+ * @remarks
470
+ * Must return a negative number when `a < b`, a positive number when `a > b`, and `0` when equal.
471
+ * Matches the signature expected by `Array.prototype.sort`.
472
+ *
473
+ * @typeParam T - The type of values being compared.
474
+ * @group Types
475
+ */
476
+ type Comparer<T> = (a: T, b: T) => number;
477
+ /**
478
+ * A function that tests two values for equality.
479
+ *
480
+ * @typeParam T - The type of values being compared.
481
+ * @group Types
482
+ */
483
+ type EqualityComparer<T> = (a: T, b: T) => boolean;
484
+ /**
485
+ * A lazy, re-iterable sequence.
486
+ *
487
+ * @remarks
488
+ * Each call to `[Symbol.iterator]()` or `getEnumerator()` produces a fresh enumerator with
489
+ * independent state, allowing the same sequence to be iterated multiple times.
490
+ *
491
+ * @typeParam T - Element type.
492
+ * @group Interfaces
493
+ */
494
+ interface Enumerable<T> extends Iterable<T>, EnumeratorFactory<T> {
495
+ [Symbol.iterator](): Enumerator<T>;
496
+ }
497
+ /**
498
+ * Function that produces a fresh {@link Enumerator} each time it is called.
499
+ *
500
+ * @group Types
501
+ */
502
+ type IteratorFactory<T> = () => Enumerator<T>;
503
+ /**
504
+ * Function that wraps an iterator factory in a concrete `TyneqSequence` subclass.
505
+ *
506
+ * @group Types
507
+ * @internal
508
+ */
509
+ type TyneqEnumerableFactory<TSource, TEnumerable extends TyneqSequence<TSource>> = (iteratorFactory: IteratorFactory<TSource>) => TEnumerable;
510
+ /**
511
+ * The primary public API for a lazy sequence - the type returned by all Tyneq operators.
512
+ *
513
+ * @remarks
514
+ * Every operator method returns a new `TyneqSequence` without consuming the source.
515
+ * The source is not iterated until the returned sequence is iterated.
516
+ *
517
+ * @typeParam TSource - Element type.
518
+ * @group Interfaces
519
+ */
520
+ interface TyneqSequence<TSource> extends Enumerable<TSource> {
521
+ /**
522
+ * The query plan node for this sequence, or `null` if no plan is available.
523
+ *
524
+ * @remarks
525
+ * Use {@link QueryPlanPrinter} to render this as a string.
526
+ * Sequences created via `pipe()` always have `null` here.
527
+ */
528
+ readonly [tyneqQueryNode]: Nullable<QueryPlanNode>;
529
+ /**
530
+ * Returns `true` if any element satisfies the predicate.
531
+ *
532
+ * @remarks
533
+ * Returns `false` for an empty sequence.
534
+ * The predicate receives each element and its zero-based index.
535
+ *
536
+ * @throws {ArgumentNullError} When `predicate` is null.
537
+ * @throws {ArgumentError} When `predicate` is undefined.
538
+ */
539
+ any(predicate: ItemPredicate<TSource>): boolean;
540
+ /**
541
+ * Returns `true` if all elements satisfy the predicate.
542
+ *
543
+ * @remarks
544
+ * Returns `true` for an empty sequence (vacuous truth).
545
+ * The predicate receives each element and its zero-based index.
546
+ *
547
+ * @throws {ArgumentNullError} When `predicate` is null.
548
+ * @throws {ArgumentError} When `predicate` is undefined.
549
+ */
550
+ all(predicate: ItemPredicate<TSource>): boolean;
551
+ /**
552
+ * Returns `true` if the source sequence contains `value`.
553
+ *
554
+ * @remarks
555
+ * Uses `equalityComparer` for element comparison, or `===` when omitted.
556
+ * Returns `false` for an empty sequence.
557
+ * Enumerates the source until a match is found or the sequence is exhausted.
558
+ *
559
+ * @throws {ArgumentNullError} When `equalityComparer` is null (undefined is allowed).
560
+ */
561
+ contains(value: TSource, equalityComparer?: EqualityComparer<TSource>): boolean;
562
+ /**
563
+ * Returns the number of elements.
564
+ *
565
+ * @remarks
566
+ * Returns `0` for an empty sequence.
567
+ */
568
+ count(): number;
569
+ /**
570
+ * Returns the number of elements that satisfy the predicate.
571
+ *
572
+ * @remarks
573
+ * Returns `0` if no elements match or the sequence is empty.
574
+ * The predicate receives each element and its zero-based index.
575
+ *
576
+ * @throws {ArgumentNullError} When `predicate` is null.
577
+ * @throws {ArgumentError} When `predicate` is undefined.
578
+ */
579
+ countBy(predicate: ItemPredicate<TSource>): number;
580
+ /**
581
+ * Iterates the entire sequence and discards all elements.
582
+ *
583
+ * @remarks
584
+ * Useful for triggering side effects (e.g., after `tap`).
585
+ */
586
+ consume(): void;
587
+ /**
588
+ * Returns `true` if the sequence is empty or if the first element is `null` or `undefined`.
589
+ */
590
+ isNullOrEmpty(): boolean;
591
+ /**
592
+ * Returns the element at `index`.
593
+ *
594
+ * @throws {ArgumentError} When `index` is not a safe integer.
595
+ * @throws {ArgumentOutOfRangeError} When `index` is negative or greater than or equal to the sequence length.
596
+ */
597
+ elementAt(index: number): TSource;
598
+ /**
599
+ * Returns the element at `index`, or `defaultValue` if the index is out of range.
600
+ *
601
+ * @throws {ArgumentError} When `index` is not a safe integer.
602
+ * @throws {ArgumentOutOfRangeError} When `index` is negative.
603
+ */
604
+ elementAtOrDefault(index: number, defaultValue: TSource): TSource;
605
+ /**
606
+ * Returns the first element that satisfies the predicate.
607
+ *
608
+ * @remarks
609
+ * The predicate receives each element and its zero-based index.
610
+ *
611
+ * @throws {ArgumentNullError} When `predicate` is null.
612
+ * @throws {ArgumentError} When `predicate` is undefined.
613
+ * @throws {InvalidOperationError} When no element satisfies the predicate.
614
+ */
615
+ first(predicate: ItemPredicate<TSource>): TSource;
616
+ /**
617
+ * Returns the first element that satisfies the predicate, or `defaultValue` if none does.
618
+ *
619
+ * @remarks
620
+ * The predicate receives each element and its zero-based index.
621
+ *
622
+ * @throws {ArgumentNullError} When `predicate` is null.
623
+ * @throws {ArgumentError} When `predicate` is undefined.
624
+ */
625
+ firstOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource;
626
+ /**
627
+ * Returns the zero-based index of the first element that satisfies the predicate.
628
+ *
629
+ * @remarks
630
+ * Returns `-1` if no element satisfies the predicate.
631
+ * When `startIndex` is provided, the search starts at that index.
632
+ * The predicate receives each element and its zero-based index within the full sequence.
633
+ *
634
+ * @throws {ArgumentNullError} When `predicate` is null.
635
+ * @throws {ArgumentError} When `predicate` is undefined.
636
+ * @throws {ArgumentOutOfRangeError} When `startIndex` is negative.
637
+ */
638
+ indexOf(predicate: ItemPredicate<TSource>, startIndex?: number): number;
639
+ /**
640
+ * Returns the last element that satisfies the predicate.
641
+ *
642
+ * @remarks
643
+ * The predicate receives each element and its zero-based index.
644
+ *
645
+ * @throws {ArgumentNullError} When `predicate` is null.
646
+ * @throws {ArgumentError} When `predicate` is undefined.
647
+ * @throws {InvalidOperationError} When no element satisfies the predicate.
648
+ */
649
+ last(predicate: ItemPredicate<TSource>): TSource;
650
+ /**
651
+ * Returns the last element that satisfies the predicate, or `defaultValue` if none does.
652
+ *
653
+ * @remarks
654
+ * The predicate receives each element and its zero-based index.
655
+ *
656
+ * @throws {ArgumentNullError} When `predicate` is null.
657
+ * @throws {ArgumentError} When `predicate` is undefined.
658
+ */
659
+ lastOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource;
660
+ /**
661
+ * Returns the maximum element according to the comparer.
662
+ *
663
+ * @remarks
664
+ * Uses the natural `>` operator when no comparer is provided.
665
+ *
666
+ * @throws {SequenceContainsNoElementsError} When the sequence is empty.
667
+ */
668
+ max(comparer?: Comparer<TSource>): TSource;
669
+ /**
670
+ * Returns the element with the maximum key.
671
+ *
672
+ * @throws {SequenceContainsNoElementsError} When the sequence is empty.
673
+ * @throws {ArgumentNullError} When `keySelector` is null.
674
+ * @throws {ArgumentError} When `keySelector` is undefined.
675
+ */
676
+ maxBy<TKey>(keySelector: (element: TSource) => TKey, comparer?: Comparer<TKey>): TSource;
677
+ /**
678
+ * Returns the minimum element according to the comparer.
679
+ *
680
+ * @remarks
681
+ * Uses the natural `<` operator when no comparer is provided.
682
+ *
683
+ * @throws {SequenceContainsNoElementsError} When the sequence is empty.
684
+ */
685
+ min(comparer?: Comparer<TSource>): TSource;
686
+ /**
687
+ * Returns the element with the minimum key.
688
+ *
689
+ * @throws {SequenceContainsNoElementsError} When the sequence is empty.
690
+ * @throws {ArgumentNullError} When `keySelector` is null.
691
+ * @throws {ArgumentError} When `keySelector` is undefined.
692
+ */
693
+ minBy<TKey>(keySelector: (element: TSource) => TKey, comparer?: Comparer<TKey>): TSource;
694
+ /**
695
+ * Returns `true` if this sequence and `other` have the same elements in the same order.
696
+ *
697
+ * @remarks
698
+ * Uses `equalityComparer` for element comparison, or `===` when omitted.
699
+ * Returns `true` if both sequences are empty.
700
+ */
701
+ sequenceEqual(other: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean;
702
+ /**
703
+ * Returns the only element that satisfies the predicate.
704
+ *
705
+ * @remarks
706
+ * The predicate receives each element and its zero-based index.
707
+ *
708
+ * @throws {ArgumentNullError} When `predicate` is null.
709
+ * @throws {ArgumentError} When `predicate` is undefined.
710
+ * @throws {InvalidOperationError} When no element satisfies the predicate, or when more than one does.
711
+ */
712
+ single(predicate: ItemPredicate<TSource>): TSource;
713
+ /**
714
+ * Returns the only element that satisfies the predicate, or `defaultValue` if none does.
715
+ *
716
+ * @remarks
717
+ * The predicate receives each element and its zero-based index.
718
+ *
719
+ * @throws {ArgumentNullError} When `predicate` is null.
720
+ * @throws {ArgumentError} When `predicate` is undefined.
721
+ * @throws {InvalidOperationError} When more than one element satisfies the predicate.
722
+ */
723
+ singleOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource;
724
+ /**
725
+ * Returns `true` if this sequence ends with all elements of `sequence` in order.
726
+ *
727
+ * @remarks
728
+ * Uses `equalityComparer` for element comparison, or `===` when omitted.
729
+ * Returns `true` when `sequence` is empty (vacuous truth).
730
+ * Returns `false` when `sequence` is longer than the source.
731
+ *
732
+ * @example
733
+ * ```ts
734
+ * Tyneq.from([1, 2, 3, 4, 5]).endsWith([4, 5]); // true
735
+ * Tyneq.from([1, 2, 3, 4, 5]).endsWith([3, 5]); // false
736
+ * Tyneq.from([1, 2, 3]).endsWith([]); // true
737
+ * Tyneq.from([1, 2]).endsWith([1, 2, 3]); // false
738
+ *
739
+ * // Custom equality
740
+ * Tyneq.from(["A", "B", "C"]).endsWith(
741
+ * ["b", "c"],
742
+ * (a, b) => a.toLowerCase() === b.toLowerCase()
743
+ * ); // true
744
+ * ```
745
+ *
746
+ * @throws {ArgumentNullError} When `sequence` is null.
747
+ * @throws {ArgumentError} When `sequence` is undefined.
748
+ * @throws {ArgumentTypeError} When `sequence` is not iterable.
749
+ * @throws {ArgumentNullError} When `equalityComparer` is null (undefined is allowed).
750
+ */
751
+ endsWith(sequence: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean;
752
+ /**
753
+ * Returns `true` if this sequence starts with all elements of `sequence` in order.
754
+ *
755
+ * @remarks
756
+ * Uses `equalityComparer` for element comparison, or `===` when omitted.
757
+ * Returns `true` when `sequence` is empty (vacuous truth).
758
+ * Returns `false` when `sequence` is longer than the source.
759
+ *
760
+ * @throws {ArgumentNullError} When `sequence` is null.
761
+ * @throws {ArgumentError} When `sequence` is undefined.
762
+ * @throws {ArgumentTypeError} When `sequence` is not iterable.
763
+ * @throws {ArgumentNullError} When `equalityComparer` is null (undefined is allowed).
764
+ */
765
+ startsWith(sequence: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean;
766
+ /**
767
+ * Returns the sum of `selector` applied to each element.
768
+ *
769
+ * @remarks
770
+ * Returns `0` for an empty sequence.
771
+ *
772
+ * @throws {ArgumentNullError} When `selector` is null.
773
+ * @throws {ArgumentError} When `selector` is undefined.
774
+ */
775
+ sum(selector: (item: TSource) => number): number;
776
+ /**
777
+ * Materializes the sequence into an array.
778
+ *
779
+ * @remarks
780
+ * Returns `[]` for an empty sequence.
781
+ */
782
+ toArray(): TSource[];
783
+ /**
784
+ * Returns an `AsyncIterable` that iterates this sequence asynchronously.
785
+ *
786
+ * @remarks
787
+ * Deferred - each `for await...of` loop produces a fresh traversal of the source.
788
+ */
789
+ toAsync(): AsyncIterable<TSource>;
790
+ /**
791
+ * Materializes the sequence into a `Map`.
792
+ *
793
+ * @throws {ArgumentNullError} When `selector` is null.
794
+ * @throws {ArgumentError} When `selector` is undefined.
795
+ */
796
+ toMap<TKey, TValue>(selector: (item: TSource) => KeyValuePair<TKey, TValue>): Map<TKey, TValue>;
797
+ /**
798
+ * Materializes the sequence into a plain object record.
799
+ *
800
+ * @throws {ArgumentNullError} When `selector` is null.
801
+ * @throws {ArgumentError} When `selector` is undefined.
802
+ */
803
+ toRecord<TKey extends string | number | symbol, TValue>(selector: (item: TSource) => KeyValuePair<TKey, TValue>): Record<TKey, TValue>;
804
+ /**
805
+ * Materializes the sequence into a `Set`.
806
+ *
807
+ * @remarks
808
+ * Duplicate elements are deduplicated using `Set` identity semantics.
809
+ */
810
+ toSet(): Set<TSource>;
811
+ /**
812
+ * Returns the arithmetic mean of `selector` applied to each element.
813
+ *
814
+ * @throws {SequenceContainsNoElementsError} When the sequence is empty.
815
+ * @throws {ArgumentNullError} When `selector` is null.
816
+ * @throws {ArgumentError} When `selector` is undefined.
817
+ */
818
+ average(selector: (item: TSource) => number): number;
819
+ /**
820
+ * Folds the sequence into a single result value.
821
+ *
822
+ * @remarks
823
+ * Applies `func` to each element in order, starting from `seed`. Returns `resultSelector(seed)` for an empty sequence.
824
+ *
825
+ * @throws {ArgumentNullError} When `func` or `resultSelector` is null.
826
+ * @throws {ArgumentError} When `func` or `resultSelector` is undefined.
827
+ */
828
+ aggregate<UAccumulate, VResult>(seed: UAccumulate, func: (accumulate: UAccumulate, item: TSource) => UAccumulate, resultSelector: (accumulate: UAccumulate) => VResult): VResult;
829
+ /** Returns a new sequence with `item` appended after all source elements. */
830
+ append(item: TSource): TyneqSequence<TSource>;
831
+ /**
832
+ * Partitions the sequence into non-overlapping arrays of length `size`.
833
+ *
834
+ * @remarks
835
+ * The last chunk may be shorter than `size` if the sequence length is not divisible by `size`.
836
+ *
837
+ * @throws {ArgumentError} When `size` is not a safe integer.
838
+ * @throws {ArgumentOutOfRangeError} When `size` is less than or equal to `0`.
839
+ */
840
+ chunk(size: number): TyneqSequence<TSource[]>;
841
+ /** Returns a new sequence with the elements of `other` appended after the source. */
842
+ concat(other: Iterable<TSource>): TyneqSequence<TSource>;
843
+ /**
844
+ * Returns a sequence that yields `defaultValue` when the source is empty.
845
+ *
846
+ * @remarks
847
+ * Passes source elements through unchanged when the source is non-empty.
848
+ */
849
+ defaultIfEmpty(defaultValue: TSource): TyneqSequence<TSource>;
850
+ /**
851
+ * Flattens one level of nesting from a sequence of iterables.
852
+ *
853
+ * @remarks
854
+ * Deferred. Each inner iterable is consumed lazily as the outer sequence advances.
855
+ * Returns an empty sequence when the source is empty.
856
+ * Equivalent to `selectMany(x => x)` but without requiring a selector.
857
+ *
858
+ * @example
859
+ * ```ts
860
+ * Tyneq.from([[1, 2], [3, 4], [5]]).flatten().toArray();
861
+ * // [1, 2, 3, 4, 5]
862
+ *
863
+ * Tyneq.from(["hello", "world"]).flatten().toArray();
864
+ * // ["h", "e", "l", "l", "o", "w", "o", "r", "l", "d"]
865
+ * ```
866
+ */
867
+ flatten<TInner>(this: TyneqSequence<Iterable<TInner>>): TyneqSequence<TInner>;
868
+ /**
869
+ * Returns consecutive overlapping pairs of elements: `[e0,e1]`, `[e1,e2]`, ...
870
+ *
871
+ * @remarks
872
+ * Returns an empty sequence when the source has fewer than two elements.
873
+ */
874
+ pairwise(): TyneqSequence<[TSource, TSource]>;
875
+ /**
876
+ * Filters elements to those for which `guard` returns `true`, narrowing the type to `U`.
877
+ *
878
+ * @throws {ArgumentNullError} When `guard` is null.
879
+ * @throws {ArgumentError} When `guard` is undefined.
880
+ */
881
+ ofType<U extends TSource>(guard: (value: TSource) => value is U): TyneqSequence<U>;
882
+ /** Returns a new sequence with `item` prepended before all source elements. */
883
+ prepend(item: TSource): TyneqSequence<TSource>;
884
+ /**
885
+ * Repeats the source sequence `count` times.
886
+ *
887
+ * @remarks
888
+ * Deferred. Re-enumerates the source from the beginning for each repetition.
889
+ * Returns an empty sequence when `count` is `0`.
890
+ *
891
+ * @example
892
+ * ```ts
893
+ * Tyneq.from([1, 2]).repeat(3).toArray();
894
+ * // [1, 2, 1, 2, 1, 2]
895
+ *
896
+ * Tyneq.from([1, 2]).repeat(0).toArray();
897
+ * // []
898
+ * ```
899
+ *
900
+ * @throws {ArgumentOutOfRangeError} When `count` is negative.
901
+ * @throws {ArgumentError} When `count` is not an integer.
902
+ */
903
+ repeat(count: number): TyneqSequence<TSource>;
904
+ /**
905
+ * Replaces each element with `value`, keeping the same sequence length.
906
+ *
907
+ * @remarks
908
+ * Useful for generating a sequence of a fixed value with a known length derived from the source.
909
+ */
910
+ populate<TValue>(value: TValue): TyneqSequence<TValue>;
911
+ /**
912
+ * Projects each element through `selector`.
913
+ *
914
+ * @remarks
915
+ * The selector receives each element and its zero-based index.
916
+ *
917
+ * @throws {ArgumentNullError} When `selector` is null.
918
+ * @throws {ArgumentError} When `selector` is undefined.
919
+ */
920
+ select<TResult>(selector: ItemSelector<TSource, TResult>): TyneqSequence<TResult>;
921
+ /**
922
+ * Projects each element to an iterable and flattens the results into a single sequence.
923
+ *
924
+ * @throws {ArgumentNullError} When `selector` is null.
925
+ * @throws {ArgumentError} When `selector` is undefined.
926
+ */
927
+ selectMany<TResult>(selector: (item: TSource) => Iterable<TResult>): TyneqSequence<TResult>;
928
+ /**
929
+ * Yields fixed-size windows (sub-arrays) over the source sequence.
930
+ *
931
+ * @remarks
932
+ * Deferred. O(`size`) memory - only the current window is held in memory.
933
+ * When `step` is 1 (the default), windows slide one element at a time (overlapping).
934
+ * When `step` equals `size`, windows are non-overlapping (tumbling).
935
+ * When `step` exceeds `size`, elements between windows are skipped (gaps).
936
+ * Yields no windows when the source has fewer than `size` elements.
937
+ * Each yielded array is a snapshot - mutating it does not affect subsequent windows.
938
+ *
939
+ * @example
940
+ * ```ts
941
+ * // Sliding (default step = 1)
942
+ * Tyneq.range(1, 5).window(3).toArray();
943
+ * // [[1,2,3], [2,3,4], [3,4,5]]
944
+ *
945
+ * // Tumbling (step = size)
946
+ * Tyneq.range(1, 6).window(2, 2).toArray();
947
+ * // [[1,2], [3,4], [5,6]]
948
+ * ```
949
+ *
950
+ * @throws {ArgumentError} When `size` or `step` is not a safe integer.
951
+ * @throws {ArgumentOutOfRangeError} When `size` is less than `1`.
952
+ * @throws {ArgumentOutOfRangeError} When `step` is less than `1`.
953
+ */
954
+ window(size: number, step?: number): TyneqSequence<TSource[]>;
955
+ /**
956
+ * Skips the first `count` elements.
957
+ *
958
+ * @remarks
959
+ * Returns an empty sequence when `count` exceeds the sequence length.
960
+ * `count` must be non-negative.
961
+ *
962
+ * @throws {ArgumentError} When `count` is not a safe integer.
963
+ * @throws {ArgumentOutOfRangeError} When `count` is negative.
964
+ */
965
+ skip(count: number): TyneqSequence<TSource>;
966
+ /**
967
+ * Skips the last `count` elements.
968
+ *
969
+ * @remarks
970
+ * Buffers `count` elements to determine the cutoff.
971
+ *
972
+ * @throws {ArgumentError} When `count` is not a safe integer.
973
+ * @throws {ArgumentOutOfRangeError} When `count` is negative.
974
+ */
975
+ skipLast(count: number): TyneqSequence<TSource>;
976
+ /**
977
+ * Skips elements until `predicate` returns `true`, then yields all remaining elements
978
+ * including the one that triggered the predicate.
979
+ *
980
+ * @remarks
981
+ * The predicate receives each element and its zero-based index.
982
+ * Once the predicate returns `true` it is never called again.
983
+ *
984
+ * @throws {ArgumentNullError} When `predicate` is null.
985
+ * @throws {ArgumentError} When `predicate` is undefined.
986
+ */
987
+ skipUntil(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
988
+ /**
989
+ * Skips elements while `predicate` returns `true`, then yields the rest.
990
+ *
991
+ * @remarks
992
+ * The predicate receives each element and its zero-based index.
993
+ *
994
+ * @throws {ArgumentNullError} When `predicate` is null.
995
+ * @throws {ArgumentError} When `predicate` is undefined.
996
+ */
997
+ skipWhile(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
998
+ /**
999
+ * Yields elements between `start` (inclusive) and `end` (exclusive) by index.
1000
+ *
1001
+ * @remarks
1002
+ * Deferred. Enumerates only as far as `end`.
1003
+ * When `end` is omitted, yields all elements from `start` to the end of the sequence.
1004
+ * Returns an empty sequence when `start` is beyond the sequence length.
1005
+ *
1006
+ * @example
1007
+ * ```ts
1008
+ * Tyneq.from([0, 1, 2, 3, 4]).slice(1, 4).toArray();
1009
+ * // [1, 2, 3]
1010
+ *
1011
+ * Tyneq.from([0, 1, 2, 3, 4]).slice(2).toArray();
1012
+ * // [2, 3, 4]
1013
+ * ```
1014
+ *
1015
+ * @throws {ArgumentOutOfRangeError} When `start` is negative.
1016
+ * @throws {ArgumentOutOfRangeError} When `end` is negative or less than `start`.
1017
+ */
1018
+ slice(start: number, end?: number): TyneqSequence<TSource>;
1019
+ /**
1020
+ * Splits the sequence at elements where `splitOn` returns `true`.
1021
+ *
1022
+ * @remarks
1023
+ * The delimiter elements are consumed and not included in any sub-array.
1024
+ *
1025
+ * @throws {ArgumentNullError} When `splitOn` is null.
1026
+ * @throws {ArgumentError} When `splitOn` is undefined.
1027
+ */
1028
+ split(splitOn: (item: TSource) => boolean): TyneqSequence<TSource[]>;
1029
+ /**
1030
+ * Takes at most the first `count` elements.
1031
+ *
1032
+ * @throws {ArgumentError} When `count` is not a safe integer.
1033
+ * @throws {ArgumentOutOfRangeError} When `count` is negative.
1034
+ */
1035
+ take(count: number): TyneqSequence<TSource>;
1036
+ /**
1037
+ * Yields elements until `predicate` returns `true`, then stops.
1038
+ * The element that triggered the predicate is not included.
1039
+ *
1040
+ * @remarks
1041
+ * The predicate receives each element and its zero-based index.
1042
+ * Once the predicate returns `true` the sequence ends immediately.
1043
+ *
1044
+ * @throws {ArgumentNullError} When `predicate` is null.
1045
+ * @throws {ArgumentError} When `predicate` is undefined.
1046
+ */
1047
+ takeUntil(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
1048
+ /**
1049
+ * Takes elements while `predicate` returns `true`, then stops.
1050
+ *
1051
+ * @remarks
1052
+ * The predicate receives each element and its zero-based index.
1053
+ *
1054
+ * @throws {ArgumentNullError} When `predicate` is null.
1055
+ * @throws {ArgumentError} When `predicate` is undefined.
1056
+ */
1057
+ takeWhile(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
1058
+ /**
1059
+ * Executes `action` for each element as it passes through the pipeline, then yields it unchanged.
1060
+ *
1061
+ * @remarks
1062
+ * The action receives each element and its zero-based index.
1063
+ *
1064
+ * @throws {ArgumentNullError} When `action` is null.
1065
+ * @throws {ArgumentError} When `action` is undefined.
1066
+ */
1067
+ tap(action: ItemAction<TSource>): TyneqSequence<TSource>;
1068
+ /**
1069
+ * Executes `action` for each element only while `predicate()` returns `true`.
1070
+ *
1071
+ * @remarks
1072
+ * The action receives each element and its zero-based index.
1073
+ *
1074
+ * @throws {ArgumentNullError} When `action` or `predicate` is null.
1075
+ * @throws {ArgumentError} When `action` or `predicate` is undefined.
1076
+ */
1077
+ tapIf(action: ItemAction<TSource>, predicate: () => boolean): TyneqSequence<TSource>;
1078
+ /**
1079
+ * Yields every `count`-th element (i.e. elements at indices 0, `count`, `2*count`, ...).
1080
+ *
1081
+ * @throws {ArgumentError} When `count` is not a safe integer.
1082
+ * @throws {ArgumentOutOfRangeError} When `count` is less than or equal to `0`.
1083
+ */
1084
+ throttle(count: number): TyneqSequence<TSource>;
1085
+ /**
1086
+ * Yields only elements for which `predicate` returns `true`.
1087
+ *
1088
+ * @remarks
1089
+ * The predicate receives each element and its zero-based index.
1090
+ *
1091
+ * @throws {ArgumentNullError} When `predicate` is null.
1092
+ * @throws {ArgumentError} When `predicate` is undefined.
1093
+ */
1094
+ where(predicate: ItemPredicate<TSource>): TyneqSequence<TSource>;
1095
+ /**
1096
+ * Pairs each element with the corresponding element from `other` using `selector`.
1097
+ *
1098
+ * @remarks
1099
+ * Stops at the shorter of the two sequences.
1100
+ *
1101
+ * @throws {ArgumentNullError} When `other` or `selector` is null.
1102
+ * @throws {ArgumentError} When `other` or `selector` is undefined.
1103
+ * @throws {ArgumentTypeError} When `other` is not iterable.
1104
+ */
1105
+ zip<TOther, TResult>(other: Iterable<TOther>, selector: (first: TSource, second: TOther) => TResult): TyneqSequence<TResult>;
1106
+ /** Returns the sequence without duplicate elements, using SameValueZero (Set) equality. */
1107
+ distinct(): TyneqSequence<TSource>;
1108
+ /**
1109
+ * Returns the sequence without duplicate elements, comparing by the result of `keySelector`.
1110
+ *
1111
+ * @throws {ArgumentNullError} When `keySelector` is null.
1112
+ * @throws {ArgumentError} When `keySelector` is undefined.
1113
+ */
1114
+ distinctBy<TKey>(keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
1115
+ /** Returns elements not present in `excludedValues`, using SameValueZero (Set) equality. */
1116
+ except(excludedValues: Iterable<TSource>): TyneqSequence<TSource>;
1117
+ /**
1118
+ * Returns elements whose key (via `keySelector`) is not found in `excludedKeys`.
1119
+ *
1120
+ * @throws {ArgumentNullError} When `keySelector` is null.
1121
+ * @throws {ArgumentError} When `keySelector` is undefined.
1122
+ */
1123
+ exceptBy<TKey>(excludedKeys: Iterable<TKey>, keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
1124
+ /**
1125
+ * Groups elements by key and projects each group with `resultSelector`.
1126
+ *
1127
+ * @throws {ArgumentNullError} When `keySelector`, `valueSelector`, or `resultSelector` is null.
1128
+ * @throws {ArgumentError} When `keySelector`, `valueSelector`, or `resultSelector` is undefined.
1129
+ */
1130
+ groupBy<TKey, TValue, TResult>(keySelector: (item: TSource) => TKey, valueSelector: (item: TSource) => TValue, resultSelector: (key: TKey, values: TyneqSequence<TValue>) => TResult): TyneqSequence<TResult>;
1131
+ /**
1132
+ * Performs a left outer join: each outer element is paired with its matching inner group.
1133
+ *
1134
+ * @remarks
1135
+ * Elements with no match in `inner` receive an empty group.
1136
+ *
1137
+ * @throws {ArgumentNullError} When any selector is null.
1138
+ * @throws {ArgumentError} When any selector is undefined.
1139
+ * @throws {ArgumentTypeError} When `inner` is not iterable.
1140
+ */
1141
+ groupJoin<TInner, TKey, TResult>(inner: Iterable<TInner>, outerKeySelector: (outer: TSource) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: TSource, group: TyneqSequence<TInner>) => TResult): TyneqSequence<TResult>;
1142
+ /** Returns elements that are also present in `intersectedValues`, using SameValueZero (Set) equality. */
1143
+ intersect(intersectedValues: Iterable<TSource>): TyneqSequence<TSource>;
1144
+ /**
1145
+ * Returns elements whose key (via `keySelector`) is found in `intersectedKeys`.
1146
+ *
1147
+ * @throws {ArgumentNullError} When `keySelector` is null.
1148
+ * @throws {ArgumentError} When `keySelector` is undefined.
1149
+ */
1150
+ intersectBy<TKey>(intersectedKeys: Iterable<TKey>, keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
1151
+ /**
1152
+ * Performs an inner join: produces one result for each matching pair of outer and inner elements.
1153
+ *
1154
+ * @throws {ArgumentNullError} When any selector is null.
1155
+ * @throws {ArgumentError} When any selector is undefined.
1156
+ */
1157
+ join<TInner, TKey, TResult>(inner: Iterable<TInner>, outerKeySelector: (outer: TSource) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: TSource, inner: TInner) => TResult): TyneqSequence<TResult>;
1158
+ /**
1159
+ * Returns a sequence that caches elements incrementally as they are iterated.
1160
+ *
1161
+ * @remarks
1162
+ * Subsequent iterations replay the cache; the source is only iterated once.
1163
+ * Call `refresh()` on the returned sequence to clear the cache and re-enumerate the source.
1164
+ */
1165
+ memoize(): TyneqCachedSequence<TSource>;
1166
+ /**
1167
+ * Returns the sequence sorted in ascending order by `keySelector`.
1168
+ *
1169
+ * @remarks
1170
+ * Stable sort. Append `thenBy`/`thenByDescending` for multi-key sorting.
1171
+ *
1172
+ * @throws {ArgumentNullError} When `keySelector` is null.
1173
+ * @throws {ArgumentError} When `keySelector` is undefined.
1174
+ */
1175
+ orderBy<TKey>(keySelector: (item: TSource) => TKey, comparer?: Comparer<TKey>): TyneqOrderedSequence<TSource>;
1176
+ /**
1177
+ * Returns the sequence sorted in descending order by `keySelector`.
1178
+ *
1179
+ * @remarks
1180
+ * Stable sort. Append `thenBy`/`thenByDescending` for multi-key sorting.
1181
+ *
1182
+ * @throws {ArgumentNullError} When `keySelector` is null.
1183
+ * @throws {ArgumentError} When `keySelector` is undefined.
1184
+ */
1185
+ orderByDescending<TKey>(keySelector: (item: TSource) => TKey, comparer?: Comparer<TKey>): TyneqOrderedSequence<TSource>;
1186
+ /**
1187
+ * Returns all possible permutations of the sequence.
1188
+ *
1189
+ * @remarks
1190
+ * O(n!) time and O(n) auxiliary memory. Use only on short sequences.
1191
+ * For a sequence of length n, produces n! result arrays, each of length n.
1192
+ */
1193
+ permutations(): TyneqSequence<TSource[]>;
1194
+ /** Returns the sequence in reverse order. */
1195
+ reverse(): TyneqSequence<TSource>;
1196
+ /**
1197
+ * Returns the sequence in random order using `Math.random()`.
1198
+ *
1199
+ * @remarks
1200
+ * Uses the Fisher-Yates shuffle. Not cryptographically secure.
1201
+ */
1202
+ shuffle(): TyneqSequence<TSource>;
1203
+ /**
1204
+ * Inserts elements from `other` into the sequence at `index`.
1205
+ *
1206
+ * @remarks
1207
+ * `index` is zero-based and counts from the end of the sequence.
1208
+ * Use `0` to append after the last element, `1` to insert before the last element.
1209
+ *
1210
+ * @example
1211
+ * ```ts
1212
+ * Tyneq.from([1, 2, 3]).backsert(0, [4, 5]).toArray();
1213
+ * // [1, 2, 3, 4, 5] (appended)
1214
+ *
1215
+ * Tyneq.from([1, 2, 3]).backsert(1, [99]).toArray();
1216
+ * // [1, 2, 99, 3] (inserted before the last element)
1217
+ * ```
1218
+ *
1219
+ * @throws {ArgumentOutOfRangeError} When `index` is negative.
1220
+ */
1221
+ backsert(index: number, other: Iterable<TSource>): TyneqSequence<TSource>;
1222
+ /** Returns the distinct elements from both this sequence and `otherValues`, using SameValueZero (Set) equality. */
1223
+ union(otherValues: Iterable<TSource>): TyneqSequence<TSource>;
1224
+ /**
1225
+ * Returns the elements from both sequences whose keys are distinct.
1226
+ *
1227
+ * @throws {ArgumentNullError} When `keySelector` is null.
1228
+ * @throws {ArgumentError} When `keySelector` is undefined.
1229
+ */
1230
+ unionBy<TKey>(otherValues: Iterable<TSource>, keySelector: (item: TSource) => TKey): TyneqSequence<TSource>;
1231
+ /**
1232
+ * Passes this sequence through a custom `factory` function and wraps the result.
1233
+ *
1234
+ * @remarks
1235
+ * The returned sequence tracks a `"pipe"` node in the query plan, with `factory` recorded
1236
+ * as the argument. Use this for one-off operator compositions that do not need to be
1237
+ * registered via the plugin API.
1238
+ *
1239
+ * @throws {ArgumentNullError} When `factory` is null.
1240
+ * @throws {ArgumentError} When `factory` is undefined.
1241
+ */
1242
+ pipe<TResult>(factory: (source: Iterable<TSource>) => Enumerator<TResult> | IterableIterator<TResult>): TyneqSequence<TResult>;
1243
+ /**
1244
+ * Returns a sequence of running aggregates.
1245
+ *
1246
+ * @remarks
1247
+ * The first element of the output is `accumulator(seed, source[0])`. Returns an empty sequence when the source is empty.
1248
+ *
1249
+ * @throws {ArgumentNullError} When `accumulator` is null.
1250
+ * @throws {ArgumentError} When `accumulator` is undefined.
1251
+ */
1252
+ scan<TResult>(seed: TResult, accumulator: (acc: TResult, item: TSource) => TResult): TyneqSequence<TResult>;
1253
+ /**
1254
+ * Returns the minimum and maximum element in one pass.
1255
+ *
1256
+ * @remarks
1257
+ * Uses the natural `<` / `>` operators when no comparer is provided.
1258
+ *
1259
+ * @throws {SequenceContainsNoElementsError} When the sequence is empty.
1260
+ */
1261
+ minMax(comparer?: Comparer<TSource>): MinMaxResult<TSource>;
1262
+ }
1263
+ /**
1264
+ * A `TyneqSequence` with additional secondary sort keys applied.
1265
+ *
1266
+ * @remarks
1267
+ * Produced by `orderBy` / `orderByDescending`. Chain `thenBy` / `thenByDescending` to add secondary sort criteria.
1268
+ *
1269
+ * @typeParam TSource - Element type.
1270
+ * @group Interfaces
1271
+ */
1272
+ interface TyneqOrderedSequence<TSource> extends TyneqSequence<TSource> {
1273
+ /**
1274
+ * Adds an ascending secondary sort key.
1275
+ *
1276
+ * @throws {ArgumentNullError} When `keySelector` is null.
1277
+ * @throws {ArgumentError} When `keySelector` is undefined.
1278
+ */
1279
+ thenBy<TKey>(keySelector: (item: TSource) => TKey, comparer?: Comparer<TKey>): TyneqOrderedSequence<TSource>;
1280
+ /**
1281
+ * Adds a descending secondary sort key.
1282
+ *
1283
+ * @throws {ArgumentNullError} When `keySelector` is null.
1284
+ * @throws {ArgumentError} When `keySelector` is undefined.
1285
+ */
1286
+ thenByDescending<TKey>(keySelector: (item: TSource) => TKey, comparer?: Comparer<TKey>): TyneqOrderedSequence<TSource>;
1287
+ /** Sets the ordering to ascending according to the current sort keys. */
1288
+ asc(): TyneqOrderedSequence<TSource>;
1289
+ /** Sets the ordering to descending according to the current sort keys. */
1290
+ desc(): TyneqOrderedSequence<TSource>;
1291
+ }
1292
+ /**
1293
+ * A `TyneqSequence` that caches elements as they are iterated.
1294
+ *
1295
+ * @remarks
1296
+ * Produced by `memoize()`. Call `refresh()` to clear the cache and allow re-enumeration from the source.
1297
+ *
1298
+ * @typeParam TSource - Element type.
1299
+ * @group Interfaces
1300
+ */
1301
+ interface TyneqCachedSequence<TSource> extends TyneqSequence<TSource> {
1302
+ /**
1303
+ * Clears the element cache and returns a new `TyneqCachedSequence` that will re-enumerate from the source.
1304
+ */
1305
+ refresh(): TyneqCachedSequence<TSource>;
1306
+ }
1307
+ /**
1308
+ * Low-level interface for a sequence that supports incremental cache access.
1309
+ *
1310
+ * @typeParam TSource - Element type.
1311
+ * @group Interfaces
1312
+ * @internal
1313
+ */
1314
+ interface CachedEnumerable<TSource> extends Enumerable<TSource> {
1315
+ /**
1316
+ * Attempts to return the cached element at `index`.
1317
+ *
1318
+ * @returns `{ has: true, value }` if cached, `{ has: false }` otherwise.
1319
+ */
1320
+ tryGetAtFromCache(index: number): CacheResult<TSource>;
1321
+ }
1322
+ /** Result returned by the cache-lookup method on a memoized sequence. */
1323
+ type CacheResult<TSource> = {
1324
+ has: true;
1325
+ value: TSource;
1326
+ } | {
1327
+ has: false;
1328
+ };
1329
+ /**
1330
+ * Low-level interface for a sequence that can produce a sort comparator.
1331
+ *
1332
+ * @remarks
1333
+ * Implemented by `TyneqOrderedEnumerable`. Consumed by the ordering infrastructure.
1334
+ *
1335
+ * @typeParam TSource - Element type.
1336
+ * @group Interfaces
1337
+ * @internal
1338
+ */
1339
+ interface OrderedEnumerable<TSource> extends Enumerable<TSource> {
1340
+ source: TyneqSequence<TSource>;
1341
+ /** The parent ordering level, or `null` for the primary sort. */
1342
+ parent: Nullable<OrderedEnumerable<TSource>>;
1343
+ /**
1344
+ * Produces a sorter chain that combines this level with any chained levels.
1345
+ *
1346
+ * @param next - The child sorter, or `null` if this is the innermost level.
1347
+ */
1348
+ getSorter(next: Nullable<BaseEnumerableSorter<TSource>>): BaseEnumerableSorter<TSource>;
1349
+ }
1350
+ /** Result of `minMax()`, containing both the minimum and maximum elements. */
1351
+ type MinMaxResult<T> = {
1352
+ readonly min: T;
1353
+ readonly max: T;
1354
+ };
1355
+ /** A key-value pair used by `toMap()` and `toRecord()` selectors. */
1356
+ type KeyValuePair<TKey, TValue> = {
1357
+ key: TKey;
1358
+ value: TValue;
1359
+ };
1360
+ /**
1361
+ * Structural interface used by registration machinery to call the protected factory methods
1362
+ * on sequence classes without exposing them publicly.
1363
+ *
1364
+ * The double-cast `(this as unknown as SequenceFactory<T>)` is intentional:
1365
+ * these methods are `protected`, so the cast is the only way to call them from
1366
+ * outside the class hierarchy without changing their access modifier.
1367
+ *
1368
+ * @internal
1369
+ */
1370
+ interface SequenceFactory<TSource> {
1371
+ readonly [tyneqQueryNode]: Nullable<QueryPlanNode>;
1372
+ createEnumerable(factory: {
1373
+ getEnumerator(): unknown;
1374
+ }, node?: Nullable<QueryPlanNode>): unknown;
1375
+ createOrderedEnumerable<TKey>(keySelector: (x: TSource) => TKey, comparer: Comparer<TKey>, descending: boolean, node?: Nullable<QueryPlanNode>): TyneqOrderedSequence<TSource>;
1376
+ createCachedEnumerable(source: TyneqSequence<TSource>, node?: Nullable<QueryPlanNode>): TyneqCachedSequence<TSource>;
1377
+ }
1378
+ /** A fully resolved operator entry: metadata plus the prototype-level implementation. */
1379
+ interface OperatorEntry {
1380
+ readonly metadata: OperatorMetadata;
1381
+ readonly impl: BoundMethod<TyneqEnumerableBase<unknown>>;
1382
+ }
1383
+ /** Source of an operator implementation, used internally to track where operators come from. */
1384
+ type OperatorSource = "internal" | "external";
1385
+ /** Kind of an operator, used internally to categorize operators. Extends `OperatorCategory` with registry-only kinds. */
1386
+ type OperatorKind = OperatorCategory | "cache" | "extension" | "unknown";
1387
+ /** Constructor type for a sequence class. */
1388
+ type SequenceConstructor = abstract new (...args: any[]) => TyneqEnumerableCore<unknown>;
1389
+
1390
+ export { TyneqEnumerableBase as $, type Action as A, type BoundMethod as B, type Comparer as C, type OrderedEnumerable as D, type Enumerator as E, type Factory as F, type GenericFunction as G, type HasLength as H, type ItemSelector as I, QueryNode as J, type KeyValuePair as K, type QueryPlanTraversalDirection as L, type Maybe as M, type Nullable as N, type OperatorSource as O, type Predicate as P, type QueryPlanVisitor as Q, type SequenceFactory as R, type SequenceConstructor as S, type TyneqSequence as T, type SourceKind as U, type TyneqCachedSequence as V, type TyneqEnumerableFactory as W, type TyneqOrderedSequence as X, type WithProperties as Y, isSourceNode as Z, tyneqQueryNode as _, type Optional as a, BaseEnumerableSorter as a0, OperatorMetadata as b, type QueryPlanPrinterOptions as c, type QueryPlanNode as d, type QueryPlanWalkerOptions as e, type Assume as f, type CacheResult as g, type CachedEnumerable as h, type Cast as i, type Constructor as j, type Enumerable as k, type EnumeratorFactory as l, type EqualityComparer as m, type FieldKeys as n, type Func as o, type InstanceOf as p, type ItemAction as q, type ItemPredicate as r, type IteratorFactory as s, type Method as t, type MethodKeys as u, type MinMaxResult as v, type NoInfer as w, type OperatorCategory as x, type OperatorEntry as y, type OperatorKind as z };