linqx 0.2.1 → 0.3.3
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/README.md +143 -3
- package/dist/core/dictionary.d.ts +15 -0
- package/dist/core/dictionary.d.ts.map +1 -0
- package/dist/core/enumerable.d.ts +10 -0
- package/dist/core/enumerable.d.ts.map +1 -0
- package/dist/core/enumerator.d.ts +11 -0
- package/dist/core/enumerator.d.ts.map +1 -0
- package/dist/core/grouping.d.ts +12 -0
- package/dist/core/grouping.d.ts.map +1 -0
- package/dist/core/lookup.d.ts +13 -0
- package/dist/core/lookup.d.ts.map +1 -0
- package/dist/core/memoized-enumerable.d.ts +13 -0
- package/dist/core/memoized-enumerable.d.ts.map +1 -0
- package/dist/core/ordered-enumerable.d.ts +15 -0
- package/dist/core/ordered-enumerable.d.ts.map +1 -0
- package/dist/core/shared-enumerable.d.ts +11 -0
- package/dist/core/shared-enumerable.d.ts.map +1 -0
- package/dist/extensions.d.ts +19 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +13 -0
- package/dist/factories/choice.d.ts +9 -0
- package/dist/factories/choice.d.ts.map +1 -0
- package/dist/factories/cycle.d.ts +9 -0
- package/dist/factories/cycle.d.ts.map +1 -0
- package/dist/factories/defer.d.ts +9 -0
- package/dist/factories/defer.d.ts.map +1 -0
- package/dist/factories/empty.d.ts +4 -0
- package/dist/factories/empty.d.ts.map +1 -0
- package/dist/factories/from.d.ts +47 -0
- package/dist/factories/from.d.ts.map +1 -0
- package/dist/factories/generate.d.ts +10 -0
- package/dist/factories/generate.d.ts.map +1 -0
- package/dist/factories/make.d.ts +9 -0
- package/dist/factories/make.d.ts.map +1 -0
- package/dist/factories/matches.d.ts +15 -0
- package/dist/factories/matches.d.ts.map +1 -0
- package/dist/factories/range-down.d.ts +11 -0
- package/dist/factories/range-down.d.ts.map +1 -0
- package/dist/factories/range-to.d.ts +13 -0
- package/dist/factories/range-to.d.ts.map +1 -0
- package/dist/factories/range.d.ts +11 -0
- package/dist/factories/range.d.ts.map +1 -0
- package/dist/factories/repeat-with-finalize.d.ts +10 -0
- package/dist/factories/repeat-with-finalize.d.ts.map +1 -0
- package/dist/factories/repeat.d.ts +10 -0
- package/dist/factories/repeat.d.ts.map +1 -0
- package/dist/factories/to-infinity.d.ts +10 -0
- package/dist/factories/to-infinity.d.ts.map +1 -0
- package/dist/factories/to-negative-infinity.d.ts +10 -0
- package/dist/factories/to-negative-infinity.d.ts.map +1 -0
- package/dist/factories/unfold.d.ts +10 -0
- package/dist/factories/unfold.d.ts.map +1 -0
- package/dist/index.d.ts +88 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -4
- package/dist/internal/create-enumerable.d.ts +4 -0
- package/dist/internal/create-enumerable.d.ts.map +1 -0
- package/dist/internal/functions.d.ts +7 -0
- package/dist/internal/functions.d.ts.map +1 -0
- package/dist/internal/to-iterable.d.ts +3 -0
- package/dist/internal/to-iterable.d.ts.map +1 -0
- package/dist/operators/aggregate-by.d.ts +3 -0
- package/dist/operators/aggregate-by.d.ts.map +1 -0
- package/dist/operators/aggregate.d.ts +3 -0
- package/dist/operators/aggregate.d.ts.map +1 -0
- package/dist/operators/all.d.ts +3 -0
- package/dist/operators/all.d.ts.map +1 -0
- package/dist/operators/alternate.d.ts +3 -0
- package/dist/operators/alternate.d.ts.map +1 -0
- package/dist/operators/any.d.ts +3 -0
- package/dist/operators/any.d.ts.map +1 -0
- package/dist/operators/append.d.ts +3 -0
- package/dist/operators/append.d.ts.map +1 -0
- package/dist/operators/as-enumerable.d.ts +3 -0
- package/dist/operators/as-enumerable.d.ts.map +1 -0
- package/dist/operators/average.d.ts +3 -0
- package/dist/operators/average.d.ts.map +1 -0
- package/dist/operators/buffer.d.ts +3 -0
- package/dist/operators/buffer.d.ts.map +1 -0
- package/dist/operators/cast.d.ts +3 -0
- package/dist/operators/cast.d.ts.map +1 -0
- package/dist/operators/catch-error.d.ts +3 -0
- package/dist/operators/catch-error.d.ts.map +1 -0
- package/dist/operators/choose.d.ts +3 -0
- package/dist/operators/choose.d.ts.map +1 -0
- package/dist/operators/chunk.d.ts +3 -0
- package/dist/operators/chunk.d.ts.map +1 -0
- package/dist/operators/concat.d.ts +3 -0
- package/dist/operators/concat.d.ts.map +1 -0
- package/dist/operators/contains.d.ts +3 -0
- package/dist/operators/contains.d.ts.map +1 -0
- package/dist/operators/count-by.d.ts +3 -0
- package/dist/operators/count-by.d.ts.map +1 -0
- package/dist/operators/count.d.ts +3 -0
- package/dist/operators/count.d.ts.map +1 -0
- package/dist/operators/create-ordered-enumerable.d.ts +3 -0
- package/dist/operators/create-ordered-enumerable.d.ts.map +1 -0
- package/dist/operators/default-if-empty.d.ts +3 -0
- package/dist/operators/default-if-empty.d.ts.map +1 -0
- package/dist/operators/distinct-by.d.ts +3 -0
- package/dist/operators/distinct-by.d.ts.map +1 -0
- package/dist/operators/distinct-until-changed.d.ts +3 -0
- package/dist/operators/distinct-until-changed.d.ts.map +1 -0
- package/dist/operators/distinct.d.ts +3 -0
- package/dist/operators/distinct.d.ts.map +1 -0
- package/dist/operators/do-action.d.ts +4 -0
- package/dist/operators/do-action.d.ts.map +1 -0
- package/dist/operators/element-at-or-default.d.ts +3 -0
- package/dist/operators/element-at-or-default.d.ts.map +1 -0
- package/dist/operators/element-at.d.ts +3 -0
- package/dist/operators/element-at.d.ts.map +1 -0
- package/dist/operators/except-by.d.ts +3 -0
- package/dist/operators/except-by.d.ts.map +1 -0
- package/dist/operators/except.d.ts +3 -0
- package/dist/operators/except.d.ts.map +1 -0
- package/dist/operators/finally-action.d.ts +3 -0
- package/dist/operators/finally-action.d.ts.map +1 -0
- package/dist/operators/first-or-default.d.ts +3 -0
- package/dist/operators/first-or-default.d.ts.map +1 -0
- package/dist/operators/first.d.ts +3 -0
- package/dist/operators/first.d.ts.map +1 -0
- package/dist/operators/flatten.d.ts +3 -0
- package/dist/operators/flatten.d.ts.map +1 -0
- package/dist/operators/for-each.d.ts +4 -0
- package/dist/operators/for-each.d.ts.map +1 -0
- package/dist/operators/force.d.ts +3 -0
- package/dist/operators/force.d.ts.map +1 -0
- package/dist/operators/group-by.d.ts +3 -0
- package/dist/operators/group-by.d.ts.map +1 -0
- package/dist/operators/group-join.d.ts +3 -0
- package/dist/operators/group-join.d.ts.map +1 -0
- package/dist/operators/index-of.d.ts +3 -0
- package/dist/operators/index-of.d.ts.map +1 -0
- package/dist/operators/index.d.ts +3 -0
- package/dist/operators/index.d.ts.map +1 -0
- package/dist/operators/insert.d.ts +3 -0
- package/dist/operators/insert.d.ts.map +1 -0
- package/dist/operators/intersect-by.d.ts +3 -0
- package/dist/operators/intersect-by.d.ts.map +1 -0
- package/dist/operators/intersect.d.ts +3 -0
- package/dist/operators/intersect.d.ts.map +1 -0
- package/dist/operators/is-empty.d.ts +3 -0
- package/dist/operators/is-empty.d.ts.map +1 -0
- package/dist/operators/join-with.d.ts +3 -0
- package/dist/operators/join-with.d.ts.map +1 -0
- package/dist/operators/join.d.ts +3 -0
- package/dist/operators/join.d.ts.map +1 -0
- package/dist/operators/last-index-of.d.ts +3 -0
- package/dist/operators/last-index-of.d.ts.map +1 -0
- package/dist/operators/last-or-default.d.ts +3 -0
- package/dist/operators/last-or-default.d.ts.map +1 -0
- package/dist/operators/last.d.ts +3 -0
- package/dist/operators/last.d.ts.map +1 -0
- package/dist/operators/left-join.d.ts +3 -0
- package/dist/operators/left-join.d.ts.map +1 -0
- package/dist/operators/let-bind.d.ts +3 -0
- package/dist/operators/let-bind.d.ts.map +1 -0
- package/dist/operators/log.d.ts +3 -0
- package/dist/operators/log.d.ts.map +1 -0
- package/dist/operators/map.d.ts +3 -0
- package/dist/operators/map.d.ts.map +1 -0
- package/dist/operators/max-by.d.ts +3 -0
- package/dist/operators/max-by.d.ts.map +1 -0
- package/dist/operators/max.d.ts +3 -0
- package/dist/operators/max.d.ts.map +1 -0
- package/dist/operators/memoize.d.ts +3 -0
- package/dist/operators/memoize.d.ts.map +1 -0
- package/dist/operators/merge.d.ts +3 -0
- package/dist/operators/merge.d.ts.map +1 -0
- package/dist/operators/min-by.d.ts +3 -0
- package/dist/operators/min-by.d.ts.map +1 -0
- package/dist/operators/min.d.ts +3 -0
- package/dist/operators/min.d.ts.map +1 -0
- package/dist/operators/of-type.d.ts +3 -0
- package/dist/operators/of-type.d.ts.map +1 -0
- package/dist/operators/operators.d.ts +209 -0
- package/dist/operators/operators.d.ts.map +1 -0
- package/dist/operators/order-by-descending.d.ts +3 -0
- package/dist/operators/order-by-descending.d.ts.map +1 -0
- package/dist/operators/order-by.d.ts +3 -0
- package/dist/operators/order-by.d.ts.map +1 -0
- package/dist/operators/page.d.ts +3 -0
- package/dist/operators/page.d.ts.map +1 -0
- package/dist/operators/pairwise.d.ts +3 -0
- package/dist/operators/pairwise.d.ts.map +1 -0
- package/dist/operators/partition-by.d.ts +3 -0
- package/dist/operators/partition-by.d.ts.map +1 -0
- package/dist/operators/position.d.ts +3 -0
- package/dist/operators/position.d.ts.map +1 -0
- package/dist/operators/prepend.d.ts +3 -0
- package/dist/operators/prepend.d.ts.map +1 -0
- package/dist/operators/reverse.d.ts +3 -0
- package/dist/operators/reverse.d.ts.map +1 -0
- package/dist/operators/right-join.d.ts +3 -0
- package/dist/operators/right-join.d.ts.map +1 -0
- package/dist/operators/scan.d.ts +3 -0
- package/dist/operators/scan.d.ts.map +1 -0
- package/dist/operators/select-many.d.ts +3 -0
- package/dist/operators/select-many.d.ts.map +1 -0
- package/dist/operators/select.d.ts +3 -0
- package/dist/operators/select.d.ts.map +1 -0
- package/dist/operators/sequence-equal.d.ts +3 -0
- package/dist/operators/sequence-equal.d.ts.map +1 -0
- package/dist/operators/share.d.ts +3 -0
- package/dist/operators/share.d.ts.map +1 -0
- package/dist/operators/shuffle.d.ts +3 -0
- package/dist/operators/shuffle.d.ts.map +1 -0
- package/dist/operators/single-or-default.d.ts +3 -0
- package/dist/operators/single-or-default.d.ts.map +1 -0
- package/dist/operators/single.d.ts +3 -0
- package/dist/operators/single.d.ts.map +1 -0
- package/dist/operators/skip-last.d.ts +3 -0
- package/dist/operators/skip-last.d.ts.map +1 -0
- package/dist/operators/skip-while.d.ts +3 -0
- package/dist/operators/skip-while.d.ts.map +1 -0
- package/dist/operators/skip.d.ts +3 -0
- package/dist/operators/skip.d.ts.map +1 -0
- package/dist/operators/sum.d.ts +3 -0
- package/dist/operators/sum.d.ts.map +1 -0
- package/dist/operators/take-except-last.d.ts +3 -0
- package/dist/operators/take-except-last.d.ts.map +1 -0
- package/dist/operators/take-from-last.d.ts +3 -0
- package/dist/operators/take-from-last.d.ts.map +1 -0
- package/dist/operators/take-last.d.ts +3 -0
- package/dist/operators/take-last.d.ts.map +1 -0
- package/dist/operators/take-while.d.ts +3 -0
- package/dist/operators/take-while.d.ts.map +1 -0
- package/dist/operators/take.d.ts +3 -0
- package/dist/operators/take.d.ts.map +1 -0
- package/dist/operators/then-by-descending.d.ts +3 -0
- package/dist/operators/then-by-descending.d.ts.map +1 -0
- package/dist/operators/then-by.d.ts +3 -0
- package/dist/operators/then-by.d.ts.map +1 -0
- package/dist/operators/to-array.d.ts +3 -0
- package/dist/operators/to-array.d.ts.map +1 -0
- package/dist/operators/to-dictionary.d.ts +3 -0
- package/dist/operators/to-dictionary.d.ts.map +1 -0
- package/dist/operators/to-joined-string.d.ts +3 -0
- package/dist/operators/to-joined-string.d.ts.map +1 -0
- package/dist/operators/to-json-string.d.ts +3 -0
- package/dist/operators/to-json-string.d.ts.map +1 -0
- package/dist/operators/to-lookup.d.ts +3 -0
- package/dist/operators/to-lookup.d.ts.map +1 -0
- package/dist/operators/to-map.d.ts +3 -0
- package/dist/operators/to-map.d.ts.map +1 -0
- package/dist/operators/to-object.d.ts +3 -0
- package/dist/operators/to-object.d.ts.map +1 -0
- package/dist/operators/to-set.d.ts +3 -0
- package/dist/operators/to-set.d.ts.map +1 -0
- package/dist/operators/trace.d.ts +3 -0
- package/dist/operators/trace.d.ts.map +1 -0
- package/dist/operators/traverse-breadth-first.d.ts +3 -0
- package/dist/operators/traverse-breadth-first.d.ts.map +1 -0
- package/dist/operators/traverse-depth-first.d.ts +3 -0
- package/dist/operators/traverse-depth-first.d.ts.map +1 -0
- package/dist/operators/union-by.d.ts +3 -0
- package/dist/operators/union-by.d.ts.map +1 -0
- package/dist/operators/union.d.ts +3 -0
- package/dist/operators/union.d.ts.map +1 -0
- package/dist/operators/weighted-sample.d.ts +3 -0
- package/dist/operators/weighted-sample.d.ts.map +1 -0
- package/dist/operators/where-if.d.ts +3 -0
- package/dist/operators/where-if.d.ts.map +1 -0
- package/dist/operators/where.d.ts +3 -0
- package/dist/operators/where.d.ts.map +1 -0
- package/dist/operators/with-neighbors.d.ts +3 -0
- package/dist/operators/with-neighbors.d.ts.map +1 -0
- package/dist/operators/zip.d.ts +3 -0
- package/dist/operators/zip.d.ts.map +1 -0
- package/dist/src-D_Mk3oMP.js +1597 -0
- package/dist/types.d.ts +1155 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +57 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +21 -11
- package/dist/linq.d.ts +0 -256
- package/dist/linq.js +0 -3085
- package/dist/linqx.d.ts +0 -36
- package/dist/linqx.js +0 -153
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Modern fork of the original [linq](https://github.com/mihaifm/linq) for JavaScri
|
|
|
4
4
|
|
|
5
5
|
linqx keeps the familiar LINQ-style API while adding modern exports, new utility methods, improved TypeScript support, and active maintenance.
|
|
6
6
|
|
|
7
|
-
Written in
|
|
7
|
+
Written in TypeScript with no runtime dependencies.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -66,6 +66,18 @@ chunk(size)
|
|
|
66
66
|
index()
|
|
67
67
|
position()
|
|
68
68
|
withNeighbors()
|
|
69
|
+
append(element)
|
|
70
|
+
prepend(element)
|
|
71
|
+
skipLast(count)
|
|
72
|
+
takeLast(count)
|
|
73
|
+
distinctBy(keySelector)
|
|
74
|
+
exceptBy(keys, keySelector)
|
|
75
|
+
intersectBy(keys, keySelector)
|
|
76
|
+
unionBy(sequence, keySelector)
|
|
77
|
+
countBy(keySelector)
|
|
78
|
+
aggregateBy(keySelector, seed, accumulator)
|
|
79
|
+
rightJoin(sequence, outerKeySelector, innerKeySelector, resultSelector)
|
|
80
|
+
toSet()
|
|
69
81
|
```
|
|
70
82
|
|
|
71
83
|
---
|
|
@@ -80,7 +92,7 @@ npm install linqx
|
|
|
80
92
|
|
|
81
93
|
# Usage
|
|
82
94
|
|
|
83
|
-
## ES Modules
|
|
95
|
+
## ES Modules
|
|
84
96
|
|
|
85
97
|
```ts
|
|
86
98
|
import Enumerable from "linqx";
|
|
@@ -111,6 +123,79 @@ import Enumerable from "linqx";
|
|
|
111
123
|
|
|
112
124
|
const items: Enumerable.IEnumerable<number> = Enumerable.from([1, 2, 3]);
|
|
113
125
|
```
|
|
126
|
+
|
|
127
|
+
## Repeated Enumeration
|
|
128
|
+
|
|
129
|
+
You can enumerate an `IEnumerable<T>` again only if its source supports it. With arrays,
|
|
130
|
+
maps, and sets, each enumeration starts a new iterator. This also applies to the
|
|
131
|
+
`asEnumerable()` extensions for arrays, maps, and DOM collections.
|
|
132
|
+
|
|
133
|
+
A generator object or an existing iterator has a consumption position. Wrapping it with
|
|
134
|
+
`Enumerable.from()` does not reset that position:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import Enumerable from "linqx";
|
|
138
|
+
|
|
139
|
+
function* numbers() {
|
|
140
|
+
yield 1;
|
|
141
|
+
yield 2;
|
|
142
|
+
yield 3;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const once = Enumerable.from(numbers());
|
|
146
|
+
|
|
147
|
+
once.toArray(); // [1, 2, 3]
|
|
148
|
+
once.toArray(); // []: the generator object is exhausted
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**For repeated enumeration of a generator or iterator, use the factory overload:
|
|
152
|
+
`Enumerable.from(() => ...)`. Create a new generator or iterator inside the callback.**
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const reusable = Enumerable.from(() => numbers());
|
|
156
|
+
|
|
157
|
+
reusable.toArray(); // [1, 2, 3]
|
|
158
|
+
reusable.toArray(); // [1, 2, 3]
|
|
159
|
+
|
|
160
|
+
const query = reusable.where(value => value > 1).select(value => value * 10);
|
|
161
|
+
|
|
162
|
+
query.toArray(); // [20, 30]
|
|
163
|
+
query.toArray(); // [20, 30]
|
|
164
|
+
|
|
165
|
+
const values = new Set([1, 2, 3]);
|
|
166
|
+
const entries = Enumerable.from(() => values.entries());
|
|
167
|
+
|
|
168
|
+
entries.toArray(); // [[1, 1], [2, 2], [3, 3]]
|
|
169
|
+
entries.toArray(); // [[1, 1], [2, 2], [3, 3]]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Returning an existing iterator from the callback still shares its consumption position:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const iterator = numbers();
|
|
176
|
+
const stillOnce = Enumerable.from(() => iterator);
|
|
177
|
+
|
|
178
|
+
stillOnce.toArray(); // [1, 2, 3]
|
|
179
|
+
stillOnce.toArray(); // []: the callback returns the same iterator
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Early termination matters too: calling `any()`, `first()`, or `take(1).toArray()` on a
|
|
183
|
+
wrapped generator object closes that generator, so later enumeration returns no values.
|
|
184
|
+
Use a factory if you need to enumerate again after these operations.
|
|
185
|
+
|
|
186
|
+
With a factory, you rerun the generator and query callbacks on each enumeration, including
|
|
187
|
+
their side effects. Results can change if the underlying data changes. To reuse cached
|
|
188
|
+
values, call `memoize()` before consuming the sequence. Calling `share()` instead opts
|
|
189
|
+
into sharing one forward-only iterator among consumers.
|
|
190
|
+
|
|
191
|
+
## Tutorial
|
|
192
|
+
|
|
193
|
+
Build the package and run the TypeScript tutorial:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
pnpm tutorial
|
|
197
|
+
```
|
|
198
|
+
|
|
114
199
|
---
|
|
115
200
|
|
|
116
201
|
## New API Examples
|
|
@@ -134,9 +219,54 @@ for (const { prev, item, next } of Enumerable.from([10, 20, 30]).withNeighbors()
|
|
|
134
219
|
}
|
|
135
220
|
|
|
136
221
|
// position
|
|
137
|
-
for (const { index, item, isFirst, isLast } of Enumerable.from(["a", "b", "c"]).position()) {
|
|
222
|
+
for (const { index, item, isFirst, isLast } of Enumerable.from(["a", "b", "c"]).position()) {
|
|
138
223
|
}
|
|
224
|
+
|
|
225
|
+
// Standard sequence helpers
|
|
226
|
+
Enumerable.from([2, 3]).prepend(1).append(4).toArray();
|
|
227
|
+
// result: [1, 2, 3, 4]
|
|
228
|
+
|
|
229
|
+
Enumerable.from([1, 2, 3, 4]).skipLast(2).toArray();
|
|
230
|
+
// result: [1, 2]
|
|
231
|
+
|
|
232
|
+
Enumerable.from([1, 2, 3, 4]).takeLast(2).toArray();
|
|
233
|
+
// result: [3, 4]
|
|
234
|
+
|
|
235
|
+
// Key-based set operations
|
|
236
|
+
Enumerable
|
|
237
|
+
.from([{ id: 1, name: "first" }, { id: 1, name: "second" }])
|
|
238
|
+
.distinctBy(item => item.id)
|
|
239
|
+
.toArray();
|
|
240
|
+
// result: [{ id: 1, name: "first" }]
|
|
241
|
+
|
|
242
|
+
Enumerable
|
|
243
|
+
.from([{ id: 1 }, { id: 2 }, { id: 3 }])
|
|
244
|
+
.exceptBy([2], item => item.id)
|
|
245
|
+
.toArray();
|
|
246
|
+
// result: [{ id: 1 }, { id: 3 }]
|
|
247
|
+
|
|
248
|
+
// Per-key aggregation
|
|
249
|
+
Enumerable
|
|
250
|
+
.from(["a", "b", "a"])
|
|
251
|
+
.countBy(value => value)
|
|
252
|
+
.toArray();
|
|
253
|
+
// result: [{ key: "a", value: 2 }, { key: "b", value: 1 }]
|
|
254
|
+
|
|
255
|
+
Enumerable
|
|
256
|
+
.from([{ category: "a", amount: 2 }, { category: "a", amount: 3 }])
|
|
257
|
+
.aggregateBy(item => item.category, 0, (sum, item) => sum + item.amount)
|
|
258
|
+
.toArray();
|
|
259
|
+
// result: [{ key: "a", value: 5 }]
|
|
260
|
+
|
|
261
|
+
// Native Set materialization
|
|
262
|
+
Enumerable.from([1, 1, 2]).toSet();
|
|
139
263
|
```
|
|
264
|
+
|
|
265
|
+
`countBy` and `aggregateBy` return
|
|
266
|
+
`Enumerable.IEnumerable<Enumerable.KeyValuePair<TKey, TValue>>`. Key-based methods accept an
|
|
267
|
+
optional final comparison selector when keys need normalization, such as
|
|
268
|
+
`key => key.toLowerCase()` for case-insensitive string keys.
|
|
269
|
+
|
|
140
270
|
---
|
|
141
271
|
|
|
142
272
|
# Migration from linq
|
|
@@ -148,6 +278,16 @@ Most projects can switch directly:
|
|
|
148
278
|
+import Enumerable from "linqx";
|
|
149
279
|
```
|
|
150
280
|
|
|
281
|
+
The original string Lambda syntax is no longer supported. Pass JavaScript functions instead:
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
// supported
|
|
285
|
+
Enumerable.from([1, 2, 3, 4]).where(value => value % 2 === 0);
|
|
286
|
+
|
|
287
|
+
// not supported
|
|
288
|
+
Enumerable.from([1, 2, 3, 4]).where("value => value % 2 === 0");
|
|
289
|
+
```
|
|
290
|
+
|
|
151
291
|
---
|
|
152
292
|
|
|
153
293
|
# Repository
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IDictionary, IEnumerable, KeyValuePair } from '../types.js';
|
|
2
|
+
export declare class Dictionary<TKey, TValue> implements IDictionary<TKey, TValue> {
|
|
3
|
+
private readonly compareSelector;
|
|
4
|
+
private readonly entries;
|
|
5
|
+
constructor(compareSelector?: (key: TKey) => unknown);
|
|
6
|
+
add(key: TKey, value: TValue): void;
|
|
7
|
+
get(key: TKey): TValue;
|
|
8
|
+
set(key: TKey, value: TValue): boolean;
|
|
9
|
+
contains(key: TKey): boolean;
|
|
10
|
+
clear(): void;
|
|
11
|
+
remove(key: TKey): void;
|
|
12
|
+
count(): number;
|
|
13
|
+
toEnumerable(): IEnumerable<KeyValuePair<TKey, TValue>>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/core/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAS1E,qBAAa,UAAU,CAAC,IAAI,EAAE,MAAM,CAAE,YAAW,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;IAG5D,OAAO,CAAC,QAAQ,CAAC,eAAe;IAF5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IAEnE,YAA6B,eAAe,GAAE,CAAC,GAAG,EAAE,IAAI,KAAK,OAAkB,EAAI;IAEnF,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAElC;IAED,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,CAErB;IAED,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAKrC;IAED,QAAQ,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAE3B;IAED,KAAK,IAAI,IAAI,CAEZ;IAED,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAEtB;IAED,KAAK,IAAI,MAAM,CAEd;IAED,YAAY,IAAI,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAUtD;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IEnumerable, IEnumerator } from '../types.js';
|
|
2
|
+
export declare class EnumerableSequence<T> implements Iterable<T> {
|
|
3
|
+
private readonly iteratorFactory;
|
|
4
|
+
constructor(iteratorFactory: () => Iterator<T>);
|
|
5
|
+
[Symbol.iterator](): Iterator<T>;
|
|
6
|
+
getEnumerator(): IEnumerator<T>;
|
|
7
|
+
}
|
|
8
|
+
export interface EnumerableSequence<T> extends IEnumerable<T> {
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=enumerable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumerable.d.ts","sourceRoot":"","sources":["../../src/core/enumerable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG5D,qBAAa,kBAAkB,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,QAAQ,CAAC,eAAe;IAA5C,YAA6B,eAAe,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAI;IAEnE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAE/B;IAED,aAAa,IAAI,WAAW,CAAC,CAAC,CAAC,CAE9B;CACF;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;CAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IEnumerator } from '../types.js';
|
|
2
|
+
export declare class Enumerator<T> implements IEnumerator<T> {
|
|
3
|
+
private readonly iterator;
|
|
4
|
+
private value;
|
|
5
|
+
private done;
|
|
6
|
+
constructor(iterator: Iterator<T>);
|
|
7
|
+
current(): T;
|
|
8
|
+
moveNext(): boolean;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=enumerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumerator.d.ts","sourceRoot":"","sources":["../../src/core/enumerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,qBAAa,UAAU,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAItC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,IAAI,CAAS;IAErB,YAA6B,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAI;IAEtD,OAAO,IAAI,CAAC,CAEX;IAED,QAAQ,IAAI,OAAO,CAalB;IAED,OAAO,IAAI,IAAI,CAGd;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EnumerableSequence } from './enumerable.js';
|
|
2
|
+
import type { IGrouping } from '../types.js';
|
|
3
|
+
export declare class Grouping<TKey, TElement> extends EnumerableSequence<TElement> {
|
|
4
|
+
private readonly groupKey;
|
|
5
|
+
private readonly source;
|
|
6
|
+
constructor(groupKey: TKey, source: TElement[]);
|
|
7
|
+
key(): TKey;
|
|
8
|
+
getSource(): TElement[];
|
|
9
|
+
}
|
|
10
|
+
export interface Grouping<TKey, TElement> extends IGrouping<TKey, TElement> {
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=grouping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grouping.d.ts","sourceRoot":"","sources":["../../src/core/grouping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAE,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAC5D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAAQ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAApE,YAA6B,QAAQ,EAAE,IAAI,EAAmB,MAAM,EAAE,QAAQ,EAAE,EAE/E;IAED,GAAG,IAAI,IAAI,CAEV;IAED,SAAS,IAAI,QAAQ,EAAE,CAEtB;CACF;AAED,MAAM,WAAW,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAE,SAAQ,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;CAAG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEnumerable, ILookup } from '../types.js';
|
|
2
|
+
import { Grouping } from './grouping.js';
|
|
3
|
+
export declare class Lookup<TKey, TElement> implements ILookup<TKey, TElement> {
|
|
4
|
+
private readonly compareSelector;
|
|
5
|
+
private readonly entries;
|
|
6
|
+
constructor(compareSelector?: (key: TKey) => unknown);
|
|
7
|
+
add(key: TKey, element: TElement): void;
|
|
8
|
+
count(): number;
|
|
9
|
+
get(key: TKey): IEnumerable<TElement>;
|
|
10
|
+
contains(key: TKey): boolean;
|
|
11
|
+
toEnumerable(): IEnumerable<Grouping<TKey, TElement>>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/core/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AASzC,qBAAa,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAE,YAAW,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;IAGxD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAF5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmD;IAE3E,YAA6B,eAAe,GAAE,CAAC,GAAG,EAAE,IAAI,KAAK,OAAkB,EAAI;IAEnF,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAStC;IAED,KAAK,IAAI,MAAM,CAEd;IAED,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,CAGpC;IAED,QAAQ,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAE3B;IAED,YAAY,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAOpD;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IDisposableEnumerable } from '../types.js';
|
|
2
|
+
import { EnumerableSequence } from './enumerable.js';
|
|
3
|
+
export declare class MemoizedEnumerable<T> extends EnumerableSequence<T> {
|
|
4
|
+
private readonly sourceIterator;
|
|
5
|
+
private readonly cache;
|
|
6
|
+
private completed;
|
|
7
|
+
constructor(source: Iterable<T>);
|
|
8
|
+
private nextAt;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface MemoizedEnumerable<T> extends IDisposableEnumerable<T> {
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=memoized-enumerable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoized-enumerable.d.ts","sourceRoot":"","sources":["../../src/core/memoized-enumerable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,qBAAa,kBAAkB,CAAC,CAAC,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,SAAS,CAAS;IAE1B,YAAY,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAY9B;IAED,OAAO,CAAC,MAAM;IAmBd,OAAO,IAAI,IAAI,CAOd;CACF;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,qBAAqB,CAAC,CAAC,CAAC;CAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Comparer, IOrderedEnumerable } from '../types.js';
|
|
2
|
+
import { EnumerableSequence } from './enumerable.js';
|
|
3
|
+
export interface SortCriterion<T> {
|
|
4
|
+
keySelector: (element: T) => unknown;
|
|
5
|
+
comparer: Comparer<unknown>;
|
|
6
|
+
descending: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class OrderedEnumerable<T> extends EnumerableSequence<T> {
|
|
9
|
+
readonly source: Iterable<T>;
|
|
10
|
+
readonly criteria: readonly SortCriterion<T>[];
|
|
11
|
+
constructor(source: Iterable<T>, criteria: readonly SortCriterion<T>[]);
|
|
12
|
+
}
|
|
13
|
+
export interface OrderedEnumerable<T> extends IOrderedEnumerable<T> {
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ordered-enumerable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordered-enumerable.d.ts","sourceRoot":"","sources":["../../src/core/ordered-enumerable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC;IACrC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,iBAAiB,CAAC,CAAC,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IACjD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,CAAC,CAAC,CAAC,EAAE;IAAxF,YAAqB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAW,QAAQ,EAAE,SAAS,aAAa,CAAC,CAAC,CAAC,EAAE,EAmBvF;CACF;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;CAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDisposableEnumerable } from '../types.js';
|
|
2
|
+
import { EnumerableSequence } from './enumerable.js';
|
|
3
|
+
export declare class SharedEnumerable<T> extends EnumerableSequence<T> {
|
|
4
|
+
private readonly sourceIterator;
|
|
5
|
+
private disposed;
|
|
6
|
+
constructor(source: Iterable<T>);
|
|
7
|
+
dispose(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface SharedEnumerable<T> extends IDisposableEnumerable<T> {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=shared-enumerable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-enumerable.d.ts","sourceRoot":"","sources":["../../src/core/shared-enumerable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;IAC7C,OAAO,CAAC,QAAQ,CAAS;IAEzB,YAAY,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAa9B;IAED,OAAO,IAAI,IAAI,CAOd;CACF;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,qBAAqB,CAAC,CAAC,CAAC;CAAG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Enumerable } from './index.js';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Map<K, V> {
|
|
4
|
+
asEnumerable(): Enumerable.IEnumerable<[K, V]>;
|
|
5
|
+
}
|
|
6
|
+
interface Array<T> {
|
|
7
|
+
asEnumerable(): Enumerable.IEnumerable<T>;
|
|
8
|
+
}
|
|
9
|
+
interface NamedNodeMap {
|
|
10
|
+
asEnumerable(): Enumerable.IEnumerable<Attr>;
|
|
11
|
+
}
|
|
12
|
+
interface NodeList {
|
|
13
|
+
asEnumerable(): Enumerable.IEnumerable<Node>;
|
|
14
|
+
}
|
|
15
|
+
interface HTMLCollection {
|
|
16
|
+
asEnumerable(): Enumerable.IEnumerable<Element>;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;QAChB,YAAY,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAChD;IAED,UAAU,KAAK,CAAC,CAAC;QACf,YAAY,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;KAC3C;IAED,UAAU,YAAY;QACpB,YAAY,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KAC9C;IAED,UAAU,QAAQ;QAChB,YAAY,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KAC9C;IAED,UAAU,cAAc;QACtB,YAAY,IAAI,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;KACjD;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as e, t } from "./src-D_Mk3oMP.js";
|
|
2
|
+
e(Array.prototype, "asEnumerable", function() {
|
|
3
|
+
return t.from(this);
|
|
4
|
+
}), e(Map.prototype, "asEnumerable", function() {
|
|
5
|
+
return t.from(this);
|
|
6
|
+
}), typeof document < "u" && (e(NamedNodeMap.prototype, "asEnumerable", function() {
|
|
7
|
+
return t.from(this);
|
|
8
|
+
}), e(NodeList.prototype, "asEnumerable", function() {
|
|
9
|
+
return t.from(this);
|
|
10
|
+
}), e(HTMLCollection.prototype, "asEnumerable", function() {
|
|
11
|
+
return t.from(this);
|
|
12
|
+
}));
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a sequence that randomly selects from a fixed set with replacement.
|
|
4
|
+
*
|
|
5
|
+
* @param values The candidate values.
|
|
6
|
+
* @returns An infinite deferred sequence, or an empty sequence when no values are supplied.
|
|
7
|
+
*/
|
|
8
|
+
export declare function choice<T>(...values: T[]): IEnumerable<T>;
|
|
9
|
+
//# sourceMappingURL=choice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../../src/factories/choice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAOxD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a sequence that repeatedly emits a fixed set of values in order.
|
|
4
|
+
*
|
|
5
|
+
* @param values The values in each cycle.
|
|
6
|
+
* @returns An infinite deferred sequence, or an empty sequence when no values are supplied.
|
|
7
|
+
*/
|
|
8
|
+
export declare function cycle<T>(...values: T[]): IEnumerable<T>;
|
|
9
|
+
//# sourceMappingURL=cycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cycle.d.ts","sourceRoot":"","sources":["../../src/factories/cycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAMvD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defers creation of a sequence until enumeration begins.
|
|
4
|
+
*
|
|
5
|
+
* @param factory Creates the sequence used by each enumeration.
|
|
6
|
+
* @returns A deferred sequence that invokes `factory` once per enumeration.
|
|
7
|
+
*/
|
|
8
|
+
export declare function defer<T>(factory: () => IEnumerable<T>): IEnumerable<T>;
|
|
9
|
+
//# sourceMappingURL=defer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defer.d.ts","sourceRoot":"","sources":["../../src/factories/defer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../src/factories/empty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,2DAA2D;AAC3D,wBAAgB,KAAK,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAEzC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/** @returns An empty sequence. */
|
|
3
|
+
export declare function from(): IEnumerable<unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a number as a single-element sequence.
|
|
6
|
+
*
|
|
7
|
+
* @param source The number to wrap.
|
|
8
|
+
* @returns A sequence containing `source`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function from(source: number): IEnumerable<number>;
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a boolean as a single-element sequence.
|
|
13
|
+
*
|
|
14
|
+
* @param source The boolean to wrap.
|
|
15
|
+
* @returns A sequence containing `source`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function from(source: boolean): IEnumerable<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Enumerates the characters in a string.
|
|
20
|
+
*
|
|
21
|
+
* @param source The string to enumerate.
|
|
22
|
+
* @returns A reusable sequence of Unicode code-point strings.
|
|
23
|
+
*/
|
|
24
|
+
export declare function from(source: string): IEnumerable<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Converts an iterable, iterator, array-like object, or source factory to a linqx sequence.
|
|
27
|
+
*
|
|
28
|
+
* A source factory is called once per enumeration. A bare iterator is forward-only and is not
|
|
29
|
+
* reset between enumerations.
|
|
30
|
+
*
|
|
31
|
+
* @param source The source to adapt or a function that creates one.
|
|
32
|
+
* @returns A sequence over the source values.
|
|
33
|
+
*/
|
|
34
|
+
export declare function from<T>(source: Iterable<T> | Iterator<T> | ArrayLike<T> | (() => Iterable<T> | Iterator<T>)): IEnumerable<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Enumerates an object's own enumerable string-keyed, non-function properties.
|
|
37
|
+
*
|
|
38
|
+
* @param source The object whose properties will be enumerated.
|
|
39
|
+
* @returns A deferred sequence of key-value entries.
|
|
40
|
+
*/
|
|
41
|
+
export declare function from<TKey extends PropertyKey, TValue>(source: Record<TKey, TValue>): IEnumerable<{
|
|
42
|
+
/** The property's key. */
|
|
43
|
+
key: TKey;
|
|
44
|
+
/** The property's value. */
|
|
45
|
+
value: TValue;
|
|
46
|
+
}>;
|
|
47
|
+
//# sourceMappingURL=from.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../src/factories/from.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,kCAAkC;AAClC,wBAAgB,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GACnF,WAAW,CAAC,CAAC,CAAC,CAAC;AAElB;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,SAAS,WAAW,EAAE,MAAM,EACnD,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAC3B,WAAW,CAAC;IACb,0BAA0B;IAC1B,GAAG,EAAE,IAAI,CAAC;IACV,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates elements by repeatedly invoking a function.
|
|
4
|
+
*
|
|
5
|
+
* @param func Produces the next element.
|
|
6
|
+
* @param count The number of elements to produce. Omit it for an infinite sequence.
|
|
7
|
+
* @returns A deferred generated sequence.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generate<T>(func: () => T, count?: number): IEnumerable<T>;
|
|
10
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/factories/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAMzE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a sequence containing exactly one element.
|
|
4
|
+
*
|
|
5
|
+
* @param element The element to contain.
|
|
6
|
+
* @returns A reusable single-element sequence.
|
|
7
|
+
*/
|
|
8
|
+
export declare function make<T>(element: T): IEnumerable<T>;
|
|
9
|
+
//# sourceMappingURL=make.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make.d.ts","sourceRoot":"","sources":["../../src/factories/make.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAIlD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enumerates every regular-expression match in a string.
|
|
4
|
+
*
|
|
5
|
+
* A cloned expression is made global automatically, so the supplied `RegExp.lastIndex` is not
|
|
6
|
+
* read or modified.
|
|
7
|
+
*
|
|
8
|
+
* @param input The string to search.
|
|
9
|
+
* @param pattern A regular expression or pattern string.
|
|
10
|
+
* @param flags Flags used only when `pattern` is a string; `g` is added when absent.
|
|
11
|
+
* @returns A deferred sequence of regular-expression match arrays.
|
|
12
|
+
* @throws {SyntaxError} When a pattern string or its flags are invalid.
|
|
13
|
+
*/
|
|
14
|
+
export declare function matches<T extends RegExpMatchArray = RegExpMatchArray>(input: string, pattern: RegExp | string, flags?: string): IEnumerable<T>;
|
|
15
|
+
//# sourceMappingURL=matches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matches.d.ts","sourceRoot":"","sources":["../../src/factories/matches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EACnE,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,KAAK,CAAC,EAAE,MAAM,GACb,WAAW,CAAC,CAAC,CAAC,CA0BhB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a counted descending arithmetic sequence.
|
|
4
|
+
*
|
|
5
|
+
* @param start The first value.
|
|
6
|
+
* @param count The number of values; non-positive values produce an empty sequence.
|
|
7
|
+
* @param step The absolute decrement between consecutive values; defaults to one.
|
|
8
|
+
* @returns A deferred descending numeric sequence.
|
|
9
|
+
*/
|
|
10
|
+
export declare function rangeDown(start: number, count: number, step?: number): IEnumerable<number>;
|
|
11
|
+
//# sourceMappingURL=range-down.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-down.d.ts","sourceRoot":"","sources":["../../src/factories/range-down.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAErF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an arithmetic sequence between two inclusive endpoints.
|
|
4
|
+
*
|
|
5
|
+
* The direction is inferred from the endpoints and the absolute value of `step` is used.
|
|
6
|
+
*
|
|
7
|
+
* @param start The first value.
|
|
8
|
+
* @param to The inclusive endpoint.
|
|
9
|
+
* @param step The non-zero distance between consecutive values; defaults to one.
|
|
10
|
+
* @returns A deferred numeric sequence.
|
|
11
|
+
*/
|
|
12
|
+
export declare function rangeTo(start: number, to: number, step?: number): IEnumerable<number>;
|
|
13
|
+
//# sourceMappingURL=range-to.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-to.d.ts","sourceRoot":"","sources":["../../src/factories/range-to.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAahF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a counted arithmetic sequence.
|
|
4
|
+
*
|
|
5
|
+
* @param start The first value.
|
|
6
|
+
* @param count The number of values; non-positive values produce an empty sequence.
|
|
7
|
+
* @param step The difference between consecutive values; defaults to one.
|
|
8
|
+
* @returns A deferred numeric sequence.
|
|
9
|
+
*/
|
|
10
|
+
export declare function range(start: number, count: number, step?: number): IEnumerable<number>;
|
|
11
|
+
//# sourceMappingURL=range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/factories/range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAMjF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Initializes one value, repeats it indefinitely, and finalizes it when enumeration stops.
|
|
4
|
+
*
|
|
5
|
+
* @param initializer Creates the value once per enumeration.
|
|
6
|
+
* @param finalizer Releases the value after completion, failure, or early termination.
|
|
7
|
+
* @returns An infinite deferred sequence with deterministic finalization.
|
|
8
|
+
*/
|
|
9
|
+
export declare function repeatWithFinalize<T>(initializer: () => T, finalizer: (element: T) => void): IEnumerable<T>;
|
|
10
|
+
//# sourceMappingURL=repeat-with-finalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeat-with-finalize.d.ts","sourceRoot":"","sources":["../../src/factories/repeat-with-finalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,WAAW,EAAE,MAAM,CAAC,EACpB,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAC9B,WAAW,CAAC,CAAC,CAAC,CAYhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Repeats one element.
|
|
4
|
+
*
|
|
5
|
+
* @param element The value to repeat.
|
|
6
|
+
* @param count The number of repetitions. Omit it for an infinite sequence.
|
|
7
|
+
* @returns A deferred repeated sequence.
|
|
8
|
+
*/
|
|
9
|
+
export declare function repeat<T>(element: T, count?: number): IEnumerable<T>;
|
|
10
|
+
//# sourceMappingURL=repeat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeat.d.ts","sourceRoot":"","sources":["../../src/factories/repeat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAMpE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an infinite ascending arithmetic sequence.
|
|
4
|
+
*
|
|
5
|
+
* @param start The first value; defaults to zero.
|
|
6
|
+
* @param step The amount added after each element; defaults to one.
|
|
7
|
+
* @returns An infinite deferred numeric sequence.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toInfinity(start?: number, step?: number): IEnumerable<number>;
|
|
10
|
+
//# sourceMappingURL=to-infinity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-infinity.d.ts","sourceRoot":"","sources":["../../src/factories/to-infinity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,SAAI,EAAE,IAAI,SAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAMnE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IEnumerable } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an infinite descending arithmetic sequence.
|
|
4
|
+
*
|
|
5
|
+
* @param start The first value; defaults to zero.
|
|
6
|
+
* @param step The amount subtracted after each element; defaults to one.
|
|
7
|
+
* @returns An infinite deferred numeric sequence.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toNegativeInfinity(start?: number, step?: number): IEnumerable<number>;
|
|
10
|
+
//# sourceMappingURL=to-negative-infinity.d.ts.map
|