linqx 0.2.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +79 -3
  2. package/dist/core/dictionary.d.ts +14 -0
  3. package/dist/core/enumerable.d.ts +9 -0
  4. package/dist/core/enumerator.d.ts +10 -0
  5. package/dist/core/grouping.d.ts +11 -0
  6. package/dist/core/lookup.d.ts +12 -0
  7. package/dist/core/memoized-enumerable.d.ts +12 -0
  8. package/dist/core/ordered-enumerable.d.ts +14 -0
  9. package/dist/core/shared-enumerable.d.ts +10 -0
  10. package/dist/extensions.d.ts +18 -0
  11. package/dist/extensions.js +13 -0
  12. package/dist/factories/choice.d.ts +8 -0
  13. package/dist/factories/cycle.d.ts +8 -0
  14. package/dist/factories/defer.d.ts +8 -0
  15. package/dist/factories/empty.d.ts +3 -0
  16. package/dist/factories/from.d.ts +46 -0
  17. package/dist/factories/generate.d.ts +9 -0
  18. package/dist/factories/make.d.ts +8 -0
  19. package/dist/factories/matches.d.ts +14 -0
  20. package/dist/factories/range-down.d.ts +10 -0
  21. package/dist/factories/range-to.d.ts +12 -0
  22. package/dist/factories/range.d.ts +10 -0
  23. package/dist/factories/repeat-with-finalize.d.ts +9 -0
  24. package/dist/factories/repeat.d.ts +9 -0
  25. package/dist/factories/to-infinity.d.ts +9 -0
  26. package/dist/factories/to-negative-infinity.d.ts +9 -0
  27. package/dist/factories/unfold.d.ts +9 -0
  28. package/dist/index.d.ts +87 -3
  29. package/dist/index.js +2 -4
  30. package/dist/internal/create-enumerable.d.ts +3 -0
  31. package/dist/internal/functions.d.ts +6 -0
  32. package/dist/internal/to-iterable.d.ts +2 -0
  33. package/dist/operators/aggregate-by.d.ts +2 -0
  34. package/dist/operators/aggregate.d.ts +2 -0
  35. package/dist/operators/all.d.ts +2 -0
  36. package/dist/operators/alternate.d.ts +2 -0
  37. package/dist/operators/any.d.ts +2 -0
  38. package/dist/operators/append.d.ts +2 -0
  39. package/dist/operators/as-enumerable.d.ts +2 -0
  40. package/dist/operators/average.d.ts +2 -0
  41. package/dist/operators/buffer.d.ts +2 -0
  42. package/dist/operators/cast.d.ts +2 -0
  43. package/dist/operators/catch-error.d.ts +2 -0
  44. package/dist/operators/choose.d.ts +2 -0
  45. package/dist/operators/chunk.d.ts +2 -0
  46. package/dist/operators/concat.d.ts +2 -0
  47. package/dist/operators/contains.d.ts +2 -0
  48. package/dist/operators/count-by.d.ts +2 -0
  49. package/dist/operators/count.d.ts +2 -0
  50. package/dist/operators/create-ordered-enumerable.d.ts +2 -0
  51. package/dist/operators/default-if-empty.d.ts +2 -0
  52. package/dist/operators/distinct-by.d.ts +2 -0
  53. package/dist/operators/distinct-until-changed.d.ts +2 -0
  54. package/dist/operators/distinct.d.ts +2 -0
  55. package/dist/operators/do-action.d.ts +3 -0
  56. package/dist/operators/element-at-or-default.d.ts +2 -0
  57. package/dist/operators/element-at.d.ts +2 -0
  58. package/dist/operators/except-by.d.ts +2 -0
  59. package/dist/operators/except.d.ts +2 -0
  60. package/dist/operators/finally-action.d.ts +2 -0
  61. package/dist/operators/first-or-default.d.ts +2 -0
  62. package/dist/operators/first.d.ts +2 -0
  63. package/dist/operators/flatten.d.ts +2 -0
  64. package/dist/operators/for-each.d.ts +3 -0
  65. package/dist/operators/force.d.ts +2 -0
  66. package/dist/operators/group-by.d.ts +2 -0
  67. package/dist/operators/group-join.d.ts +2 -0
  68. package/dist/operators/index-of.d.ts +2 -0
  69. package/dist/operators/index.d.ts +2 -0
  70. package/dist/operators/insert.d.ts +2 -0
  71. package/dist/operators/intersect-by.d.ts +2 -0
  72. package/dist/operators/intersect.d.ts +2 -0
  73. package/dist/operators/is-empty.d.ts +2 -0
  74. package/dist/operators/join-with.d.ts +2 -0
  75. package/dist/operators/join.d.ts +2 -0
  76. package/dist/operators/last-index-of.d.ts +2 -0
  77. package/dist/operators/last-or-default.d.ts +2 -0
  78. package/dist/operators/last.d.ts +2 -0
  79. package/dist/operators/left-join.d.ts +2 -0
  80. package/dist/operators/let-bind.d.ts +2 -0
  81. package/dist/operators/log.d.ts +2 -0
  82. package/dist/operators/map.d.ts +2 -0
  83. package/dist/operators/max-by.d.ts +2 -0
  84. package/dist/operators/max.d.ts +2 -0
  85. package/dist/operators/memoize.d.ts +2 -0
  86. package/dist/operators/merge.d.ts +2 -0
  87. package/dist/operators/min-by.d.ts +2 -0
  88. package/dist/operators/min.d.ts +2 -0
  89. package/dist/operators/of-type.d.ts +2 -0
  90. package/dist/operators/operators.d.ts +208 -0
  91. package/dist/operators/order-by-descending.d.ts +2 -0
  92. package/dist/operators/order-by.d.ts +2 -0
  93. package/dist/operators/page.d.ts +2 -0
  94. package/dist/operators/pairwise.d.ts +2 -0
  95. package/dist/operators/partition-by.d.ts +2 -0
  96. package/dist/operators/position.d.ts +2 -0
  97. package/dist/operators/prepend.d.ts +2 -0
  98. package/dist/operators/reverse.d.ts +2 -0
  99. package/dist/operators/right-join.d.ts +2 -0
  100. package/dist/operators/scan.d.ts +2 -0
  101. package/dist/operators/select-many.d.ts +2 -0
  102. package/dist/operators/select.d.ts +2 -0
  103. package/dist/operators/sequence-equal.d.ts +2 -0
  104. package/dist/operators/share.d.ts +2 -0
  105. package/dist/operators/shuffle.d.ts +2 -0
  106. package/dist/operators/single-or-default.d.ts +2 -0
  107. package/dist/operators/single.d.ts +2 -0
  108. package/dist/operators/skip-last.d.ts +2 -0
  109. package/dist/operators/skip-while.d.ts +2 -0
  110. package/dist/operators/skip.d.ts +2 -0
  111. package/dist/operators/sum.d.ts +2 -0
  112. package/dist/operators/take-except-last.d.ts +2 -0
  113. package/dist/operators/take-from-last.d.ts +2 -0
  114. package/dist/operators/take-last.d.ts +2 -0
  115. package/dist/operators/take-while.d.ts +2 -0
  116. package/dist/operators/take.d.ts +2 -0
  117. package/dist/operators/then-by-descending.d.ts +2 -0
  118. package/dist/operators/then-by.d.ts +2 -0
  119. package/dist/operators/to-array.d.ts +2 -0
  120. package/dist/operators/to-dictionary.d.ts +2 -0
  121. package/dist/operators/to-joined-string.d.ts +2 -0
  122. package/dist/operators/to-json-string.d.ts +2 -0
  123. package/dist/operators/to-lookup.d.ts +2 -0
  124. package/dist/operators/to-map.d.ts +2 -0
  125. package/dist/operators/to-object.d.ts +2 -0
  126. package/dist/operators/to-set.d.ts +2 -0
  127. package/dist/operators/trace.d.ts +2 -0
  128. package/dist/operators/traverse-breadth-first.d.ts +2 -0
  129. package/dist/operators/traverse-depth-first.d.ts +2 -0
  130. package/dist/operators/union-by.d.ts +2 -0
  131. package/dist/operators/union.d.ts +2 -0
  132. package/dist/operators/weighted-sample.d.ts +2 -0
  133. package/dist/operators/where-if.d.ts +2 -0
  134. package/dist/operators/where.d.ts +2 -0
  135. package/dist/operators/with-neighbors.d.ts +2 -0
  136. package/dist/operators/zip.d.ts +2 -0
  137. package/dist/src-D_Mk3oMP.js +1597 -0
  138. package/dist/types.d.ts +1154 -0
  139. package/dist/utils.d.ts +56 -0
  140. package/package.json +18 -11
  141. package/dist/linq.d.ts +0 -256
  142. package/dist/linq.js +0 -3085
  143. package/dist/linqx.d.ts +0 -36
  144. package/dist/linqx.js +0 -153
