tyneq 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/dist/Lazy.cjs +762 -0
- package/dist/Lazy.cjs.map +1 -0
- package/dist/Lazy.js +691 -0
- package/dist/Lazy.js.map +1 -0
- package/dist/TyneqCachedTerminalOperator.cjs +4950 -0
- package/dist/TyneqCachedTerminalOperator.cjs.map +1 -0
- package/dist/TyneqCachedTerminalOperator.d.cts +724 -0
- package/dist/TyneqCachedTerminalOperator.d.cts.map +1 -0
- package/dist/TyneqCachedTerminalOperator.d.ts +724 -0
- package/dist/TyneqCachedTerminalOperator.d.ts.map +1 -0
- package/dist/TyneqCachedTerminalOperator.js +4741 -0
- package/dist/TyneqCachedTerminalOperator.js.map +1 -0
- package/dist/ValidationBuilder.cjs +80 -0
- package/dist/ValidationBuilder.cjs.map +1 -0
- package/dist/ValidationBuilder.d.cts +319 -0
- package/dist/ValidationBuilder.d.cts.map +1 -0
- package/dist/ValidationBuilder.d.ts +319 -0
- package/dist/ValidationBuilder.d.ts.map +1 -0
- package/dist/ValidationBuilder.js +69 -0
- package/dist/ValidationBuilder.js.map +1 -0
- package/dist/core.d.cts +1393 -0
- package/dist/core.d.cts.map +1 -0
- package/dist/core.d.ts +1393 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/index.cjs +863 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1038 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1038 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +809 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/index.cjs +24 -0
- package/dist/plugin/index.d.cts +89 -0
- package/dist/plugin/index.d.cts.map +1 -0
- package/dist/plugin/index.d.ts +89 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +2 -0
- package/dist/utility/index.cjs +9 -0
- package/dist/utility/index.d.cts +2 -0
- package/dist/utility/index.d.ts +2 -0
- package/dist/utility/index.js +3 -0
- package/package.json +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TyneqCachedTerminalOperator.cjs","names":["TyneqError","TyneqError","Lazy","reflect","reflect","ArgumentOutOfRangeError","nameof","TyneqError","ArgumentOutOfRangeError","reflect","reflect","reflect","reflect"],"sources":["../src/core/enumerators/TyneqBaseEnumerator.ts","../src/core/TyneqComparer.ts","../src/types/queryplan.ts","../src/queryplan/QueryNode.ts","../src/plugin/decorators/builtin.ts","../src/core/errors/PluginError.ts","../src/core/OperatorMetadata.ts","../src/core/errors/RegistryError.ts","../src/core/registry/TyneqOperatorRegistry.ts","../src/plugin/decorators/sequence.ts","../src/core/TyneqEnumerableCore.ts","../src/core/terminal/TyneqTerminalOperator.ts","../src/operators/aggregate.ts","../src/operators/all.ts","../src/operators/any.ts","../src/operators/average.ts","../src/operators/consume.ts","../src/operators/contains.ts","../src/operators/count.ts","../src/operators/countBy.ts","../src/operators/elementAt.ts","../src/operators/elementAtOrDefault.ts","../src/core/errors/InvalidOperationError.ts","../src/operators/first.ts","../src/operators/firstOrDefault.ts","../src/operators/indexOf.ts","../src/utility/EnumeratorUtility.ts","../src/operators/isNullOrEmpty.ts","../src/operators/last.ts","../src/operators/lastOrDefault.ts","../src/core/errors/SequenceContainsNoElementsError.ts","../src/operators/extremum.ts","../src/operators/minMax.ts","../src/operators/sequenceEqual.ts","../src/operators/single.ts","../src/operators/singleOrDefault.ts","../src/operators/endsWith.ts","../src/operators/startsWith.ts","../src/operators/sum.ts","../src/operators/toArray.ts","../src/operators/toAsync.ts","../src/operators/toMap.ts","../src/operators/toRecord.ts","../src/operators/toSet.ts","../src/core/enumerators/TyneqEnumerator.ts","../src/enumerators/streaming/append.ts","../src/enumerators/streaming/chunk.ts","../src/enumerators/streaming/concat.ts","../src/enumerators/streaming/flatten.ts","../src/enumerators/streaming/defaultIfEmpty.ts","../src/enumerators/streaming/ofType.ts","../src/enumerators/streaming/pairwise.ts","../src/enumerators/streaming/populate.ts","../src/enumerators/streaming/prepend.ts","../src/enumerators/streaming/scan.ts","../src/enumerators/streaming/select.ts","../src/enumerators/streaming/selectMany.ts","../src/enumerators/streaming/repeatSequence.ts","../src/enumerators/streaming/skip.ts","../src/enumerators/streaming/skipLast.ts","../src/enumerators/streaming/skipUntil.ts","../src/enumerators/streaming/skipWhile.ts","../src/enumerators/streaming/slice.ts","../src/enumerators/streaming/split.ts","../src/enumerators/streaming/take.ts","../src/enumerators/streaming/takeUntil.ts","../src/enumerators/streaming/takeWhile.ts","../src/enumerators/streaming/tap.ts","../src/enumerators/streaming/tapIf.ts","../src/enumerators/streaming/throttle.ts","../src/enumerators/streaming/where.ts","../src/enumerators/streaming/window.ts","../src/enumerators/streaming/zip.ts","../src/enumerators/buffer/backsert.ts","../src/enumerators/buffer/distinct.ts","../src/enumerators/buffer/distinctBy.ts","../src/enumerators/buffer/except.ts","../src/enumerators/buffer/exceptBy.ts","../src/utility/DefaultingMap.ts","../src/enumerators/buffer/groupBy.ts","../src/enumerators/buffer/groupJoin.ts","../src/enumerators/buffer/intersect.ts","../src/enumerators/buffer/intersectBy.ts","../src/enumerators/buffer/join.ts","../src/enumerators/buffer/reverse.ts","../src/enumerators/buffer/shuffle.ts","../src/enumerators/buffer/union.ts","../src/enumerators/buffer/unionBy.ts","../src/enumerators/buffer/permutations.ts","../src/core/TyneqEnumerableBase.ts","../src/enumerators/buffer/memoize.ts","../src/core/ordering/BaseEnumerableSorter.ts","../src/core/ordering/TyneqEnumerableSorter.ts","../src/enumerators/buffer/orderBy.ts","../src/core/ordering/TyneqOrderedEnumerable.ts","../src/core/TyneqCachedEnumerable.ts","../src/core/TyneqEnumerable.ts","../src/plugin/decorators/source.ts","../src/plugin/RegistrationUtility.ts","../src/plugin/decorators/operator.ts","../src/plugin/decorators/orderedOperator.ts","../src/plugin/decorators/cachedOperator.ts","../src/plugin/decorators/terminal.ts","../src/plugin/decorators/orderedTerminal.ts","../src/plugin/decorators/cachedTerminal.ts","../src/plugin/registration/createOperator.ts","../src/plugin/registration/createGeneratorOperator.ts","../src/plugin/registration/createOrderedOperator.ts","../src/plugin/registration/createCachedOperator.ts","../src/plugin/registration/createTerminalOperator.ts","../src/plugin/registration/createOrderedTerminalOperator.ts","../src/plugin/registration/createCachedTerminalOperator.ts","../src/core/enumerators/TyneqOrderedEnumerator.ts","../src/core/enumerators/TyneqCachedEnumerator.ts","../src/core/terminal/TyneqOrderedTerminalOperator.ts","../src/core/terminal/TyneqCachedTerminalOperator.ts"],"sourcesContent":["import { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Abstract base class implementing the pull-iterator lifecycle for all Tyneq enumerators.\r\n *\r\n * @remarks\r\n * State machine:\r\n * - `next()` calls `initialize()` on the first invocation, then delegates to `handleNext()`.\r\n * - When `handleNext()` returns `{ done: true }`, `dispose()` is called then the enumerator marks itself completed.\r\n * - `doneWithYield(value)` emits one final element, calls `dispose()`, then marks completed.\r\n * - `earlyComplete()` calls `dispose()` and marks completed without yielding.\r\n * - `return()` triggers early termination: calls `dispose()` then marks completed. Idempotent.\r\n * - Once completed, all `next()` calls return `{ done: true }` without re-invoking `handleNext()`.\r\n *\r\n * Subclasses must implement `handleNext()`. Override `initialize()`, `disposeSource()`, and\r\n * `disposeAdditional()` as needed.\r\n *\r\n * @typeParam TInput - Source element type.\r\n * @typeParam TOutput - Output element type (defaults to `TInput`).\r\n * @group Plugin\r\n */\r\nexport abstract class TyneqBaseEnumerator<TInput, TOutput = TInput> implements Enumerator<TOutput> {\r\n private _initialized = false;\r\n private _completed = false;\r\n\r\n public constructor() { }\r\n\r\n /** Advances the iterator, calling `initialize()` on first call. Idempotent after completion. */\r\n public next(): IteratorResult<TOutput> {\r\n if (this._completed) {\r\n return this.done();\r\n }\r\n\r\n if (!this._initialized) {\r\n this.initialize();\r\n this._initialized = true;\r\n }\r\n\r\n const result = this.handleNext();\r\n\r\n if (result.done) {\r\n if (!this._completed) {\r\n this.dispose();\r\n this._completed = true;\r\n }\r\n\r\n return this.done();\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /** Terminates iteration early, disposes resources, and marks completed. Idempotent. */\r\n public return(value?: unknown): IteratorResult<TOutput> {\r\n if (!this._completed) {\r\n this.dispose(value);\r\n this._completed = true;\r\n }\r\n\r\n return this.done();\r\n }\r\n\r\n /** Called once before the first `handleNext()` invocation. Override to set up state. */\r\n protected initialize(): void { }\r\n\r\n /** Wraps `value` in a non-done `IteratorResult`. */\r\n protected yield(value: TOutput): IteratorResult<TOutput> {\r\n return { done: false, value };\r\n }\r\n\r\n /** Returns a done `IteratorResult`. */\r\n protected done(): IteratorResult<TOutput> {\r\n return { done: true, value: undefined };\r\n }\r\n\r\n /**\r\n * Marks the enumerator completed and yields `value` as the final element.\r\n *\r\n * @remarks\r\n * Use when the last element must be emitted together with completion in one step.\r\n */\r\n protected doneWithYield(value: TOutput): IteratorResult<TOutput> {\r\n this.dispose();\r\n this._completed = true;\r\n return this.yield(value);\r\n }\r\n\r\n /**\r\n * Disposes resources, marks completed, and returns a done result.\r\n *\r\n * @remarks\r\n * Use inside `handleNext()` to terminate iteration before the source is exhausted.\r\n */\r\n protected earlyComplete(reason?: unknown): IteratorResult<TOutput> {\r\n this.dispose(reason);\r\n this._completed = true;\r\n return this.done();\r\n }\r\n\r\n /** Calls `disposeSource()` then `disposeAdditional()`. */\r\n protected dispose(value?: unknown): void {\r\n this.disposeSource();\r\n this.disposeAdditional(value);\r\n }\r\n\r\n /** Override to dispose the upstream source enumerator. */\r\n protected disposeSource(): void { }\r\n\r\n /**\r\n * Override to release any additional resources.\r\n *\r\n * @remarks\r\n * Called after `disposeSource()`. `value` is the return value passed to `return()`.\r\n * Must be idempotent and must not throw.\r\n */\r\n protected disposeAdditional(_value?: unknown): void { }\r\n\r\n /** Produces the next element. Return `{ done: true }` to signal exhaustion. */\r\n protected abstract handleNext(): IteratorResult<TOutput>;\r\n}\r\n","import { Comparer } from \"../types/core\";\r\n\r\n/**\r\n * Built-in comparers and equality comparers used by ordering and equality operators.\r\n *\r\n * @remarks\r\n * All members are static. This class cannot be instantiated.\r\n *\r\n * @group Utilities\r\n */\r\nexport class TyneqComparer {\r\n private constructor() {}\r\n\r\n /**\r\n * Natural-order comparer using `<` and `>`.\r\n *\r\n * @remarks\r\n * Works correctly for numbers, strings, dates, and any type that supports the relational operators.\r\n *\r\n * @returns Negative if `a < b`, positive if `a > b`, `0` if equal.\r\n */\r\n public static defaultComparer<T>(a: T, b: T): number {\r\n return a > b ? 1 : a < b ? -1 : 0;\r\n }\r\n\r\n /** Strict equality comparer using `===`. */\r\n public static defaultEqualityComparer<T>(a: T, b: T): boolean {\r\n return a === b;\r\n }\r\n\r\n /**\r\n * Returns a comparer that reverses the order of `comparer`.\r\n *\r\n * @remarks\r\n * Use this to invert any custom comparer - for example, to sort by a locale-aware comparer\r\n * in descending order without rewriting it.\r\n *\r\n * @example\r\n * ```ts\r\n * const desc = TyneqComparer.reverse(TyneqComparer.createLocaleComparer(\"en\"));\r\n * seq.orderBy((s) => s, desc);\r\n * ```\r\n */\r\n public static reverse<T>(comparer: Comparer<T>): Comparer<T> {\r\n return (a, b) => comparer(b, a);\r\n }\r\n\r\n /**\r\n * Returns a locale-aware string comparer backed by `Intl.Collator`.\r\n *\r\n * @remarks\r\n * Pass a `locale` and optional `options` for deterministic cross-environment ordering.\r\n * Without arguments the comparer uses the runtime locale, which may vary across environments.\r\n *\r\n * @example\r\n * ```ts\r\n * seq.orderBy((s) => s, TyneqComparer.createLocaleComparer(\"en\"));\r\n * ```\r\n *\r\n * @param locale - BCP 47 language tag(s) passed to `Intl.Collator`.\r\n * @param options - `Intl.CollatorOptions` passed to `Intl.Collator`.\r\n *\r\n * @see {@link caseInsensitiveComparer} for a locale-independent case-insensitive ordering comparer.\r\n */\r\n public static createLocaleComparer(locale?: string | string[], options?: Intl.CollatorOptions): Comparer<string> {\r\n const collator = new Intl.Collator(locale, options);\r\n return (a, b) => collator.compare(a, b);\r\n }\r\n\r\n /**\r\n * Case-insensitive string equality comparer.\r\n *\r\n * @remarks\r\n * Converts both values to lower-case with `toLowerCase()` before comparing with `===`.\r\n * Locale-independent: results are consistent across environments.\r\n *\r\n * Use {@link createLocaleComparer} with `{ sensitivity: \"base\" }` for locale-aware\r\n * case-insensitive equality.\r\n *\r\n * @see {@link caseInsensitiveComparer} for the ordering (negative/zero/positive) counterpart.\r\n */\r\n public static caseInsensitiveEqualityComparer(a: string, b: string): boolean {\r\n return a.toLowerCase() === b.toLowerCase();\r\n }\r\n\r\n /**\r\n * Case-insensitive ordering comparer.\r\n *\r\n * @remarks\r\n * Converts both values to lower-case with `toLowerCase()` and compares with `<` / `>`.\r\n * Locale-independent: results are consistent across environments and match\r\n * {@link caseInsensitiveEqualityComparer} - strings that compare equal here return `true`\r\n * there, and vice versa.\r\n *\r\n * Use {@link createLocaleComparer} when you need locale-aware case-insensitive ordering.\r\n *\r\n * @example\r\n * ```ts\r\n * seq.orderBy((s) => s, TyneqComparer.caseInsensitiveComparer)\r\n * ```\r\n *\r\n * @see {@link caseInsensitiveEqualityComparer} for the boolean equality counterpart.\r\n * @see {@link createLocaleComparer} for locale-aware ordering.\r\n */\r\n public static caseInsensitiveComparer(a: string, b: string): number {\r\n const la = a.toLowerCase();\r\n const lb = b.toLowerCase();\r\n return la > lb ? 1 : la < lb ? -1 : 0;\r\n }\r\n}\r\n","import { Nullable } from \"./utility\";\r\n\r\n/**\r\n * Symbol key used to access the {@link QueryPlanNode} on a `TyneqSequence`.\r\n *\r\n * @example\r\n * ```ts\r\n * import { tyneqQueryNode } from \"tyneq\";\r\n * const node = seq[tyneqQueryNode]; // QueryPlanNode | null\r\n * ```\r\n *\r\n * @group QueryPlan\r\n */\r\nexport const tyneqQueryNode: unique symbol = Symbol(\"tyneq.queryNode\");\r\n\r\n/**\r\n * Categories of operators.\r\n *\r\n * @remarks\r\n * String literal types used to classify operator behaviour.\r\n *\r\n * @group QueryPlan\r\n */\r\nexport type OperatorCategory = \"source\" | \"streaming\" | \"buffer\" | \"terminal\";\r\n\r\n/**\r\n * The JavaScript collection type that backs a source node.\r\n *\r\n * @group QueryPlan\r\n */\r\nexport type SourceKind = \"array\" | \"set\" | \"map\" | \"string\" | \"other\";\r\n\r\n/**\r\n * A node in the query plan tree representing one operator in a pipeline.\r\n *\r\n * @remarks\r\n * Nodes form a linked list via `source`. The head node has `source === null` and represents the data source.\r\n *\r\n * @group QueryPlan\r\n */\r\nexport interface QueryPlanNode {\r\n /** The operator name as registered with the registry. */\r\n readonly operatorName: string;\r\n\r\n /** The arguments passed to the operator. Functions render as `<fn>` in printed output. */\r\n readonly args: readonly unknown[];\r\n\r\n /** The upstream node, or `null` for source nodes. */\r\n readonly source: Nullable<QueryPlanNode>;\r\n\r\n /**\r\n * Operator category describing behaviour (`\"source\" | \"streaming\" | \"buffer\" | \"terminal\").\r\n */\r\n readonly category: OperatorCategory;\r\n\r\n /**\r\n * The backing JavaScript collection type for source nodes.\r\n *\r\n * @remarks\r\n * Only meaningful when `category === \"source\"`. For all other categories this field is\r\n * `undefined`. Use {@link isSourceNode} to narrow the type before reading this field.\r\n */\r\n readonly sourceKind?: SourceKind;\r\n\r\n /**\r\n * Accepts a visitor and returns its result.\r\n *\r\n * @param visitor - The visitor to invoke.\r\n */\r\n accept<T>(visitor: QueryPlanVisitor<T>): T;\r\n}\r\n\r\n/**\r\n * Narrows a `QueryPlanNode` to one that is guaranteed to have a `sourceKind`.\r\n *\r\n * @remarks\r\n * `sourceKind` is only present on source nodes (`category === \"source\"`). Reading it on any\r\n * other node returns `undefined`. Use this guard before accessing `node.sourceKind` to get\r\n * proper type narrowing and avoid ambiguous `undefined`.\r\n *\r\n * @example\r\n * ```ts\r\n * if (isSourceNode(node)) {\r\n * console.log(node.sourceKind); // \"array\" | \"set\" | \"map\" | \"string\" | \"other\"\r\n * }\r\n * ```\r\n *\r\n * @group QueryPlan\r\n */\r\nexport function isSourceNode(node: QueryPlanNode): node is QueryPlanNode & { sourceKind: SourceKind } {\r\n return node.category === \"source\";\r\n}\r\n\r\n/**\r\n * Traversal direction for {@link QueryPlanWalker}.\r\n *\r\n * - `\"source-to-terminal\"` - visits from the source node up to the terminal (bottom-up).\r\n * `from` is visited before `where`, `where` before `select`. This is the default.\r\n * - `\"terminal-to-source\"` - visits from the terminal node down to the source (top-down).\r\n * `select` is visited before `where`, `where` before `from`.\r\n *\r\n * @group QueryPlan\r\n */\r\nexport type QueryPlanTraversalDirection = \"source-to-terminal\" | \"terminal-to-source\";\r\n\r\n/**\r\n * Options for {@link QueryPlanWalker}.\r\n *\r\n * @group QueryPlan\r\n */\r\nexport interface QueryPlanWalkerOptions {\r\n /**\r\n * Callback invoked by the default `visitNode` implementation for each node.\r\n * Ignored when `visitNode` is overridden in a subclass without calling `super.visitNode`.\r\n */\r\n callback?: (node: QueryPlanNode) => void;\r\n\r\n /**\r\n * Traversal direction. Defaults to `\"source-to-terminal\"`.\r\n */\r\n direction?: QueryPlanTraversalDirection;\r\n}\r\n\r\n/**\r\n * Visitor for traversing a query plan tree.\r\n *\r\n * @typeParam T - The value produced by visiting a node.\r\n * @group QueryPlan\r\n */\r\nexport interface QueryPlanVisitor<T> {\r\n /** Called for each node during traversal. */\r\n visit(node: QueryPlanNode): T;\r\n}\r\n\r\n/**\r\n * Options for {@link QueryPlanPrinter}.\r\n *\r\n * @group QueryPlan\r\n */\r\nexport interface QueryPlanPrinterOptions {\r\n /** Indentation string per nesting level. Defaults to `\" \"` (two spaces). */\r\n indent?: string;\r\n\r\n /** Arrow string between levels. Defaults to `\"->\"`. */\r\n arrow?: string;\r\n\r\n /** Maximum number of array items to render inline. Defaults to `3`. */\r\n maxInlineArrayItems?: number;\r\n}\r\n","import type { QueryPlanNode, QueryPlanVisitor, OperatorCategory, SourceKind } from \"../types/queryplan\";\r\nimport type { Nullable } from \"../types/utility\";\r\n\r\n/**\r\n * Concrete `QueryPlanNode` implementation.\r\n * One node is created per operator call and linked to its upstream source node,\r\n * forming a singly-linked list that represents the full query plan.\r\n *\r\n * @group QueryPlan\r\n * @internal\r\n */\r\nexport class QueryNode implements QueryPlanNode {\r\n\r\n public constructor(\r\n public readonly operatorName: string,\r\n public readonly args: readonly unknown[],\r\n public readonly source: Nullable<QueryPlanNode>,\r\n public readonly category: OperatorCategory,\r\n public readonly sourceKind?: SourceKind\r\n ) {}\r\n\r\n public accept<T>(visitor: QueryPlanVisitor<T>): T {\r\n return visitor.visit(this);\r\n }\r\n}\r\n","import { OperatorKind } from \"../../types/core\";\r\nimport { Method } from \"../../types/utility\";\r\n\r\nexport const builtinMeta = Symbol(\"tyneq.builtinMetadata\");\r\n\r\nexport type BuiltinMetadata = {\r\n name: string;\r\n kind: OperatorKind;\r\n}\r\n\r\nexport type MethodWithMetadata = Method & { [builtinMeta]: BuiltinMetadata };\r\n\r\nexport interface BuiltinOptions {\r\n readonly kind: OperatorKind;\r\n}\r\n\r\n/**\r\n * Method decorator - declares this method as a built-in operator.\r\n *\r\n * Stores `BuiltinOptions` on the function object so `@sequence` can find it.\r\n * Does NOT register anything by itself - registration happens in `@sequence`.\r\n *\r\n * @remarks\r\n * This is one half of a two-decorator pattern. Apply `@builtin` to each method on a class\r\n * decorated with `@sequence`. When the module is evaluated, `@sequence` will scan all\r\n * `@builtin`-tagged methods and call `OperatorRegistry.registerBuiltin` for each.\r\n *\r\n * Only use on methods of `TyneqEnumerableCore` or `TyneqEnumerableBase`. Third-party\r\n * operators should use `@operator`, `@terminal`, or the `createOperator` factory instead.\r\n *\r\n * @internal\r\n */\r\nexport function builtin(options: BuiltinOptions) {\r\n return function <T extends Method>(value: T, context: ClassMethodDecoratorContext): T {\r\n (value as unknown as MethodWithMetadata)[builtinMeta] = {\r\n name: context.name as string,\r\n kind: options.kind,\r\n };\r\n\r\n return value;\r\n };\r\n}","import { Maybe } from \"../../types/utility\";\r\nimport { TyneqError } from \"./TyneqError\";\r\n\r\n/**\r\n * Thrown when a plugin, decorator (`@operator`, `@terminal`), or factory\r\n * (`createOperator`, `createTerminalOperator`) is used incorrectly.\r\n *\r\n * @example\r\n * ```ts\r\n * // @operator('myOp') applied to a class that doesn't extend TyneqEnumerator\r\n * // throws PluginError with decoratorName = \"operator\" and targetName = \"MyOp\"\r\n * ```\r\n *\r\n * @see {@link TyneqError}\r\n * @group Errors\r\n */\r\nexport class PluginError extends TyneqError {\r\n /**\r\n * The name of the decorator or factory that produced the error.\r\n * e.g. `\"operator\"`, `\"terminal\"`, `\"createOperator\"`.\r\n */\r\n public readonly decoratorName: string;\r\n\r\n /**\r\n * The name of the class or function the decorator was applied to, if available.\r\n */\r\n public readonly targetName: Maybe<string>;\r\n\r\n public constructor(\r\n message: string,\r\n decoratorName: string,\r\n targetName?: string,\r\n inner?: Error\r\n ) {\r\n super(message, { inner });\r\n this.decoratorName = decoratorName;\r\n this.targetName = targetName;\r\n }\r\n}\r\n","import { OperatorKind, OperatorSource, SequenceConstructor } from \"../types/core\";\r\nimport { TyneqEnumerableBase } from \"./TyneqEnumerableBase\";\r\nimport { PluginError } from \"./errors/PluginError\";\r\nimport type { Maybe } from \"../types/utility\";\r\n\r\n/**\r\n * Metadata describing a registered operator.\r\n *\r\n * @group Classes\r\n */\r\nexport class OperatorMetadata {\r\n public readonly name: string;\r\n public readonly kind: OperatorKind;\r\n public readonly source: OperatorSource;\r\n public readonly targetClass: Maybe<SequenceConstructor>;\r\n public readonly extensions: Readonly<Record<string, unknown>>;\r\n\r\n public constructor(\r\n name: string,\r\n kind: OperatorKind,\r\n source: OperatorSource = \"external\",\r\n targetClass?: Maybe<SequenceConstructor>,\r\n extensions: Readonly<Record<string, unknown>> = {}\r\n ) {\r\n this.name = name;\r\n this.kind = kind;\r\n this.source = source;\r\n this.targetClass = arguments.length < 4 ? TyneqEnumerableBase : targetClass;\r\n this.extensions = extensions;\r\n }\r\n\r\n /**\r\n * Creates metadata for a source operator.\r\n *\r\n * @remarks\r\n * `targetClass` is always `undefined` for source operators - they are static\r\n * factories with no prototype and are never patched onto a class instance.\r\n */\r\n public static source(\r\n name: string,\r\n src: OperatorSource = \"external\"\r\n ): OperatorMetadata {\r\n return new OperatorMetadata(name, \"source\", src, undefined);\r\n }\r\n\r\n /** Creates metadata for a streaming operator. Defaults targetClass to TyneqEnumerableBase. */\r\n public static streaming(\r\n name: string,\r\n targetClass: SequenceConstructor = TyneqEnumerableBase,\r\n source?: OperatorSource,\r\n extensions?: Record<string, unknown>\r\n ): OperatorMetadata {\r\n return new OperatorMetadata(name, \"streaming\", source ?? \"external\", targetClass, extensions);\r\n }\r\n\r\n /** Creates metadata for a buffering operator. Defaults targetClass to TyneqEnumerableBase. */\r\n public static buffer(\r\n name: string,\r\n targetClass: SequenceConstructor = TyneqEnumerableBase,\r\n source?: OperatorSource,\r\n extensions?: Record<string, unknown>\r\n ): OperatorMetadata {\r\n return new OperatorMetadata(name, \"buffer\", source ?? \"external\", targetClass, extensions);\r\n }\r\n\r\n /** Creates metadata for a terminal operator. Defaults targetClass to TyneqEnumerableBase. */\r\n public static terminal(\r\n name: string,\r\n targetClass: SequenceConstructor = TyneqEnumerableBase,\r\n source?: OperatorSource,\r\n extensions?: Record<string, unknown>\r\n ): OperatorMetadata {\r\n return new OperatorMetadata(name, \"terminal\", source ?? \"external\", targetClass, extensions);\r\n }\r\n\r\n /**\r\n * Creates metadata for a streaming or buffer operator determined at runtime.\r\n *\r\n * @remarks\r\n * Use when the category is a variable rather than a compile-time literal --\r\n * for example in `@operator` and `@orderedOperator` whose `category` parameter\r\n * is provided by the caller. For compile-time-known categories prefer the\r\n * dedicated {@link streaming} / {@link buffer} / {@link terminal} statics.\r\n *\r\n * Only `\"streaming\"` and `\"buffer\"` are valid; passing `\"terminal\"` or `\"source\"` throws.\r\n */\r\n public static forCategory(\r\n category: \"streaming\" | \"buffer\",\r\n name: string,\r\n targetClass: SequenceConstructor = TyneqEnumerableBase,\r\n source?: OperatorSource,\r\n extensions?: Record<string, unknown>\r\n ): OperatorMetadata {\r\n if (category === \"streaming\") {\r\n return OperatorMetadata.streaming(name, targetClass, source, extensions);\r\n }\r\n if (category === \"buffer\") {\r\n return OperatorMetadata.buffer(name, targetClass, source, extensions);\r\n }\r\n\r\n throw new PluginError(\r\n `OperatorMetadata.forCategory: unsupported category \"${category}\". Use .terminal() or .source() directly.`,\r\n \"forCategory\",\r\n name\r\n );\r\n }\r\n}\r\n","import { TyneqError } from \"./TyneqError\";\r\nimport { OperatorMetadata } from \"../OperatorMetadata\";\r\nimport { Maybe } from \"../../types/utility\";\r\n\r\n/**\r\n * Thrown when the operator registry encounters a conflict or invalid state\r\n * during operator registration or invocation.\r\n *\r\n * @example\r\n * ```ts\r\n * try { OperatorRegistry.register(entry); }\r\n * catch (e) {\r\n * if (e instanceof RegistryError) {\r\n * console.log(e.operatorName, e.conflictingKind, e.message);\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @see {@link TyneqError}\r\n * @group Errors\r\n */\r\nexport class RegistryError extends TyneqError {\r\n /** The name of the operator involved in the error. */\r\n public readonly operatorName: string;\r\n\r\n /**\r\n * The kind of the operator that was being registered or invoked.\r\n * `undefined` if the kind is not applicable to this error.\r\n */\r\n public readonly kind: Maybe<OperatorMetadata[\"kind\"]>;\r\n\r\n /**\r\n * The kind already present in the registry for this name, when there is a conflict.\r\n * `undefined` when the error is not a duplicate-registration conflict.\r\n */\r\n public readonly conflictingKind: Maybe<OperatorMetadata[\"kind\"]>;\r\n\r\n /**\r\n * The source that originally registered the conflicting operator.\r\n * `undefined` when the error is not a duplicate-registration conflict.\r\n */\r\n public readonly conflictingSource: Maybe<OperatorMetadata[\"source\"]>;\r\n\r\n public constructor(\r\n message: string,\r\n operatorName: string,\r\n kind?: OperatorMetadata[\"kind\"],\r\n conflict?: { kind: OperatorMetadata[\"kind\"]; source: OperatorMetadata[\"source\"] },\r\n inner?: Error\r\n ) {\r\n super(message, { inner });\r\n this.operatorName = operatorName;\r\n this.kind = kind;\r\n this.conflictingKind = conflict?.kind;\r\n this.conflictingSource = conflict?.source;\r\n }\r\n}\r\n","import { OperatorEntry, OperatorSource, SequenceConstructor } from \"../../types/core\";\r\nimport { OperatorMetadata } from \"../OperatorMetadata\";\r\nimport { reflect } from \"../../utility/reflect\";\r\nimport { Lazy } from \"../../utility/Lazy\";\r\nimport { RegistryError } from \"../errors/RegistryError\";\r\nimport { Maybe } from \"../../types/utility\";\r\n\r\n/**\r\n * Central registry for all Tyneq operators.\r\n *\r\n * Every registration path - `@operator`, `@terminal`, `createOperator`,\r\n * `createGeneratorOperator`, `createTerminalOperator` - flows through this class.\r\n * It is the single source of truth for which operators exist, their kind, and their\r\n * prototype-level implementation.\r\n *\r\n * Internally the registry maintains two separate namespaces:\r\n * - Source factories (`Tyneq.from`, `Tyneq.range`, etc.) - keyed by name alone.\r\n * - Instance operators (`.where`, `.select`, etc.) - keyed by (name, targetClass).\r\n *\r\n * This means a source factory and an instance method can share a name without\r\n * conflict (e.g. `Tyneq.concat` and `seq.concat`), and two instance operators\r\n * with the same name on different prototype chains (e.g. `ordered.foo` and\r\n * `cached.foo`) also coexist without conflict.\r\n *\r\n * @example\r\n * ```ts\r\n * import { OperatorRegistry } from \"tyneq/plugin\";\r\n *\r\n * OperatorRegistry.has(\"where\"); // -> true\r\n * OperatorRegistry.list(); // -> OperatorMetadata[]\r\n * ```\r\n *\r\n * @group Classes\r\n */\r\nexport class OperatorRegistry {\r\n private static readonly _sources = new Map<string, OperatorEntry>();\r\n private static readonly _operators = new Map<string, Map<SequenceConstructor, OperatorEntry>>();\r\n\r\n private static readonly _registrationHooks: Array<(entry: OperatorEntry) => void> = [];\r\n private static readonly _registrationGuards: Array<(entry: OperatorEntry) => void> = [];\r\n\r\n /**\r\n * Registers an operator entry and patches the method onto `entry.metadata.targetClass.prototype`.\r\n *\r\n * @throws {RegistryError} When an operator with the same name is already registered on the same targetClass.\r\n */\r\n public static register(input: OperatorEntry): void {\r\n const { name } = input.metadata;\r\n\r\n if (input.metadata.targetClass === undefined) {\r\n throw new RegistryError(\r\n `Cannot register \"${name}\": targetClass is required for prototype-patching operators. Use registerSource() for source operators.`,\r\n name,\r\n input.metadata.kind\r\n );\r\n }\r\n\r\n const targetMap = this._operators.get(name);\r\n if (targetMap?.has(input.metadata.targetClass)) {\r\n const existing = targetMap.get(input.metadata.targetClass)!.metadata;\r\n throw new RegistryError(\r\n `Cannot register \"${name}\" (${input.metadata.kind}) on ${input.metadata.targetClass.name}: ` +\r\n `already registered as \"${existing.kind}\" from source \"${existing.source}\".`,\r\n name,\r\n input.metadata.kind,\r\n { kind: existing.kind, source: existing.source }\r\n );\r\n }\r\n\r\n for (const guard of this._registrationGuards) {\r\n guard(input);\r\n }\r\n\r\n if (!this._operators.has(name)) {\r\n this._operators.set(name, new Map());\r\n }\r\n\r\n this._operators.get(name)!.set(input.metadata.targetClass, input);\r\n (input.metadata.targetClass.prototype as Record<string, unknown>)[name] = input.impl;\r\n\r\n for (const hook of this._registrationHooks) {\r\n hook(input);\r\n }\r\n }\r\n\r\n /**\r\n * Removes an operator registration and deletes the prototype method for external operators.\r\n *\r\n * Checks the instance operator namespace first, then the source namespace.\r\n *\r\n * @returns `true` if the operator was found and removed; `false` if no operator with that name existed.\r\n * @remarks\r\n * Internal operators (source `\"internal\"`) are not removed from the prototype - only\r\n * their registry entry is deleted.\r\n *\r\n * For targeted removal use {@link unregisterOperator} or {@link unregisterSource}.\r\n */\r\n public static unregister(name: string): boolean {\r\n if (this._operators.has(name)) {\r\n const targetMap = this._operators.get(name)!;\r\n for (const [targetClass, entry] of targetMap) {\r\n if (entry.metadata.source !== \"internal\" && targetClass !== undefined) {\r\n delete (targetClass.prototype as Record<string, unknown>)[name];\r\n }\r\n }\r\n\r\n this._operators.delete(name);\r\n return true;\r\n }\r\n\r\n if (this._sources.has(name)) {\r\n this._sources.delete(name);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Removes a specific instance operator registration for a given (name, targetClass) pair\r\n * and deletes the prototype method for external operators.\r\n *\r\n * @returns `true` if the entry was found and removed; `false` otherwise.\r\n */\r\n public static unregisterOperator(name: string, targetClass: SequenceConstructor): boolean {\r\n const targetMap = this._operators.get(name);\r\n if (!targetMap?.has(targetClass)) {\r\n return false;\r\n }\r\n\r\n const entry = targetMap.get(targetClass)!;\r\n if (entry.metadata.source !== \"internal\") {\r\n delete (targetClass.prototype as Record<string, unknown>)[name];\r\n }\r\n\r\n targetMap.delete(targetClass);\r\n if (targetMap.size === 0) {\r\n this._operators.delete(name);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Removes a source factory registration.\r\n *\r\n * @returns `true` if the source was found and removed; `false` otherwise.\r\n */\r\n public static unregisterSource(name: string): boolean {\r\n return this._sources.delete(name);\r\n }\r\n\r\n /**\r\n * Registers a hook called after every successful operator registration (both namespaces).\r\n *\r\n * @returns A function that removes the hook when called.\r\n */\r\n public static onRegister(hook: (entry: OperatorEntry) => void): () => void {\r\n this._registrationHooks.push(hook);\r\n return () => {\r\n const i = this._registrationHooks.indexOf(hook);\r\n if (i !== -1) this._registrationHooks.splice(i, 1);\r\n };\r\n }\r\n\r\n /**\r\n * Registers a guard called before every registration (both namespaces).\r\n * Throw from the guard to reject the registration.\r\n *\r\n * @returns A function that removes the guard when called.\r\n */\r\n public static addGuard(guard: (entry: OperatorEntry) => void): () => void {\r\n this._registrationGuards.push(guard);\r\n return () => {\r\n const i = this._registrationGuards.indexOf(guard);\r\n if (i !== -1) this._registrationGuards.splice(i, 1);\r\n };\r\n }\r\n\r\n /**\r\n * Returns `true` if a name exists in either the source or instance operator namespace.\r\n * Use {@link hasSource} or {@link hasOperator} for namespace-specific checks.\r\n */\r\n public static has(name: string): boolean {\r\n return this._sources.has(name) || this._operators.has(name);\r\n }\r\n\r\n /**\r\n * Returns `true` if a source factory with `name` is registered.\r\n */\r\n public static hasSource(name: string): boolean {\r\n return this._sources.has(name);\r\n }\r\n\r\n /**\r\n * Returns `true` if an instance operator with `name` is registered.\r\n * When `targetClass` is provided, checks only that specific (name, targetClass) pair.\r\n * When omitted, returns `true` if any target has an operator with that name.\r\n */\r\n public static hasOperator(name: string, targetClass?: SequenceConstructor): boolean {\r\n if (targetClass !== undefined) {\r\n return this._operators.get(name)?.has(targetClass) ?? false;\r\n }\r\n\r\n return this._operators.has(name);\r\n }\r\n\r\n /**\r\n * Returns the operator entry for `name` from either namespace, or `undefined` if not found.\r\n * Checks the instance operator namespace first, then the source namespace.\r\n * For namespace-specific retrieval use {@link getSource} or {@link getOperator}.\r\n */\r\n public static get(name: string): Maybe<OperatorEntry> {\r\n // Return the first instance operator entry found (any target)\r\n const targetMap = this._operators.get(name);\r\n if (targetMap !== undefined) {\r\n return targetMap.values().next().value;\r\n }\r\n\r\n return this._sources.get(name);\r\n }\r\n\r\n /**\r\n * Returns the source factory entry for `name`, or `undefined` if not registered.\r\n */\r\n public static getSource(name: string): Maybe<OperatorEntry> {\r\n return this._sources.get(name);\r\n }\r\n\r\n /**\r\n * Returns the instance operator entry for `name` on `targetClass`, or `undefined`.\r\n * When `targetClass` is omitted, returns the first entry found across all targets.\r\n */\r\n public static getOperator(name: string, targetClass?: SequenceConstructor): Maybe<OperatorEntry> {\r\n const targetMap = this._operators.get(name);\r\n if (targetMap === undefined) {\r\n return undefined;\r\n }\r\n\r\n if (targetClass !== undefined) {\r\n return targetMap.get(targetClass);\r\n }\r\n\r\n return targetMap.values().next().value;\r\n }\r\n\r\n /**\r\n * Returns the metadata for `name` from either namespace, or `undefined` if not found.\r\n * Checks instance operators first, then sources.\r\n */\r\n public static getMetadata(name: string): Maybe<OperatorMetadata> {\r\n return this.get(name)?.metadata;\r\n }\r\n\r\n /**\r\n * Returns metadata for all registered operators and source factories.\r\n * Use {@link listOperators} or {@link listSources} for namespace-specific lists.\r\n */\r\n public static list(): readonly OperatorMetadata[] {\r\n return [...this.listSources(), ...this.listOperators()];\r\n }\r\n\r\n /**\r\n * Returns metadata for all registered source factories.\r\n */\r\n public static listSources(): readonly OperatorMetadata[] {\r\n return [...this._sources.values()].map((e) => e.metadata);\r\n }\r\n\r\n /**\r\n * Returns metadata for all registered instance operators.\r\n * When `targetClass` is provided, returns only entries for that specific target class.\r\n */\r\n public static listOperators(targetClass?: SequenceConstructor): readonly OperatorMetadata[] {\r\n const all: OperatorMetadata[] = [];\r\n for (const targetMap of this._operators.values()) {\r\n if (targetClass !== undefined) {\r\n const entry = targetMap.get(targetClass);\r\n if (entry !== undefined) {\r\n all.push(entry.metadata);\r\n }\r\n } else {\r\n for (const entry of targetMap.values()) {\r\n all.push(entry.metadata);\r\n }\r\n }\r\n }\r\n\r\n return all;\r\n }\r\n\r\n /** Returns metadata for all operators of `kind` across both namespaces. */\r\n public static listByKind(kind: OperatorMetadata[\"kind\"]): readonly OperatorMetadata[] {\r\n return this.list().filter((m) => m.kind === kind);\r\n }\r\n\r\n /** Returns metadata for all operators from `source` across both namespaces. */\r\n public static listBySource(source: OperatorMetadata[\"source\"]): readonly OperatorMetadata[] {\r\n return this.list().filter((m) => m.source === source);\r\n }\r\n\r\n /** Returns the total number of registered operators across both namespaces. */\r\n public static count(): number {\r\n let operatorCount = 0;\r\n for (const targetMap of this._operators.values()) {\r\n operatorCount += targetMap.size;\r\n }\r\n\r\n return this._sources.size + operatorCount;\r\n }\r\n\r\n /**\r\n * Registers a source operator (a static factory, not a prototype method).\r\n *\r\n * @remarks\r\n * Source operators differ from prototype operators in two ways:\r\n * - They are called with `null` as `this` - they have no instance.\r\n * - They are looked up by the compiler via {@link getSource} rather than\r\n * being patched onto a prototype.\r\n *\r\n * The entry is stored in the source namespace and is never patched onto any prototype.\r\n * Registration guards run for `\"external\"` sources (same policy as {@link register}).\r\n * Guards are skipped for `\"internal\"` sources (same policy used for internal builtins).\r\n *\r\n * Third-party source operators registered here are automatically compiled by\r\n * `QueryPlanCompiler` without any changes to the compiler.\r\n *\r\n * @param name - The operator name, matching the `operatorName` on the `QueryPlanNode`.\r\n * @param factory - The factory function; receives the node args in order, `this` is `null`.\r\n * @param source - Whether this is a built-in or external source operator. Defaults to `\"external\"`.\r\n *\r\n * @example\r\n * ```ts\r\n * import { OperatorRegistry } from \"tyneq/plugin\";\r\n * import { Tyneq } from \"tyneq\";\r\n *\r\n * OperatorRegistry.registerSource(\"fibonacci\", (count) => {\r\n * // return a Tyneq sequence of fibonacci numbers\r\n * });\r\n * ```\r\n *\r\n * @group Classes\r\n */\r\n public static registerSource(\r\n name: string,\r\n factory: (...args: unknown[]) => unknown,\r\n source: OperatorSource = \"external\"\r\n ): void {\r\n if (this._sources.has(name)) {\r\n const existing = this._sources.get(name)!.metadata;\r\n throw new RegistryError(\r\n `Cannot register source \"${name}\": ` +\r\n `already registered as \"${existing.kind}\" from source \"${existing.source}\".`,\r\n name,\r\n \"source\",\r\n { kind: existing.kind, source: existing.source }\r\n );\r\n }\r\n\r\n const entry: OperatorEntry = {\r\n metadata: OperatorMetadata.source(name, source),\r\n impl: function (this: unknown, ...args: unknown[]) {\r\n return factory(...args);\r\n },\r\n };\r\n\r\n if (source !== \"internal\") {\r\n for (const guard of this._registrationGuards) {\r\n guard(entry);\r\n }\r\n }\r\n\r\n this._sources.set(name, entry);\r\n\r\n for (const hook of this._registrationHooks) {\r\n hook(entry);\r\n }\r\n }\r\n\r\n /**\r\n * Records a built-in operator in the instance operator namespace without patching the prototype.\r\n * Built-in operators already live as direct methods on their target class.\r\n *\r\n * @remarks\r\n * Registration guards are intentionally skipped - builtins are internal and\r\n * trusted; guards exist to validate external plugin registrations only.\r\n *\r\n * @internal\r\n */\r\n public static registerBuiltin(\r\n name: string,\r\n kind: OperatorMetadata[\"kind\"],\r\n targetClass: SequenceConstructor\r\n ): void {\r\n const targetMap = this._operators.get(name);\r\n if (targetMap?.has(targetClass)) {\r\n const existing = targetMap.get(targetClass)!.metadata;\r\n throw new RegistryError(\r\n `Cannot register builtin \"${name}\" (${kind}) on ${targetClass.name}: ` +\r\n `already registered as \"${existing.kind}\" from source \"${existing.source}\".`,\r\n name,\r\n kind,\r\n { kind: existing.kind, source: existing.source }\r\n );\r\n }\r\n\r\n const lazyMethod = new Lazy(() => reflect(targetClass.prototype).tryGetMethod(name)?.value);\r\n const entry: OperatorEntry = {\r\n metadata: new OperatorMetadata(name, kind, \"internal\", targetClass),\r\n impl: function (this: unknown, ...args: unknown[]) {\r\n const method = lazyMethod.value;\r\n if (!method) {\r\n throw new RegistryError(\r\n `Cannot invoke builtin \"${name}\" (${kind}): method not found on prototype. ` +\r\n \"Ensure the method exists on the target class before registering.\",\r\n name,\r\n kind\r\n );\r\n }\r\n\r\n return method.apply(this, args);\r\n },\r\n };\r\n\r\n if (!this._operators.has(name)) {\r\n this._operators.set(name, new Map());\r\n }\r\n\r\n this._operators.get(name)!.set(targetClass, entry);\r\n\r\n for (const hook of this._registrationHooks) {\r\n hook(entry);\r\n }\r\n }\r\n}\r\n","import { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { SequenceConstructor } from \"../../types/core\";\r\nimport { reflect } from \"../../utility/reflect\";\r\nimport { builtinMeta, BuiltinMetadata, MethodWithMetadata } from \"./builtin\";\r\n\r\n/**\r\n * Class decorator - declares this class as a sequence whose `@builtin` methods are operators.\r\n *\r\n * Scans the prototype for `@builtin`-tagged methods and registers each one via\r\n * `OperatorRegistry.registerBuiltin`, passing this class as `targetClass`.\r\n *\r\n * @remarks\r\n * Works in tandem with `@builtin`. The two-decorator pattern:\r\n * 1. Decorate each built-in method with `@builtin({ kind: \"streaming\" | \"buffer\" })`.\r\n * `@builtin` stamps a `builtinMeta` symbol onto the function object - it does NOT register.\r\n * 2. Decorate the containing class with `@sequence`.\r\n * `@sequence` scans the prototype, finds all `@builtin`-tagged methods, and calls\r\n * `OperatorRegistry.registerBuiltin` for each one.\r\n *\r\n * Apply only to `TyneqEnumerableCore` and `TyneqEnumerableBase` - the two base classes\r\n * whose methods form the built-in operator surface. Never use on third-party or test classes.\r\n *\r\n * @internal\r\n */\r\nexport function sequence(\r\n target: SequenceConstructor,\r\n _context: ClassDecoratorContext\r\n): void {\r\n for (const key of Object.getOwnPropertyNames(target.prototype)) {\r\n const method = reflect(target.prototype).tryGetMethod(key)?.value;\r\n if (method && builtinMeta in method) {\r\n const metadata: BuiltinMetadata = (method as MethodWithMetadata)[builtinMeta];\r\n OperatorRegistry.registerBuiltin(metadata.name, metadata.kind, target);\r\n }\r\n }\r\n}","import { Enumerator, EnumeratorFactory, TyneqCachedSequence, TyneqSequence, TyneqOrderedSequence, Comparer } from \"../types/core\";\r\nimport { TyneqComparer } from \"./TyneqComparer\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\nimport { tyneqQueryNode } from \"../types/queryplan\";\r\nimport type { OperatorCategory, QueryPlanNode } from \"../types/queryplan\";\r\nimport { QueryNode } from \"../queryplan/QueryNode\";\r\nimport { builtin } from \"../plugin/decorators/builtin\";\r\nimport { sequence } from \"../plugin/decorators/sequence\";\r\nimport { Nullable } from \"../types/utility\";\r\n\r\n/**\r\n * Abstract base that adds `orderBy`, `orderByDescending`, `memoize`, and `pipe` to a sequence.\r\n *\r\n * @remarks\r\n * All four methods build `QueryNode`s and delegate to abstract factory methods, allowing\r\n * subclasses to control which concrete sequence types are produced.\r\n *\r\n * @internal\r\n */\r\n@sequence\r\nexport abstract class TyneqEnumerableCore<TSource> {\r\n\r\n public abstract readonly [tyneqQueryNode]: Nullable<QueryPlanNode>;\r\n\r\n public [Symbol.iterator](): Enumerator<TSource> {\r\n return this.getEnumerator();\r\n }\r\n\r\n public abstract getEnumerator(): Enumerator<TSource>;\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public orderBy<TKey>(\r\n keySelector: (item: TSource) => TKey,\r\n comparer?: Comparer<TKey>\r\n ): TyneqOrderedSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n const orderByArgs = comparer !== undefined ? [keySelector, comparer] : [keySelector];\r\n return this.createOrderedEnumerable(\r\n keySelector,\r\n comparer ?? TyneqComparer.defaultComparer,\r\n false,\r\n this.createNode(\"orderBy\", \"buffer\", orderByArgs)\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public orderByDescending<TKey>(\r\n keySelector: (item: TSource) => TKey,\r\n comparer?: Comparer<TKey>\r\n ): TyneqOrderedSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n const orderByDescArgs = comparer !== undefined ? [keySelector, comparer] : [keySelector];\r\n return this.createOrderedEnumerable(\r\n keySelector,\r\n comparer ?? TyneqComparer.defaultComparer,\r\n true,\r\n this.createNode(\"orderByDescending\", \"buffer\", orderByDescArgs)\r\n );\r\n }\r\n\r\n @builtin({ kind: \"cache\" })\r\n public memoize(): TyneqCachedSequence<TSource> {\r\n return this.createCachedEnumerable(this as unknown as TyneqSequence<TSource>, this.createNode(\"memoize\", \"buffer\"));\r\n }\r\n\r\n @builtin({ kind: \"extension\" })\r\n public pipe<TResult>(factory: (source: Iterable<TSource>) => Enumerator<TResult> | IterableIterator<TResult>): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ factory });\r\n const self = this;\r\n return this.createSequence(\r\n () => factory(self),\r\n this.createNode(\"pipe\", \"streaming\", [factory])\r\n );\r\n }\r\n\r\n /**\r\n * Helper that creates a new sequence with the provided enumerator factory and query node.\r\n * @param factory The factory function that produces an enumerator for the new sequence.\r\n * @param node The query plan node associated with the new sequence.\r\n * @returns A new TyneqSequence instance.\r\n */\r\n protected createSequence<TResult>(factory: () => Enumerator<TResult>, node: QueryPlanNode): TyneqSequence<TResult> {\r\n return this.createEnumerable({ getEnumerator: factory }, node);\r\n }\r\n\r\n /**\r\n * Helper for creating a query node with the current sequence's node as its parent.\r\n * @param name The name of the query node.\r\n * @param category The category of the operator.\r\n * @param args The arguments for the query node.\r\n * @returns A new QueryNode instance.\r\n */\r\n protected createNode(name: string, category: OperatorCategory, args: unknown[] = []): QueryNode {\r\n return new QueryNode(name, args, this[tyneqQueryNode], category);\r\n }\r\n\r\n protected abstract createEnumerable<TResult>(factory: EnumeratorFactory<TResult>, node: Nullable<QueryPlanNode>): TyneqSequence<TResult>;\r\n\r\n protected abstract createOrderedEnumerable<TKey>(\r\n keySelector: (x: TSource) => TKey,\r\n comparer: Comparer<TKey>,\r\n descending: boolean,\r\n node: Nullable<QueryPlanNode>\r\n ): TyneqOrderedSequence<TSource>;\r\n\r\n protected abstract createCachedEnumerable(source: TyneqSequence<TSource>, node: Nullable<QueryPlanNode>): TyneqCachedSequence<TSource>;\r\n}\r\n","import { Enumerable } from \"../../types/core\";\r\nimport { ArgumentUtility } from \"../../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Abstract base for all terminal operators.\r\n *\r\n * @remarks\r\n * Terminal operators consume a sequence and return a concrete value.\r\n * Subclasses implement `process()` which enumerates `this.source` and returns the result.\r\n * Register with `@terminal` or `createTerminalOperator`.\r\n *\r\n * @typeParam TSource - Element type of the source sequence.\r\n * @typeParam TResult - The return type of `process()`.\r\n * @group Plugin\r\n */\r\nexport abstract class TyneqTerminalOperator<TSource, TResult = TSource> {\r\n protected readonly source: Enumerable<TSource>;\r\n\r\n public constructor(source: Enumerable<TSource>) {\r\n ArgumentUtility.checkNotOptional({ source });\r\n this.source = source;\r\n }\r\n\r\n /** Executes the terminal operation and returns the result. */\r\n public abstract process(): TResult;\r\n}\r\n","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Applies an accumulator over the sequence and transforms the final result through a selector.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.aggregate}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class AggregateOperator<TSource, UAccumulate, VResult> extends TyneqTerminalOperator<TSource, VResult> {\r\n private readonly seed: UAccumulate;\r\n private readonly func: (accumulate: UAccumulate, item: TSource) => UAccumulate;\r\n private readonly resultSelector: (accumulate: UAccumulate) => VResult;\r\n\r\n \r\n public constructor(\r\n source: Enumerable<TSource>,\r\n seed: UAccumulate,\r\n func: (accumulate: UAccumulate, item: TSource) => UAccumulate,\r\n resultSelector: (accumulate: UAccumulate) => VResult\r\n ) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ func });\r\n ArgumentUtility.checkNotOptional({ resultSelector });\r\n\r\n this.seed = seed;\r\n this.func = func;\r\n this.resultSelector = resultSelector;\r\n }\r\n\r\n public process(): VResult {\r\n let accumulate = this.seed;\r\n for (const item of this.source) {\r\n accumulate = this.func(accumulate, item);\r\n }\r\n\r\n return this.resultSelector(accumulate);\r\n }\r\n\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { ItemPredicate } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns true if every element satisfies a predicate.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.all}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class AllOperator<T> extends TyneqTerminalOperator<T, boolean> {\r\n private readonly predicate: ItemPredicate<T>;\r\n\r\n\r\n public constructor(source: Enumerable<T>, predicate: ItemPredicate<T>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n\r\n this.predicate = predicate;\r\n }\r\n\r\n public process(): boolean {\r\n let index = 0;\r\n for (const item of this.source) {\r\n if (!this.predicate(item, index++)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { ItemPredicate } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns true if any element satisfies a predicate.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.any}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class AnyOperator<T> extends TyneqTerminalOperator<T, boolean> {\r\n private readonly predicate: ItemPredicate<T>;\r\n\r\n\r\n public constructor(source: Enumerable<T>, predicate: ItemPredicate<T>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n\r\n this.predicate = predicate;\r\n }\r\n\r\n public process(): boolean {\r\n let index = 0;\r\n for (const item of this.source) {\r\n if (this.predicate(item, index++)) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the average of all elements projected through a selector.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.average}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class AverageOperator<T> extends TyneqTerminalOperator<T, number> {\r\n private readonly selector: (item: T) => number;\r\n\r\n \r\n public constructor(source: Enumerable<T>, selector: (item: T) => number) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ selector });\r\n\r\n this.selector = selector;\r\n }\r\n\r\n public process(): number {\r\n let count = 0;\r\n let sum = 0;\r\n\r\n for (const item of this.source) {\r\n sum += this.selector(item);\r\n count++;\r\n }\r\n\r\n return count === 0 ? 0 : sum / count;\r\n }\r\n\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\n\r\n/**\r\n * Iterates the source sequence and discards all elements.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.consume}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ConsumeOperator<T> extends TyneqTerminalOperator<T, void> {\r\n public constructor(source: Enumerable<T>) {\r\n super(source);\r\n }\r\n\r\n public process(): void {\r\n for (const _ of this.source) {\r\n // intentionally consume all elements\r\n }\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqComparer } from \"../core/TyneqComparer\";\r\nimport { Enumerable, EqualityComparer } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns `true` if the source sequence contains `value`.\r\n *\r\n * @remarks\r\n * Immediate. Enumerates the source until a match is found or the sequence is exhausted.\r\n * Uses `equalityComparer` for element comparison, or `===` when omitted.\r\n * Returns `false` for an empty sequence.\r\n *\r\n * @see {@link TyneqSequence.contains}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ContainsOperator<TSource> extends TyneqTerminalOperator<TSource, boolean> {\r\n private readonly value: TSource;\r\n private readonly equalityComparer: EqualityComparer<TSource>;\r\n\r\n public constructor(source: Enumerable<TSource>, value: TSource, equalityComparer?: EqualityComparer<TSource>) {\r\n super(source);\r\n ArgumentUtility.checkNotNull({ equalityComparer });\r\n\r\n this.value = value;\r\n this.equalityComparer = equalityComparer ?? TyneqComparer.defaultEqualityComparer;\r\n }\r\n\r\n public process(): boolean {\r\n for (const item of this.source) {\r\n if (this.equalityComparer(item, this.value)) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\n\r\n/**\r\n * Returns the total number of elements in the sequence.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.count}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class CountOperator<T> extends TyneqTerminalOperator<T, number> {\r\n \r\n public constructor(source: Enumerable<T>) {\r\n super(source);\r\n }\r\n\r\n public process(): number {\r\n if (Array.isArray(this.source)) {\r\n return (this.source as T[]).length;\r\n }\r\n\r\n let count = 0;\r\n for (const _ of this.source) {\r\n count++;\r\n }\r\n\r\n return count;\r\n }\r\n\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { ItemPredicate } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the number of elements that satisfy a predicate.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.countBy}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class CountByOperator<T> extends TyneqTerminalOperator<T, number> {\r\n private readonly predicate: ItemPredicate<T>;\r\n\r\n\r\n public constructor(source: Enumerable<T>, predicate: ItemPredicate<T>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n this.predicate = predicate;\r\n }\r\n\r\n public process(): number {\r\n let count = 0;\r\n let index = 0;\r\n for (const item of this.source) {\r\n if (this.predicate(item, index++)) {\r\n count++;\r\n }\r\n }\r\n\r\n return count;\r\n }\r\n}","import { ArgumentOutOfRangeError } from \"../core/errors/argument/ArgumentOutOfRangeError\";\r\nimport { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\nimport { nameof } from \"../utility/nameof\";\r\n\r\n/**\r\n * Returns the element at a specified index, or throws if the index is out of range.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.elementAt}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ElementAtOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly index: number;\r\n\r\n \r\n public constructor(source: TyneqSequence<TSource>, index: number) {\r\n super(source);\r\n this.index = index;\r\n }\r\n\r\n public process(): TSource {\r\n const index = this.index;\r\n let currentIndex = 0;\r\n for (const element of this.source) {\r\n if (currentIndex === index) {\r\n return element;\r\n }\r\n\r\n currentIndex++;\r\n }\r\n\r\n throw new ArgumentOutOfRangeError(nameof({ index })[0]);\r\n }\r\n\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\n\r\n/**\r\n * Returns the element at a specified index, or a default value if the index is out of range.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.elementAtOrDefault}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ElementAtOrDefaultOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly index: number;\r\n private readonly defaultValue: TSource;\r\n\r\n \r\n public constructor(source: TyneqSequence<TSource>, index: number, defaultValue: TSource) {\r\n super(source);\r\n this.index = index;\r\n this.defaultValue = defaultValue;\r\n }\r\n\r\n public process(): TSource {\r\n const index = this.index;\r\n let currentIndex = 0;\r\n for (const element of this.source) {\r\n if (currentIndex === index) {\r\n return element;\r\n }\r\n\r\n currentIndex++;\r\n }\r\n\r\n return this.defaultValue;\r\n }\r\n\r\n}","import { TyneqError } from \"./TyneqError\";\r\n\r\n/**\r\n * Thrown when a method call is invalid for the current state of the object.\r\n *\r\n * @example\r\n * ```ts\r\n * try { Tyneq.from([1, 2]).single(); }\r\n * catch (e) { if (e instanceof InvalidOperationError) { ... } }\r\n * ```\r\n *\r\n * @see {@link TyneqError}\r\n * @group Errors\r\n */\r\nexport class InvalidOperationError extends TyneqError {\r\n public constructor(message = \"The operation is invalid in the current state.\", inner?: Error) {\r\n super(message, { inner });\r\n }\r\n}\r\n","import { InvalidOperationError } from \"../core/errors/InvalidOperationError\";\r\nimport { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\nimport { ItemPredicate } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the first element matching a predicate, or throws if no match is found.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.first}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class FirstOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly predicate: ItemPredicate<TSource>;\r\n\r\n\r\n public constructor(source: TyneqSequence<TSource>, predicate: ItemPredicate<TSource>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n this.predicate = predicate;\r\n }\r\n\r\n public process(): TSource {\r\n let index = 0;\r\n for (const element of this.source) {\r\n if (this.predicate(element, index++)) {\r\n return element;\r\n }\r\n }\r\n\r\n throw new InvalidOperationError(\"Sequence contains no matching element\");\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\nimport { ItemPredicate } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the first element matching a predicate, or a default value if no match is found.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.firstOrDefault}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class FirstOrDefaultOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly predicate: ItemPredicate<TSource>;\r\n private readonly defaultValue: TSource;\r\n\r\n\r\n public constructor(source: TyneqSequence<TSource>, predicate: ItemPredicate<TSource>, defaultValue: TSource) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n\r\n this.predicate = predicate;\r\n this.defaultValue = defaultValue;\r\n }\r\n\r\n public process(): TSource {\r\n let index = 0;\r\n for (const element of this.source) {\r\n if (this.predicate(element, index++)) {\r\n return element;\r\n }\r\n }\r\n\r\n return this.defaultValue;\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { ItemPredicate } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the zero-based index of the first element matching a predicate, or -1 if not found.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.indexOf}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class IndexOfOperator<T> extends TyneqTerminalOperator<T, number> {\r\n private readonly predicate: ItemPredicate<T>;\r\n private readonly startIndex: number;\r\n\r\n\r\n public constructor(source: Enumerable<T>, predicate: ItemPredicate<T>, startIndex: number = 0) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n ArgumentUtility.checkNonNegative({ startIndex });\r\n\r\n this.predicate = predicate;\r\n this.startIndex = startIndex;\r\n }\r\n\r\n public process(): number {\r\n let index = -1;\r\n for (const item of this.source) {\r\n index++;\r\n if (index < this.startIndex) {\r\n continue;\r\n }\r\n\r\n if (this.predicate(item, index)) {\r\n return index;\r\n }\r\n }\r\n\r\n return -1;\r\n }\r\n}","import { Enumerator } from \"../types/core\";\r\nimport { Optional } from \"../types/utility\";\r\n\r\n/**\r\n * Low-level helpers for working with `Enumerator<T>` objects inside custom operator enumerators.\r\n *\r\n * Import from `\"tyneq/plugin\"` when writing class-based operators that need to convert\r\n * between `Iterable<T>` and `Enumerator<T>`, or that need safe cleanup via `tryDispose`.\r\n *\r\n * @group Plugin Utilities\r\n */\r\nexport class EnumeratorUtility {\r\n private constructor() { }\r\n\r\n /**\r\n * Calls `enumerator.return()` if it exists, swallowing any error.\r\n * Safe to call on `null` or `undefined`.\r\n */\r\n public static tryDispose<TSource>(enumerator: Optional<Enumerator<TSource>>): void {\r\n try {\r\n enumerator?.return?.();\r\n } catch {\r\n // swallow\r\n }\r\n }\r\n\r\n /** Wraps an `Enumerator<T>` in a minimal `Iterable<T>` adapter (no buffering). */\r\n public static toIterable<TSource>(enumerator: Enumerator<TSource>): Iterable<TSource> {\r\n return {\r\n [Symbol.iterator]: () => enumerator\r\n };\r\n }\r\n\r\n /** Gets an `Enumerator<T>` from any `Iterable<T>`. */\r\n public static fromIterable<TSource>(iterable: Iterable<TSource>): Enumerator<TSource> {\r\n return iterable[Symbol.iterator]() as Enumerator<TSource>;\r\n }\r\n\r\n /**\r\n * Advances the enumerator by one position and returns `true` if that position was done.\r\n *\r\n * **Warning:** this calls `next()` and irrevocably consumes one element.\r\n * If the enumerator is not exhausted, the yielded element is discarded.\r\n * Only call this when advancing past the current position is intentional.\r\n */\r\n public static checkAndConsume<TSource>(enumerator: Enumerator<TSource>): boolean {\r\n return enumerator.next().done === true;\r\n }\r\n}\r\n","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { EnumeratorUtility } from \"../utility/EnumeratorUtility\";\r\n\r\n/**\r\n * Returns true if the sequence has no elements, or if its first element is null or undefined.\r\n *\r\n * @remarks\r\n * Immediate. Reads at most one element from the source (O(1) enumeration) and then disposes the iterator.\r\n *\r\n * @see {@link TyneqSequence.isNullOrEmpty}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class IsNullOrEmptyOperator<T> extends TyneqTerminalOperator<T, boolean> {\r\n public constructor(source: Enumerable<T>) {\r\n super(source);\r\n }\r\n\r\n public process(): boolean {\r\n const iterator = this.source[Symbol.iterator]();\r\n const first = iterator.next();\r\n\r\n EnumeratorUtility.tryDispose(iterator);\r\n return first.done === true || first.value === null || first.value === undefined;\r\n }\r\n}","import { InvalidOperationError } from \"../core/errors/InvalidOperationError\";\r\nimport { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\nimport { ItemPredicate, Nullable } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the last element matching a predicate, or throws if no match is found.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.last}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class LastOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly predicate: ItemPredicate<TSource>;\r\n\r\n\r\n public constructor(source: TyneqSequence<TSource>, predicate: ItemPredicate<TSource>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n\r\n this.predicate = predicate;\r\n }\r\n\r\n public process(): TSource {\r\n let lastMatchingElement: Nullable<TSource> = null;\r\n let found = false;\r\n let index = 0;\r\n\r\n for (const element of this.source) {\r\n if (this.predicate(element, index++)) {\r\n lastMatchingElement = element;\r\n found = true;\r\n }\r\n }\r\n\r\n if (!found) {\r\n throw new InvalidOperationError(\"Sequence contains no matching element\");\r\n }\r\n\r\n return lastMatchingElement as TSource;\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\nimport { ItemPredicate, Nullable } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the last element matching a predicate, or a default value if no match is found.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.lastOrDefault}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class LastOrDefaultOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly predicate: ItemPredicate<TSource>;\r\n private readonly defaultValue: TSource;\r\n\r\n\r\n public constructor(source: TyneqSequence<TSource>, predicate: ItemPredicate<TSource>, defaultValue: TSource) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n\r\n this.predicate = predicate;\r\n this.defaultValue = defaultValue;\r\n }\r\n\r\n public process(): TSource {\r\n let lastMatchingElement: Nullable<TSource> = null;\r\n let found = false;\r\n let index = 0;\r\n\r\n for (const element of this.source) {\r\n if (this.predicate(element, index++)) {\r\n lastMatchingElement = element;\r\n found = true;\r\n }\r\n }\r\n\r\n if (!found) {\r\n return this.defaultValue;\r\n }\r\n\r\n return lastMatchingElement as TSource;\r\n }\r\n}","import { InvalidOperationError } from \"./InvalidOperationError\";\r\nimport type { Maybe } from \"../../types/utility\";\r\n\r\n/**\r\n * Thrown when an element is required from a sequence that contains no elements.\r\n *\r\n * @example\r\n * ```ts\r\n * try { Tyneq.from([]).first(); }\r\n * catch (e) { if (e instanceof SequenceContainsNoElementsError) { ... } }\r\n * ```\r\n *\r\n * @see {@link InvalidOperationError}\r\n * @group Errors\r\n */\r\nexport class SequenceContainsNoElementsError extends InvalidOperationError {\r\n public readonly operatorName: Maybe<string>;\r\n\r\n public constructor(operatorName?: string, inner?: Error) {\r\n const message = operatorName\r\n ? `Sequence contains no elements (in \"${operatorName}\").`\r\n : \"Sequence contains no elements.\";\r\n super(message, inner);\r\n this.operatorName = operatorName;\r\n }\r\n}\r\n","import { SequenceContainsNoElementsError } from \"../core/errors/SequenceContainsNoElementsError\";\r\nimport { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqComparer } from \"../core/TyneqComparer\";\r\nimport { TyneqSequence, Comparer } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\nimport { Nullable } from \"../types/utility\";\r\n\r\n/**\r\n * Comparison direction for extremum operators.\r\n *\r\n * - `1` selects the maximum (comparer result > 0 means replacement).\r\n * - `-1` selects the minimum (comparer result < 0 means replacement).\r\n *\r\n * @internal\r\n */\r\ntype ExtremumDirection = 1 | -1;\r\n\r\n/**\r\n * Returns the minimum or maximum element in the sequence using a comparer.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n * Parameterised by direction to avoid duplicating the iteration logic\r\n * across separate min and max operators.\r\n *\r\n * @see {@link TyneqSequence.min}\r\n * @see {@link TyneqSequence.max}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ExtremumOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly comparer: Comparer<TSource>;\r\n private readonly direction: ExtremumDirection;\r\n private readonly operatorName: string;\r\n\r\n public constructor(\r\n source: TyneqSequence<TSource>,\r\n direction: ExtremumDirection,\r\n operatorName: string,\r\n comparer?: Comparer<TSource>\r\n ) {\r\n super(source);\r\n this.comparer = comparer ?? TyneqComparer.defaultComparer;\r\n this.direction = direction;\r\n this.operatorName = operatorName;\r\n }\r\n\r\n public process(): TSource {\r\n let best: Nullable<TSource> = null;\r\n let hasElement = false;\r\n\r\n for (const element of this.source) {\r\n if (!hasElement || this.comparer(element, best!) * this.direction > 0) {\r\n best = element;\r\n hasElement = true;\r\n }\r\n }\r\n\r\n if (!hasElement) {\r\n throw new SequenceContainsNoElementsError(this.operatorName);\r\n }\r\n\r\n return best as TSource;\r\n }\r\n}\r\n\r\n/**\r\n * Returns the element with the minimum or maximum key as determined by a key selector.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n * Parameterised by direction to avoid duplicating the iteration logic\r\n * across separate minBy and maxBy operators.\r\n *\r\n * @see {@link TyneqSequence.minBy}\r\n * @see {@link TyneqSequence.maxBy}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ExtremumByOperator<TSource, TKey> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly comparer: Comparer<TKey>;\r\n private readonly keySelector: (element: TSource) => TKey;\r\n private readonly direction: ExtremumDirection;\r\n private readonly operatorName: string;\r\n\r\n public constructor(\r\n source: TyneqSequence<TSource>,\r\n keySelector: (element: TSource) => TKey,\r\n direction: ExtremumDirection,\r\n operatorName: string,\r\n comparer?: Comparer<TKey>\r\n ) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n this.comparer = comparer ?? TyneqComparer.defaultComparer;\r\n this.keySelector = keySelector;\r\n this.direction = direction;\r\n this.operatorName = operatorName;\r\n }\r\n\r\n public process(): TSource {\r\n let bestElement: Nullable<TSource> = null;\r\n let bestKey: Nullable<TKey> = null;\r\n let hasElement = false;\r\n\r\n for (const element of this.source) {\r\n const key = this.keySelector(element);\r\n if (!hasElement || this.comparer(key, bestKey!) * this.direction > 0) {\r\n bestElement = element;\r\n bestKey = key;\r\n hasElement = true;\r\n }\r\n }\r\n\r\n if (!hasElement) {\r\n throw new SequenceContainsNoElementsError(this.operatorName);\r\n }\r\n\r\n return bestElement as TSource;\r\n }\r\n}\r\n","import { Enumerable, MinMaxResult, Comparer } from \"../types/core\";\r\nimport { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { SequenceContainsNoElementsError } from \"../core/errors/SequenceContainsNoElementsError\";\r\nimport { TyneqComparer } from \"../core/TyneqComparer\";\r\nimport { Maybe } from \"../types/utility\";\r\n\r\n// MinMaxResult is defined in types/core.ts to avoid a circular dependency.\r\n// Re-export it from there so consumers can import it from either location.\r\nexport type { MinMaxResult } from \"../types/core\";\r\n\r\n/**\r\n * Returns both the minimum and maximum elements of the sequence in a single pass.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.minMax}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class MinMaxOperator<T> extends TyneqTerminalOperator<T, MinMaxResult<T>> {\r\n\r\n private readonly comparer: Comparer<T>;\r\n\r\n\r\n public constructor(source: Enumerable<T>, comparer?: Comparer<T>) {\r\n super(source);\r\n this.comparer = comparer ?? TyneqComparer.defaultComparer;\r\n }\r\n\r\n public override process(): MinMaxResult<T> {\r\n let min: Maybe<T>;\r\n let max: Maybe<T>;\r\n let hasElements = false;\r\n\r\n for (const item of this.source) {\r\n if (!hasElements) {\r\n min = item;\r\n max = item;\r\n hasElements = true;\r\n } else {\r\n if (this.comparer(item, min as T) < 0) min = item;\r\n if (this.comparer(item, max as T) > 0) max = item;\r\n }\r\n }\r\n\r\n if (!hasElements) {\r\n throw new SequenceContainsNoElementsError(\"minMax\");\r\n }\r\n\r\n return { min: min as T, max: max as T };\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqComparer } from \"../core/TyneqComparer\";\r\nimport { TyneqSequence, EqualityComparer } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns true if the source and a second sequence contain equal elements in the same order.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.sequenceEqual}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class SequenceEqualOperator<TSource> extends TyneqTerminalOperator<TSource, boolean> {\r\n private readonly other: Iterable<TSource>;\r\n private readonly equalityComparer: EqualityComparer<TSource>;\r\n\r\n\r\n public constructor(source: TyneqSequence<TSource>, other: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ other });\r\n ArgumentUtility.checkNotNull({ equalityComparer });\r\n\r\n this.equalityComparer = equalityComparer ?? TyneqComparer.defaultEqualityComparer;\r\n this.other = other;\r\n }\r\n\r\n public process(): boolean {\r\n const sourceIterator = this.source[Symbol.iterator]();\r\n const otherIterator = this.other[Symbol.iterator]();\r\n\r\n while (true) {\r\n const sourceNext = sourceIterator.next();\r\n const otherNext = otherIterator.next();\r\n\r\n if (sourceNext.done && otherNext.done) {\r\n break;\r\n }\r\n\r\n if (sourceNext.done !== otherNext.done) {\r\n return false;\r\n }\r\n\r\n if (!this.equalityComparer(sourceNext.value, otherNext.value)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}","import { InvalidOperationError } from \"../core/errors/InvalidOperationError\";\r\nimport { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\nimport { ItemPredicate, Nullable } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the single element matching a predicate, or throws if there is not exactly one match.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.single}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class SingleOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly predicate: ItemPredicate<TSource>;\r\n\r\n\r\n public constructor(source: TyneqSequence<TSource>, predicate: ItemPredicate<TSource>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n\r\n this.predicate = predicate;\r\n }\r\n\r\n public process(): TSource {\r\n let found = false;\r\n let single: Nullable<TSource> = null;\r\n let index = 0;\r\n for (const element of this.source) {\r\n if (this.predicate(element, index++)) {\r\n if (found) {\r\n throw new InvalidOperationError(\"Sequence contains more than one matching element\");\r\n }\r\n\r\n found = true;\r\n single = element;\r\n }\r\n }\r\n\r\n if (!found) {\r\n throw new InvalidOperationError(\"Sequence contains no matching element\");\r\n }\r\n\r\n return single as TSource;\r\n }\r\n}","import { InvalidOperationError } from \"../core/errors/InvalidOperationError\";\r\nimport { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\nimport { ItemPredicate, Nullable } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the single element matching a predicate, or a default value if no match is found.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.singleOrDefault}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class SingleOrDefaultOperator<TSource> extends TyneqTerminalOperator<TSource, TSource> {\r\n private readonly predicate: ItemPredicate<TSource>;\r\n private readonly defaultValue: TSource;\r\n\r\n\r\n public constructor(source: TyneqSequence<TSource>, predicate: ItemPredicate<TSource>, defaultValue: TSource) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n\r\n this.predicate = predicate;\r\n this.defaultValue = defaultValue;\r\n }\r\n\r\n public process(): TSource {\r\n let found = false;\r\n let single: Nullable<TSource> = null;\r\n let index = 0;\r\n for (const element of this.source) {\r\n if (this.predicate(element, index++)) {\r\n if (found) {\r\n throw new InvalidOperationError(\"Sequence contains more than one matching element\");\r\n }\r\n\r\n found = true;\r\n single = element;\r\n }\r\n }\r\n\r\n if (!found) {\r\n return this.defaultValue;\r\n }\r\n\r\n return single as TSource;\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqComparer } from \"../core/TyneqComparer\";\r\nimport { Enumerable, EqualityComparer } from \"../types/core\";\r\nimport { Nullable } from \"../types/utility\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns `true` if the source sequence ends with all elements of `sequence` in order.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n * Uses `equalityComparer` for element comparison, or `===` when omitted.\r\n * Returns `true` when `sequence` is empty (vacuous truth).\r\n * Returns `false` when `sequence` is longer than the source.\r\n *\r\n * @see {@link TyneqSequence.endsWith}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\ntype CircularBufferResult<T> = { buffer: T[], readIndex: number };\r\n\r\nexport class EndsWithOperator<T> extends TyneqTerminalOperator<T, boolean> {\r\n private readonly sequence: Iterable<T>;\r\n private readonly equalityComparer: EqualityComparer<T>;\r\n\r\n public constructor(source: Enumerable<T>, sequence: Iterable<T>, equalityComparer?: EqualityComparer<T>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ sequence });\r\n ArgumentUtility.checkIterable({ sequence });\r\n ArgumentUtility.checkNotNull({ equalityComparer });\r\n\r\n this.sequence = sequence;\r\n this.equalityComparer = equalityComparer ?? TyneqComparer.defaultEqualityComparer;\r\n }\r\n\r\n public process(): boolean {\r\n const suffixElements = Array.from(this.sequence);\r\n\r\n if (suffixElements.length === 0) {\r\n return true;\r\n }\r\n\r\n const bufferResult = this.fillCircularBuffer(this.source, suffixElements.length);\r\n\r\n if (bufferResult === null) {\r\n return false;\r\n }\r\n\r\n const { buffer, readIndex } = bufferResult;\r\n\r\n for (let i = 0; i < suffixElements.length; i++) {\r\n if (!this.equalityComparer(buffer[(readIndex + i) % buffer.length], suffixElements[i])) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private fillCircularBuffer(elements: Iterable<T>, windowSize: number): Nullable<CircularBufferResult<T>> {\r\n const buffer: T[] = new Array(windowSize);\r\n let writeIndex = 0;\r\n\r\n for (const item of elements) {\r\n buffer[writeIndex % windowSize] = item;\r\n writeIndex++;\r\n }\r\n\r\n // Source shorter than the requested window - suffix cannot match\r\n if (writeIndex < windowSize) {\r\n return null;\r\n }\r\n\r\n return { buffer, readIndex: writeIndex % windowSize };\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqComparer } from \"../core/TyneqComparer\";\r\nimport { Enumerable, EqualityComparer } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns `true` if the source sequence begins with all elements of `sequence` in order.\r\n *\r\n * @remarks\r\n * Immediate. Enumerates the source only until the result is determined.\r\n * Uses `equalityComparer` for element comparison, or `===` when omitted.\r\n * Returns `true` when `sequence` is empty (vacuous truth).\r\n * Returns `false` when `sequence` is longer than the source.\r\n *\r\n * @see {@link TyneqSequence.startsWith}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class StartsWithOperator<T> extends TyneqTerminalOperator<T, boolean> {\r\n private readonly sequence: Iterable<T>;\r\n private readonly equalityComparer: EqualityComparer<T>;\r\n\r\n public constructor(source: Enumerable<T>, sequence: Iterable<T>, equalityComparer?: EqualityComparer<T>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ sequence });\r\n ArgumentUtility.checkIterable({ sequence });\r\n ArgumentUtility.checkNotNull({ equalityComparer });\r\n\r\n this.sequence = sequence;\r\n this.equalityComparer = equalityComparer ?? TyneqComparer.defaultEqualityComparer;\r\n }\r\n\r\n public process(): boolean {\r\n const sourceEnumerator = this.source[Symbol.iterator]();\r\n const sequenceEnumerator = this.sequence[Symbol.iterator]();\r\n\r\n while (true) {\r\n const { value: sourceValue, done: sourceDone } = sourceEnumerator.next();\r\n const { value: sequenceValue, done: sequenceDone } = sequenceEnumerator.next();\r\n\r\n if (sequenceDone) {\r\n return true;\r\n }\r\n\r\n if (sourceDone || !this.equalityComparer(sourceValue, sequenceValue)) {\r\n return false;\r\n }\r\n }\r\n }\r\n}\r\n","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { Enumerable } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Returns the sum of all elements projected through a selector.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.sum}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class SumOperator<T> extends TyneqTerminalOperator<T, number> {\r\n private readonly selector: (item: T) => number;\r\n\r\n \r\n public constructor(source: Enumerable<T>, selector: (item: T) => number) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ selector });\r\n\r\n this.selector = selector;\r\n }\r\n\r\n public process(): number {\r\n let sum = 0;\r\n\r\n for (const item of this.source) {\r\n sum += this.selector(item);\r\n }\r\n\r\n return sum;\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\n\r\n/**\r\n * Collects all elements into an array.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.toArray}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ToArrayOperator<TSource> extends TyneqTerminalOperator<TSource, TSource[]> {\r\n \r\n public constructor(source: TyneqSequence<TSource>) {\r\n super(source);\r\n }\r\n\r\n public process(): TSource[] {\r\n return Array.from(this.source);\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\n\r\n/**\r\n * Wraps the source sequence as an async iterable.\r\n *\r\n * @remarks\r\n * Deferred. The source is enumerated lazily as the returned async iterable is iterated.\r\n *\r\n * @see {@link TyneqSequence.toAsync}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ToAsyncOperator<TSource> extends TyneqTerminalOperator<TSource, AsyncIterable<TSource>> {\r\n \r\n public constructor(source: TyneqSequence<TSource>) {\r\n super(source);\r\n }\r\n\r\n public process(): AsyncIterable<TSource> {\r\n const source = this.source;\r\n return {\r\n async *[Symbol.asyncIterator]() {\r\n for (const item of source) {\r\n yield item;\r\n }\r\n }\r\n };\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence, KeyValuePair } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Collects all elements into a Map using a key-value selector.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.toMap}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ToMapOperator<TSource, TKey, TValue> extends TyneqTerminalOperator<TSource, Map<TKey, TValue>> {\r\n private readonly selector: (item: TSource) => KeyValuePair<TKey, TValue>;\r\n\r\n \r\n public constructor(source: TyneqSequence<TSource>, selector: (item: TSource) => KeyValuePair<TKey, TValue>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ selector });\r\n\r\n this.selector = selector;\r\n }\r\n\r\n public process(): Map<TKey, TValue> {\r\n return new Map<TKey, TValue>(Array.from(this.source, (item) => {\r\n const pair: KeyValuePair<TKey, TValue> = this.selector(item);\r\n return this.transformPairToTuple(pair);\r\n }));\r\n }\r\n\r\n private transformPairToTuple(pair: KeyValuePair<TKey, TValue>): [TKey, TValue] {\r\n return [pair.key, pair.value];\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence, KeyValuePair } from \"../types/core\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Collects all elements into a plain object record using a key-value selector.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.toRecord}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ToRecordOperator<TSource, TKey extends string | number | symbol, TValue> extends TyneqTerminalOperator<TSource, Record<TKey, TValue>> {\r\n private readonly selector: (item: TSource) => KeyValuePair<TKey, TValue>;\r\n\r\n \r\n public constructor(source: TyneqSequence<TSource>, selector: (item: TSource) => KeyValuePair<TKey, TValue>) {\r\n super(source);\r\n ArgumentUtility.checkNotOptional({ selector });\r\n\r\n this.selector = selector;\r\n }\r\n\r\n public process(): Record<TKey, TValue> {\r\n const result = {} as Record<TKey, TValue>;\r\n\r\n for (const item of this.source) {\r\n const pair = this.selector(item);\r\n result[pair.key] = pair.value;\r\n }\r\n\r\n return result;\r\n }\r\n}","import { TyneqTerminalOperator } from \"../core/terminal/TyneqTerminalOperator\";\r\nimport { TyneqSequence } from \"../types/core\";\r\n\r\n/**\r\n * Collects all elements into a Set.\r\n *\r\n * @remarks\r\n * Immediate. Source is fully enumerated when this method is called.\r\n *\r\n * @see {@link TyneqSequence.toSet}\r\n * @group Operators\r\n * @category Terminal\r\n * @internal\r\n */\r\nexport class ToSetOperator<TSource> extends TyneqTerminalOperator<TSource, Set<TSource>> {\r\n \r\n public constructor(source: TyneqSequence<TSource>) {\r\n super(source);\r\n }\r\n\r\n public process(): Set<TSource> {\r\n return new Set(this.source);\r\n }\r\n}","import { Enumerator } from \"../../types/core\";\r\nimport { ArgumentUtility } from \"../../utility/ArgumentUtility\";\r\nimport { EnumeratorUtility } from \"../../utility/EnumeratorUtility\";\r\nimport { TyneqBaseEnumerator } from \"./TyneqBaseEnumerator\";\r\n\r\n/**\r\n * Base class for all pipeline operator enumerators (streaming and buffering).\r\n *\r\n * @remarks\r\n * Extends {@link TyneqBaseEnumerator} with a typed source enumerator.\r\n * Override `initialize()` to buffer or prepare state before the first `handleNext()`.\r\n * Override `disposeAdditional()` to release resources beyond the source enumerator.\r\n *\r\n * @typeParam TInput - Source element type.\r\n * @typeParam TOutput - Output element type (defaults to `TInput`).\r\n * @group Plugin\r\n */\r\nexport abstract class TyneqEnumerator<TInput, TOutput = TInput> extends TyneqBaseEnumerator<TInput, TOutput> {\r\n protected readonly sourceEnumerator: Enumerator<TInput>;\r\n private sourceDisposed = false;\r\n\r\n public constructor(sourceEnumerator: Enumerator<TInput>) {\r\n super();\r\n ArgumentUtility.checkNotOptional({ sourceEnumerator });\r\n\r\n this.sourceEnumerator = sourceEnumerator;\r\n }\r\n\r\n protected override disposeSource(): void {\r\n if (this.sourceDisposed) {\r\n return;\r\n }\r\n\r\n this.sourceDisposed = true;\r\n EnumeratorUtility.tryDispose(this.sourceEnumerator);\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Appends a single element to the end of the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.append}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class AppendEnumerator<T> extends TyneqEnumerator<T> {\r\n private isSourceDone = false;\r\n private appended = false;\r\n private readonly item: T;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, item: T) {\r\n super(sourceEnumerator);\r\n this.item = item;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (!this.isSourceDone) {\r\n const sourceNext = this.sourceEnumerator.next();\r\n if (!sourceNext.done) {\r\n return this.yield(sourceNext.value);\r\n }\r\n\r\n this.isSourceDone = true;\r\n }\r\n\r\n if (!this.appended) {\r\n this.appended = true;\r\n return this.yield(this.item);\r\n }\r\n\r\n return this.done();\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Splits the source sequence into non-overlapping chunks of a fixed size.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.chunk}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class ChunkEnumerator<T> extends TyneqEnumerator<T, T[]> {\r\n private readonly size: number;\r\n private currentChunk: T[] = [];\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, size: number) {\r\n super(sourceEnumerator);\r\n this.size = size;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T[]> {\r\n while (this.currentChunk.length < this.size) {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) break;\r\n\r\n this.currentChunk.push(next.value);\r\n }\r\n\r\n if (this.currentChunk.length === 0) {\r\n return this.done();\r\n }\r\n\r\n const chunk = this.currentChunk;\r\n this.currentChunk = [];\r\n return this.yield(chunk);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { EnumeratorUtility } from \"../../utility/EnumeratorUtility\";\r\n\r\n/**\r\n * Concatenates a second sequence after the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.concat}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class ConcatEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly otherEnumerator: Enumerator<T>;\r\n private isSourceDone = false;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, other: Iterable<T>) {\r\n super(sourceEnumerator);\r\n this.otherEnumerator = other[Symbol.iterator]();\r\n }\r\n\r\n protected override disposeAdditional(): void {\r\n EnumeratorUtility.tryDispose(this.otherEnumerator);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (!this.isSourceDone) {\r\n const next = this.sourceEnumerator.next();\r\n if (!next.done) {\r\n return this.yield(next.value);\r\n }\r\n\r\n this.isSourceDone = true;\r\n }\r\n\r\n const next = this.otherEnumerator.next();\r\n if (!next.done) {\r\n return this.yield(next.value);\r\n }\r\n\r\n return this.done();\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { Nullable } from \"../../types/utility\";\r\n\r\n/**\r\n * Flattens one level of nesting from a sequence of iterables.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n * Each inner iterable is consumed lazily as the outer sequence advances.\r\n *\r\n * @see {@link TyneqSequence.flatten}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class FlattenEnumerator<TInner> extends TyneqEnumerator<Iterable<TInner>, TInner> {\r\n private innerEnumerator: Nullable<Enumerator<TInner>> = null;\r\n\r\n public constructor(sourceEnumerator: Enumerator<Iterable<TInner>>) {\r\n super(sourceEnumerator);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TInner> {\r\n while (true) {\r\n if (this.innerEnumerator !== null) {\r\n const innerNext = this.innerEnumerator.next();\r\n if (!innerNext.done) {\r\n return this.yield(innerNext.value);\r\n }\r\n\r\n this.innerEnumerator = null;\r\n }\r\n\r\n const sourceNext = this.sourceEnumerator.next();\r\n if (sourceNext.done) {\r\n return this.done();\r\n }\r\n\r\n this.innerEnumerator = sourceNext.value[Symbol.iterator]();\r\n }\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns the source sequence, or a single default element if the source is empty.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.defaultIfEmpty}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class DefaultIfEmptyEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private readonly defaultValue: TSource;\r\n private sourceDone = false;\r\n private hasYieldedAny = false;\r\n private defaultYielded = false;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, defaultValue: TSource) {\r\n super(sourceEnumerator);\r\n this.defaultValue = defaultValue;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n if (!this.sourceDone) {\r\n const next = this.sourceEnumerator.next();\r\n if (!next.done) {\r\n this.hasYieldedAny = true;\r\n return this.yield(next.value);\r\n }\r\n\r\n this.sourceDone = true;\r\n }\r\n\r\n if (!this.hasYieldedAny && !this.defaultYielded) {\r\n this.defaultYielded = true;\r\n return this.doneWithYield(this.defaultValue);\r\n }\r\n\r\n return this.done();\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Filters elements to only those matching a type guard.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.ofType}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class OfTypeEnumerator<T, U extends T> extends TyneqEnumerator<T, U> {\r\n private readonly guard: (value: T) => value is U;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, guard: (value: T) => value is U) {\r\n super(sourceEnumerator);\r\n this.guard = guard;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<U> {\r\n while (true) {\r\n const { value, done } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n if (this.guard(value)) {\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Projects each consecutive pair of elements as a two-element tuple.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.pairwise}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class PairwiseEnumerator<T> extends TyneqEnumerator<T, [T, T]> {\r\n private hasPrevious = false;\r\n private previous!: T;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>) {\r\n super(sourceEnumerator);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<[T, T]> {\r\n while (true) {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n if (!this.hasPrevious) {\r\n this.previous = next.value;\r\n this.hasPrevious = true;\r\n continue;\r\n }\r\n\r\n const pair: [T, T] = [this.previous, next.value];\r\n this.previous = next.value;\r\n return this.yield(pair);\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Replaces every element in the source with a fixed value.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.populate}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class PopulateEnumerator<TSource, TValue> extends TyneqEnumerator<TSource, TValue> {\r\n private readonly value: TValue;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, value: TValue) {\r\n super(sourceEnumerator);\r\n this.value = value;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TValue> {\r\n while (true) {\r\n const { done } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n return this.yield(this.value);\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Prepends a single element to the beginning of the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.prepend}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class PrependEnumerator<T> extends TyneqEnumerator<T> {\r\n private prepended = false;\r\n private readonly item: T;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, item: T) {\r\n super(sourceEnumerator);\r\n this.item = item;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (!this.prepended) {\r\n this.prepended = true;\r\n return this.yield(this.item);\r\n }\r\n\r\n const nextItem = this.sourceEnumerator.next();\r\n if (!nextItem.done) {\r\n return this.yield(nextItem.value);\r\n }\r\n\r\n return this.done();\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Applies an accumulator function and yields the running result after each element.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.scan}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class ScanEnumerator<TSource, TResult> extends TyneqEnumerator<TSource, TResult> {\r\n private readonly accumulator: (acc: TResult, item: TSource) => TResult;\r\n private current: TResult;\r\n\r\n \r\n public constructor(\r\n sourceEnumerator: Enumerator<TSource>,\r\n seed: TResult,\r\n accumulator: (acc: TResult, item: TSource) => TResult\r\n ) {\r\n super(sourceEnumerator);\r\n this.current = seed;\r\n this.accumulator = accumulator;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TResult> {\r\n const { value, done } = this.sourceEnumerator.next();\r\n\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n this.current = this.accumulator(this.current, value);\r\n return this.yield(this.current);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemSelector } from \"../../types/utility\";\r\n\r\n/**\r\n * Projects each element through a selector.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.select}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SelectEnumerator<T, U> extends TyneqEnumerator<T, U> {\r\n private readonly selector: ItemSelector<T, U>;\r\n private index: number = 0;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, selector: ItemSelector<T, U>) {\r\n super(sourceEnumerator);\r\n this.selector = selector;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<U> {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n return this.yield(this.selector(next.value, this.index++));\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { Nullable } from \"../../types/utility\";\r\n\r\n/**\r\n * Flattens each element into a sub-sequence and yields each element of those sub-sequences.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.selectMany}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SelectManyEnumerator<T, U> extends TyneqEnumerator<T, U> {\r\n private readonly selector: (item: T) => Iterable<U>;\r\n private innerEnumerator: Nullable<Enumerator<U>> = null;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, selector: (item: T) => Iterable<U>) {\r\n super(sourceEnumerator);\r\n this.selector = selector;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<U> {\r\n while (true) {\r\n if (this.innerEnumerator !== null) {\r\n const innerNext = this.innerEnumerator.next();\r\n if (!innerNext.done) {\r\n return this.yield(innerNext.value);\r\n }\r\n\r\n this.innerEnumerator = null;\r\n }\r\n\r\n const sourceNext = this.sourceEnumerator.next();\r\n if (sourceNext.done) {\r\n return this.done();\r\n }\r\n\r\n this.innerEnumerator = this.selector(sourceNext.value)[Symbol.iterator]();\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator, Enumerable } from \"../../types/core\";\r\nimport { EnumeratorUtility } from \"../../utility/EnumeratorUtility\";\r\n\r\n/**\r\n * Repeats the source sequence a specified number of times.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n * Re-enumerates the source from the beginning for each repetition.\r\n * Returns an empty sequence when `count` is 0.\r\n *\r\n * @see {@link TyneqSequence.repeat}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class RepeatSequenceEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly source: Enumerable<T>;\r\n private readonly count: number;\r\n private repetition = 0;\r\n private currentEnumerator: Enumerator<T>;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, source: Enumerable<T>, count: number) {\r\n super(sourceEnumerator);\r\n this.source = source;\r\n this.count = count;\r\n this.currentEnumerator = sourceEnumerator;\r\n }\r\n\r\n protected override disposeAdditional(): void {\r\n if (this.currentEnumerator !== this.sourceEnumerator) {\r\n EnumeratorUtility.tryDispose(this.currentEnumerator);\r\n }\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n while (this.repetition < this.count) {\r\n const next = this.currentEnumerator.next();\r\n if (!next.done) {\r\n return this.yield(next.value);\r\n }\r\n\r\n this.repetition++;\r\n\r\n if (this.repetition < this.count) {\r\n const fresh = this.source[Symbol.iterator]();\r\n const probe = fresh.next();\r\n if (probe.done) {\r\n // Source is empty; all remaining repetitions will also be empty.\r\n this.repetition = this.count;\r\n return this.done();\r\n }\r\n\r\n this.currentEnumerator = fresh;\r\n return this.yield(probe.value);\r\n }\r\n }\r\n\r\n return this.done();\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Skips a specified number of elements from the beginning of the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.skip}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SkipEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly count: number;\r\n private skipped = false;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, count: number) {\r\n super(sourceEnumerator);\r\n this.count = count;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (!this.skipped) {\r\n let skippedCount = 0;\r\n while (skippedCount < this.count) {\r\n const sourceNext = this.sourceEnumerator.next();\r\n if (sourceNext.done) {\r\n return this.done();\r\n }\r\n\r\n skippedCount++;\r\n }\r\n\r\n this.skipped = true;\r\n }\r\n\r\n const sourceNext = this.sourceEnumerator.next();\r\n if (sourceNext.done) {\r\n return this.done();\r\n }\r\n\r\n return this.yield(sourceNext.value);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Skips a specified number of elements from the end of the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.skipLast}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SkipLastEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly count: number;\r\n private readonly buffer: T[];\r\n private writeIndex: number = 0;\r\n private filledCount: number = 0;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, count: number) {\r\n super(sourceEnumerator);\r\n this.count = count;\r\n this.buffer = new Array<T>(this.count);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (this.count === 0) {\r\n const current = this.sourceEnumerator.next();\r\n if (current.done) {\r\n return this.done();\r\n } else {\r\n return this.yield(current.value);\r\n }\r\n }\r\n\r\n while (true) {\r\n const current = this.sourceEnumerator.next();\r\n if (current.done) {\r\n return this.done();\r\n }\r\n\r\n if (this.filledCount < this.count) {\r\n this.buffer[this.writeIndex] = current.value;\r\n this.writeIndex = (this.writeIndex + 1) % this.count;\r\n this.filledCount++;\r\n continue;\r\n }\r\n\r\n const oldest = this.buffer[this.writeIndex];\r\n this.buffer[this.writeIndex] = current.value;\r\n this.writeIndex = (this.writeIndex + 1) % this.count;\r\n return this.yield(oldest);\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemPredicate } from \"../../types/utility\";\r\n\r\n/**\r\n * Skips elements from the beginning of the source sequence until a predicate returns `true`,\r\n * then yields all remaining elements including the one that triggered the predicate.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.skipUntil}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SkipUntilEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly predicate: ItemPredicate<T>;\r\n private index = 0;\r\n private triggered = false;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, predicate: ItemPredicate<T>) {\r\n super(sourceEnumerator);\r\n this.predicate = predicate;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n while (true) {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n if (!this.triggered) {\r\n this.triggered = this.predicate(next.value, this.index++);\r\n }\r\n\r\n if (this.triggered) {\r\n return this.yield(next.value);\r\n }\r\n }\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemPredicate } from \"../../types/utility\";\r\n\r\n/**\r\n * Skips elements from the beginning of the source sequence as long as a predicate is true.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.skipWhile}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SkipWhileEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly predicate: ItemPredicate<T>;\r\n private index: number = 0;\r\n private isSkipping = true;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, predicate: ItemPredicate<T>) {\r\n super(sourceEnumerator);\r\n this.predicate = predicate;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n while (true) {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n this.isSkipping = this.isSkipping && this.predicate(next.value, this.index++);\r\n if (!this.isSkipping) {\r\n return this.yield(next.value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Yields elements between a start index (inclusive) and an end index (exclusive).\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.slice}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SliceEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly start: number;\r\n private readonly end: number;\r\n private index = 0;\r\n private started = false;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, start: number, end: number) {\r\n super(sourceEnumerator);\r\n this.start = start;\r\n this.end = end;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (!this.started) {\r\n this.started = true;\r\n while (this.index < this.start) {\r\n if (this.sourceEnumerator.next().done) {\r\n return this.done();\r\n }\r\n\r\n this.index++;\r\n }\r\n }\r\n\r\n if (this.index >= this.end) {\r\n return this.earlyComplete();\r\n }\r\n\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n this.index++;\r\n return this.yield(next.value);\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Splits the source sequence into sub-arrays at each element matching a predicate.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.split}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class SplitEnumerator<TSource> extends TyneqEnumerator<TSource, TSource[]> {\r\n private readonly splitOn: (item: TSource) => boolean;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, splitOn: (item: TSource) => boolean) {\r\n super(sourceEnumerator);\r\n this.splitOn = splitOn;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource[]> {\r\n const currentSplit: TSource[] = [];\r\n\r\n while (true) {\r\n const { value, done } = this.sourceEnumerator.next();\r\n if (done) {\r\n if (currentSplit.length > 0) {\r\n return this.doneWithYield(currentSplit);\r\n }\r\n\r\n return this.done();\r\n }\r\n\r\n if (this.splitOn(value)) {\r\n if (currentSplit.length > 0) {\r\n return this.yield(currentSplit);\r\n }\r\n } else {\r\n currentSplit.push(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns a specified number of elements from the beginning of the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.take}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class TakeEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly count: number;\r\n private takenCount = 0;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, count: number) {\r\n super(sourceEnumerator);\r\n this.count = count;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (this.takenCount >= this.count) {\r\n return this.earlyComplete();\r\n }\r\n\r\n const result = this.sourceEnumerator.next();\r\n if (result.done) {\r\n return this.done();\r\n }\r\n\r\n this.takenCount++;\r\n return this.yield(result.value);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemPredicate } from \"../../types/utility\";\r\n\r\n/**\r\n * Yields elements from the beginning of the source sequence until a predicate returns `true`,\r\n * then stops. The element that triggered the predicate is not included.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.takeUntil}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class TakeUntilEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly predicate: ItemPredicate<T>;\r\n private index = 0;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, predicate: ItemPredicate<T>) {\r\n super(sourceEnumerator);\r\n this.predicate = predicate;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n if (this.predicate(next.value, this.index++)) {\r\n return this.earlyComplete();\r\n }\r\n\r\n return this.yield(next.value);\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemPredicate } from \"../../types/utility\";\r\n\r\n/**\r\n * Yields elements from the beginning of the source sequence as long as a predicate is true.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.takeWhile}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class TakeWhileEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly predicate: ItemPredicate<T>;\r\n private index: number = 0;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, predicate: ItemPredicate<T>) {\r\n super(sourceEnumerator);\r\n this.predicate = predicate;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n const result = this.sourceEnumerator.next();\r\n if (result.done) {\r\n return this.done();\r\n }\r\n\r\n if (this.predicate(result.value, this.index++)) {\r\n return this.yield(result.value);\r\n }\r\n\r\n return this.earlyComplete();\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemAction } from \"../../types/utility\";\r\n\r\n/**\r\n * Invokes a side-effect action for each element without modifying the sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.tap}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class TapEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private readonly action: ItemAction<TSource>;\r\n private index: number = 0;\r\n\r\n public constructor(sourceEnumerator: Enumerator<TSource>, action: ItemAction<TSource>) {\r\n super(sourceEnumerator);\r\n this.action = action;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n this.action(next.value, this.index++);\r\n return this.yield(next.value);\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemAction } from \"../../types/utility\";\r\n\r\n/**\r\n * Conditionally invokes a side-effect action for each element based on a predicate.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.tapIf}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class TapIfEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private readonly action: ItemAction<TSource>;\r\n private readonly predicate: () => boolean;\r\n private index: number = 0;\r\n\r\n public constructor(sourceEnumerator: Enumerator<TSource>, action: ItemAction<TSource>, predicate: () => boolean) {\r\n super(sourceEnumerator);\r\n this.action = action;\r\n this.predicate = predicate;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n if (this.predicate()) {\r\n this.action(next.value, this.index);\r\n }\r\n\r\n this.index++;\r\n return this.yield(next.value);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Yields every nth element from the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.throttle}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class ThrottleEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly count: number;\r\n private index: number = -1;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, count: number) {\r\n super(sourceEnumerator);\r\n this.count = count;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n while (true) {\r\n const { value, done } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n this.index++;\r\n if (this.index % this.count === 0) {\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { ItemPredicate } from \"../../types/utility\";\r\n\r\n/**\r\n * Filters elements using a predicate.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.where}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class WhereEnumerator<T> extends TyneqEnumerator<T> {\r\n private index: number = 0;\r\n private readonly predicate: ItemPredicate<T>;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, predicate: ItemPredicate<T>) {\r\n super(sourceEnumerator);\r\n this.predicate = predicate;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n while (true) {\r\n const { value, done } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n if (this.predicate(value, this.index++)) {\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Yields overlapping or tumbling windows (fixed-size sub-arrays) over the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n * Windows with fewer elements than `size` are not yielded.\r\n * Each yielded array is a snapshot - mutating it does not affect subsequent windows.\r\n *\r\n * @see {@link TyneqSequence.window}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class WindowEnumerator<T> extends TyneqEnumerator<T, T[]> {\r\n private readonly size: number;\r\n private readonly step: number;\r\n private buffer: T[] = [];\r\n private started = false;\r\n\r\n public constructor(sourceEnumerator: Enumerator<T>, size: number, step: number) {\r\n super(sourceEnumerator);\r\n this.size = size;\r\n this.step = step;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T[]> {\r\n // Fill the initial buffer on first call\r\n if (!this.started) {\r\n this.started = true;\r\n while (this.buffer.length < this.size) {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n this.buffer.push(next.value);\r\n }\r\n\r\n return this.yield(this.buffer.slice());\r\n }\r\n\r\n // Advance by step:\r\n // - When step <= size: keep the tail of the buffer and fill the rest from source.\r\n // - When step > size: the buffer is fully replaced; skip (step - size) source elements first.\r\n if (this.step <= this.size) {\r\n this.buffer = this.buffer.slice(this.step);\r\n } else {\r\n this.buffer = [];\r\n const toSkip = this.step - this.size;\r\n for (let i = 0; i < toSkip; i++) {\r\n if (this.sourceEnumerator.next().done) {\r\n return this.done();\r\n }\r\n }\r\n }\r\n\r\n while (this.buffer.length < this.size) {\r\n const next = this.sourceEnumerator.next();\r\n if (next.done) {\r\n return this.done();\r\n }\r\n\r\n this.buffer.push(next.value);\r\n }\r\n\r\n return this.yield(this.buffer.slice());\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { EnumeratorUtility } from \"../../utility/EnumeratorUtility\";\r\n\r\n/**\r\n * Merges two sequences element-by-element using a selector.\r\n *\r\n * @remarks\r\n * Deferred. Source is not enumerated until the returned sequence is iterated.\r\n *\r\n * @see {@link TyneqSequence.zip}\r\n * @group Operators\r\n * @category Streaming\r\n * @internal\r\n */\r\nexport class ZipEnumerator<T, U, V> extends TyneqEnumerator<T, V> {\r\n private readonly otherEnumerator: Enumerator<U>;\r\n private readonly selector: (first: T, second: U) => V;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, other: Iterable<U>, selector: (first: T, second: U) => V) {\r\n super(sourceEnumerator);\r\n this.otherEnumerator = other[Symbol.iterator]();\r\n this.selector = selector;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<V> {\r\n const first = this.sourceEnumerator.next();\r\n if (first.done) {\r\n this.disposeAdditional();\r\n return this.done();\r\n }\r\n\r\n const second = this.otherEnumerator.next();\r\n if (second.done) {\r\n return this.earlyComplete();\r\n }\r\n\r\n return this.yield(this.selector(first.value, second.value));\r\n }\r\n\r\n protected override disposeAdditional(): void {\r\n EnumeratorUtility.tryDispose(this.otherEnumerator);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { EnumeratorUtility } from \"../../utility/EnumeratorUtility\";\r\n\r\n/**\r\n * Inserts a second sequence at a specified offset from the end of the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.backsert}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class BacksertEnumerator<T> extends TyneqEnumerator<T> {\r\n private readonly other: Iterable<T>;\r\n private readonly backIndex: number;\r\n private buffer: T[] = [];\r\n private current = 0;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>, backIndex: number, other: Iterable<T>) {\r\n super(sourceEnumerator);\r\n this.backIndex = backIndex;\r\n this.other = other;\r\n }\r\n\r\n protected override initialize(): void {\r\n const source = Array.from(EnumeratorUtility.toIterable(this.sourceEnumerator));\r\n const other = Array.from(this.other);\r\n\r\n const insertionIndex = Math.max(0, source.length - this.backIndex);\r\n\r\n this.buffer = [\r\n ...source.slice(0, insertionIndex),\r\n ...other,\r\n ...source.slice(insertionIndex)\r\n ];\r\n\r\n this.current = 0;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (this.current >= this.buffer.length) {\r\n return this.done();\r\n }\r\n\r\n return this.yield(this.buffer[this.current++]);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns distinct elements by eliminating duplicates.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.distinct}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class DistinctEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private readonly seenValues = new Set<TSource>();\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>) {\r\n super(sourceEnumerator);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n if (!this.seenValues.has(value)) {\r\n this.seenValues.add(value);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns distinct elements by eliminating duplicates based on a key selector.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.distinctBy}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class DistinctByEnumerator<TSource, TKey> extends TyneqEnumerator<TSource> {\r\n private readonly seenValues = new Set<TKey>();\r\n private readonly keySelector: (item: TSource) => TKey;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, keySelector: (item: TSource) => TKey) {\r\n super(sourceEnumerator);\r\n this.keySelector = keySelector;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n const key = this.keySelector(value);\r\n\r\n if (!this.seenValues.has(key)) {\r\n this.seenValues.add(key);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns elements from the source sequence that are not present in a second sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.except}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class ExceptEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private readonly excludedValues: Iterable<TSource>;\r\n private excludeSet = new Set<TSource>();\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, excludedValues: Iterable<TSource>) {\r\n super(sourceEnumerator);\r\n this.excludedValues = excludedValues;\r\n }\r\n\r\n protected override initialize(): void {\r\n this.excludeSet = new Set<TSource>(this.excludedValues);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n if (!this.excludeSet.has(value)) {\r\n this.excludeSet.add(value);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns elements from the source sequence whose keys are not present in a second key sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.exceptBy}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class ExceptByEnumerator<TSource, TKey> extends TyneqEnumerator<TSource> {\r\n private readonly excludedKeys: Iterable<TKey>;\r\n private excludeSet = new Set<TKey>();\r\n private readonly keySelector: (item: TSource) => TKey;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, excludedKeys: Iterable<TKey>, keySelector: (item: TSource) => TKey) {\r\n super(sourceEnumerator);\r\n this.excludedKeys = excludedKeys;\r\n this.keySelector = keySelector;\r\n }\r\n\r\n protected override initialize(): void {\r\n this.excludeSet = new Set<TKey>(this.excludedKeys);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n const key = this.keySelector(value);\r\n if (!this.excludeSet.has(key)) {\r\n this.excludeSet.add(key);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","\r\n/**\r\n * `Map` subclass with convenience helpers for initialise-on-first-access patterns.\r\n *\r\n * @internal\r\n */\r\nexport class DefaultingMap<TKey, TValue> extends Map<TKey, TValue> {\r\n\r\n /** Returns the value for `key`, or initialises and stores it via `initValue()` if absent. */\r\n public getOrInit(key: TKey, initValue: () => TValue): TValue {\r\n if (!this.has(key)) {\r\n this.set(key, initValue());\r\n }\r\n\r\n return this.get(key) as TValue;\r\n }\r\n\r\n /** Sets `key` to `initValue` if absent; otherwise replaces the current value with `updateValue(current)`. */\r\n public setOrUpdate(key: TKey, updateValue: (currentValue: TValue) => TValue, initValue: TValue): void {\r\n if (!this.has(key)) {\r\n this.set(key, initValue);\r\n return;\r\n }\r\n\r\n this.set(key, updateValue(this.get(key) as TValue));\r\n }\r\n}\r\n","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator, TyneqSequence } from \"../../types/core\";\r\nimport { DefaultingMap } from \"../../utility/DefaultingMap\";\r\n\r\n/**\r\n * Groups elements by a key selector and projects each group through a result selector.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.groupBy}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class GroupByEnumerator<TSource, TKey, TValue, TResult> extends TyneqEnumerator<TSource, TResult> {\r\n private readonly keySelector: (item: TSource) => TKey;\r\n private readonly valueSelector: (item: TSource) => TValue;\r\n private readonly resultSelector: (key: TKey, values: TyneqSequence<TValue>) => TResult;\r\n private readonly groupFactory: (values: TValue[]) => TyneqSequence<TValue>;\r\n private lookupEnumerator?: Enumerator<[TKey, TValue[]]>;\r\n private lookup = new DefaultingMap<TKey, TValue[]>();\r\n\r\n \r\n public constructor(\r\n sourceEnumerator: Enumerator<TSource>,\r\n keySelector: (item: TSource) => TKey,\r\n valueSelector: (item: TSource) => TValue,\r\n resultSelector: (key: TKey, values: TyneqSequence<TValue>) => TResult,\r\n groupFactory: (values: TValue[]) => TyneqSequence<TValue>\r\n ) {\r\n super(sourceEnumerator);\r\n this.keySelector = keySelector;\r\n this.valueSelector = valueSelector;\r\n this.resultSelector = resultSelector;\r\n this.groupFactory = groupFactory;\r\n }\r\n\r\n protected override initialize(): void {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n break;\r\n }\r\n\r\n const key = this.keySelector(value);\r\n const mappedValue = this.valueSelector(value);\r\n const group = this.lookup.getOrInit(key, () => []);\r\n group.push(mappedValue);\r\n }\r\n\r\n this.lookupEnumerator = this.lookup.entries();\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TResult> {\r\n if (this.lookupEnumerator === undefined) {\r\n return this.done();\r\n }\r\n\r\n const { done, value } = this.lookupEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n const [key, values] = value;\r\n const result = this.resultSelector(key, this.groupFactory(values));\r\n return this.yield(result);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator, TyneqSequence } from \"../../types/core\";\r\nimport { DefaultingMap } from \"../../utility/DefaultingMap\";\r\n\r\n/**\r\n * Correlates outer elements with groups of matching inner elements.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.groupJoin}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class GroupJoinEnumerator<TOuter, TInner, TKey, TResult> extends TyneqEnumerator<TOuter, TResult> {\r\n private readonly innerSource: Iterable<TInner>;\r\n private readonly outerKeySelector: (outer: TOuter) => TKey;\r\n private readonly innerKeySelector: (inner: TInner) => TKey;\r\n private readonly resultSelector: (outer: TOuter, group: TyneqSequence<TInner>) => TResult;\r\n private readonly groupFactory: (values: TInner[]) => TyneqSequence<TInner>;\r\n private innerLookup = new DefaultingMap<TKey, TInner[]>();\r\n\r\n \r\n public constructor(\r\n sourceEnumerator: Enumerator<TOuter>,\r\n innerSource: Iterable<TInner>,\r\n outerKeySelector: (outer: TOuter) => TKey,\r\n innerKeySelector: (inner: TInner) => TKey,\r\n resultSelector: (outer: TOuter, group: TyneqSequence<TInner>) => TResult,\r\n groupFactory: (values: TInner[]) => TyneqSequence<TInner>\r\n ) {\r\n super(sourceEnumerator);\r\n this.innerSource = innerSource;\r\n this.outerKeySelector = outerKeySelector;\r\n this.innerKeySelector = innerKeySelector;\r\n this.resultSelector = resultSelector;\r\n this.groupFactory = groupFactory;\r\n }\r\n\r\n protected override initialize(): void {\r\n for (const innerItem of this.innerSource) {\r\n const key = this.innerKeySelector(innerItem);\r\n const bucket = this.innerLookup.getOrInit(key, () => []);\r\n bucket.push(innerItem);\r\n }\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TResult> {\r\n const { done, value: outerItem } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n const outerKey = this.outerKeySelector(outerItem);\r\n const innerItems = this.innerLookup.get(outerKey) ?? [];\r\n\r\n const resultItem = this.resultSelector(outerItem, this.groupFactory(innerItems));\r\n return this.yield(resultItem);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns elements that are present in both the source and a second sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.intersect}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class IntersectEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private readonly otherValues: Iterable<TSource>;\r\n private intersectionValues = new Set<TSource>();\r\n private bufferedValues = new Set<TSource>();\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, otherValues: Iterable<TSource>) {\r\n super(sourceEnumerator);\r\n this.otherValues = otherValues;\r\n }\r\n\r\n protected override initialize(): void {\r\n this.intersectionValues = new Set<TSource>(this.otherValues);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n if (this.intersectionValues.has(value) && !this.bufferedValues.has(value)) {\r\n this.bufferedValues.add(value);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns elements whose keys appear in both the source and a second key sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.intersectBy}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class IntersectByEnumerator<TSource, TKey> extends TyneqEnumerator<TSource> {\r\n private readonly otherValues: Iterable<TKey>;\r\n private readonly keySelector: (item: TSource) => TKey;\r\n private intersectionKeys = new Set<TKey>();\r\n private bufferedKeys = new Set<TKey>();\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, otherValues: Iterable<TKey>, keySelector: (item: TSource) => TKey) {\r\n super(sourceEnumerator);\r\n this.otherValues = otherValues;\r\n this.keySelector = keySelector;\r\n }\r\n\r\n protected override initialize(): void {\r\n this.intersectionKeys = new Set<TKey>(this.otherValues);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n return this.done();\r\n }\r\n\r\n const key = this.keySelector(value);\r\n\r\n if (this.intersectionKeys.has(key) && !this.bufferedKeys.has(key)) {\r\n this.bufferedKeys.add(key);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\nimport { Nullable } from \"../../types/utility\";\r\nimport { DefaultingMap } from \"../../utility/DefaultingMap\";\r\n\r\n/**\r\n * Correlates outer elements with matching inner elements using a key equality comparison.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.join}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class JoinEnumerator<TOuter, TInner, TKey, TResult> extends TyneqEnumerator<TOuter, TResult> {\r\n private readonly innerSource: Iterable<TInner>;\r\n private readonly outerKeySelector: (outer: TOuter) => TKey;\r\n private readonly innerKeySelector: (inner: TInner) => TKey;\r\n private readonly resultSelector: (outer: TOuter, inner: TInner) => TResult;\r\n private innerLookup = new DefaultingMap<TKey, TInner[]>();\r\n private pendingOuter!: TOuter;\r\n private pendingMatches: Nullable<TInner[]> = null;\r\n private pendingIndex = 0;\r\n\r\n \r\n public constructor(\r\n sourceEnumerator: Enumerator<TOuter>,\r\n innerSource: Iterable<TInner>,\r\n outerKeySelector: (outer: TOuter) => TKey,\r\n innerKeySelector: (inner: TInner) => TKey,\r\n resultSelector: (outer: TOuter, inner: TInner) => TResult\r\n ) {\r\n super(sourceEnumerator);\r\n this.innerSource = innerSource;\r\n this.outerKeySelector = outerKeySelector;\r\n this.innerKeySelector = innerKeySelector;\r\n this.resultSelector = resultSelector;\r\n }\r\n\r\n protected override initialize(): void {\r\n for (const innerItem of this.innerSource) {\r\n const key = this.innerKeySelector(innerItem);\r\n const bucket = this.innerLookup.getOrInit(key, () => []);\r\n bucket.push(innerItem);\r\n }\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TResult> {\r\n while (true) {\r\n if (this.pendingMatches !== null) {\r\n if (this.pendingIndex < this.pendingMatches.length) {\r\n return this.yield(this.resultSelector(this.pendingOuter, this.pendingMatches[this.pendingIndex++]));\r\n }\r\n\r\n this.pendingMatches = null;\r\n }\r\n\r\n const nextOuter = this.sourceEnumerator.next();\r\n if (nextOuter.done) {\r\n return this.done();\r\n }\r\n\r\n const outerItem = nextOuter.value;\r\n const outerKey = this.outerKeySelector(outerItem);\r\n const innerItems = this.innerLookup.get(outerKey);\r\n\r\n if (innerItems === undefined || innerItems.length === 0) {\r\n continue;\r\n }\r\n\r\n this.pendingOuter = outerItem;\r\n this.pendingMatches = innerItems;\r\n this.pendingIndex = 0;\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Reverses the order of elements in the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.reverse}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class ReverseEnumerator<T> extends TyneqEnumerator<T> {\r\n private buffer: T[] = [];\r\n private index: number = -1;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<T>) {\r\n super(sourceEnumerator);\r\n }\r\n\r\n protected override initialize(): void {\r\n while (true) {\r\n const { done, value } = this.sourceEnumerator.next();\r\n if (done) {\r\n this.index = this.buffer.length - 1;\r\n break;\r\n }\r\n\r\n this.buffer.push(value);\r\n }\r\n }\r\n\r\n protected override handleNext(): IteratorResult<T> {\r\n if (this.index < 0) {\r\n return this.done();\r\n }\r\n\r\n return this.yield(this.buffer[this.index--]);\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns the elements of the source sequence in a random order.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.shuffle}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class ShuffleEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private buffer: TSource[] = [];\r\n private currentIndex = 0;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>) {\r\n super(sourceEnumerator);\r\n }\r\n\r\n protected override initialize(): void {\r\n const buffer = Array.from(this.toIterable(this.sourceEnumerator));\r\n this.shuffle(buffer);\r\n this.buffer = buffer;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n if (this.buffer.length <= this.currentIndex) {\r\n return this.done();\r\n }\r\n\r\n const result = this.buffer[this.currentIndex];\r\n this.currentIndex++;\r\n return this.yield(result);\r\n }\r\n\r\n private shuffle<T>(array: T[]): T[] {\r\n for (let i = array.length - 1; i > 0; i--) {\r\n const j = Math.floor(Math.random() * (i + 1));\r\n [array[i], array[j]] = [array[j], array[i]];\r\n }\r\n\r\n return array;\r\n }\r\n\r\n private toIterable(sourceEnumerator: Enumerator<TSource>): Iterable<TSource> {\r\n return {\r\n [Symbol.iterator]: () => sourceEnumerator\r\n };\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns the set union of the source and a second sequence, eliminating duplicates.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.union}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class UnionEnumerator<TSource> extends TyneqEnumerator<TSource> {\r\n private readonly otherValues: Iterable<TSource>;\r\n private bufferedValues = new Set<TSource>();\r\n private currentEnumerator: Enumerator<TSource>;\r\n private isSourceDone = false;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, otherValues: Iterable<TSource>) {\r\n super(sourceEnumerator);\r\n this.otherValues = otherValues;\r\n this.currentEnumerator = this.sourceEnumerator;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.currentEnumerator.next();\r\n if (done) {\r\n if (this.isSourceDone) {\r\n return this.done();\r\n }\r\n\r\n this.isSourceDone = true;\r\n this.currentEnumerator = this.otherValues[Symbol.iterator]();\r\n continue;\r\n }\r\n\r\n if (!this.bufferedValues.has(value)) {\r\n this.bufferedValues.add(value);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { Enumerator } from \"../../types/core\";\r\n\r\n/**\r\n * Returns the set union of the source and a second sequence, eliminating duplicates by key.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.unionBy}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class UnionByEnumerator<TSource, TKey> extends TyneqEnumerator<TSource> {\r\n private readonly otherValues: Iterable<TSource>;\r\n private readonly bufferedKeys = new Set<TKey>();\r\n private readonly keySelector: (item: TSource) => TKey;\r\n private currentEnumerator: Enumerator<TSource>;\r\n private isSourceDone = false;\r\n\r\n \r\n public constructor(sourceEnumerator: Enumerator<TSource>, otherValues: Iterable<TSource>, keySelector: (item: TSource) => TKey) {\r\n super(sourceEnumerator);\r\n this.otherValues = otherValues;\r\n this.currentEnumerator = this.sourceEnumerator;\r\n this.keySelector = keySelector;\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n while (true) {\r\n const { done, value } = this.currentEnumerator.next();\r\n if (done) {\r\n if (this.isSourceDone) {\r\n return this.done();\r\n }\r\n\r\n this.isSourceDone = true;\r\n this.currentEnumerator = this.otherValues[Symbol.iterator]();\r\n continue;\r\n }\r\n\r\n const key = this.keySelector(value);\r\n if (!this.bufferedKeys.has(key)) {\r\n this.bufferedKeys.add(key);\r\n return this.yield(value);\r\n }\r\n }\r\n }\r\n}","import { TyneqEnumerator } from \"../../core/enumerators/TyneqEnumerator\";\r\nimport { EnumeratorUtility } from \"../../utility/EnumeratorUtility\";\r\n\r\n/**\r\n * Yields all permutations of the elements in the source sequence.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.permutations}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class PermutationsEnumerator<TSource> extends TyneqEnumerator<TSource, TSource[]> {\r\n private buffer: TSource[] = [];\r\n private c: number[] = [];\r\n private n = 0;\r\n private i = -1;\r\n\r\n protected override initialize(): void {\r\n this.buffer = Array.from(EnumeratorUtility.toIterable(this.sourceEnumerator));\r\n this.n = this.buffer.length;\r\n this.c = new Array(this.n).fill(0);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource[]> {\r\n if (this.i === -1) {\r\n this.i = 1;\r\n return this.yield([...this.buffer]);\r\n }\r\n\r\n while (this.i < this.n) {\r\n if (this.c[this.i] < this.i) { // can we swap?\r\n const swapIndex = this.i % 2 === 0\r\n ? 0\r\n : this.c[this.i];\r\n [this.buffer[swapIndex], this.buffer[this.i]] = [this.buffer[this.i], this.buffer[swapIndex]];\r\n this.c[this.i]++;\r\n this.i = 1;\r\n return this.yield([...this.buffer]);\r\n } else {\r\n this.c[this.i] = 0;\r\n this.i++; // go deeper\r\n }\r\n }\r\n \r\n return this.done();\r\n }\r\n\r\n}","import { Enumerator, TyneqSequence, KeyValuePair, MinMaxResult, Comparer, EqualityComparer } from \"../types/core\";\r\nimport { ArgumentOutOfRangeError } from \"./errors/argument/ArgumentOutOfRangeError\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\nimport { ItemAction, ItemPredicate, ItemSelector } from \"../types/utility\";\r\nimport { TyneqEnumerableCore } from \"./TyneqEnumerableCore\";\r\nimport { sequence } from \"../plugin/decorators/sequence\";\r\nimport { builtin } from \"../plugin/decorators/builtin\";\r\n\r\nimport { AggregateOperator } from \"../operators/aggregate\";\r\nimport { AllOperator } from \"../operators/all\";\r\nimport { AnyOperator } from \"../operators/any\";\r\nimport { AverageOperator } from \"../operators/average\";\r\nimport { ConsumeOperator } from \"../operators/consume\";\r\nimport { ContainsOperator } from \"../operators/contains\";\r\nimport { CountOperator } from \"../operators/count\";\r\nimport { CountByOperator } from \"../operators/countBy\";\r\nimport { ElementAtOperator } from \"../operators/elementAt\";\r\nimport { ElementAtOrDefaultOperator } from \"../operators/elementAtOrDefault\";\r\nimport { FirstOperator } from \"../operators/first\";\r\nimport { FirstOrDefaultOperator } from \"../operators/firstOrDefault\";\r\nimport { IndexOfOperator } from \"../operators/indexOf\";\r\nimport { IsNullOrEmptyOperator } from \"../operators/isNullOrEmpty\";\r\nimport { LastOperator } from \"../operators/last\";\r\nimport { LastOrDefaultOperator } from \"../operators/lastOrDefault\";\r\nimport { ExtremumOperator, ExtremumByOperator } from \"../operators/extremum\";\r\nimport { MinMaxOperator } from \"../operators/minMax\";\r\nimport { SequenceEqualOperator } from \"../operators/sequenceEqual\";\r\nimport { SingleOperator } from \"../operators/single\";\r\nimport { SingleOrDefaultOperator } from \"../operators/singleOrDefault\";\r\nimport { EndsWithOperator } from \"../operators/endsWith\";\r\nimport { StartsWithOperator } from \"../operators/startsWith\";\r\nimport { SumOperator } from \"../operators/sum\";\r\nimport { ToArrayOperator } from \"../operators/toArray\";\r\nimport { ToAsyncOperator } from \"../operators/toAsync\";\r\nimport { ToMapOperator } from \"../operators/toMap\";\r\nimport { ToRecordOperator } from \"../operators/toRecord\";\r\nimport { ToSetOperator } from \"../operators/toSet\";\r\nimport { AppendEnumerator } from \"../enumerators/streaming/append\";\r\nimport { ChunkEnumerator } from \"../enumerators/streaming/chunk\";\r\nimport { ConcatEnumerator } from \"../enumerators/streaming/concat\";\r\nimport { FlattenEnumerator } from \"../enumerators/streaming/flatten\";\r\nimport { DefaultIfEmptyEnumerator } from \"../enumerators/streaming/defaultIfEmpty\";\r\nimport { OfTypeEnumerator } from \"../enumerators/streaming/ofType\";\r\nimport { PairwiseEnumerator } from \"../enumerators/streaming/pairwise\";\r\nimport { PopulateEnumerator } from \"../enumerators/streaming/populate\";\r\nimport { PrependEnumerator } from \"../enumerators/streaming/prepend\";\r\nimport { ScanEnumerator } from \"../enumerators/streaming/scan\";\r\nimport { SelectEnumerator } from \"../enumerators/streaming/select\";\r\nimport { SelectManyEnumerator } from \"../enumerators/streaming/selectMany\";\r\nimport { RepeatSequenceEnumerator } from \"../enumerators/streaming/repeatSequence\";\r\nimport { SkipEnumerator } from \"../enumerators/streaming/skip\";\r\nimport { SkipLastEnumerator } from \"../enumerators/streaming/skipLast\";\r\nimport { SkipUntilEnumerator } from \"../enumerators/streaming/skipUntil\";\r\nimport { SkipWhileEnumerator } from \"../enumerators/streaming/skipWhile\";\r\nimport { SliceEnumerator } from \"../enumerators/streaming/slice\";\r\nimport { SplitEnumerator } from \"../enumerators/streaming/split\";\r\nimport { TakeEnumerator } from \"../enumerators/streaming/take\";\r\nimport { TakeUntilEnumerator } from \"../enumerators/streaming/takeUntil\";\r\nimport { TakeWhileEnumerator } from \"../enumerators/streaming/takeWhile\";\r\nimport { TapEnumerator } from \"../enumerators/streaming/tap\";\r\nimport { TapIfEnumerator } from \"../enumerators/streaming/tapIf\";\r\nimport { ThrottleEnumerator } from \"../enumerators/streaming/throttle\";\r\nimport { WhereEnumerator } from \"../enumerators/streaming/where\";\r\nimport { WindowEnumerator } from \"../enumerators/streaming/window\";\r\nimport { ZipEnumerator } from \"../enumerators/streaming/zip\";\r\nimport { BacksertEnumerator } from \"../enumerators/buffer/backsert\";\r\nimport { DistinctEnumerator } from \"../enumerators/buffer/distinct\";\r\nimport { DistinctByEnumerator } from \"../enumerators/buffer/distinctBy\";\r\nimport { ExceptEnumerator } from \"../enumerators/buffer/except\";\r\nimport { ExceptByEnumerator } from \"../enumerators/buffer/exceptBy\";\r\nimport { GroupByEnumerator } from \"../enumerators/buffer/groupBy\";\r\nimport { GroupJoinEnumerator } from \"../enumerators/buffer/groupJoin\";\r\nimport { IntersectEnumerator } from \"../enumerators/buffer/intersect\";\r\nimport { IntersectByEnumerator } from \"../enumerators/buffer/intersectBy\";\r\nimport { JoinEnumerator } from \"../enumerators/buffer/join\";\r\nimport { ReverseEnumerator } from \"../enumerators/buffer/reverse\";\r\nimport { ShuffleEnumerator } from \"../enumerators/buffer/shuffle\";\r\nimport { UnionEnumerator } from \"../enumerators/buffer/union\";\r\nimport { UnionByEnumerator } from \"../enumerators/buffer/unionBy\";\r\nimport { PermutationsEnumerator } from \"../enumerators/buffer/permutations\";\r\n\r\n/**\r\n * Abstract base class that implements all {@link TyneqSequence} operator methods.\r\n *\r\n * @remarks\r\n * All operator methods delegate to the corresponding operator class registered via\r\n * `@operator`, `@terminal`, or the functional registration APIs.\r\n * Subclasses implement `createEnumerable`, `createOrderedEnumerable`, and `createCachedEnumerable`\r\n * to control which concrete sequence types are returned.\r\n *\r\n * @internal\r\n */\r\n@sequence\r\nexport abstract class TyneqEnumerableBase<TSource> extends TyneqEnumerableCore<TSource> implements TyneqSequence<TSource> {\r\n @builtin({ kind: \"terminal\" })\r\n public aggregate<UAccumulate, VResult>(\r\n seed: UAccumulate,\r\n func: (accumulate: UAccumulate, item: TSource) => UAccumulate,\r\n resultSelector: (accumulate: UAccumulate) => VResult\r\n ): VResult {\r\n return new AggregateOperator<TSource, UAccumulate, VResult>(this, seed, func, resultSelector).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public all(predicate: ItemPredicate<TSource>): boolean {\r\n return new AllOperator(this, predicate).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public any(predicate: ItemPredicate<TSource>): boolean {\r\n return new AnyOperator(this, predicate).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public average(selector: (item: TSource) => number): number {\r\n return new AverageOperator(this, selector).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n\r\n public consume(): void {\r\n new ConsumeOperator(this).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public contains(value: TSource, equalityComparer?: EqualityComparer<TSource>): boolean {\r\n return new ContainsOperator(this, value, equalityComparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public count(): number {\r\n return new CountOperator(this).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public countBy(predicate: ItemPredicate<TSource>): number {\r\n return new CountByOperator(this, predicate).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public elementAt(index: number): TSource {\r\n ArgumentUtility.checkSafeInteger({ index });\r\n ArgumentUtility.checkNonNegative({ index });\r\n return new ElementAtOperator(this, index).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public elementAtOrDefault(index: number, defaultValue: TSource): TSource {\r\n ArgumentUtility.checkSafeInteger({ index });\r\n ArgumentUtility.checkNonNegative({ index });\r\n return new ElementAtOrDefaultOperator(this, index, defaultValue).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public first(predicate: ItemPredicate<TSource>): TSource {\r\n return new FirstOperator(this, predicate).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public firstOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource {\r\n return new FirstOrDefaultOperator(this, predicate, defaultValue).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public indexOf(predicate: ItemPredicate<TSource>, startIndex: number = 0): number {\r\n return new IndexOfOperator(this, predicate, startIndex).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public isNullOrEmpty(): boolean {\r\n return new IsNullOrEmptyOperator(this).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public last(predicate: ItemPredicate<TSource>): TSource {\r\n return new LastOperator(this, predicate).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public lastOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource {\r\n return new LastOrDefaultOperator(this, predicate, defaultValue).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public max(comparer?: Comparer<TSource>): TSource {\r\n return new ExtremumOperator(this, 1, \"max\", comparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public maxBy<TKey>(\r\n keySelector: (element: TSource) => TKey,\r\n comparer?: Comparer<TKey>\r\n ): TSource {\r\n return new ExtremumByOperator<TSource, TKey>(this, keySelector, 1, \"maxBy\", comparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public min(comparer?: Comparer<TSource>): TSource {\r\n return new ExtremumOperator(this, -1, \"min\", comparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public minBy<TKey>(\r\n keySelector: (element: TSource) => TKey,\r\n comparer?: Comparer<TKey>\r\n ): TSource {\r\n return new ExtremumByOperator<TSource, TKey>(this, keySelector, -1, \"minBy\", comparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public minMax(comparer?: Comparer<TSource>): MinMaxResult<TSource> {\r\n return new MinMaxOperator(this, comparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public sequenceEqual(\r\n other: Iterable<TSource>,\r\n equalityComparer?: EqualityComparer<TSource>\r\n ): boolean {\r\n return new SequenceEqualOperator(this, other, equalityComparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public single(predicate: ItemPredicate<TSource>): TSource {\r\n return new SingleOperator(this, predicate).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public singleOrDefault(predicate: ItemPredicate<TSource>, defaultValue: TSource): TSource {\r\n return new SingleOrDefaultOperator(this, predicate, defaultValue).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public endsWith(sequence: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean {\r\n return new EndsWithOperator(this, sequence, equalityComparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public startsWith(sequence: Iterable<TSource>, equalityComparer?: EqualityComparer<TSource>): boolean {\r\n return new StartsWithOperator(this, sequence, equalityComparer).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public sum(selector: (item: TSource) => number): number {\r\n return new SumOperator(this, selector).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public toArray(): TSource[] {\r\n return new ToArrayOperator(this).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public toAsync(): AsyncIterable<TSource> {\r\n return new ToAsyncOperator(this).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public toMap<TKey, TValue>(\r\n selector: (item: TSource) => KeyValuePair<TKey, TValue>\r\n ): Map<TKey, TValue> {\r\n return new ToMapOperator<TSource, TKey, TValue>(this, selector).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public toRecord<TKey extends string | number | symbol, TValue>(\r\n selector: (item: TSource) => KeyValuePair<TKey, TValue>\r\n ): Record<TKey, TValue> {\r\n return new ToRecordOperator<TSource, TKey, TValue>(this, selector).process();\r\n }\r\n\r\n @builtin({ kind: \"terminal\" })\r\n public toSet(): Set<TSource> {\r\n return new ToSetOperator(this).process();\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public ofType<U extends TSource>(guard: (value: TSource) => value is U): TyneqSequence<U> {\r\n ArgumentUtility.checkNotOptional({ guard });\r\n return this.createSequence(\r\n () => new OfTypeEnumerator<TSource, U>(this.getEnumerator(), guard),\r\n this.createNode(\"ofType\", \"streaming\", [guard])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public append(item: TSource): TyneqSequence<TSource> {\r\n return this.createSequence(\r\n () => new AppendEnumerator<TSource>(this.getEnumerator(), item),\r\n this.createNode(\"append\", \"streaming\", [item])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public chunk(size: number): TyneqSequence<TSource[]> {\r\n ArgumentUtility.checkSafeInteger({ size });\r\n ArgumentUtility.checkPositive({ size });\r\n return this.createSequence(\r\n () => new ChunkEnumerator<TSource>(this.getEnumerator(), size),\r\n this.createNode(\"chunk\", \"streaming\", [size])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public concat(other: Iterable<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ other });\r\n ArgumentUtility.checkIterable({ other });\r\n return this.createSequence(\r\n () => new ConcatEnumerator<TSource>(this.getEnumerator(), other),\r\n this.createNode(\"concat\", \"streaming\", [other])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public defaultIfEmpty(defaultValue: TSource): TyneqSequence<TSource> {\r\n return this.createSequence(\r\n () => new DefaultIfEmptyEnumerator<TSource>(this.getEnumerator(), defaultValue),\r\n this.createNode(\"defaultIfEmpty\", \"streaming\", [defaultValue])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public flatten<TInner>(): TyneqSequence<TInner> {\r\n const self = this as unknown as TyneqEnumerableBase<Iterable<TInner>>;\r\n return self.createSequence(\r\n () => new FlattenEnumerator<TInner>(self.getEnumerator()),\r\n self.createNode(\"flatten\", \"streaming\")\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public pairwise(): TyneqSequence<[TSource, TSource]> {\r\n return this.createSequence(\r\n () => new PairwiseEnumerator<TSource>(this.getEnumerator()),\r\n this.createNode(\"pairwise\", \"streaming\")\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public populate<TValue>(value: TValue): TyneqSequence<TValue> {\r\n return this.createSequence(\r\n () => new PopulateEnumerator<TSource, TValue>(this.getEnumerator(), value),\r\n this.createNode(\"populate\", \"streaming\", [value])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public prepend(item: TSource): TyneqSequence<TSource> {\r\n return this.createSequence(\r\n () => new PrependEnumerator<TSource>(this.getEnumerator(), item),\r\n this.createNode(\"prepend\", \"streaming\", [item])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public scan<TResult>(\r\n seed: TResult,\r\n accumulator: (acc: TResult, item: TSource) => TResult\r\n ): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ accumulator });\r\n ArgumentUtility.checkFunction({ accumulator });\r\n return this.createSequence(\r\n () => new ScanEnumerator<TSource, TResult>(this.getEnumerator(), seed, accumulator),\r\n this.createNode(\"scan\", \"streaming\", [seed, accumulator])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public select<TResult>(\r\n selector: ItemSelector<TSource, TResult>\r\n ): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ selector });\r\n return this.createSequence(\r\n () => new SelectEnumerator<TSource, TResult>(this.getEnumerator(), selector),\r\n this.createNode(\"select\", \"streaming\", [selector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public selectMany<TResult>(\r\n selector: (item: TSource) => Iterable<TResult>\r\n ): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ selector });\r\n return this.createSequence(\r\n () => new SelectManyEnumerator<TSource, TResult>(this.getEnumerator(), selector),\r\n this.createNode(\"selectMany\", \"streaming\", [selector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public window(size: number, step: number = 1): TyneqSequence<TSource[]> {\r\n ArgumentUtility.checkSafeInteger({ size });\r\n ArgumentUtility.checkPositive({ size });\r\n ArgumentUtility.checkSafeInteger({ step });\r\n ArgumentUtility.checkPositive({ step });\r\n return this.createSequence(\r\n () => new WindowEnumerator<TSource>(this.getEnumerator(), size, step),\r\n this.createNode(\"window\", \"streaming\", [size, step])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public repeat(count: number): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNonNegative({ count });\r\n ArgumentUtility.checkInteger({ count });\r\n return this.createSequence(\r\n () => new RepeatSequenceEnumerator<TSource>(this.getEnumerator(), this, count),\r\n this.createNode(\"repeat\", \"streaming\", [count])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public skip(count: number): TyneqSequence<TSource> {\r\n ArgumentUtility.checkSafeInteger({ count });\r\n ArgumentUtility.checkNonNegative({ count });\r\n return this.createSequence(\r\n () => new SkipEnumerator<TSource>(this.getEnumerator(), count),\r\n this.createNode(\"skip\", \"streaming\", [count])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public skipLast(count: number): TyneqSequence<TSource> {\r\n ArgumentUtility.checkSafeInteger({ count });\r\n ArgumentUtility.checkNonNegative({ count });\r\n return this.createSequence(\r\n () => new SkipLastEnumerator<TSource>(this.getEnumerator(), count),\r\n this.createNode(\"skipLast\", \"streaming\", [count])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public skipUntil(predicate: ItemPredicate<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n return this.createSequence(\r\n () => new SkipUntilEnumerator<TSource>(this.getEnumerator(), predicate),\r\n this.createNode(\"skipUntil\", \"streaming\", [predicate])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public skipWhile(predicate: ItemPredicate<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n return this.createSequence(\r\n () => new SkipWhileEnumerator<TSource>(this.getEnumerator(), predicate),\r\n this.createNode(\"skipWhile\", \"streaming\", [predicate])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public slice(start: number, end?: number): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNonNegative({ start });\r\n ArgumentUtility.checkSafeInteger({ start });\r\n if (end !== undefined) {\r\n ArgumentUtility.checkNonNegative({ end });\r\n ArgumentUtility.checkSafeInteger({ end });\r\n if (end < start) {\r\n throw new ArgumentOutOfRangeError(\"end\", \"`end` must be greater than or equal to `start`.\");\r\n }\r\n }\r\n\r\n const resolvedEnd = end ?? Number.MAX_SAFE_INTEGER;\r\n return this.createSequence(\r\n () => new SliceEnumerator<TSource>(this.getEnumerator(), start, resolvedEnd),\r\n this.createNode(\"slice\", \"streaming\", [start, end])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public split(splitOn: (item: TSource) => boolean): TyneqSequence<TSource[]> {\r\n ArgumentUtility.checkNotOptional({ splitOn });\r\n return this.createSequence(\r\n () => new SplitEnumerator<TSource>(this.getEnumerator(), splitOn),\r\n this.createNode(\"split\", \"streaming\", [splitOn])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public take(count: number): TyneqSequence<TSource> {\r\n ArgumentUtility.checkSafeInteger({ count });\r\n ArgumentUtility.checkNonNegative({ count });\r\n return this.createSequence(\r\n () => new TakeEnumerator<TSource>(this.getEnumerator(), count),\r\n this.createNode(\"take\", \"streaming\", [count])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public takeUntil(predicate: ItemPredicate<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n return this.createSequence(\r\n () => new TakeUntilEnumerator<TSource>(this.getEnumerator(), predicate),\r\n this.createNode(\"takeUntil\", \"streaming\", [predicate])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public takeWhile(predicate: ItemPredicate<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n return this.createSequence(\r\n () => new TakeWhileEnumerator<TSource>(this.getEnumerator(), predicate),\r\n this.createNode(\"takeWhile\", \"streaming\", [predicate])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public tap(action: ItemAction<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ action });\r\n return this.createSequence(\r\n () => new TapEnumerator<TSource>(this.getEnumerator(), action),\r\n this.createNode(\"tap\", \"streaming\", [action])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public tapIf(action: ItemAction<TSource>, predicate: () => boolean): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ action });\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n return this.createSequence(\r\n () => new TapIfEnumerator<TSource>(this.getEnumerator(), action, predicate),\r\n this.createNode(\"tapIf\", \"streaming\", [action, predicate])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public throttle(count: number): TyneqSequence<TSource> {\r\n ArgumentUtility.checkSafeInteger({ count });\r\n ArgumentUtility.checkPositive({ count });\r\n return this.createSequence(\r\n () => new ThrottleEnumerator<TSource>(this.getEnumerator(), count),\r\n this.createNode(\"throttle\", \"streaming\", [count])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public where(predicate: ItemPredicate<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ predicate });\r\n return this.createSequence(\r\n () => new WhereEnumerator<TSource>(this.getEnumerator(), predicate),\r\n this.createNode(\"where\", \"streaming\", [predicate])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"streaming\" })\r\n public zip<TOther, TResult>(\r\n other: Iterable<TOther>,\r\n selector: (first: TSource, second: TOther) => TResult\r\n ): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ other });\r\n ArgumentUtility.checkIterable({ other });\r\n ArgumentUtility.checkNotOptional({ selector });\r\n return this.createSequence(\r\n () => new ZipEnumerator<TSource, TOther, TResult>(this.getEnumerator(), other, selector),\r\n this.createNode(\"zip\", \"streaming\", [other, selector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public backsert(index: number, other: Iterable<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ other });\r\n ArgumentUtility.checkSafeInteger({ index });\r\n ArgumentUtility.checkNonNegative({ index });\r\n ArgumentUtility.checkIterable({ other });\r\n return this.createSequence(\r\n () => new BacksertEnumerator<TSource>(this.getEnumerator(), index, other),\r\n this.createNode(\"backsert\", \"buffer\", [index, other])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public distinct(): TyneqSequence<TSource> {\r\n return this.createSequence(\r\n () => new DistinctEnumerator<TSource>(this.getEnumerator()),\r\n this.createNode(\"distinct\", \"buffer\")\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public distinctBy<TKey>(keySelector: (item: TSource) => TKey): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n return this.createSequence(\r\n () => new DistinctByEnumerator<TSource, TKey>(this.getEnumerator(), keySelector),\r\n this.createNode(\"distinctBy\", \"buffer\", [keySelector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public except(excludedValues: Iterable<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ excludedValues });\r\n ArgumentUtility.checkIterable({ excludedValues });\r\n return this.createSequence(\r\n () => new ExceptEnumerator<TSource>(this.getEnumerator(), excludedValues),\r\n this.createNode(\"except\", \"buffer\", [excludedValues])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public exceptBy<TKey>(\r\n excludedKeys: Iterable<TKey>,\r\n keySelector: (item: TSource) => TKey\r\n ): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ excludedKeys });\r\n ArgumentUtility.checkIterable({ excludedKeys });\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n return this.createSequence(\r\n () => new ExceptByEnumerator<TSource, TKey>(this.getEnumerator(), excludedKeys, keySelector),\r\n this.createNode(\"exceptBy\", \"buffer\", [excludedKeys, keySelector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public groupBy<TKey, TValue, TResult>(\r\n keySelector: (item: TSource) => TKey,\r\n valueSelector: (item: TSource) => TValue,\r\n resultSelector: (key: TKey, values: TyneqSequence<TValue>) => TResult\r\n ): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n ArgumentUtility.checkNotOptional({ valueSelector });\r\n ArgumentUtility.checkNotOptional({ resultSelector });\r\n const groupFactory = (values: TValue[]): TyneqSequence<TValue> =>\r\n this.createEnumerable({ getEnumerator: () => values[Symbol.iterator]() as Enumerator<TValue> }, null);\r\n return this.createSequence(\r\n () => new GroupByEnumerator<TSource, TKey, TValue, TResult>(\r\n this.getEnumerator(), keySelector, valueSelector, resultSelector, groupFactory\r\n ),\r\n this.createNode(\"groupBy\", \"buffer\", [keySelector, valueSelector, resultSelector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public groupJoin<TInner, TKey, TResult>(\r\n inner: Iterable<TInner>,\r\n outerKeySelector: (outer: TSource) => TKey,\r\n innerKeySelector: (inner: TInner) => TKey,\r\n resultSelector: (outer: TSource, group: TyneqSequence<TInner>) => TResult\r\n ): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ inner });\r\n ArgumentUtility.checkIterable({ inner });\r\n ArgumentUtility.checkNotOptional({ outerKeySelector });\r\n ArgumentUtility.checkNotOptional({ innerKeySelector });\r\n ArgumentUtility.checkNotOptional({ resultSelector });\r\n const groupFactory = (values: TInner[]): TyneqSequence<TInner> =>\r\n this.createEnumerable({ getEnumerator: () => values[Symbol.iterator]() as Enumerator<TInner> }, null);\r\n return this.createSequence(\r\n () => new GroupJoinEnumerator<TSource, TInner, TKey, TResult>(\r\n this.getEnumerator(), inner, outerKeySelector, innerKeySelector, resultSelector, groupFactory\r\n ),\r\n this.createNode(\"groupJoin\", \"buffer\", [inner, outerKeySelector, innerKeySelector, resultSelector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public intersect(intersectedValues: Iterable<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ intersectedValues });\r\n ArgumentUtility.checkIterable({ intersectedValues });\r\n return this.createSequence(\r\n () => new IntersectEnumerator<TSource>(this.getEnumerator(), intersectedValues),\r\n this.createNode(\"intersect\", \"buffer\", [intersectedValues])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public intersectBy<TKey>(\r\n intersectedKeys: Iterable<TKey>,\r\n keySelector: (item: TSource) => TKey\r\n ): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ intersectedKeys });\r\n ArgumentUtility.checkIterable({ intersectedKeys });\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n return this.createSequence(\r\n () => new IntersectByEnumerator<TSource, TKey>(this.getEnumerator(), intersectedKeys, keySelector),\r\n this.createNode(\"intersectBy\", \"buffer\", [intersectedKeys, keySelector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public join<TInner, TKey, TResult>(\r\n inner: Iterable<TInner>,\r\n outerKeySelector: (outer: TSource) => TKey,\r\n innerKeySelector: (inner: TInner) => TKey,\r\n resultSelector: (outer: TSource, inner: TInner) => TResult\r\n ): TyneqSequence<TResult> {\r\n ArgumentUtility.checkNotOptional({ inner });\r\n ArgumentUtility.checkIterable({ inner });\r\n ArgumentUtility.checkNotOptional({ outerKeySelector });\r\n ArgumentUtility.checkNotOptional({ innerKeySelector });\r\n ArgumentUtility.checkNotOptional({ resultSelector });\r\n return this.createSequence(\r\n () => new JoinEnumerator<TSource, TInner, TKey, TResult>(\r\n this.getEnumerator(), inner, outerKeySelector, innerKeySelector, resultSelector\r\n ),\r\n this.createNode(\"join\", \"buffer\", [inner, outerKeySelector, innerKeySelector, resultSelector])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public permutations(): TyneqSequence<TSource[]> {\r\n return this.createSequence(\r\n () => new PermutationsEnumerator<TSource>(this.getEnumerator()),\r\n this.createNode(\"permutations\", \"buffer\")\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public reverse(): TyneqSequence<TSource> {\r\n return this.createSequence(\r\n () => new ReverseEnumerator<TSource>(this.getEnumerator()),\r\n this.createNode(\"reverse\", \"buffer\")\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public shuffle(): TyneqSequence<TSource> {\r\n return this.createSequence(\r\n () => new ShuffleEnumerator<TSource>(this.getEnumerator()),\r\n this.createNode(\"shuffle\", \"buffer\")\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public union(otherValues: Iterable<TSource>): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ otherValues });\r\n ArgumentUtility.checkIterable({ otherValues });\r\n return this.createSequence(\r\n () => new UnionEnumerator<TSource>(this.getEnumerator(), otherValues),\r\n this.createNode(\"union\", \"buffer\", [otherValues])\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public unionBy<TKey>(\r\n otherValues: Iterable<TSource>,\r\n keySelector: (item: TSource) => TKey\r\n ): TyneqSequence<TSource> {\r\n ArgumentUtility.checkNotOptional({ otherValues });\r\n ArgumentUtility.checkIterable({ otherValues });\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n return this.createSequence(\r\n () => new UnionByEnumerator<TSource, TKey>(this.getEnumerator(), otherValues, keySelector),\r\n this.createNode(\"unionBy\", \"buffer\", [otherValues, keySelector])\r\n );\r\n }\r\n}\r\n","import { TyneqCachedEnumerable } from \"../../core/TyneqCachedEnumerable\";\r\nimport { TyneqBaseEnumerator } from \"../../core/enumerators/TyneqBaseEnumerator\";\r\n\r\n/**\r\n * Iterates a cached enumerable, replaying previously computed elements on subsequent iterations.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.memoize}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class MemoizeEnumerator<TSource> extends TyneqBaseEnumerator<TSource> {\r\n private readonly cachedEnumerable: TyneqCachedEnumerable<TSource>;\r\n private index = 0;\r\n\r\n \r\n public constructor(cachedEnumerable: TyneqCachedEnumerable<TSource>) {\r\n super();\r\n this.cachedEnumerable = cachedEnumerable;\r\n }\r\n\r\n protected override disposeSource(): void { }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n const result = this.cachedEnumerable.tryGetAtFromCache(this.index);\r\n\r\n if (!result.has) {\r\n return this.done();\r\n }\r\n\r\n this.index++;\r\n return this.yield(result.value);\r\n }\r\n}\r\n","\r\n/**\r\n * Abstract base for multi-key stable sorters used by the ordering infrastructure.\r\n *\r\n * @remarks\r\n * `computeKeys()` pre-computes sort keys for each element; `compareKeys()` compares by index.\r\n * Sorters chain together via the `next` field on {@link TyneqEnumerableSorter} to implement\r\n * multi-key (thenBy) sorting.\r\n *\r\n * @internal\r\n */\r\nexport abstract class BaseEnumerableSorter<TSource> {\r\n /** Pre-computes the sort key for each element in `source[0..count-1]`. */\r\n public abstract computeKeys(source: TSource[], count: number): void;\r\n\r\n /** Compares the sort keys at indices `i` and `j`. Returns negative, zero, or positive. */\r\n public abstract compareKeys(i: number, j: number): number;\r\n\r\n /**\r\n * Returns a stable sorted index map for `source[0..count-1]`.\r\n *\r\n * @returns An array of indices sorted by the key order defined by this sorter chain.\r\n */\r\n public sort(source: TSource[], count: number): number[] {\r\n this.computeKeys([...source], count);\r\n const indexMap: number[] = Array.from({ length: count }, (_, i) => i);\r\n\r\n indexMap.sort((a, b) => this.compareKeys(a, b));\r\n return indexMap;\r\n }\r\n}\r\n","import { Nullable } from \"../../types/utility\";\r\nimport { Comparer } from \"../../types/core\";\r\nimport { ArgumentUtility } from \"../../utility/ArgumentUtility\";\r\nimport { BaseEnumerableSorter } from \"./BaseEnumerableSorter\";\r\n\r\n/**\r\n * Concrete sorter that extracts keys via a selector and compares them with a comparer.\r\n *\r\n * @remarks\r\n * Chains to a `next` sorter for secondary sort keys (thenBy). Stability is preserved by\r\n * falling back to index comparison when keys are equal at the innermost sorter level.\r\n *\r\n * @internal\r\n */\r\nexport class TyneqEnumerableSorter<TSource, TKey> extends BaseEnumerableSorter<TSource> {\r\n private keys: TKey[] = [];\r\n private readonly keySelector: (item: TSource) => TKey;\r\n private readonly comparer: Comparer<TKey>;\r\n private readonly descending: number;\r\n private next: Nullable<BaseEnumerableSorter<TSource>> = null;\r\n\r\n\r\n public constructor(keySelector: (item: TSource) => TKey, comparer: Comparer<TKey>, descending: boolean, next?: BaseEnumerableSorter<TSource>) {\r\n super();\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n ArgumentUtility.checkNotOptional({ comparer });\r\n\r\n this.keySelector = keySelector;\r\n this.comparer = comparer;\r\n this.descending = descending ? -1 : 1;\r\n this.next = next ?? null;\r\n }\r\n\r\n \r\n public override computeKeys(source: TSource[], count: number): void {\r\n this.keys = new Array<TKey>(count);\r\n for (let i = 0; i < count; i++) {\r\n this.keys[i] = this.keySelector(source[i]);\r\n }\r\n\r\n this.next?.computeKeys(source, count);\r\n }\r\n\r\n \r\n public override compareKeys(i: number, j: number): number {\r\n const result = this.comparer(this.keys[i], this.keys[j]) * this.descending;\r\n if (result !== 0) {\r\n return result;\r\n }\r\n\r\n if (this.next === null) {\r\n return this.stabilityCompare(i, j);\r\n }\r\n\r\n return this.next.compareKeys(i, j);\r\n }\r\n\r\n \r\n protected stabilityCompare(i: number, j: number): number {\r\n return i - j;\r\n }\r\n}\r\n","import { OrderedEnumerable } from \"../../types/core\";\r\nimport { Nullable } from \"../../types/utility\";\r\nimport { BaseEnumerableSorter } from \"../../core/ordering/BaseEnumerableSorter\";\r\nimport { TyneqBaseEnumerator } from \"../../core/enumerators/TyneqBaseEnumerator\";\r\n\r\n/**\r\n * Yields the elements of an ordered sequence in sorted order.\r\n *\r\n * @remarks\r\n * Deferred. Source is fully buffered on the first iteration of the returned sequence.\r\n *\r\n * @see {@link TyneqSequence.orderBy}\r\n * @group Operators\r\n * @category Buffering\r\n * @internal\r\n */\r\nexport class OrderByEnumerator<TSource, _TKey> extends TyneqBaseEnumerator<TSource> {\r\n private buffer: TSource[] = [];\r\n private indexMap: number[] = [];\r\n private currentIndex = 0;\r\n private readonly orderedEnumerable: OrderedEnumerable<TSource>;\r\n\r\n \r\n public constructor(orderedEnumerable: OrderedEnumerable<TSource>) {\r\n super();\r\n this.orderedEnumerable = orderedEnumerable;\r\n }\r\n\r\n protected override initialize(): void {\r\n this.buffer = Array.from(this.orderedEnumerable.source);\r\n const sorter = this.getSorter(this.orderedEnumerable);\r\n this.indexMap = sorter.sort(this.buffer, this.buffer.length);\r\n }\r\n\r\n protected override handleNext(): IteratorResult<TSource> {\r\n if (this.currentIndex >= this.indexMap.length) {\r\n return this.done();\r\n }\r\n\r\n const index = this.indexMap[this.currentIndex++];\r\n return this.yield(this.buffer[index]);\r\n }\r\n\r\n private getSorter(base: OrderedEnumerable<TSource>): BaseEnumerableSorter<TSource> {\r\n let sorter: Nullable<BaseEnumerableSorter<TSource>> = null;\r\n for (let enumerable: Nullable<OrderedEnumerable<TSource>> = base; enumerable !== null; enumerable = enumerable.parent) {\r\n sorter = enumerable.getSorter(sorter);\r\n }\r\n\r\n return sorter!;\r\n }\r\n}\r\n","import { Nullable } from \"../../types/utility\";\r\nimport { BaseEnumerableSorter } from \"./BaseEnumerableSorter\";\r\nimport { TyneqEnumerableSorter } from \"./TyneqEnumerableSorter\";\r\nimport type { Enumerator, EnumeratorFactory, OrderedEnumerable, TyneqCachedSequence, TyneqSequence, TyneqOrderedSequence, Comparer } from \"../../types/core\";\r\nimport { tyneqQueryNode } from \"../../types/queryplan\";\r\nimport type { QueryPlanNode } from \"../../types/queryplan\";\r\nimport { QueryNode } from \"../../queryplan/QueryNode\";\r\nimport { TyneqEnumerable } from \"../TyneqEnumerable\";\r\nimport { OrderByEnumerator } from \"../../enumerators/buffer/orderBy\";\r\nimport { TyneqEnumerableBase } from \"../TyneqEnumerableBase\";\r\nimport { TyneqComparer } from \"../TyneqComparer\";\r\nimport { ArgumentUtility } from \"../../utility/ArgumentUtility\";\r\nimport { TyneqCachedEnumerable } from \"../TyneqCachedEnumerable\";\r\nimport { sequence } from \"../../plugin/decorators/sequence\";\r\nimport { builtin } from \"../../plugin/decorators/builtin\";\r\n\r\nconst ASC_TO_DESC: Readonly<Record<string, string>> = {\r\n \"orderBy\": \"orderByDescending\",\r\n \"thenBy\": \"thenByDescending\",\r\n};\r\n\r\nconst DESC_TO_ASC: Readonly<Record<string, string>> = {\r\n \"orderByDescending\": \"orderBy\",\r\n \"thenByDescending\": \"thenBy\",\r\n};\r\n\r\n/**\r\n * Concrete implementation of {@link TyneqOrderedSequence}.\r\n *\r\n * @remarks\r\n * Created by `orderBy` and `orderByDescending`. Chains to a parent `TyneqOrderedEnumerable`\r\n * via `thenBy` / `thenByDescending` to build a multi-key sorter.\r\n *\r\n * @internal\r\n */\r\n@sequence\r\nexport class TyneqOrderedEnumerable<TSource, TKey> extends TyneqEnumerableBase<TSource> implements TyneqOrderedSequence<TSource> {\r\n private readonly keySelector: (item: TSource) => TKey;\r\n private readonly comparer: Comparer<TKey>;\r\n private readonly descending: boolean;\r\n\r\n public readonly source: TyneqSequence<TSource>;\r\n public readonly parent: Nullable<OrderedEnumerable<TSource>>;\r\n public readonly [tyneqQueryNode]: Nullable<QueryPlanNode>;\r\n \r\n public constructor(\r\n source: TyneqSequence<TSource>,\r\n keySelector: (item: TSource) => TKey,\r\n comparer: Comparer<TKey>,\r\n descending: boolean,\r\n parent?: OrderedEnumerable<TSource>,\r\n node?: Nullable<QueryPlanNode>\r\n ) {\r\n super();\r\n ArgumentUtility.checkNotOptional({ source });\r\n ArgumentUtility.checkNotOptional({ keySelector });\r\n ArgumentUtility.checkNotOptional({ comparer });\r\n\r\n this.source = source;\r\n this.keySelector = keySelector;\r\n this.comparer = comparer;\r\n this.descending = descending;\r\n this.parent = parent ?? null;\r\n this[tyneqQueryNode] = node ?? null;\r\n }\r\n\r\n public asc(): TyneqOrderedSequence<TSource> {\r\n if (!this.descending) {\r\n return this;\r\n }\r\n\r\n const currentNode = this[tyneqQueryNode];\r\n const node = currentNode\r\n ? new QueryNode(DESC_TO_ASC[currentNode.operatorName] ?? currentNode.operatorName, currentNode.args, currentNode.source, currentNode.category, currentNode.sourceKind)\r\n : null;\r\n\r\n return new TyneqOrderedEnumerable(\r\n this.source,\r\n this.keySelector,\r\n this.comparer,\r\n false,\r\n this.parent ?? undefined,\r\n node);\r\n }\r\n\r\n public desc(): TyneqOrderedSequence<TSource> {\r\n if (this.descending) {\r\n return this;\r\n }\r\n\r\n const currentNode = this[tyneqQueryNode];\r\n const node = currentNode\r\n ? new QueryNode(ASC_TO_DESC[currentNode.operatorName] ?? currentNode.operatorName, currentNode.args, currentNode.source, currentNode.category, currentNode.sourceKind)\r\n : null;\r\n\r\n return new TyneqOrderedEnumerable(\r\n this.source,\r\n this.keySelector,\r\n this.comparer,\r\n true,\r\n this.parent ?? undefined,\r\n node);\r\n }\r\n\r\n public override getEnumerator(): Enumerator<TSource> {\r\n return new OrderByEnumerator<TSource, TKey>(this);\r\n }\r\n\r\n \r\n public getSorter(next: Nullable<BaseEnumerableSorter<TSource>>): BaseEnumerableSorter<TSource> {\r\n return new TyneqEnumerableSorter<TSource, TKey>(\r\n this.keySelector,\r\n this.comparer,\r\n this.descending,\r\n next ?? undefined\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public thenBy<UKey>(\r\n keySelector: (item: TSource) => UKey,\r\n comparer?: Comparer<UKey>\r\n ): TyneqOrderedSequence<TSource> {\r\n const thenByArgs = comparer !== undefined ? [keySelector, comparer] : [keySelector];\r\n const node = new QueryNode(\"thenBy\", thenByArgs, this[tyneqQueryNode], \"buffer\");\r\n\r\n return new TyneqOrderedEnumerable<TSource, UKey>(\r\n this.source,\r\n keySelector,\r\n comparer ?? TyneqComparer.defaultComparer,\r\n false,\r\n this,\r\n node\r\n );\r\n }\r\n\r\n @builtin({ kind: \"buffer\" })\r\n public thenByDescending<UKey>(\r\n keySelector: (item: TSource) => UKey,\r\n comparer?: Comparer<UKey>\r\n ): TyneqOrderedSequence<TSource> {\r\n const thenByDescArgs = comparer !== undefined ? [keySelector, comparer] : [keySelector];\r\n const node = new QueryNode(\"thenByDescending\", thenByDescArgs, this[tyneqQueryNode], \"buffer\");\r\n return new TyneqOrderedEnumerable<TSource, UKey>(\r\n this.source,\r\n keySelector,\r\n comparer ?? TyneqComparer.defaultComparer,\r\n true,\r\n this,\r\n node\r\n );\r\n }\r\n\r\n protected override createEnumerable<TResult>(factory: EnumeratorFactory<TResult>, node: Nullable<QueryPlanNode>): TyneqSequence<TResult> {\r\n return new TyneqEnumerable<TResult>(factory, node);\r\n }\r\n\r\n protected override createOrderedEnumerable<TKey>(\r\n keySelector: (x: TSource) => TKey,\r\n comparer: Comparer<TKey>,\r\n descending: boolean,\r\n node: Nullable<QueryPlanNode>\r\n ): TyneqOrderedSequence<TSource> {\r\n return new TyneqOrderedEnumerable<TSource, TKey>(\r\n this.source,\r\n keySelector,\r\n comparer,\r\n descending,\r\n this,\r\n node\r\n );\r\n }\r\n\r\n protected override createCachedEnumerable(source: TyneqSequence<TSource>, node: Nullable<QueryPlanNode>): TyneqCachedSequence<TSource> {\r\n return new TyneqCachedEnumerable<TSource>(source, node);\r\n }\r\n}\r\n","import { MemoizeEnumerator } from \"../enumerators/buffer/memoize\";\r\nimport { builtin } from \"../plugin/decorators/builtin\";\r\nimport { sequence } from \"../plugin/decorators/sequence\";\r\nimport { CacheResult, CachedEnumerable, Enumerator, EnumeratorFactory, TyneqCachedSequence, TyneqSequence, TyneqOrderedSequence, Comparer } from \"../types/core\";\r\nimport { tyneqQueryNode } from \"../types/queryplan\";\r\nimport type { QueryPlanNode } from \"../types/queryplan\";\r\nimport type { Nullable } from \"../types/utility\";\r\nimport { TyneqOrderedEnumerable } from \"./ordering/TyneqOrderedEnumerable\";\r\nimport { TyneqEnumerable } from \"./TyneqEnumerable\";\r\nimport { TyneqEnumerableBase } from \"./TyneqEnumerableBase\";\r\n\r\n/**\r\n * Concrete implementation of {@link TyneqCachedSequence} - caches elements incrementally.\r\n *\r\n * @remarks\r\n * Created by `memoize()`. On the first iteration the source is enumerated one element at a time\r\n * and each element is appended to an internal array. Subsequent iterations replay the cache;\r\n * the source is not re-enumerated. Call `refresh()` to clear the cache and start over.\r\n *\r\n * @internal\r\n */\r\n@sequence\r\nexport class TyneqCachedEnumerable<TSource> extends TyneqEnumerableBase<TSource> implements TyneqCachedSequence<TSource>, CachedEnumerable<TSource> {\r\n private source: TyneqSequence<TSource>;\r\n private cache: TSource[] = [];\r\n private done: boolean = false;\r\n private sourceEnumerator: Nullable<Enumerator<TSource>> = null;\r\n\r\n public readonly [tyneqQueryNode]: Nullable<QueryPlanNode>;\r\n\r\n public constructor(source: TyneqSequence<TSource>, node?: Nullable<QueryPlanNode>) {\r\n super();\r\n this.source = source;\r\n this[tyneqQueryNode] = node ?? null;\r\n }\r\n\r\n public getEnumerator(): Enumerator<TSource> {\r\n return new MemoizeEnumerator(this);\r\n }\r\n\r\n @builtin({ kind: \"cache\" })\r\n public refresh(): TyneqCachedSequence<TSource> {\r\n this.cache = [];\r\n this.done = false;\r\n this.sourceEnumerator?.return?.();\r\n this.sourceEnumerator = null;\r\n return this;\r\n }\r\n\r\n public tryGetAtFromCache(index: number): CacheResult<TSource> {\r\n if (index < this.cache.length) {\r\n return { has: true, value: this.cache[index] };\r\n }\r\n\r\n if (this.done) {\r\n return { has: false };\r\n }\r\n\r\n if (this.sourceEnumerator === null) {\r\n this.sourceEnumerator = this.source.getEnumerator();\r\n }\r\n\r\n const next = this.sourceEnumerator.next();\r\n\r\n if (!next.done) {\r\n const value = next.value;\r\n this.cache.push(value);\r\n return { has: true, value };\r\n }\r\n\r\n this.done = true;\r\n this.sourceEnumerator.return?.();\r\n this.sourceEnumerator = null;\r\n return { has: false };\r\n }\r\n\r\n protected createEnumerable<TResult>(factory: EnumeratorFactory<TResult>, node: Nullable<QueryPlanNode>): TyneqSequence<TResult> {\r\n return new TyneqEnumerable<TResult>(factory, node);\r\n }\r\n protected createOrderedEnumerable<TKey>(keySelector: (x: TSource) => TKey, comparer: Comparer<TKey>, descending: boolean, node: Nullable<QueryPlanNode>): TyneqOrderedSequence<TSource> {\r\n return new TyneqOrderedEnumerable<TSource, TKey>(\r\n this,\r\n keySelector,\r\n comparer,\r\n descending,\r\n undefined,\r\n node\r\n );\r\n }\r\n\r\n protected createCachedEnumerable(source: TyneqSequence<TSource>, node: Nullable<QueryPlanNode>): TyneqCachedSequence<TSource> {\r\n return new TyneqCachedEnumerable<TSource>(source, node);\r\n }\r\n}\r\n","import { Enumerator, EnumeratorFactory, TyneqCachedSequence, TyneqSequence, TyneqOrderedSequence, Comparer } from \"../types/core\";\r\nimport { TyneqEnumerableBase } from \"./TyneqEnumerableBase\";\r\nimport { tyneqQueryNode } from \"../types/queryplan\";\r\nimport type { QueryPlanNode } from \"../types/queryplan\";\r\nimport { ArgumentUtility } from \"../utility/ArgumentUtility\";\r\nimport { TyneqCachedEnumerable } from \"./TyneqCachedEnumerable\";\r\nimport { TyneqOrderedEnumerable } from \"./ordering/TyneqOrderedEnumerable\";\r\nimport { Nullable } from \"../types/utility\";\r\n\r\n/**\r\n * The standard concrete implementation of {@link TyneqSequence}.\r\n *\r\n * @remarks\r\n * Created by operator methods in {@link TyneqEnumerableBase} and by the `Tyneq` factory.\r\n * Delegates element production to the `EnumeratorFactory` passed at construction.\r\n *\r\n * @internal\r\n */\r\nexport class TyneqEnumerable<TSource> extends TyneqEnumerableBase<TSource> {\r\n protected readonly enumeratorFactory: EnumeratorFactory<TSource>;\r\n\r\n public readonly [tyneqQueryNode]: Nullable<QueryPlanNode>;\r\n\r\n \r\n public constructor(enumeratorFactory: EnumeratorFactory<TSource>, node: Nullable<QueryPlanNode>) {\r\n super();\r\n ArgumentUtility.checkNotOptional({ enumeratorFactory });\r\n this.enumeratorFactory = enumeratorFactory;\r\n this[tyneqQueryNode] = node ?? null;\r\n }\r\n\r\n public override getEnumerator(): Enumerator<TSource> {\r\n return this.enumeratorFactory.getEnumerator();\r\n }\r\n\r\n protected override createEnumerable<TResult>(factory: EnumeratorFactory<TResult>, node: Nullable<QueryPlanNode>): TyneqSequence<TResult> {\r\n return new TyneqEnumerable<TResult>(factory, node);\r\n }\r\n\r\n protected createOrderedEnumerable<TKey>(\r\n keySelector: (x: TSource) => TKey,\r\n comparer: Comparer<TKey>,\r\n descending: boolean,\r\n node: Nullable<QueryPlanNode>\r\n ): TyneqOrderedSequence<TSource> {\r\n return new TyneqOrderedEnumerable<TSource, TKey>(\r\n this,\r\n keySelector,\r\n comparer,\r\n descending,\r\n undefined,\r\n node\r\n );\r\n }\r\n\r\n protected createCachedEnumerable(source: TyneqSequence<TSource>, node: Nullable<QueryPlanNode>): TyneqCachedSequence<TSource> {\r\n return new TyneqCachedEnumerable<TSource>(source, node);\r\n }\r\n}\r\n","import { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport type { OperatorSource } from \"../../types/core\";\r\n\r\n/**\r\n * Options for the {@link source} decorator.\r\n */\r\nexport interface SourceDecoratorOptions {\r\n /**\r\n * The operator name used to look up this source in the registry.\r\n * Must match the `operatorName` on the `QueryPlanNode`.\r\n * Defaults to the decorated method's name when omitted.\r\n */\r\n readonly name?: string;\r\n /**\r\n * Whether this is a built-in (`\"internal\"`) or third-party (`\"external\"`) source.\r\n * Defaults to `\"external\"`.\r\n */\r\n readonly source?: OperatorSource;\r\n}\r\n\r\n/**\r\n * Static method decorator that registers the decorated method as a source operator.\r\n *\r\n * The method itself becomes the factory: when the compiler resolves a source node\r\n * whose `operatorName` matches the registered name, it calls the method with the\r\n * node's `args`. No duplication of implementation - the registration points directly\r\n * at the method.\r\n *\r\n * The operator name defaults to the method name, so `@source()` is sufficient when\r\n * they match.\r\n *\r\n * @param options - Optional config. Omit entirely to use all defaults.\r\n *\r\n * @example\r\n * ```ts\r\n * import { source } from \"tyneq/plugin\";\r\n * import { Tyneq } from \"tyneq\";\r\n *\r\n * class MySources {\r\n * @source()\r\n * public static fibonacci(count: number): ReturnType<typeof Tyneq.range> {\r\n * // registered as \"fibonacci\"\r\n * }\r\n *\r\n * @source({ name: \"fib2\", source: \"external\" })\r\n * public static fibonacci2(count: number): ReturnType<typeof Tyneq.range> {\r\n * // registered as \"fib2\"\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @group Decorators\r\n */\r\nexport function source(options: SourceDecoratorOptions = {}) {\r\n return function <TMethod extends (...args: any[]) => any>(\r\n method: TMethod,\r\n context: ClassMethodDecoratorContext & { static: true }\r\n ): void {\r\n const operatorName = options.name ?? (context.name as string);\r\n const operatorSource = options.source ?? \"external\";\r\n OperatorRegistry.registerSource(operatorName, method as (...args: unknown[]) => unknown, operatorSource);\r\n };\r\n}\r\n","import type { EnumeratorFactory, SequenceFactory } from \"../types/core\";\r\nimport type { OperatorCategory, QueryPlanNode } from \"../types/queryplan\";\r\nimport type { TyneqEnumerableBase } from \"../core/TyneqEnumerableBase\";\r\nimport { QueryNode } from \"../queryplan/QueryNode\";\r\nimport { tyneqQueryNode } from \"../types/queryplan\";\r\n\r\n/**\r\n * Low-level helpers used by every decorator and registration function in `src/plugin`.\r\n *\r\n * @remarks\r\n * These methods centralise two patterns that would otherwise be copy-pasted into every\r\n * operator `impl` closure:\r\n *\r\n * - {@link buildEnumerable} - validate, create a query node, then call\r\n * `createEnumerable`. Used by every standard operator decorator and factory.\r\n * - {@link buildQueryNode} - create a query node only. Used by `createOrderedOperator`\r\n * and `createCachedOperator`, which construct the result sequence themselves.\r\n *\r\n * `asSequenceFactory` is kept private to this class; it exists only to resolve the\r\n * `protected` access modifier on `createEnumerable` via a structural double-cast.\r\n *\r\n * @internal\r\n */\r\nexport class RegistrationUtility {\r\n private constructor() { }\r\n\r\n /**\r\n * Builds a new sequence from an enumerator factory and registers a query plan node.\r\n *\r\n * @remarks\r\n * Every standard (non-terminal, non-ordered, non-cached) operator `impl` follows\r\n * the same pattern: get the `SequenceFactory` view of `this`, create a `QueryNode`,\r\n * then call `factory.createEnumerable(enumeratorFactory, node)`. This method\r\n * centralises that pattern so decorator and factory `impl` bodies stay minimal.\r\n *\r\n * @param sequence - The current sequence (`this` inside an `impl` function).\r\n * @param name - Operator name, used as the query node label.\r\n * @param userArgs - Arguments passed by the caller, captured in the query node.\r\n * @param category - Operator category for the query node.\r\n * @param enumeratorFactory - The factory that produces the new enumerator.\r\n */\r\n public static buildEnumerable(\r\n sequence: TyneqEnumerableBase<unknown>,\r\n name: string,\r\n userArgs: unknown[],\r\n category: OperatorCategory,\r\n enumeratorFactory: EnumeratorFactory<unknown>\r\n ): unknown {\r\n const factory = RegistrationUtility.asSequenceFactory(sequence);\r\n const node = new QueryNode(name, userArgs, factory[tyneqQueryNode], category);\r\n return factory.createEnumerable(enumeratorFactory, node);\r\n }\r\n\r\n /**\r\n * Creates a `QueryPlanNode` for an operator, linked to the upstream node on `sequence`.\r\n *\r\n * @remarks\r\n * Used by `createOrderedOperator` and `createCachedOperator`, which hand the node\r\n * directly to their own factory function (because those factories construct the result\r\n * sequence themselves rather than delegating to `createEnumerable`).\r\n *\r\n * @param sequence - The current sequence (`this` inside an `impl` function).\r\n * @param name - Operator name, used as the query node label.\r\n * @param userArgs - Arguments passed by the caller, captured in the query node.\r\n * @param category - Operator category for the query node.\r\n */\r\n public static buildQueryNode(\r\n sequence: TyneqEnumerableBase<unknown>,\r\n name: string,\r\n userArgs: unknown[],\r\n category: OperatorCategory\r\n ): QueryPlanNode {\r\n const factory = RegistrationUtility.asSequenceFactory(sequence);\r\n return new QueryNode(name, userArgs, factory[tyneqQueryNode], category);\r\n }\r\n\r\n /**\r\n * Narrows a `TyneqEnumerableBase` to its `SequenceFactory` view.\r\n *\r\n * @remarks\r\n * The double-cast (`as unknown as SequenceFactory`) is required because\r\n * `createEnumerable` and `createCachedEnumerable` are `protected` on the\r\n * class hierarchy. `SequenceFactory` is a structural interface that describes\r\n * the same shape, allowing registration-time closures to call factory methods\r\n * without changing their access modifier. This is a known architectural trade-off\r\n * documented in `tasks/lessons.md` under \"Architecture Decisions\".\r\n */\r\n private static asSequenceFactory<TSource>(sequence: TyneqEnumerableBase<TSource>): SequenceFactory<TSource> {\r\n return sequence as unknown as SequenceFactory<TSource>;\r\n }\r\n}\r\n","import { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { PluginError } from \"../../core/errors/PluginError\";\r\nimport { reflect } from \"../../utility/reflect\";\r\nimport { RegistrationUtility } from \"../RegistrationUtility\";\r\n\r\n/**\r\n * Class decorator that registers a `TyneqEnumerator` subclass as an operator on every sequence.\r\n *\r\n * Validation runs eagerly at the call site, before the lazy enumerator is created.\r\n *\r\n * @param name - Method name to expose on every sequence.\r\n * @param category - Operator kind (`\"streaming\"` | `\"buffer\"`).\r\n * @param validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * import { operator, TyneqEnumerator } from \"tyneq/plugin\";\r\n * import type { Enumerator } from \"tyneq\";\r\n *\r\n * @operator<[predicate: (item: unknown) => boolean]>(\"myFilter\", \"streaming\", (predicate) => {\r\n * if (typeof predicate !== \"function\") throw new Error(\"predicate must be a function\");\r\n * })\r\n * class MyFilterEnumerator<T> extends TyneqEnumerator<T> {\r\n * public constructor(source: Enumerator<T>, private readonly predicate: (item: T) => boolean) {\r\n * super(source);\r\n * }\r\n * protected handleNext(): IteratorResult<T> {\r\n * while (true) {\r\n * const next = this.sourceEnumerator.next();\r\n * if (next.done || this.predicate(next.value)) return next;\r\n * }\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @group Decorators\r\n */\r\nexport function operator<TArgs extends unknown[] = never>(\r\n name: string,\r\n category: \"streaming\" | \"buffer\",\r\n validate?: (...args: TArgs) => void\r\n) {\r\n return function <TClass extends new (...args: any[]) => any>(\r\n target: TClass,\r\n _context: ClassDecoratorContext\r\n ): TClass {\r\n if (!reflect(target.prototype).hasMethod(\"handleNext\")) {\r\n throw new PluginError(\r\n `@operator(\"${name}\"): class \"${target.name}\" must define a protected handleNext(): IteratorResult<T> method. `\r\n + \"Ensure the class extends TyneqEnumerator<TInput, TOutput>.\",\r\n \"operator\",\r\n target.name\r\n );\r\n }\r\n\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.forCategory(category, name, TyneqEnumerableBase),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n validate?.(...(userArgs as TArgs));\r\n const base = this;\r\n return RegistrationUtility.buildEnumerable(this, name, userArgs, category, {\r\n getEnumerator() {\r\n return new target(base.getEnumerator(), ...userArgs);\r\n }\r\n });\r\n }\r\n });\r\n return target;\r\n };\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqOrderedEnumerable } from \"../../core/ordering/TyneqOrderedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { Constructor } from \"../../types/utility\";\r\nimport { PluginError } from \"../../core/errors/PluginError\";\r\nimport { reflect } from \"../../utility/reflect\";\r\nimport { RegistrationUtility } from \"../RegistrationUtility\";\r\n\r\n/**\r\n * Class decorator that registers a `TyneqOrderedEnumerator` subclass as an operator\r\n * available only on ordered sequences.\r\n *\r\n * The enumerator constructor receives the full `TyneqOrderedEnumerable` as its first\r\n * argument (not just an `Enumerator<T>`).\r\n *\r\n * @param name - Method name to expose on ordered sequences.\r\n * @param category - Operator kind (`\"streaming\"` | `\"buffer\"`).\r\n * @param validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * import { orderedOperator, TyneqOrderedEnumerator } from \"tyneq/plugin\";\r\n *\r\n * @orderedOperator(\"myThenBy\", \"buffer\", (keySelector) => {\r\n * if (typeof keySelector !== \"function\") throw new Error(\"keySelector must be a function\");\r\n * })\r\n * class MyThenByEnumerator<T> extends TyneqOrderedEnumerator<T> {\r\n * private readonly iter: Enumerator<T>;\r\n * public constructor(source: OrderedEnumerable<T>, private readonly keySelector: (item: T) => unknown) {\r\n * super(source);\r\n * this.iter = this.orderedSource.getEnumerator();\r\n * }\r\n * protected handleNext(): IteratorResult<T> {\r\n * // this.orderedSource gives access to the full OrderedEnumerable\r\n * return this.iter.next();\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @group Decorators\r\n */\r\nexport function orderedOperator<TArgs extends unknown[] = never>(\r\n name: string,\r\n category: \"streaming\" | \"buffer\",\r\n validate?: (...args: TArgs) => void\r\n) {\r\n return function <TClass extends Constructor<any>>(target: TClass, _context: ClassDecoratorContext<TClass>): TClass {\r\n if (!reflect(target.prototype).hasMethod(\"handleNext\")) {\r\n throw new PluginError(\r\n `@orderedOperator(\"${name}\"): class \"${target.name}\" must define a protected handleNext(): IteratorResult<T> method. `\r\n + \"Ensure the class extends TyneqOrderedEnumerator<T>.\",\r\n \"orderedOperator\",\r\n target.name\r\n );\r\n }\r\n\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.forCategory(category, name, TyneqOrderedEnumerable),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n validate?.(...(userArgs as TArgs));\r\n const base = this as unknown as TyneqOrderedEnumerable<unknown, unknown>;\r\n return RegistrationUtility.buildEnumerable(this, name, userArgs, category, {\r\n getEnumerator: () => new target(base, ...userArgs)\r\n });\r\n }\r\n });\r\n return target;\r\n };\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqCachedEnumerable } from \"../../core/TyneqCachedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { Constructor } from \"../../types/utility\";\r\nimport { PluginError } from \"../../core/errors/PluginError\";\r\nimport { reflect } from \"../../utility/reflect\";\r\nimport { RegistrationUtility } from \"../RegistrationUtility\";\r\n\r\n/**\r\n * Class decorator that registers a `TyneqCachedEnumerator` subclass as an operator\r\n * available only on cached sequences.\r\n *\r\n * The enumerator constructor receives the full `TyneqCachedEnumerable` as its first\r\n * argument (not just an `Enumerator<T>`).\r\n *\r\n * @param name - Method name to expose on cached sequences.\r\n * @param category - Operator kind (`\"streaming\"` | `\"buffer\"`).\r\n * @param validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * import { cachedOperator, TyneqCachedEnumerator } from \"tyneq/plugin\";\r\n *\r\n * @cachedOperator(\"myRefresh\", \"buffer\")\r\n * class MyRefreshEnumerator<T> extends TyneqCachedEnumerator<T> {\r\n * private readonly iter: Enumerator<T>;\r\n * public constructor(source: CachedEnumerable<T>) {\r\n * super(source);\r\n * this.iter = this.cachedSource.getEnumerator();\r\n * }\r\n * protected handleNext(): IteratorResult<T> {\r\n * // this.cachedSource gives access to the full CachedEnumerable\r\n * return this.iter.next();\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @group Decorators\r\n */\r\nexport function cachedOperator<TArgs extends unknown[] = never>(\r\n name: string,\r\n category: \"streaming\" | \"buffer\",\r\n validate?: (...args: TArgs) => void\r\n) {\r\n return function <TClass extends Constructor<any>>(target: TClass, _context: ClassDecoratorContext<TClass>): TClass {\r\n if (!reflect(target.prototype).hasMethod(\"handleNext\")) {\r\n throw new PluginError(\r\n `@cachedOperator(\"${name}\"): class \"${target.name}\" must define a protected handleNext(): IteratorResult<T> method. `\r\n + \"Ensure the class extends TyneqCachedEnumerator<T>.\",\r\n \"cachedOperator\",\r\n target.name\r\n );\r\n }\r\n\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.forCategory(category, name, TyneqCachedEnumerable),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n validate?.(...(userArgs as TArgs));\r\n const base = this as unknown as TyneqCachedEnumerable<unknown>;\r\n return RegistrationUtility.buildEnumerable(this, name, userArgs, category, {\r\n getEnumerator: () => new target(base, ...userArgs)\r\n });\r\n }\r\n });\r\n return target;\r\n };\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { PluginError } from \"../../core/errors/PluginError\";\r\nimport { reflect } from \"../../utility/reflect\";\r\n\r\n/**\r\n * Class decorator that registers a class as a terminal operator.\r\n *\r\n * The class must have a `process()` method returning the result.\r\n * Validation runs eagerly at the call site before the class is instantiated.\r\n *\r\n * @param name - Method name to expose on every sequence.\r\n * @param validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * import { terminal } from \"tyneq/plugin\";\r\n * import { TyneqTerminalOperator } from \"tyneq/plugin\";\r\n * import type { Enumerable } from \"tyneq\";\r\n *\r\n * @terminal(\"product\")\r\n * class ProductOperator extends TyneqTerminalOperator<number, number> {\r\n * public process(): number {\r\n * let result = 1;\r\n * for (const item of this.source) result *= item;\r\n * return result;\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @group Decorators\r\n */\r\nexport function terminal<TArgs extends unknown[] = never>(\r\n name: string,\r\n validate?: (...args: TArgs) => void\r\n) {\r\n return function <TClass extends new (...args: any[]) => { process(): unknown }>(\r\n target: TClass,\r\n _context: ClassDecoratorContext\r\n ): TClass {\r\n if (!reflect(target.prototype).hasMethod(\"process\")) {\r\n throw new PluginError(\r\n `@terminal(\"${name}\"): class \"${target.name}\" must define a public process(): TResult method. `\r\n + \"Ensure the class extends TyneqTerminalOperator<TSource, TResult>.\",\r\n \"terminal\",\r\n target.name\r\n );\r\n }\r\n\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.terminal(name, TyneqEnumerableBase),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n validate?.(...(userArgs as TArgs));\r\n return new target(this, ...userArgs).process();\r\n }\r\n });\r\n return target;\r\n };\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqOrderedEnumerable } from \"../../core/ordering/TyneqOrderedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { OrderedEnumerable } from \"../../types/core\";\r\nimport { Constructor } from \"../../types/utility\";\r\n\r\n/**\r\n * Class decorator that registers a `TyneqOrderedTerminalOperator` subclass as a terminal\r\n * operator available only on ordered sequences.\r\n *\r\n * The class constructor receives the full `OrderedEnumerable` as its first argument,\r\n * giving access to ordered-sequence members (comparers, parent chain, etc.).\r\n *\r\n * @param name - Method name to expose on ordered sequences.\r\n * @param validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * @orderedTerminal(\"isSorted\")\r\n * class IsSortedOperator<T> extends TyneqOrderedTerminalOperator<T, boolean> {\r\n * process(): boolean {\r\n * const items = [...this.source];\r\n * for (let i = 1; i < items.length; i++) {\r\n * if (this.source.comparer(items[i - 1], items[i]) > 0) return false;\r\n * }\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @group Decorators\r\n */\r\nexport function orderedTerminal<TArgs extends unknown[] = never>(\r\n name: string,\r\n validate?: (...args: TArgs) => void\r\n) {\r\n return function <TClass extends Constructor<{ process(): unknown }>>(\r\n target: TClass,\r\n _context: ClassDecoratorContext<TClass>\r\n ): TClass {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.terminal(name, TyneqOrderedEnumerable),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n validate?.(...(userArgs as TArgs));\r\n const source = this as unknown as OrderedEnumerable<unknown>;\r\n return new target(source, ...userArgs).process();\r\n }\r\n });\r\n return target;\r\n };\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqCachedEnumerable } from \"../../core/TyneqCachedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { CachedEnumerable } from \"../../types/core\";\r\nimport { Constructor } from \"../../types/utility\";\r\n\r\n/**\r\n * Class decorator that registers a `TyneqCachedTerminalOperator` subclass as a terminal\r\n * operator available only on cached sequences.\r\n *\r\n * The class constructor receives the full `CachedEnumerable` as its first argument,\r\n * giving access to cached-sequence members (`refresh()`, internal cache, etc.).\r\n *\r\n * @param name - Method name to expose on cached sequences.\r\n * @param validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * @cachedTerminal(\"cacheSize\")\r\n * class CacheSizeOperator<T> extends TyneqCachedTerminalOperator<T, number> {\r\n * process(): number {\r\n * return [...this.source].length;\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @group Decorators\r\n */\r\nexport function cachedTerminal<TArgs extends unknown[] = never>(\r\n name: string,\r\n validate?: (...args: TArgs) => void\r\n) {\r\n return function <TClass extends Constructor<{ process(): unknown }>>(\r\n target: TClass,\r\n _context: ClassDecoratorContext<TClass>\r\n ): TClass {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.terminal(name, TyneqCachedEnumerable),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n validate?.(...(userArgs as TArgs));\r\n const source = this as unknown as CachedEnumerable<unknown>;\r\n return new target(source, ...userArgs).process();\r\n }\r\n });\r\n return target;\r\n };\r\n}\r\n","import type { Enumerable, EnumeratorFactory, OperatorSource } from \"../../types/core\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { RegistrationUtility } from \"../RegistrationUtility\";\r\n\r\n/**\r\n * Registers a streaming or buffering operator using a factory function.\r\n *\r\n * Use this when the operator requires a class-level enumerator with custom state\r\n * but you want to avoid writing the decorator boilerplate. For simpler generator-based\r\n * operators, prefer {@link createGeneratorOperator}.\r\n *\r\n * @param config.name - Method name to expose on every sequence.\r\n * @param config.category - `\"streaming\"` or `\"buffer\"`.\r\n * @param config.factory - Returns an `EnumeratorFactory` given the source and arguments.\r\n * @param config.validate - Optional eager validation for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * import { createOperator } from \"tyneq/plugin\";\r\n * import type { Enumerator } from \"tyneq\";\r\n *\r\n * createOperator({\r\n * name: \"everyOther\",\r\n * category: \"streaming\",\r\n * factory: <T>(source: Enumerable<T>) => ({\r\n * getEnumerator(): Enumerator<T> {\r\n * let skip = false;\r\n * const iter = source[Symbol.iterator]();\r\n * return {\r\n * next(): IteratorResult<T> {\r\n * while (true) {\r\n * const r = iter.next();\r\n * if (r.done) return r;\r\n * if (!skip) { skip = true; return r; }\r\n * skip = false;\r\n * }\r\n * }\r\n * };\r\n * }\r\n * })\r\n * });\r\n * ```\r\n *\r\n * @group Factory Functions\r\n */\r\nexport function createOperator<TSource, TArgs extends unknown[], TResult>(config: {\r\n name: string;\r\n category: \"streaming\" | \"buffer\";\r\n factory: (source: Enumerable<TSource>, ...args: TArgs) => EnumeratorFactory<TResult>;\r\n validate?: (...args: NoInfer<TArgs>) => void;\r\n source?: OperatorSource;\r\n}): void {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.forCategory(config.category, config.name, TyneqEnumerableBase, config.source),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...args: unknown[]) {\r\n config.validate?.(...(args as TArgs));\r\n return RegistrationUtility.buildEnumerable(\r\n this,\r\n config.name,\r\n args,\r\n config.category,\r\n config.factory(this as Enumerable<TSource>, ...(args as TArgs)) as EnumeratorFactory<unknown>\r\n );\r\n }\r\n });\r\n}\r\n","import type { Enumerator, EnumeratorFactory, OperatorSource } from \"../../types/core\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { RegistrationUtility } from \"../RegistrationUtility\";\r\n\r\n/**\r\n * Registers an operator using a generator function.\r\n *\r\n * The generator receives the source as an `Iterable<T>` and any user arguments.\r\n * This is the simplest functional registration path and works for both streaming\r\n * and buffering use cases:\r\n *\r\n * - **Streaming**: yield elements one at a time as they arrive. The downstream\r\n * sequence only pulls the next element when needed.\r\n * - **Buffering**: collect all input first, then yield the transformed output.\r\n * Pass `category: \"buffer\"` to tell the query plan that this operator\r\n * materialises the entire upstream before yielding.\r\n *\r\n * For class-based enumerators with custom stateful logic, prefer {@link createOperator}.\r\n *\r\n * @param config.name - Method name to expose on every sequence.\r\n * @param config.category - `\"streaming\"` (default) or `\"buffer\"`.\r\n * @param config.generator - Generator that yields transformed elements from `source`.\r\n * @param config.validate - Optional eager validation for user-supplied arguments.\r\n *\r\n * @example Streaming - yield elements lazily one at a time:\r\n * ```ts\r\n * import { createGeneratorOperator } from \"tyneq/plugin\";\r\n *\r\n * createGeneratorOperator({\r\n * name: \"everyOther\",\r\n * *generator(source) {\r\n * let skip = false;\r\n * for (const item of source) {\r\n * if (!skip) yield item;\r\n * skip = !skip;\r\n * }\r\n * }\r\n * });\r\n * ```\r\n *\r\n * @example Buffering - materialise the entire input first, then yield results:\r\n * ```ts\r\n * import { createGeneratorOperator } from \"tyneq/plugin\";\r\n *\r\n * createGeneratorOperator({\r\n * name: \"sortedBy\",\r\n * category: \"buffer\",\r\n * *generator(source, keyFn: (x: number) => number) {\r\n * const items = [...source].sort((a, b) => keyFn(a) - keyFn(b));\r\n * for (const item of items) yield item;\r\n * }\r\n * });\r\n * ```\r\n *\r\n * @group Factory Functions\r\n */\r\nexport function createGeneratorOperator<TSource, TArgs extends unknown[], TResult>(config: {\r\n name: string;\r\n category?: \"streaming\" | \"buffer\";\r\n generator: (source: Iterable<TSource>, ...args: TArgs) => IterableIterator<TResult>;\r\n validate?: (...args: NoInfer<TArgs>) => void;\r\n source?: OperatorSource;\r\n}): void {\r\n const category = config.category ?? \"streaming\";\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.forCategory(category, config.name, TyneqEnumerableBase, config.source),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...args: unknown[]) {\r\n config.validate?.(...(args as TArgs));\r\n const source = this as unknown as Iterable<TSource>;\r\n return RegistrationUtility.buildEnumerable(this, config.name, args, category, {\r\n // IterableIterator<T> is structurally compatible with Enumerator<T>\r\n getEnumerator: (): Enumerator<unknown> =>\r\n config.generator(source, ...(args as TArgs)) as unknown as Enumerator<unknown>\r\n } satisfies EnumeratorFactory<unknown>);\r\n }\r\n });\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqOrderedEnumerable } from \"../../core/ordering/TyneqOrderedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport type { OperatorSource, TyneqOrderedSequence } from \"../../types/core\";\r\nimport type { QueryPlanNode } from \"../../types/queryplan\";\r\nimport { RegistrationUtility } from \"../RegistrationUtility\";\r\n\r\n/**\r\n * Registers a factory function as an operator available only on ordered sequences,\r\n * where the factory fully controls the return type.\r\n *\r\n * Use this when the operator must return a `TyneqOrderedSequence` (e.g. a `thenBy` variant).\r\n * The factory receives the ordered source and a query plan node. It is responsible for\r\n * constructing and returning the result sequence - typically by instantiating\r\n * `TyneqOrderedEnumerable` directly.\r\n *\r\n * For operators that return a plain sequence from an enumerator class, use `@orderedOperator`.\r\n *\r\n * @param config.name - Method name to expose on ordered sequences.\r\n * @param config.category - Operator kind (`\"streaming\"` | `\"buffer\"`).\r\n * @param config.factory - Constructs the result sequence from `(source, node, ...userArgs)`.\r\n * @param config.validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * createOrderedOperator({\r\n * name: \"thenByLocale\",\r\n * category: \"buffer\",\r\n * factory: (source, node, locale: string, keySelector: (item: unknown) => string) =>\r\n * new TyneqOrderedEnumerable(\r\n * source.source,\r\n * keySelector,\r\n * (a, b) => a.localeCompare(b, locale),\r\n * false,\r\n * source,\r\n * node\r\n * ),\r\n * validate: (locale, keySelector) => {\r\n * if (typeof locale !== \"string\") throw new Error(\"locale must be a string\");\r\n * if (typeof keySelector !== \"function\") throw new Error(\"keySelector must be a function\");\r\n * }\r\n * });\r\n * ```\r\n *\r\n * @group Factory Functions\r\n */\r\nexport function createOrderedOperator<TSource, TArgs extends unknown[]>(config: {\r\n name: string;\r\n category: \"streaming\" | \"buffer\";\r\n factory: (source: TyneqOrderedEnumerable<TSource, unknown>, node: QueryPlanNode, ...args: TArgs) => TyneqOrderedSequence<TSource>;\r\n validate?: (...args: NoInfer<TArgs>) => void;\r\n source?: OperatorSource;\r\n}): void {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.forCategory(config.category, config.name, TyneqOrderedEnumerable, config.source),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n config.validate?.(...(userArgs as TArgs));\r\n const source = this as unknown as TyneqOrderedEnumerable<TSource, unknown>;\r\n const node = RegistrationUtility.buildQueryNode(this, config.name, userArgs, config.category);\r\n return config.factory(source, node, ...(userArgs as TArgs));\r\n }\r\n });\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqCachedEnumerable } from \"../../core/TyneqCachedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport type { OperatorSource, TyneqCachedSequence } from \"../../types/core\";\r\nimport type { QueryPlanNode } from \"../../types/queryplan\";\r\nimport { RegistrationUtility } from \"../RegistrationUtility\";\r\n\r\n/**\r\n * Registers a factory function as an operator available only on cached sequences,\r\n * where the factory fully controls the return type.\r\n *\r\n * Use this when the operator must return a `TyneqCachedSequence`. The factory\r\n * receives the cached source and a query plan node. It is responsible for\r\n * constructing and returning the result sequence.\r\n *\r\n * For operators that return a plain sequence from an enumerator class, use `@cachedOperator`.\r\n *\r\n * @param config.name - Method name to expose on cached sequences.\r\n * @param config.category - Operator kind (`\"streaming\"` | `\"buffer\"`).\r\n * @param config.factory - Constructs the result sequence from `(source, node, ...userArgs)`.\r\n * @param config.validate - Optional eager validation function for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * createCachedOperator({\r\n * name: \"refreshWith\",\r\n * category: \"buffer\",\r\n * factory: (source, node, newSource: Iterable<unknown>) => {\r\n * const seq = tyneqFrom(newSource);\r\n * return new TyneqCachedEnumerable(seq, node);\r\n * },\r\n * validate: (newSource) => {\r\n * if (newSource == null) throw new Error(\"newSource must not be null\");\r\n * }\r\n * });\r\n * ```\r\n *\r\n * @group Factory Functions\r\n */\r\nexport function createCachedOperator<TSource, TArgs extends unknown[]>(config: {\r\n name: string;\r\n category: \"streaming\" | \"buffer\";\r\n factory: (source: TyneqCachedEnumerable<TSource>, node: QueryPlanNode, ...args: TArgs) => TyneqCachedSequence<TSource>;\r\n validate?: (...args: NoInfer<TArgs>) => void;\r\n source?: OperatorSource;\r\n}): void {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.forCategory(config.category, config.name, TyneqCachedEnumerable, config.source),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...userArgs: unknown[]) {\r\n config.validate?.(...(userArgs as TArgs));\r\n const source = this as unknown as TyneqCachedEnumerable<TSource>;\r\n const node = RegistrationUtility.buildQueryNode(this, config.name, userArgs, config.category);\r\n return config.factory(source, node, ...(userArgs as TArgs));\r\n }\r\n });\r\n}\r\n","import type { Enumerable, OperatorSource } from \"../../types/core\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\n\r\n/**\r\n * Registers a terminal operator using a plain function.\r\n *\r\n * The simplest registration API for terminal operators.\r\n * `execute` receives the full source sequence and any user arguments and returns a concrete value.\r\n *\r\n * @param config.name - Method name to expose on every sequence.\r\n * @param config.execute - Function that consumes the source and returns a result.\r\n * @param config.validate - Optional eager validation for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * import { createTerminalOperator } from \"tyneq/plugin\";\r\n *\r\n * createTerminalOperator({\r\n * name: \"product\",\r\n * execute(source: Iterable<number>): number {\r\n * let result = 1;\r\n * for (const item of source) result *= item;\r\n * return result;\r\n * }\r\n * });\r\n * ```\r\n *\r\n * @group Factory Functions\r\n */\r\nexport function createTerminalOperator<TSource, TArgs extends unknown[], TResult>(config: {\r\n name: string;\r\n execute: (source: Enumerable<TSource>, ...args: TArgs) => TResult;\r\n validate?: (...args: NoInfer<TArgs>) => void;\r\n source?: OperatorSource;\r\n}): void {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.terminal(config.name, TyneqEnumerableBase, config.source),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...args: unknown[]) {\r\n config.validate?.(...(args as TArgs));\r\n return config.execute(this as Enumerable<TSource>, ...(args as TArgs));\r\n }\r\n });\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqOrderedEnumerable } from \"../../core/ordering/TyneqOrderedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport type { OperatorSource } from \"../../types/core\";\r\nimport { OrderedEnumerable } from \"../../types/core\";\r\n\r\n/**\r\n * Registers a terminal operator available only on ordered sequences.\r\n *\r\n * The `execute` function receives the full `OrderedEnumerable` as its first argument,\r\n * giving access to ordered-sequence members (comparers, parent chain, etc.).\r\n *\r\n * @param config.name - Method name to expose on ordered sequences.\r\n * @param config.execute - Function that consumes the ordered source and returns a result.\r\n * @param config.validate - Optional eager validation for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * createOrderedTerminalOperator({\r\n * name: \"isSorted\",\r\n * execute(source: OrderedEnumerable<number>): boolean {\r\n * const items = [...source];\r\n * for (let i = 1; i < items.length; i++) {\r\n * if (items[i - 1] > items[i]) return false;\r\n * }\r\n * return true;\r\n * }\r\n * });\r\n * ```\r\n *\r\n * @group Factory Functions\r\n */\r\nexport function createOrderedTerminalOperator<TSource, TArgs extends unknown[], TResult>(config: {\r\n name: string;\r\n execute: (source: OrderedEnumerable<TSource>, ...args: TArgs) => TResult;\r\n validate?: (...args: NoInfer<TArgs>) => void;\r\n source?: OperatorSource;\r\n}): void {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.terminal(config.name, TyneqOrderedEnumerable, config.source),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...args: unknown[]) {\r\n config.validate?.(...(args as TArgs));\r\n return config.execute(this as unknown as OrderedEnumerable<TSource>, ...(args as TArgs));\r\n }\r\n });\r\n}\r\n","import { OperatorMetadata } from \"../../core/OperatorMetadata\";\r\nimport { TyneqEnumerableBase } from \"../../core/TyneqEnumerableBase\";\r\nimport { TyneqCachedEnumerable } from \"../../core/TyneqCachedEnumerable\";\r\nimport { OperatorRegistry } from \"../../core/registry/TyneqOperatorRegistry\";\r\nimport type { CachedEnumerable, OperatorSource } from \"../../types/core\";\r\n\r\n/**\r\n * Registers a terminal operator available only on cached sequences.\r\n *\r\n * The `execute` function receives the full `CachedEnumerable` as its first argument,\r\n * giving access to cached-sequence members (`refresh()`, internal cache, etc.).\r\n *\r\n * @param config.name - Method name to expose on cached sequences.\r\n * @param config.execute - Function that consumes the cached source and returns a result.\r\n * @param config.validate - Optional eager validation for user-supplied arguments.\r\n *\r\n * @example\r\n * ```ts\r\n * createCachedTerminalOperator({\r\n * name: \"cacheSize\",\r\n * execute(source: CachedEnumerable<unknown>): number {\r\n * return [...source].length;\r\n * }\r\n * });\r\n * ```\r\n *\r\n * @group Factory Functions\r\n */\r\nexport function createCachedTerminalOperator<TSource, TArgs extends unknown[], TResult>(config: {\r\n name: string;\r\n execute: (source: CachedEnumerable<TSource>, ...args: TArgs) => TResult;\r\n validate?: (...args: NoInfer<TArgs>) => void;\r\n source?: OperatorSource;\r\n}): void {\r\n OperatorRegistry.register({\r\n metadata: OperatorMetadata.terminal(config.name, TyneqCachedEnumerable, config.source),\r\n impl: function (this: TyneqEnumerableBase<unknown>, ...args: unknown[]) {\r\n config.validate?.(...(args as TArgs));\r\n return config.execute(this as unknown as CachedEnumerable<TSource>, ...(args as TArgs));\r\n }\r\n });\r\n}\r\n","import { OrderedEnumerable } from \"../../types/core\";\r\nimport { TyneqBaseEnumerator } from \"./TyneqBaseEnumerator\";\r\n\r\n/**\r\n * Base class for enumerators that need the full ordered sequence (not just an Enumerator<T>).\r\n * Lifecycle of the source is owned by the sequence, not the enumerator.\r\n *\r\n * @group Plugin\r\n * @internal\r\n */\r\nexport abstract class TyneqOrderedEnumerator<TSource> extends TyneqBaseEnumerator<TSource> {\r\n\r\n public constructor(protected readonly orderedSource: OrderedEnumerable<TSource>) {\r\n super();\r\n }\r\n\r\n protected override disposeSource(): void {\r\n // The sequence owns its own lifecycle - enumerator must not dispose it.\r\n }\r\n}","import { CachedEnumerable } from \"../../types/core\";\r\nimport { TyneqBaseEnumerator } from \"./TyneqBaseEnumerator\";\r\n\r\n/**\r\n * Base class for enumerators that need the full cached sequence (not just an Enumerator<T>).\r\n * Lifecycle of the source is owned by the sequence, not the enumerator.\r\n *\r\n * @group Plugin\r\n * @internal\r\n */\r\nexport abstract class TyneqCachedEnumerator<TSource> extends TyneqBaseEnumerator<TSource> {\r\n\r\n public constructor(protected readonly cachedSource: CachedEnumerable<TSource>) {\r\n super();\r\n }\r\n\r\n protected override disposeSource(): void {\r\n // The sequence owns its own lifecycle - enumerator must not dispose it.\r\n }\r\n}","import { OrderedEnumerable } from \"../../types/core\";\r\nimport { ArgumentUtility } from \"../../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Abstract base for terminal operators that require a fully ordered sequence.\r\n *\r\n * @remarks\r\n * Use this when your terminal operator needs access to ordered-sequence members\r\n * (comparers, parent chain, etc.). Register with `@orderedTerminal` or\r\n * `createOrderedTerminalOperator`.\r\n *\r\n * @typeParam TSource - Element type of the source sequence.\r\n * @typeParam TResult - The return type of `process()`.\r\n * @group Plugin\r\n */\r\nexport abstract class TyneqOrderedTerminalOperator<TSource, TResult = TSource> {\r\n protected readonly source: OrderedEnumerable<TSource>;\r\n\r\n public constructor(source: OrderedEnumerable<TSource>) {\r\n ArgumentUtility.checkNotOptional({ source });\r\n this.source = source;\r\n }\r\n\r\n /** Executes the terminal operation and returns the result. */\r\n public abstract process(): TResult;\r\n}\r\n","import { CachedEnumerable } from \"../../types/core\";\r\nimport { ArgumentUtility } from \"../../utility/ArgumentUtility\";\r\n\r\n/**\r\n * Abstract base for terminal operators that require a fully cached sequence.\r\n *\r\n * @remarks\r\n * Use this when your terminal operator needs access to cached-sequence members\r\n * (the internal cache, `refresh()`, etc.). Register with `@cachedTerminal` or\r\n * `createCachedTerminalOperator`.\r\n *\r\n * @typeParam TSource - Element type of the source sequence.\r\n * @typeParam TResult - The return type of `process()`.\r\n * @group Plugin\r\n */\r\nexport abstract class TyneqCachedTerminalOperator<TSource, TResult = TSource> {\r\n protected readonly source: CachedEnumerable<TSource>;\r\n\r\n public constructor(source: CachedEnumerable<TSource>) {\r\n ArgumentUtility.checkNotOptional({ source });\r\n this.source = source;\r\n }\r\n\r\n /** Executes the terminal operation and returns the result. */\r\n public abstract process(): TResult;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,IAAsB,sBAAtB,MAAmG;CAC/F,eAAuB;CACvB,aAAqB;CAErB,cAAqB;;CAGrB,OAAuC;AACnC,MAAI,KAAK,WACL,QAAO,KAAK,MAAM;AAGtB,MAAI,CAAC,KAAK,cAAc;AACpB,QAAK,YAAY;AACjB,QAAK,eAAe;;EAGxB,MAAM,SAAS,KAAK,YAAY;AAEhC,MAAI,OAAO,MAAM;AACb,OAAI,CAAC,KAAK,YAAY;AAClB,SAAK,SAAS;AACd,SAAK,aAAa;;AAGtB,UAAO,KAAK,MAAM;;AAGtB,SAAO;;;CAIX,OAAc,OAA0C;AACpD,MAAI,CAAC,KAAK,YAAY;AAClB,QAAK,QAAQ,MAAM;AACnB,QAAK,aAAa;;AAGtB,SAAO,KAAK,MAAM;;;CAItB,aAA6B;;CAG7B,MAAgB,OAAyC;AACrD,SAAO;GAAE,MAAM;GAAO;GAAO;;;CAIjC,OAA0C;AACtC,SAAO;GAAE,MAAM;GAAM,OAAO,KAAA;GAAW;;;;;;;;CAS3C,cAAwB,OAAyC;AAC7D,OAAK,SAAS;AACd,OAAK,aAAa;AAClB,SAAO,KAAK,MAAM,MAAM;;;;;;;;CAS5B,cAAwB,QAA2C;AAC/D,OAAK,QAAQ,OAAO;AACpB,OAAK,aAAa;AAClB,SAAO,KAAK,MAAM;;;C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