@@ -0,0 +1,1154 @@
1
+ /** Controls an imperative enumeration over a sequence. */
2
+ export interface IEnumerator<T> {
3
+ /**
4
+ * Gets the element at the enumerator's current position.
5
+ *
6
+ * @returns The current element. The value is valid only after `moveNext()` returns `true`.
7
+ */
8
+ current(): T;
9
+ /**
10
+ * Advances the enumerator to the next element.
11
+ *
12
+ * @returns `true` when a current element is available; otherwise, `false`.
13
+ */
14
+ moveNext(): boolean;
15
+ /** Releases the underlying iterator and prevents further enumeration. */
16
+ dispose(): void;
17
+ }
18
+ /** A composable, iterable sequence whose query operators are evaluated on demand unless noted. */
19
+ export interface IEnumerable<T> extends Iterable<T> {
20
+ /**
21
+ * Creates an imperative enumerator for this sequence.
22
+ *
23
+ * @returns A new enumerator positioned before the first element.
24
+ */
25
+ getEnumerator(): IEnumerator<T>;
26
+ /**
27
+ * Traverses a hierarchy level by level.
28
+ *
29
+ * @param childrenSelector Selects the children of each visited element.
30
+ * @returns A deferred sequence containing each element in breadth-first order.
31
+ */
32
+ traverseBreadthFirst(childrenSelector: (element: T) => IEnumerable<T>): IEnumerable<T>;
33
+ /**
34
+ * Traverses a hierarchy level by level and projects each visited element.
35
+ *
36
+ * @param childrenSelector Selects the children of each visited element.
37
+ * @param resultSelector Projects an element and its zero-based depth.
38
+ * @returns A deferred sequence of projected values in breadth-first order.
39
+ */
40
+ traverseBreadthFirst<TResult>(childrenSelector: (element: T) => IEnumerable<T>, resultSelector: (element: T, nestLevel: number) => TResult): IEnumerable<TResult>;
41
+ /**
42
+ * Traverses a hierarchy by visiting each element before its descendants.
43
+ *
44
+ * @param childrenSelector Selects the children of each visited element.
45
+ * @param resultSelector Optionally projects an element and its zero-based depth.
46
+ * @returns A deferred sequence in depth-first, pre-order traversal order.
47
+ */
48
+ traverseDepthFirst<TResult>(childrenSelector: (element: T) => IEnumerable<T>, resultSelector?: (element: T, nestLevel: number) => TResult): IEnumerable<TResult>;
49
+ /**
50
+ * Recursively expands nested iterable values, while treating strings as scalar values.
51
+ *
52
+ * @returns A deferred, flattened sequence.
53
+ */
54
+ flatten(): IEnumerable<unknown>;
55
+ /**
56
+ * Projects every adjacent pair in the source sequence.
57
+ *
58
+ * @param selector Projects the previous and current elements.
59
+ * @returns A deferred sequence containing one result for each adjacent pair.
60
+ */
61
+ pairwise<TResult>(selector: (prev: T, current: T) => TResult): IEnumerable<TResult>;
62
+ /**
63
+ * Produces each running accumulation, using the first element as the initial value.
64
+ *
65
+ * @param func Combines the previous accumulation with the current element.
66
+ * @returns A deferred sequence whose first value is the first source element.
67
+ */
68
+ scan(func: (prev: T, current: T) => T): IEnumerable<T>;
69
+ /**
70
+ * Produces each running accumulation, beginning with the supplied seed.
71
+ *
72
+ * @param seed The initial accumulation, which is also the first value returned.
73
+ * @param func Combines the previous accumulation with the current element.
74
+ * @returns A deferred sequence containing the seed followed by each accumulated value.
75
+ */
76
+ scan<TAccumulate>(seed: TAccumulate, func: (prev: TAccumulate, current: T) => TAccumulate): IEnumerable<TAccumulate>;
77
+ /**
78
+ * Projects each source element and its zero-based index.
79
+ *
80
+ * @param selector Selects the result for each element.
81
+ * @returns A deferred sequence of projected values.
82
+ */
83
+ select<TResult>(selector: (element: T, index: number) => TResult): IEnumerable<TResult>;
84
+ /**
85
+ * Eagerly projects all source elements into an array.
86
+ *
87
+ * @param selector Selects the result for each element and its zero-based index.
88
+ * @returns An array containing the projected values.
89
+ */
90
+ map<TResult>(selector: (element: T, index: number) => TResult): TResult[];
91
+ /**
92
+ * Projects each source element to a sequence and flattens the resulting sequences.
93
+ *
94
+ * @param collectionSelector Selects an inner sequence for each element and index.
95
+ * @returns A deferred sequence containing all inner elements.
96
+ */
97
+ selectMany<TOther>(collectionSelector: (element: T, index: number) => EnumerableInput<TOther>): IEnumerable<TOther>;
98
+ /**
99
+ * Projects each source element to a sequence, then combines outer and inner elements.
100
+ *
101
+ * @param collectionSelector Selects an inner sequence for each element and index.
102
+ * @param resultSelector Projects each outer and inner element pair.
103
+ * @returns A deferred sequence of combined results.
104
+ */
105
+ selectMany<TCollection, TResult>(collectionSelector: (element: T, index: number) => EnumerableInput<TCollection>, resultSelector: (outer: T, inner: TCollection) => TResult): IEnumerable<TResult>;
106
+ /**
107
+ * Filters the sequence with a type-guard predicate.
108
+ *
109
+ * @param predicate Tests each element and its zero-based index.
110
+ * @returns A deferred sequence narrowed to elements accepted by the predicate.
111
+ */
112
+ where<TOther extends T>(predicate: (element: T, index: number) => element is TOther): IEnumerable<TOther>;
113
+ /**
114
+ * Filters the sequence using a predicate.
115
+ *
116
+ * @param predicate Tests each element and its zero-based index.
117
+ * @returns A deferred sequence containing the accepted elements.
118
+ */
119
+ where(predicate: (element: T, index: number) => boolean): IEnumerable<T>;
120
+ /**
121
+ * Applies a filter only when a flag is truthy.
122
+ *
123
+ * @param flag A value that controls whether the filter is applied.
124
+ * @param filter Tests each element when `flag` is truthy.
125
+ * @returns The original sequence when the flag is falsy; otherwise, a filtered sequence.
126
+ */
127
+ whereIf(flag: boolean | string | undefined | null, filter: (element: T) => boolean): IEnumerable<T>;
128
+ /**
129
+ * Projects elements and omits projections that evaluate to `null` or `undefined`.
130
+ *
131
+ * @param selector Projects each element and its zero-based index.
132
+ * @returns A deferred sequence of non-nullish projected values.
133
+ */
134
+ choose(selector: (element: T, index: number) => T): IEnumerable<T>;
135
+ /**
136
+ * Filters elements by a constructor or primitive wrapper (`Number`, `String`, or `Boolean`).
137
+ *
138
+ * @param type The constructor or primitive wrapper to match.
139
+ * @returns A deferred sequence containing elements of the requested runtime type.
140
+ */
141
+ ofType<TResult>(type: unknown): IEnumerable<TResult>;
142
+ /**
143
+ * Combines two sequences element by element until either sequence ends.
144
+ *
145
+ * @param second The second sequence.
146
+ * @param resultSelector Projects each pair and its zero-based index.
147
+ * @returns A deferred sequence of projected pairs.
148
+ */
149
+ zip<U, TResult>(second: EnumerableInput<U>, resultSelector: (first: T, second: U, index: number) => TResult): IEnumerable<TResult>;
150
+ /**
151
+ * Combines multiple sequences element by element until any sequence ends.
152
+ *
153
+ * @param params Input sequences followed by a result-selector function. The selector also
154
+ * receives the zero-based index as its final argument.
155
+ * @returns A deferred sequence of projected tuples.
156
+ * @throws {TypeError} When no sequence is supplied or the final argument is not a function.
157
+ */
158
+ zip<TResult>(...params: unknown[]): IEnumerable<TResult>;
159
+ /**
160
+ * Interleaves this sequence and the supplied sequences in round-robin order.
161
+ *
162
+ * @param params The sequences to merge.
163
+ * @returns A deferred sequence that continues until every input is exhausted.
164
+ */
165
+ merge(...params: EnumerableInput<T>[]): IEnumerable<T>;
166
+ /**
167
+ * Correlates elements from two sequences that have equal comparison keys.
168
+ *
169
+ * @param inner The inner sequence.
170
+ * @param outerKeySelector Selects a key from an outer element.
171
+ * @param innerKeySelector Selects a key from an inner element.
172
+ * @param resultSelector Projects each matching pair.
173
+ * @param compareSelector Optionally normalizes keys before strict equality comparison.
174
+ * @returns A deferred inner-join sequence.
175
+ */
176
+ join<TInner, TKey, TResult>(inner: EnumerableInput<TInner>, outerKeySelector: (outer: T) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: T, inner: TInner) => TResult, compareSelector?: (obj: TKey) => unknown): IEnumerable<TResult>;
177
+ /**
178
+ * Correlates elements from two sequences and preserves unmatched outer elements.
179
+ *
180
+ * @param inner The inner sequence.
181
+ * @param outerKeySelector Selects a key from an outer element.
182
+ * @param innerKeySelector Selects a key from an inner element.
183
+ * @param resultSelector Projects each pair; receives `null` for an unmatched inner element.
184
+ * @param compareSelector Optionally normalizes keys before strict equality comparison.
185
+ * @returns A deferred left-join sequence.
186
+ */
187
+ leftJoin<TInner, TKey, TResult>(inner: EnumerableInput<TInner>, outerKeySelector: (outer: T) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: T, inner: TInner | null) => TResult, compareSelector?: (obj: TKey) => unknown): IEnumerable<TResult>;
188
+ /**
189
+ * Correlates two sequences while retaining every element from the inner sequence.
190
+ *
191
+ * @param inner The sequence whose elements are always retained.
192
+ * @param outerKeySelector Selects a key from an outer element.
193
+ * @param innerKeySelector Selects a key from an inner element.
194
+ * @param resultSelector Creates a result from a matching pair. The outer value is `null` when
195
+ * no match exists.
196
+ * @param compareSelector Optionally normalizes keys before strict equality comparison.
197
+ * @returns A deferred right outer join in inner-sequence order.
198
+ */
199
+ rightJoin<TInner, TKey, TResult>(inner: EnumerableInput<TInner>, outerKeySelector: (outer: T) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: T | null, inner: TInner) => TResult, compareSelector?: (obj: TKey) => unknown): IEnumerable<TResult>;
200
+ /**
201
+ * Correlates each outer element with all inner elements having an equal comparison key.
202
+ *
203
+ * @param inner The inner sequence.
204
+ * @param outerKeySelector Selects a key from an outer element.
205
+ * @param innerKeySelector Selects a key from an inner element.
206
+ * @param resultSelector Projects an outer element and its possibly empty inner group.
207
+ * @param compareSelector Optionally normalizes keys before strict equality comparison.
208
+ * @returns A deferred grouped-join sequence.
209
+ */
210
+ groupJoin<TInner, TKey, TResult>(inner: EnumerableInput<TInner>, outerKeySelector: (outer: T) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: T, inner: IEnumerable<TInner>) => TResult, compareSelector?: (obj: TKey) => unknown): IEnumerable<TResult>;
211
+ /**
212
+ * Determines whether every element satisfies a predicate.
213
+ *
214
+ * @param predicate Tests each element.
215
+ * @returns `true` for an empty sequence or when every element passes; otherwise, `false`.
216
+ */
217
+ all(predicate: (element: T) => boolean): boolean;
218
+ /**
219
+ * Determines whether the sequence contains an element, optionally matching a predicate.
220
+ *
221
+ * @param predicate Optionally tests each element.
222
+ * @returns `true` as soon as a matching element is found; otherwise, `false`.
223
+ */
224
+ any(predicate?: (element: T) => boolean): boolean;
225
+ /** @returns `true` when the sequence contains no elements; otherwise, `false`. */
226
+ isEmpty(): boolean;
227
+ /**
228
+ * Appends one or more sequences.
229
+ *
230
+ * @param sequences The sequences to append in order.
231
+ * @returns A deferred concatenated sequence.
232
+ */
233
+ concat(...sequences: EnumerableInput<T>[]): IEnumerable<T>;
234
+ /**
235
+ * Returns the source followed by one additional element.
236
+ *
237
+ * @param element The element placed after the source.
238
+ * @returns A deferred sequence ending with `element`.
239
+ */
240
+ append(element: T): IEnumerable<T>;
241
+ /**
242
+ * Returns one additional element followed by the source.
243
+ *
244
+ * @param element The element placed before the source.
245
+ * @returns A deferred sequence beginning with `element`.
246
+ */
247
+ prepend(element: T): IEnumerable<T>;
248
+ /**
249
+ * Inserts a sequence before the element at a zero-based index.
250
+ *
251
+ * @param index The insertion index. Values outside the source range append the sequence.
252
+ * @param second The sequence to insert.
253
+ * @returns A deferred sequence containing the inserted elements.
254
+ */
255
+ insert(index: number, second: EnumerableInput<T>): IEnumerable<T>;
256
+ /**
257
+ * Places a value or sequence between each pair of source elements.
258
+ *
259
+ * @param alternateValue The value or sequence to insert between adjacent elements.
260
+ * @returns A deferred sequence with separators.
261
+ */
262
+ alternate(alternateValue: T | EnumerableInput<T>): IEnumerable<T>;
263
+ /**
264
+ * Determines whether an element with the same comparison key exists.
265
+ *
266
+ * @param value The value to find.
267
+ * @param compareSelector Optionally selects a key compared with strict equality.
268
+ * @returns `true` when a matching element is found; otherwise, `false`.
269
+ */
270
+ contains<TCompare>(value: T, compareSelector?: (element: T) => TCompare): boolean;
271
+ /**
272
+ * Supplies one fallback element when the source is empty.
273
+ *
274
+ * @param defaultValue The fallback value. It defaults to `undefined`.
275
+ * @returns A deferred sequence containing the source or one fallback element.
276
+ */
277
+ defaultIfEmpty(defaultValue?: T): IEnumerable<T>;
278
+ /**
279
+ * Removes duplicate comparison keys while preserving first-occurrence order.
280
+ *
281
+ * @param compareSelector Optionally selects a key compared with `Set` semantics.
282
+ * @returns A deferred sequence of distinct elements.
283
+ */
284
+ distinct<TCompare>(compareSelector?: (element: T) => TCompare): IEnumerable<T>;
285
+ /**
286
+ * Returns the first element associated with each distinct selected key.
287
+ *
288
+ * @param keySelector Selects a key from each element.
289
+ * @param compareSelector Optionally normalizes keys before `Set` equality comparison.
290
+ * @returns A deferred sequence preserving first-occurrence order.
291
+ */
292
+ distinctBy<TKey, TCompare = TKey>(keySelector: (element: T) => TKey, compareSelector?: (key: TKey) => TCompare): IEnumerable<T>;
293
+ /**
294
+ * Removes consecutive elements with duplicate comparison keys.
295
+ *
296
+ * @param compareSelector Optionally selects a key compared with strict equality.
297
+ * @returns A deferred sequence containing the first element from each adjacent run.
298
+ */
299
+ distinctUntilChanged<TCompare>(compareSelector?: (element: T) => TCompare): IEnumerable<T>;
300
+ /**
301
+ * Produces the distinct elements whose comparison keys do not occur in another sequence.
302
+ *
303
+ * @param second The sequence of values to exclude.
304
+ * @param compareSelector Optionally selects a key compared with `Set` semantics.
305
+ * @returns A deferred set-difference sequence.
306
+ */
307
+ except<TCompare>(second: EnumerableInput<T>, compareSelector?: (element: T) => TCompare): IEnumerable<T>;
308
+ /**
309
+ * Returns distinct source elements whose selected keys are absent from a key sequence.
310
+ *
311
+ * @param second The keys to exclude.
312
+ * @param keySelector Selects a key from each source element.
313
+ * @param compareSelector Optionally normalizes keys before `Set` equality comparison.
314
+ * @returns A deferred set-difference sequence in source order.
315
+ */
316
+ exceptBy<TKey, TCompare = TKey>(second: EnumerableInput<TKey>, keySelector: (element: T) => TKey, compareSelector?: (key: TKey) => TCompare): IEnumerable<T>;
317
+ /**
318
+ * Produces the distinct elements whose comparison keys occur in both sequences.
319
+ *
320
+ * @param second The sequence to intersect with this sequence.
321
+ * @param compareSelector Optionally selects a key compared with `Set` semantics.
322
+ * @returns A deferred intersection sequence in first-sequence order.
323
+ */
324
+ intersect<TCompare>(second: EnumerableInput<T>, compareSelector?: (element: T) => TCompare): IEnumerable<T>;
325
+ /**
326
+ * Returns distinct source elements whose selected keys occur in a key sequence.
327
+ *
328
+ * @param second The keys to retain.
329
+ * @param keySelector Selects a key from each source element.
330
+ * @param compareSelector Optionally normalizes keys before `Set` equality comparison.
331
+ * @returns A deferred intersection sequence in source order.
332
+ */
333
+ intersectBy<TKey, TCompare = TKey>(second: EnumerableInput<TKey>, keySelector: (element: T) => TKey, compareSelector?: (key: TKey) => TCompare): IEnumerable<T>;
334
+ /**
335
+ * Produces the distinct elements from this sequence followed by another sequence.
336
+ *
337
+ * @param second The second sequence.
338
+ * @param compareSelector Optionally selects a key compared with `Set` semantics.
339
+ * @returns A deferred union sequence preserving first-occurrence order.
340
+ */
341
+ union<TCompare>(second: EnumerableInput<T>, compareSelector?: (element: T) => TCompare): IEnumerable<T>;
342
+ /**
343
+ * Returns the first element associated with each distinct selected key across two sequences.
344
+ *
345
+ * @param second The sequence appended before duplicate removal.
346
+ * @param keySelector Selects a key from each element.
347
+ * @param compareSelector Optionally normalizes keys before `Set` equality comparison.
348
+ * @returns A deferred union preserving first-occurrence order.
349
+ */
350
+ unionBy<TKey, TCompare = TKey>(second: EnumerableInput<T>, keySelector: (element: T) => TKey, compareSelector?: (key: TKey) => TCompare): IEnumerable<T>;
351
+ /**
352
+ * Determines whether two sequences have equal comparison keys in the same order.
353
+ *
354
+ * @param second The sequence to compare with this sequence.
355
+ * @param compareSelector Optionally selects a key compared with strict equality.
356
+ * @returns `true` when lengths and corresponding keys are equal; otherwise, `false`.
357
+ */
358
+ sequenceEqual<TCompare>(second: EnumerableInput<T>, compareSelector?: (element: T) => TCompare): boolean;
359
+ /**
360
+ * Orders elements by an ascending key while preserving source order for equal keys.
361
+ *
362
+ * @param keySelector Selects the key for each element.
363
+ * @param comparer Optionally compares two keys; negative values sort the first key earlier.
364
+ * @returns An ordered sequence that is sorted when enumerated.
365
+ */
366
+ orderBy<TKey>(keySelector: (element: T) => TKey, comparer?: Comparer<TKey>): IOrderedEnumerable<T>;
367
+ /**
368
+ * Orders elements by a descending key while preserving source order for equal keys.
369
+ *
370
+ * @param keySelector Selects the key for each element.
371
+ * @param comparer Optionally compares two keys before the result is reversed.
372
+ * @returns An ordered sequence that is sorted when enumerated.
373
+ */
374
+ orderByDescending<TKey>(keySelector: (element: T) => TKey, comparer?: Comparer<TKey>): IOrderedEnumerable<T>;
375
+ /** @returns A deferred sequence containing all elements in reverse order. */
376
+ reverse(): IEnumerable<T>;
377
+ /** @returns A deferred sequence randomly permuted with `Math.random()` on each enumeration. */
378
+ shuffle(): IEnumerable<T>;
379
+ /**
380
+ * Repeatedly samples elements with replacement according to non-negative weights.
381
+ *
382
+ * @param weightSelector Selects each element's weight; negative weights are treated as zero.
383
+ * @returns An infinite deferred sequence, or an empty sequence when the total weight is zero.
384
+ */
385
+ weightedSample(weightSelector: (element: T) => number): IEnumerable<T>;
386
+ /**
387
+ * Groups elements by key.
388
+ *
389
+ * @param keySelector Selects the key for each element.
390
+ * @returns An eager grouping represented as a sequence in first-key occurrence order.
391
+ */
392
+ groupBy<TKey>(keySelector: (element: T) => TKey): IEnumerable<IGrouping<TKey, T>>;
393
+ /**
394
+ * Groups projected elements by key.
395
+ *
396
+ * @param keySelector Selects the key for each source element.
397
+ * @param elementSelector Selects the value stored in each group.
398
+ * @returns An eager grouping represented as a sequence in first-key occurrence order.
399
+ */
400
+ groupBy<TKey, TElement>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement): IEnumerable<IGrouping<TKey, TElement>>;
401
+ /**
402
+ * Groups projected elements by key and projects each resulting group.
403
+ *
404
+ * @param keySelector Selects the key for each source element.
405
+ * @param elementSelector Selects the value stored in each group.
406
+ * @param resultSelector Projects each key and group.
407
+ * @returns A sequence of projected groups in first-key occurrence order.
408
+ */
409
+ groupBy<TKey, TElement, TResult>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, elements: IEnumerable<TElement>) => TResult): IEnumerable<TResult>;
410
+ /**
411
+ * Groups projected elements by a normalized comparison key and projects each group.
412
+ *
413
+ * @param keySelector Selects the original key for each source element.
414
+ * @param elementSelector Selects the value stored in each group.
415
+ * @param resultSelector Projects each first-occurring original key and its group.
416
+ * @param compareSelector Normalizes keys before `Map` equality comparison.
417
+ * @returns A sequence of projected groups in first-key occurrence order.
418
+ */
419
+ groupBy<TKey, TElement, TResult, TCompare>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, elements: IEnumerable<TElement>) => TResult, compareSelector: (key: TKey) => TCompare): IEnumerable<TResult>;
420
+ /**
421
+ * Groups adjacent elements having the same key.
422
+ *
423
+ * @param keySelector Selects the key for each element.
424
+ * @returns A deferred sequence of contiguous groups.
425
+ */
426
+ partitionBy<TKey>(keySelector: (element: T) => TKey): IEnumerable<IGrouping<TKey, T>>;
427
+ /**
428
+ * Groups adjacent projected elements having the same key.
429
+ *
430
+ * @param keySelector Selects the key for each source element.
431
+ * @param elementSelector Selects the value stored in each group.
432
+ * @returns A deferred sequence of contiguous groups.
433
+ */
434
+ partitionBy<TKey, TElement>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement): IEnumerable<IGrouping<TKey, TElement>>;
435
+ /**
436
+ * Groups adjacent projected elements by key and projects each group.
437
+ *
438
+ * @param keySelector Selects the key for each source element.
439
+ * @param elementSelector Selects the value stored in each group.
440
+ * @param resultSelector Projects each key and contiguous group.
441
+ * @returns A deferred sequence of projected contiguous groups.
442
+ */
443
+ partitionBy<TKey, TElement, TResult>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, elements: IEnumerable<TElement>) => TResult): IEnumerable<TResult>;
444
+ /**
445
+ * Groups adjacent projected elements by a normalized key and projects each group.
446
+ *
447
+ * @param keySelector Selects the original key for each source element.
448
+ * @param elementSelector Selects the value stored in each group.
449
+ * @param resultSelector Projects each first key in a contiguous run and its group.
450
+ * @param compareSelector Normalizes keys before strict equality comparison.
451
+ * @returns A deferred sequence of projected contiguous groups.
452
+ */
453
+ partitionBy<TKey, TElement, TResult, TCompare>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, elements: IEnumerable<TElement>) => TResult, compareSelector: (key: TKey) => TCompare): IEnumerable<TResult>;
454
+ /**
455
+ * Splits the source into arrays containing at most `count` elements.
456
+ *
457
+ * @param count The maximum number of elements in each buffer.
458
+ * @returns A deferred sequence of non-empty buffers.
459
+ * @throws {RangeError} When `count` is not greater than zero.
460
+ */
461
+ buffer(count: number): IEnumerable<T[]>;
462
+ /**
463
+ * Aggregates the sequence without a seed, using the first element as the accumulator.
464
+ *
465
+ * @param func Combines the current accumulator and next element.
466
+ * @returns The final accumulated value.
467
+ * @throws {Error} When the source sequence is empty.
468
+ */
469
+ aggregate(func: (prev: T, current: T) => T): T;
470
+ /**
471
+ * Aggregates the sequence from an initial seed.
472
+ *
473
+ * @param seed The initial accumulator value.
474
+ * @param func Combines the current accumulator and each element.
475
+ * @returns The final accumulated value, or the seed for an empty sequence.
476
+ */
477
+ aggregate<TAccumulate>(seed: TAccumulate, func: (prev: TAccumulate, current: T) => TAccumulate): TAccumulate;
478
+ /**
479
+ * Aggregates the sequence from a seed and projects the final accumulator.
480
+ *
481
+ * @param seed The initial accumulator value.
482
+ * @param func Combines the current accumulator and each element.
483
+ * @param resultSelector Projects the final accumulator.
484
+ * @returns The projected final accumulation.
485
+ */
486
+ aggregate<TAccumulate, TResult>(seed: TAccumulate, func: (prev: TAccumulate, current: T) => TAccumulate, resultSelector: (last: TAccumulate) => TResult): TResult;
487
+ /**
488
+ * Aggregates elements independently for each selected key.
489
+ *
490
+ * @param keySelector Selects a key from each element.
491
+ * @param seed The initial accumulator value used for every key.
492
+ * @param accumulator Updates a key's accumulator with one source element.
493
+ * @param compareSelector Optionally normalizes keys before `Map` equality comparison.
494
+ * @returns A deferred sequence of key and aggregate pairs in first-key order.
495
+ */
496
+ aggregateBy<TKey, TAccumulate>(keySelector: (element: T) => TKey, seed: TAccumulate, accumulator: (accumulate: TAccumulate, element: T) => TAccumulate, compareSelector?: (key: TKey) => unknown): IEnumerable<KeyValuePair<TKey, TAccumulate>>;
497
+ /**
498
+ * Computes the arithmetic mean of selected numeric values.
499
+ *
500
+ * @param selector Optionally converts each element to a number.
501
+ * @returns The mean, or `NaN` for an empty sequence.
502
+ */
503
+ average(selector?: (element: T) => number): number;
504
+ /**
505
+ * Counts all elements or only those matching a predicate.
506
+ *
507
+ * @param predicate Optionally tests each element and its zero-based index.
508
+ * @returns The number of matching elements.
509
+ */
510
+ count(predicate?: (element: T, index: number) => boolean): number;
511
+ /**
512
+ * Counts elements independently for each selected key.
513
+ *
514
+ * @param keySelector Selects a key from each element.
515
+ * @param compareSelector Optionally normalizes keys before `Map` equality comparison.
516
+ * @returns A deferred sequence of key and count pairs in first-key order.
517
+ */
518
+ countBy<TKey>(keySelector: (element: T) => TKey, compareSelector?: (key: TKey) => unknown): IEnumerable<KeyValuePair<TKey, number>>;
519
+ /**
520
+ * Finds the greatest selected numeric value.
521
+ *
522
+ * @param selector Optionally converts each element to a number.
523
+ * @returns The maximum, or `-Infinity` for an empty sequence.
524
+ */
525
+ max(selector?: (element: T) => number): number;
526
+ /**
527
+ * Finds the least selected numeric value.
528
+ *
529
+ * @param selector Optionally converts each element to a number.
530
+ * @returns The minimum, or `Infinity` for an empty sequence.
531
+ */
532
+ min(selector?: (element: T) => number): number;
533
+ /**
534
+ * Finds the first element having the greatest selected key.
535
+ *
536
+ * @param keySelector Selects the comparison key for each element.
537
+ * @returns The element with the greatest key.
538
+ * @throws {Error} When the source sequence is empty.
539
+ */
540
+ maxBy<TKey>(keySelector: (element: T) => TKey): T;
541
+ /**
542
+ * Finds the first element having the least selected key.
543
+ *
544
+ * @param keySelector Selects the comparison key for each element.
545
+ * @returns The element with the least key.
546
+ * @throws {Error} When the source sequence is empty.
547
+ */
548
+ minBy<TKey>(keySelector: (element: T) => TKey): T;
549
+ /**
550
+ * Adds selected numeric values.
551
+ *
552
+ * @param selector Optionally converts each element to a number.
553
+ * @returns The sum, or zero for an empty sequence.
554
+ */
555
+ sum(selector?: (element: T) => number): number;
556
+ /**
557
+ * Gets the element at a zero-based index.
558
+ *
559
+ * @param index The index of the element to return.
560
+ * @returns The element at `index`.
561
+ * @throws {Error} When no element exists at the requested index.
562
+ */
563
+ elementAt(index: number): T;
564
+ /**
565
+ * Gets the element at a zero-based index or a fallback value.
566
+ *
567
+ * @param index The index of the element to return.
568
+ * @param defaultValue The value returned when the index is outside the sequence.
569
+ * @returns The indexed element, `defaultValue`, or `undefined`.
570
+ */
571
+ elementAtOrDefault(index: number, defaultValue?: T): T | undefined;
572
+ /**
573
+ * Gets the first element accepted by a type-guard predicate.
574
+ *
575
+ * @param predicate Tests each element and its zero-based index.
576
+ * @returns The first accepted element, narrowed by the predicate.
577
+ * @throws {Error} When no matching element exists.
578
+ */
579
+ first<TOther extends T>(predicate: (element: T, index: number) => element is TOther): TOther;
580
+ /**
581
+ * Gets the first element, optionally restricted by a predicate.
582
+ *
583
+ * @param predicate Optionally tests each element and its zero-based index.
584
+ * @returns The first matching element.
585
+ * @throws {Error} When no matching element exists.
586
+ */
587
+ first(predicate?: (element: T, index: number) => boolean): T;
588
+ /**
589
+ * Gets the first matching element or a supplied fallback.
590
+ *
591
+ * @param predicate Tests each element and its zero-based index.
592
+ * @param defaultValue The value returned when no element matches.
593
+ * @returns The first matching element or `defaultValue`.
594
+ */
595
+ firstOrDefault<TDefault>(predicate: (element: T, index: number) => boolean, defaultValue: TDefault): T | TDefault;
596
+ /**
597
+ * Gets the first element accepted by a type guard or a supplied fallback.
598
+ *
599
+ * @param predicate Tests and narrows each element.
600
+ * @param defaultValue The value returned when no element matches.
601
+ * @returns The first narrowed element or `defaultValue`.
602
+ */
603
+ firstOrDefault<TOther extends T, TDefault>(predicate: (element: T, index: number) => element is TOther, defaultValue: TDefault): TOther | TDefault;
604
+ /**
605
+ * Gets the first element, first matching element, or a fallback.
606
+ *
607
+ * @param predicate An optional predicate. When omitted, the first element is returned.
608
+ * @returns The first matching element, or `undefined` when no element matches.
609
+ */
610
+ firstOrDefault(predicate?: (element: T, index: number) => boolean): T | undefined;
611
+ /**
612
+ * Gets the first element or a supplied fallback.
613
+ *
614
+ * @param defaultValue The value returned when the sequence is empty.
615
+ * @returns The first element or `defaultValue`.
616
+ */
617
+ firstOrDefault<TDefault>(defaultValue: TDefault): T | TDefault;
618
+ /**
619
+ * Gets the last element accepted by a type-guard predicate.
620
+ *
621
+ * @param predicate Tests each element and its zero-based index.
622
+ * @returns The last accepted element, narrowed by the predicate.
623
+ * @throws {Error} When no matching element exists.
624
+ */
625
+ last<TOther extends T>(predicate: (element: T, index: number) => element is TOther): TOther;
626
+ /**
627
+ * Gets the last element, optionally restricted by a predicate.
628
+ *
629
+ * @param predicate Optionally tests each element and its zero-based index.
630
+ * @returns The last matching element.
631
+ * @throws {Error} When no matching element exists.
632
+ */
633
+ last(predicate?: (element: T, index: number) => boolean): T;
634
+ /**
635
+ * Gets the last matching element or a supplied fallback.
636
+ *
637
+ * @param predicate Tests each element and its zero-based index.
638
+ * @param defaultValue The value returned when no element matches.
639
+ * @returns The last matching element or `defaultValue`.
640
+ */
641
+ lastOrDefault<TDefault>(predicate: (element: T, index: number) => boolean, defaultValue: TDefault): T | TDefault;
642
+ /**
643
+ * Gets the last element accepted by a type guard or a supplied fallback.
644
+ *
645
+ * @param predicate Tests and narrows each element.
646
+ * @param defaultValue The value returned when no element matches.
647
+ * @returns The last narrowed element or `defaultValue`.
648
+ */
649
+ lastOrDefault<TOther extends T, TDefault>(predicate: (element: T, index: number) => element is TOther, defaultValue: TDefault): TOther | TDefault;
650
+ /**
651
+ * Gets the last element, last matching element, or `undefined`.
652
+ *
653
+ * @param predicate Optionally tests each element and its zero-based index.
654
+ * @returns The last matching element, or `undefined` when no element matches.
655
+ */
656
+ lastOrDefault(predicate?: (element: T, index: number) => boolean): T | undefined;
657
+ /**
658
+ * Gets the last element or a supplied fallback.
659
+ *
660
+ * @param defaultValue The value returned when the sequence is empty.
661
+ * @returns The last element or `defaultValue`.
662
+ */
663
+ lastOrDefault<TDefault>(defaultValue: TDefault): T | TDefault;
664
+ /**
665
+ * Gets the only element accepted by a type-guard predicate.
666
+ *
667
+ * @param predicate Tests each element and its zero-based index.
668
+ * @returns The sole accepted element, narrowed by the predicate.
669
+ * @throws {Error} When zero or more than one matching element exists.
670
+ */
671
+ single<TOther extends T>(predicate: (element: T, index: number) => element is TOther): TOther;
672
+ /**
673
+ * Gets the only element, optionally restricted by a predicate.
674
+ *
675
+ * @param predicate Optionally tests each element and its zero-based index.
676
+ * @returns The sole matching element.
677
+ * @throws {Error} When zero or more than one matching element exists.
678
+ */
679
+ single(predicate?: (element: T, index: number) => boolean): T;
680
+ /**
681
+ * Gets the only matching element or a supplied fallback.
682
+ *
683
+ * @param predicate Tests each element and its zero-based index.
684
+ * @param defaultValue The value returned when no element matches.
685
+ * @returns The sole matching element or `defaultValue`.
686
+ * @throws {Error} When more than one element matches.
687
+ */
688
+ singleOrDefault<TDefault>(predicate: (element: T, index: number) => boolean, defaultValue: TDefault): T | TDefault;
689
+ /**
690
+ * Gets the only element accepted by a type guard or a supplied fallback.
691
+ *
692
+ * @param predicate Tests and narrows each element.
693
+ * @param defaultValue The value returned when no element matches.
694
+ * @returns The sole narrowed element or `defaultValue`.
695
+ * @throws {Error} When more than one element matches.
696
+ */
697
+ singleOrDefault<TOther extends T, TDefault>(predicate: (element: T, index: number) => element is TOther, defaultValue: TDefault): TOther | TDefault;
698
+ /**
699
+ * Gets the only element, only matching element, or `undefined`.
700
+ *
701
+ * @param predicate Optionally tests each element and its zero-based index.
702
+ * @returns The sole matching element, or `undefined` when none matches.
703
+ * @throws {Error} When more than one element matches.
704
+ */
705
+ singleOrDefault(predicate?: (element: T, index: number) => boolean): T | undefined;
706
+ /**
707
+ * Gets the only element or a supplied fallback.
708
+ *
709
+ * @param defaultValue The value returned when the sequence is empty.
710
+ * @returns The sole element or `defaultValue`.
711
+ * @throws {Error} When the sequence contains more than one element.
712
+ */
713
+ singleOrDefault<TDefault>(defaultValue: TDefault): T | TDefault;
714
+ /**
715
+ * Bypasses a number of elements.
716
+ *
717
+ * @param count The number of elements to skip; non-positive values skip none.
718
+ * @returns A deferred sequence containing the remaining elements.
719
+ */
720
+ skip(count: number): IEnumerable<T>;
721
+ /**
722
+ * Bypasses elements while a predicate remains true.
723
+ *
724
+ * @param predicate Tests each candidate element and its zero-based index.
725
+ * @returns A deferred sequence beginning with the first rejected element.
726
+ */
727
+ skipWhile(predicate: (element: T, index: number) => boolean): IEnumerable<T>;
728
+ /**
729
+ * Returns at most a specified number of leading elements.
730
+ *
731
+ * @param count The maximum number to return; non-positive values return an empty sequence.
732
+ * @returns A deferred prefix of the source sequence.
733
+ */
734
+ take(count: number): IEnumerable<T>;
735
+ /**
736
+ * Returns leading elements while a predicate remains true.
737
+ *
738
+ * @param predicate Tests each candidate element and its zero-based index.
739
+ * @returns A deferred sequence ending before the first rejected element.
740
+ */
741
+ takeWhile(predicate: (element: T, index: number) => boolean): IEnumerable<T>;
742
+ /**
743
+ * Returns every element except a number of trailing elements.
744
+ *
745
+ * @param count The number to omit; defaults to one, and non-positive values omit none.
746
+ * @returns A deferred sequence without the requested suffix.
747
+ */
748
+ takeExceptLast(count?: number): IEnumerable<T>;
749
+ /**
750
+ * Returns every element except a number of trailing elements.
751
+ *
752
+ * @param count The number of trailing elements to omit.
753
+ * @returns A deferred sequence without the requested suffix.
754
+ */
755
+ skipLast(count: number): IEnumerable<T>;
756
+ /**
757
+ * Returns up to a specified number of trailing elements.
758
+ *
759
+ * @param count The suffix length; non-positive values return an empty sequence.
760
+ * @returns A deferred sequence that buffers the source before producing the suffix.
761
+ */
762
+ takeFromLast(count: number): IEnumerable<T>;
763
+ /**
764
+ * Returns up to a specified number of trailing elements.
765
+ *
766
+ * @param count The suffix length; non-positive values return an empty sequence.
767
+ * @returns A deferred sequence that buffers the source before producing the suffix.
768
+ */
769
+ takeLast(count: number): IEnumerable<T>;
770
+ /**
771
+ * Selects a one-based page.
772
+ *
773
+ * @param pageNumber The one-based page number; values below one select the first page.
774
+ * @param pageSize The maximum number of elements in the page.
775
+ * @returns A deferred page of elements.
776
+ */
777
+ page(pageNumber: number, pageSize: number): IEnumerable<T>;
778
+ /**
779
+ * Selects a one-based page described by an object.
780
+ *
781
+ * @param info The page number and page size.
782
+ * @returns A deferred page of elements.
783
+ */
784
+ page(info: IPageInfo): IEnumerable<T>;
785
+ /**
786
+ * Finds the first index of an element using strict equality.
787
+ *
788
+ * @param item The element to find.
789
+ * @returns The zero-based index, or `-1` when the element is absent.
790
+ */
791
+ indexOf(item: T): number;
792
+ /**
793
+ * Finds the first index accepted by a predicate.
794
+ *
795
+ * @param predicate Tests each element and its zero-based index.
796
+ * @returns The first accepted index, or `-1` when no element matches.
797
+ */
798
+ indexOf(predicate: (element: T, index: number) => boolean): number;
799
+ /**
800
+ * Finds the last index of an element using strict equality.
801
+ *
802
+ * @param item The element to find.
803
+ * @returns The final zero-based index, or `-1` when the element is absent.
804
+ */
805
+ lastIndexOf(item: T): number;
806
+ /**
807
+ * Finds the last index accepted by a predicate.
808
+ *
809
+ * @param predicate Tests each element and its zero-based index.
810
+ * @returns The final accepted index, or `-1` when no element matches.
811
+ */
812
+ lastIndexOf(predicate: (element: T, index: number) => boolean): number;
813
+ /** @returns A deferred wrapper that hides the source sequence's concrete identity. */
814
+ asEnumerable(): IEnumerable<T>;
815
+ /**
816
+ * Reinterprets the element type without runtime conversion or validation.
817
+ *
818
+ * @returns This sequence typed as `IEnumerable<TResult>`.
819
+ */
820
+ cast<TResult>(): IEnumerable<TResult>;
821
+ /** @returns A newly allocated array containing all source elements. */
822
+ toArray(): T[];
823
+ /**
824
+ * Materializes the sequence into a native `Set`.
825
+ *
826
+ * @returns A set containing each distinct value in first-occurrence order.
827
+ */
828
+ toSet(): Set<T>;
829
+ /**
830
+ * Creates a lookup by grouping source elements under selected keys.
831
+ *
832
+ * @param keySelector Selects the key for each source element.
833
+ * @returns A lookup whose groups contain the original elements.
834
+ */
835
+ toLookup<TKey>(keySelector: (element: T) => TKey): ILookup<TKey, T>;
836
+ /**
837
+ * Creates a lookup from selected keys and values.
838
+ *
839
+ * @param keySelector Selects the key for each source element.
840
+ * @param elementSelector Selects the value stored in each group.
841
+ * @param compareSelector Optionally normalizes keys before `Map` equality comparison.
842
+ * @returns A lookup containing all selected values grouped by key.
843
+ */
844
+ toLookup<TKey, TElement>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, compareSelector?: (key: TKey) => unknown): ILookup<TKey, TElement>;
845
+ /**
846
+ * Creates an object from selected property keys and values.
847
+ *
848
+ * @param keySelector Selects a property key for each element.
849
+ * @param elementSelector Optionally selects the property value.
850
+ * @returns An object whose later values overwrite earlier values with the same key.
851
+ */
852
+ toObject<TKey extends PropertyKey, TElement = T>(keySelector: (element: T) => TKey, elementSelector?: (element: T) => TElement): Record<TKey, TElement>;
853
+ /**
854
+ * Creates a dictionary using each source element as its value.
855
+ *
856
+ * @param keySelector Selects a key for each element.
857
+ * @returns A dictionary containing the source elements.
858
+ */
859
+ toDictionary<TKey>(keySelector: (element: T) => TKey): IDictionary<TKey, T>;
860
+ /**
861
+ * Creates a dictionary from selected keys and values.
862
+ *
863
+ * @param keySelector Selects a key for each element.
864
+ * @param elementSelector Selects a value for each element.
865
+ * @param compareSelector Optionally normalizes keys before `Map` equality comparison.
866
+ * @returns A dictionary whose later values overwrite earlier equal comparison keys.
867
+ */
868
+ toDictionary<TKey, TValue>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TValue, compareSelector?: (key: TKey) => unknown): IDictionary<TKey, TValue>;
869
+ /**
870
+ * Serializes all source elements as a JSON array.
871
+ *
872
+ * @param replacer A JSON replacer function or property allowlist.
873
+ * @param space The indentation used in the serialized output.
874
+ * @returns The JSON representation of the materialized sequence.
875
+ */
876
+ toJSONString(replacer?: ((key: string, value: unknown) => unknown) | (string | number)[], space?: string | number): string;
877
+ /**
878
+ * Joins the string representations of all elements.
879
+ *
880
+ * @param separator The text inserted between adjacent elements; defaults to an empty string.
881
+ * @returns The joined string.
882
+ */
883
+ toJoinedString(separator?: string): string;
884
+ /**
885
+ * Projects each element and joins the resulting string representations.
886
+ *
887
+ * @param separator The text inserted between adjacent projected values.
888
+ * @param selector Projects each element and its zero-based index.
889
+ * @returns The joined string.
890
+ */
891
+ toJoinedString<TResult>(separator: string, selector: (element: T, index: number) => TResult): string;
892
+ /**
893
+ * Joins the string representations of all elements.
894
+ *
895
+ * @param separator The text inserted between adjacent elements.
896
+ * @returns The joined string.
897
+ */
898
+ joinWith(separator: string): string;
899
+ /**
900
+ * Inserts a computed separator after every element except the last.
901
+ *
902
+ * @param separator Selects the separator that follows each non-final element.
903
+ * @returns A deferred sequence alternating source elements and separators.
904
+ */
905
+ joinWith(separator: (element: T) => T): IEnumerable<T>;
906
+ /**
907
+ * Creates a native `Map` from selected keys and values.
908
+ *
909
+ * @param keySelector Selects a key for each element.
910
+ * @param valueSelector Selects a value for each element.
911
+ * @returns A map whose later values overwrite earlier values with the same key.
912
+ */
913
+ toMap<K, V>(keySelector: (element: T) => K, valueSelector: (element: T) => V): Map<K, V>;
914
+ /**
915
+ * Splits the source into arrays containing at most `size` elements.
916
+ *
917
+ * @param size A positive integer specifying the maximum chunk size.
918
+ * @returns A deferred sequence of non-empty chunks.
919
+ * @throws {RangeError} When `size` is not a positive integer.
920
+ */
921
+ chunk(size: number): IEnumerable<T[]>;
922
+ /** @returns A deferred sequence pairing every element with its zero-based index. */
923
+ index(): IEnumerable<Indexed<T>>;
924
+ /** @returns A deferred sequence describing each element's index and boundary position. */
925
+ position(): IEnumerable<Positioned<T>>;
926
+ /** @returns A deferred sequence pairing each element with its previous and next neighbors. */
927
+ withNeighbors(): IEnumerable<Neighbors<T>>;
928
+ /**
929
+ * Performs an action as elements are enumerated and passes the elements through unchanged.
930
+ *
931
+ * @param action Receives each element and index. Returning `false` stops the sequence.
932
+ * @returns A deferred sequence that invokes `action` during enumeration.
933
+ */
934
+ doAction(action: (element: T, index: number) => void): IEnumerable<T>;
935
+ doAction(action: (element: T, index: number) => boolean): IEnumerable<T>;
936
+ /**
937
+ * Eagerly enumerates the sequence and performs an action for each element.
938
+ *
939
+ * @param action Receives each element and index. Returning `false` stops enumeration.
940
+ */
941
+ forEach(action: (element: T, index: number) => void): void;
942
+ forEach(action: (element: T, index: number) => boolean): void;
943
+ /**
944
+ * Eagerly consumes the entire sequence without retaining its elements.
945
+ *
946
+ * This is useful for triggering deferred side effects. It does not terminate for an infinite
947
+ * sequence unless an earlier operator bounds that sequence.
948
+ */
949
+ force(): void;
950
+ /**
951
+ * Passes the complete source sequence to a function and enumerates its returned sequence.
952
+ *
953
+ * @param func Creates a sequence from this sequence.
954
+ * @returns A deferred sequence over the function result.
955
+ */
956
+ letBind<TResult>(func: (source: IEnumerable<T>) => EnumerableInput<TResult>): IEnumerable<TResult>;
957
+ /**
958
+ * Creates a sequence whose consumers share one forward-only source iterator.
959
+ *
960
+ * @returns A disposable sequence that distributes successive source elements among consumers.
961
+ */
962
+ share(): IDisposableEnumerable<T>;
963
+ /**
964
+ * Creates a sequence that caches elements as they are requested for subsequent enumerations.
965
+ *
966
+ * @returns A disposable sequence backed by a single source iterator and a growing cache.
967
+ */
968
+ memoize(): IDisposableEnumerable<T>;
969
+ /**
970
+ * Handles an error raised while enumerating the source and then completes the sequence.
971
+ *
972
+ * @param handler Receives the caught error.
973
+ * @returns A deferred sequence that suppresses source errors after invoking the handler.
974
+ */
975
+ catchError(handler: ((exception: unknown) => void)): IEnumerable<T>;
976
+ /**
977
+ * Runs an action after enumeration completes, fails, or is stopped by the consumer.
978
+ *
979
+ * @param action The cleanup action to execute exactly once per enumeration.
980
+ * @returns A deferred sequence that passes source elements through unchanged.
981
+ */
982
+ finallyAction(action: () => void): IEnumerable<T>;
983
+ /**
984
+ * Logs each selected value with `console.log` as the sequence is enumerated.
985
+ *
986
+ * @param selector Optionally selects the value to log.
987
+ * @returns A deferred sequence that passes source elements through unchanged.
988
+ */
989
+ log<TValue>(selector?: (element: T) => TValue): IEnumerable<T>;
990
+ /**
991
+ * Logs a message and each selected value as the sequence is enumerated.
992
+ *
993
+ * @param message The message prefix; defaults to `"Trace"`.
994
+ * @param selector Optionally selects the value to log.
995
+ * @returns A deferred sequence that passes source elements through unchanged.
996
+ */
997
+ trace<TValue>(message?: string, selector?: (element: T) => TValue): IEnumerable<T>;
998
+ }
999
+ /** A sequence with one or more stable ordering criteria. */
1000
+ export interface IOrderedEnumerable<T> extends IEnumerable<T> {
1001
+ /**
1002
+ * Appends an ordering criterion.
1003
+ *
1004
+ * @param keySelector Selects the key for each element.
1005
+ * @param comparer Optionally compares two keys.
1006
+ * @param descending Whether to apply this criterion in descending order.
1007
+ * @returns A new ordered sequence containing the additional criterion.
1008
+ */
1009
+ createOrderedEnumerable<TKey>(keySelector: (element: T) => TKey, comparer?: Comparer<TKey>, descending?: boolean): IOrderedEnumerable<T>;
1010
+ /**
1011
+ * Appends an ascending ordering criterion.
1012
+ *
1013
+ * @param keySelector Selects the key for each element.
1014
+ * @param comparer Optionally compares two keys.
1015
+ * @returns A new ordered sequence containing the additional criterion.
1016
+ */
1017
+ thenBy<TKey>(keySelector: (element: T) => TKey, comparer?: Comparer<TKey>): IOrderedEnumerable<T>;
1018
+ /**
1019
+ * Appends a descending ordering criterion.
1020
+ *
1021
+ * @param keySelector Selects the key for each element.
1022
+ * @param comparer Optionally compares two keys before the result is reversed.
1023
+ * @returns A new ordered sequence containing the additional criterion.
1024
+ */
1025
+ thenByDescending<TKey>(keySelector: (element: T) => TKey, comparer?: Comparer<TKey>): IOrderedEnumerable<T>;
1026
+ }
1027
+ /** A sequence backed by resources that can be released before natural completion. */
1028
+ export interface IDisposableEnumerable<T> extends IEnumerable<T> {
1029
+ /** Releases the underlying iterator. Repeated calls have no effect. */
1030
+ dispose(): void;
1031
+ }
1032
+ /** Associates a key with one value. */
1033
+ export interface KeyValuePair<TKey, TValue> {
1034
+ /** The entry's original key. */
1035
+ key: TKey;
1036
+ /** The entry's value. */
1037
+ value: TValue;
1038
+ }
1039
+ /** A mutable key-value collection with optional normalized-key comparison. */
1040
+ export interface IDictionary<TKey, TValue> {
1041
+ /**
1042
+ * Adds or replaces a value under a key.
1043
+ *
1044
+ * @param key The key to store.
1045
+ * @param value The associated value.
1046
+ */
1047
+ add(key: TKey, value: TValue): void;
1048
+ /**
1049
+ * Gets the value associated with a key.
1050
+ *
1051
+ * @param key The key to find.
1052
+ * @returns The associated value, or `undefined` at runtime when the key is absent.
1053
+ */
1054
+ get(key: TKey): TValue;
1055
+ /**
1056
+ * Adds or replaces a value under a key.
1057
+ *
1058
+ * @param key The key to store.
1059
+ * @param value The associated value.
1060
+ * @returns `true` when an existing entry was replaced; otherwise, `false`.
1061
+ */
1062
+ set(key: TKey, value: TValue): boolean;
1063
+ /**
1064
+ * Tests whether a key exists.
1065
+ *
1066
+ * @param key The key to find.
1067
+ * @returns `true` when the dictionary contains the key; otherwise, `false`.
1068
+ */
1069
+ contains(key: TKey): boolean;
1070
+ /** Removes every entry from the dictionary. */
1071
+ clear(): void;
1072
+ /**
1073
+ * Removes an entry when it exists.
1074
+ *
1075
+ * @param key The key to remove.
1076
+ */
1077
+ remove(key: TKey): void;
1078
+ /** @returns The number of entries in the dictionary. */
1079
+ count(): number;
1080
+ /** @returns A deferred sequence of entries in insertion order. */
1081
+ toEnumerable(): IEnumerable<KeyValuePair<TKey, TValue>>;
1082
+ }
1083
+ /** A read-only one-to-many mapping produced by grouping operations. */
1084
+ export interface ILookup<TKey, TElement> {
1085
+ /** @returns The number of distinct comparison keys. */
1086
+ count(): number;
1087
+ /**
1088
+ * Gets all elements associated with a key.
1089
+ *
1090
+ * @param key The key to find.
1091
+ * @returns A group for the key, or an empty group when the key is absent.
1092
+ */
1093
+ get(key: TKey): IEnumerable<TElement>;
1094
+ /**
1095
+ * Tests whether a key exists.
1096
+ *
1097
+ * @param key The key to find.
1098
+ * @returns `true` when the lookup contains the key; otherwise, `false`.
1099
+ */
1100
+ contains(key: TKey): boolean;
1101
+ /** @returns A deferred sequence of groups in first-key insertion order. */
1102
+ toEnumerable(): IEnumerable<IGrouping<TKey, TElement>>;
1103
+ }
1104
+ /** A sequence of elements that share a key. */
1105
+ export interface IGrouping<TKey, TElement> extends IEnumerable<TElement> {
1106
+ /** @returns The group's original key. */
1107
+ key(): TKey;
1108
+ /**
1109
+ * Gets the array that stores the group's elements.
1110
+ *
1111
+ * @returns The live backing array; modifying it changes subsequent group enumeration.
1112
+ */
1113
+ getSource(): TElement[];
1114
+ }
1115
+ /** Describes a one-based page request. */
1116
+ export interface IPageInfo {
1117
+ /** The one-based page number. Values below one select the first page. */
1118
+ pageNumber: number;
1119
+ /** The maximum number of elements in the page. */
1120
+ pageSize: number;
1121
+ }
1122
+ /** Associates a sequence element with its zero-based index. */
1123
+ export interface Indexed<T> {
1124
+ /** The element's zero-based index. */
1125
+ index: number;
1126
+ /** The sequence element. */
1127
+ item: T;
1128
+ }
1129
+ /** Describes an element's index and position within a sequence. */
1130
+ export interface Positioned<T> extends Indexed<T> {
1131
+ /** Whether this is the first element. */
1132
+ isFirst: boolean;
1133
+ /** Whether this is the last element. */
1134
+ isLast: boolean;
1135
+ }
1136
+ /** Associates an element with its immediate neighbors. */
1137
+ export interface Neighbors<T> {
1138
+ /** The previous element, or `null` for the first element. */
1139
+ prev: T | null;
1140
+ /** The current element. */
1141
+ item: T;
1142
+ /** The next element, or `null` for the last element. */
1143
+ next: T | null;
1144
+ }
1145
+ /** @deprecated Use {@link Indexed} instead. */
1146
+ export type IndexedItem<T> = Indexed<T>;
1147
+ /** @deprecated Use {@link Positioned} instead. */
1148
+ export type PositionedItem<T> = Positioned<T>;
1149
+ /** @deprecated Use {@link Neighbors} instead. */
1150
+ export type ItemWithNeighbors<T> = Neighbors<T>;
1151
+ /** Compares two values, returning a negative, zero, or positive number. */
1152
+ export type Comparer<T> = (first: T, second: T) => number;
1153
+ /** A sequence value accepted by operators: a linqx sequence, iterable, or array-like object. */
1154
+ export type EnumerableInput<T> = IEnumerable<T> | Iterable<T> | ArrayLike<T>;