iterable-linq-utility 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +527 -0
- package/dist/index.d.ts +527 -0
- package/dist/iterable-linq-utility.js +401 -173
- package/dist/iterable-linq-utility.umd.cjs +1 -1
- package/package.json +1 -1
|
@@ -49,37 +49,73 @@ function s(e) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
|
-
//#region src/utils/
|
|
53
|
-
function c(e) {
|
|
54
|
-
|
|
55
|
-
if (!n(e[Symbol.iterator])) throw Error("The provided \"sourceIterable\" does not conform to the iterator protocol https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol. It must implement the \"[Symbol.iterator]\" function.");
|
|
52
|
+
//#region src/utils/libraryError.ts
|
|
53
|
+
function c(e, t) {
|
|
54
|
+
return /* @__PURE__ */ Error(`[iterable-linq-utility/${e}] ${t}`);
|
|
56
55
|
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/utils/validations.ts
|
|
57
58
|
function l(e, t) {
|
|
58
|
-
if (
|
|
59
|
+
if (e == null) throw c(t, "The \"sourceIterable\" must be provided");
|
|
60
|
+
if (!n(e[Symbol.iterator])) throw c(t, "The provided \"sourceIterable\" does not conform to the iterator protocol https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol. It must implement the \"[Symbol.iterator]\" function.");
|
|
61
|
+
}
|
|
62
|
+
function u(e, t, r) {
|
|
63
|
+
if (!n(e)) throw c(r, `The "${t}" function must be provided`);
|
|
64
|
+
}
|
|
65
|
+
function ee(e, t, n) {
|
|
66
|
+
if (!Number.isInteger(e)) throw c(n, `The "${t}" parameter must be an integer`);
|
|
67
|
+
}
|
|
68
|
+
function d(e, t, n) {
|
|
69
|
+
if (!Number.isInteger(e) || e < 0) throw c(n, `The "${t}" parameter must be a non-negative integer`);
|
|
70
|
+
}
|
|
71
|
+
function te(e, t, n) {
|
|
72
|
+
if (!Number.isFinite(e) || e === 0) throw c(n, `The "${t}" parameter must be a finite number other than 0`);
|
|
73
|
+
}
|
|
74
|
+
function ne(e, t, n) {
|
|
75
|
+
if (typeof e != "object" || !e) throw c(n, `The "${t}" parameter must be an object`);
|
|
59
76
|
}
|
|
60
|
-
function
|
|
61
|
-
if (
|
|
77
|
+
function re(e, t, n) {
|
|
78
|
+
if (typeof e != "string" || e.length === 0) throw c(n, `The "${t}" parameter must be a non-empty string`);
|
|
62
79
|
}
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/functions/at.ts
|
|
82
|
+
function f(e, t) {
|
|
83
|
+
return l(e, "at"), ee(t, "index", "at"), t >= 0 ? ie(e, t) : ae(e, -t);
|
|
65
84
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
85
|
+
function ie(e, t) {
|
|
86
|
+
let n = 0;
|
|
87
|
+
for (let r of e) if (n++ === t) return r;
|
|
68
88
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
89
|
+
function ae(e, t) {
|
|
90
|
+
let n = [], r = 0, i = !1;
|
|
91
|
+
for (let a of e) n[r] = a, ++r === t && (r = 0, i = !0);
|
|
92
|
+
return i ? n[r] : void 0;
|
|
71
93
|
}
|
|
72
94
|
//#endregion
|
|
73
95
|
//#region src/functions/collectToArray.ts
|
|
74
|
-
function
|
|
75
|
-
if (
|
|
96
|
+
function p(e) {
|
|
97
|
+
if (l(e, "collectToArray"), Array.isArray(e) || e instanceof Set) return Array.from(e);
|
|
76
98
|
let t = [];
|
|
77
99
|
for (let n of e) t.push(n);
|
|
78
100
|
return t;
|
|
79
101
|
}
|
|
80
102
|
//#endregion
|
|
103
|
+
//#region src/functions/count.ts
|
|
104
|
+
function m(e, t) {
|
|
105
|
+
l(e, "count");
|
|
106
|
+
let n = 0;
|
|
107
|
+
if (t === void 0) {
|
|
108
|
+
for (let t of e) n++;
|
|
109
|
+
return n;
|
|
110
|
+
}
|
|
111
|
+
u(t, "predicate", "count");
|
|
112
|
+
let r = 0;
|
|
113
|
+
for (let i of e) t(i, r++) && n++;
|
|
114
|
+
return n;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
81
117
|
//#region src/iterators/baseIterator.ts
|
|
82
|
-
var
|
|
118
|
+
var h = class {
|
|
83
119
|
done = !1;
|
|
84
120
|
next() {
|
|
85
121
|
if (this.done) return s();
|
|
@@ -101,7 +137,7 @@ var f = class {
|
|
|
101
137
|
} catch {}
|
|
102
138
|
}
|
|
103
139
|
}
|
|
104
|
-
},
|
|
140
|
+
}, g = class {
|
|
105
141
|
createIterator;
|
|
106
142
|
constructor(e) {
|
|
107
143
|
this.createIterator = e;
|
|
@@ -109,7 +145,7 @@ var f = class {
|
|
|
109
145
|
[Symbol.iterator]() {
|
|
110
146
|
return this.createIterator();
|
|
111
147
|
}
|
|
112
|
-
},
|
|
148
|
+
}, _ = class extends h {
|
|
113
149
|
source;
|
|
114
150
|
index = 0;
|
|
115
151
|
constructor(e) {
|
|
@@ -121,10 +157,10 @@ var f = class {
|
|
|
121
157
|
};
|
|
122
158
|
//#endregion
|
|
123
159
|
//#region src/iterators/unfold.ts
|
|
124
|
-
function
|
|
125
|
-
return new
|
|
160
|
+
function oe(e, t) {
|
|
161
|
+
return new g(() => new se(e, t));
|
|
126
162
|
}
|
|
127
|
-
var
|
|
163
|
+
var se = class extends h {
|
|
128
164
|
state;
|
|
129
165
|
step;
|
|
130
166
|
constructor(e, t) {
|
|
@@ -136,16 +172,48 @@ var g = class extends f {
|
|
|
136
172
|
}
|
|
137
173
|
};
|
|
138
174
|
//#endregion
|
|
175
|
+
//#region src/functions/distinct.ts
|
|
176
|
+
function v(e, t) {
|
|
177
|
+
return l(e, "distinct"), t !== void 0 && u(t, "keySelector", "distinct"), new g(() => new ce(e, t));
|
|
178
|
+
}
|
|
179
|
+
var ce = class extends _ {
|
|
180
|
+
keySelector;
|
|
181
|
+
seen = /* @__PURE__ */ new Set();
|
|
182
|
+
constructor(e, t) {
|
|
183
|
+
super(e), this.keySelector = t;
|
|
184
|
+
}
|
|
185
|
+
advance() {
|
|
186
|
+
for (let e = this.source.next();; e = this.source.next()) {
|
|
187
|
+
if (e.done === !0) return e;
|
|
188
|
+
let t = e.value;
|
|
189
|
+
if (this.keySelector !== void 0) try {
|
|
190
|
+
t = this.keySelector(e.value, this.index++);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
throw this.closeAfterCallbackError(), e;
|
|
193
|
+
}
|
|
194
|
+
if (!this.seen.has(t)) return this.seen.add(t), e;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
//#endregion
|
|
139
199
|
//#region src/functions/empty.ts
|
|
140
|
-
function
|
|
141
|
-
return
|
|
200
|
+
function y() {
|
|
201
|
+
return oe(void 0, () => void 0);
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/functions/every.ts
|
|
205
|
+
function b(e, t) {
|
|
206
|
+
l(e, "every"), u(t, "predicate", "every");
|
|
207
|
+
let n = 0;
|
|
208
|
+
for (let r of e) if (!t(r, n++)) return !1;
|
|
209
|
+
return !0;
|
|
142
210
|
}
|
|
143
211
|
//#endregion
|
|
144
212
|
//#region src/functions/filter.ts
|
|
145
|
-
function
|
|
146
|
-
return
|
|
213
|
+
function x(e, t) {
|
|
214
|
+
return l(e, "filter"), u(t, "predicate", "filter"), new g(() => new le(e, t));
|
|
147
215
|
}
|
|
148
|
-
var
|
|
216
|
+
var le = class extends _ {
|
|
149
217
|
predicate;
|
|
150
218
|
constructor(e, t) {
|
|
151
219
|
super(e), this.predicate = t;
|
|
@@ -164,11 +232,45 @@ var re = class extends m {
|
|
|
164
232
|
}
|
|
165
233
|
};
|
|
166
234
|
//#endregion
|
|
235
|
+
//#region src/functions/find.ts
|
|
236
|
+
function S(e, t) {
|
|
237
|
+
l(e, "find"), u(t, "predicate", "find");
|
|
238
|
+
let n = 0;
|
|
239
|
+
for (let r of e) if (t(r, n++)) return r;
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/functions/findIndex.ts
|
|
243
|
+
function C(e, t) {
|
|
244
|
+
l(e, "findIndex"), u(t, "predicate", "findIndex");
|
|
245
|
+
let n = 0;
|
|
246
|
+
for (let r of e) {
|
|
247
|
+
if (t(r, n)) return n;
|
|
248
|
+
n++;
|
|
249
|
+
}
|
|
250
|
+
return -1;
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/functions/findLast.ts
|
|
254
|
+
function w(e, t) {
|
|
255
|
+
l(e, "findLast"), u(t, "predicate", "findLast");
|
|
256
|
+
let n, r = 0;
|
|
257
|
+
for (let i of e) t(i, r++) && (n = i);
|
|
258
|
+
return n;
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/functions/findLastIndex.ts
|
|
262
|
+
function T(e, t) {
|
|
263
|
+
l(e, "findLastIndex"), u(t, "predicate", "findLastIndex");
|
|
264
|
+
let n = -1, r = 0;
|
|
265
|
+
for (let i of e) t(i, r) && (n = r), r++;
|
|
266
|
+
return n;
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
167
269
|
//#region src/functions/flatMap.ts
|
|
168
|
-
function
|
|
169
|
-
return
|
|
270
|
+
function E(e, t) {
|
|
271
|
+
return l(e, "flatMap"), u(t, "mapper", "flatMap"), new g(() => new ue(e, t));
|
|
170
272
|
}
|
|
171
|
-
var
|
|
273
|
+
var ue = class e extends _ {
|
|
172
274
|
mapper;
|
|
173
275
|
static steps = {
|
|
174
276
|
outer: (t) => {
|
|
@@ -229,7 +331,7 @@ var ie = class e extends m {
|
|
|
229
331
|
throw e.inner = void 0, e.closeAfterCallbackError(), t;
|
|
230
332
|
}
|
|
231
333
|
}
|
|
232
|
-
},
|
|
334
|
+
}, D = class e {
|
|
233
335
|
static instance = e.createFrozen();
|
|
234
336
|
constructor() {}
|
|
235
337
|
static createFrozen() {
|
|
@@ -237,29 +339,56 @@ var ie = class e extends m {
|
|
|
237
339
|
return Object.freeze(t), t;
|
|
238
340
|
}
|
|
239
341
|
};
|
|
240
|
-
function
|
|
241
|
-
return
|
|
342
|
+
function O() {
|
|
343
|
+
return D.instance;
|
|
242
344
|
}
|
|
243
345
|
//#endregion
|
|
244
346
|
//#region src/functions/forEach.ts
|
|
245
|
-
function
|
|
246
|
-
|
|
347
|
+
function k(e, t) {
|
|
348
|
+
l(e, "forEach"), u(t, "action", "forEach");
|
|
247
349
|
let n = 0;
|
|
248
350
|
for (let r of e) t(r, n++);
|
|
249
|
-
return
|
|
351
|
+
return O();
|
|
250
352
|
}
|
|
251
|
-
async function
|
|
252
|
-
|
|
353
|
+
async function A(e, t) {
|
|
354
|
+
l(e, "forEachAsync"), u(t, "action", "forEachAsync");
|
|
253
355
|
let n = 0;
|
|
254
356
|
for (let r of e) await t(r, n++);
|
|
255
|
-
return
|
|
357
|
+
return O();
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/functions/includes.ts
|
|
361
|
+
function j(e, t) {
|
|
362
|
+
l(e, "includes");
|
|
363
|
+
let n = t !== t;
|
|
364
|
+
for (let r of e) if (r === t || n && r !== r) return !0;
|
|
365
|
+
return !1;
|
|
366
|
+
}
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/functions/indexOf.ts
|
|
369
|
+
function M(e, t) {
|
|
370
|
+
l(e, "indexOf");
|
|
371
|
+
let n = 0;
|
|
372
|
+
for (let r of e) {
|
|
373
|
+
if (r === t) return n;
|
|
374
|
+
n++;
|
|
375
|
+
}
|
|
376
|
+
return -1;
|
|
377
|
+
}
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region src/functions/lastIndexOf.ts
|
|
380
|
+
function N(e, t) {
|
|
381
|
+
l(e, "lastIndexOf");
|
|
382
|
+
let n = -1, r = 0;
|
|
383
|
+
for (let i of e) i === t && (n = r), r++;
|
|
384
|
+
return n;
|
|
256
385
|
}
|
|
257
386
|
//#endregion
|
|
258
387
|
//#region src/functions/map.ts
|
|
259
|
-
function
|
|
260
|
-
return
|
|
388
|
+
function P(e, t) {
|
|
389
|
+
return l(e, "map"), u(t, "mapper", "map"), new g(() => new de(e, t));
|
|
261
390
|
}
|
|
262
|
-
var
|
|
391
|
+
var de = class extends _ {
|
|
263
392
|
mapper;
|
|
264
393
|
constructor(e, t) {
|
|
265
394
|
super(e), this.mapper = t;
|
|
@@ -278,18 +407,18 @@ var ae = class extends m {
|
|
|
278
407
|
};
|
|
279
408
|
//#endregion
|
|
280
409
|
//#region src/collections/linkedList.ts
|
|
281
|
-
function
|
|
282
|
-
|
|
283
|
-
let t = new
|
|
410
|
+
function fe(e) {
|
|
411
|
+
l(e, "LinkedList.from");
|
|
412
|
+
let t = new pe();
|
|
284
413
|
for (let n of e) t.addLast(n);
|
|
285
414
|
return t;
|
|
286
415
|
}
|
|
287
|
-
var
|
|
416
|
+
var pe = class {
|
|
288
417
|
internalSize = 0;
|
|
289
418
|
head = null;
|
|
290
419
|
tail = null;
|
|
291
420
|
[Symbol.iterator]() {
|
|
292
|
-
return new
|
|
421
|
+
return new me(this.head);
|
|
293
422
|
}
|
|
294
423
|
addFirst(e) {
|
|
295
424
|
let t = {
|
|
@@ -308,7 +437,7 @@ var oe = class {
|
|
|
308
437
|
size() {
|
|
309
438
|
return this.internalSize;
|
|
310
439
|
}
|
|
311
|
-
},
|
|
440
|
+
}, me = class extends h {
|
|
312
441
|
current;
|
|
313
442
|
constructor(e) {
|
|
314
443
|
super(), this.current = e;
|
|
@@ -320,13 +449,13 @@ var oe = class {
|
|
|
320
449
|
};
|
|
321
450
|
//#endregion
|
|
322
451
|
//#region src/functions/materialize.ts
|
|
323
|
-
function
|
|
324
|
-
return
|
|
452
|
+
function F(e) {
|
|
453
|
+
return l(e, "materialize"), e instanceof he ? e : new he(e);
|
|
325
454
|
}
|
|
326
|
-
var
|
|
455
|
+
var he = class {
|
|
327
456
|
source;
|
|
328
457
|
constructor(e) {
|
|
329
|
-
this.source =
|
|
458
|
+
this.source = fe(e);
|
|
330
459
|
}
|
|
331
460
|
[Symbol.iterator]() {
|
|
332
461
|
return this.source[Symbol.iterator]();
|
|
@@ -334,29 +463,29 @@ var D = class {
|
|
|
334
463
|
};
|
|
335
464
|
//#endregion
|
|
336
465
|
//#region src/functions/max.ts
|
|
337
|
-
function
|
|
338
|
-
return
|
|
466
|
+
function I(e, t) {
|
|
467
|
+
return l(e, "max"), a(e, i(t), 1);
|
|
339
468
|
}
|
|
340
469
|
//#endregion
|
|
341
470
|
//#region src/functions/memoize.ts
|
|
342
|
-
function
|
|
471
|
+
function L() {
|
|
343
472
|
return { allowPartialMemoization: !0 };
|
|
344
473
|
}
|
|
345
|
-
function
|
|
346
|
-
|
|
474
|
+
function R(e, t) {
|
|
475
|
+
l(e, "memoize");
|
|
347
476
|
let n = {
|
|
348
|
-
...
|
|
477
|
+
...L(),
|
|
349
478
|
...t
|
|
350
479
|
}.allowPartialMemoization;
|
|
351
|
-
return e instanceof
|
|
480
|
+
return e instanceof V ? n ? e.changePartialMemoizationBehaviour() : e : e instanceof H ? n ? e : e.changePartialMemoizationBehaviour() : n ? new H(e) : new V(e);
|
|
352
481
|
}
|
|
353
|
-
function
|
|
482
|
+
function z() {
|
|
354
483
|
return {
|
|
355
484
|
values: [],
|
|
356
485
|
finished: !1
|
|
357
486
|
};
|
|
358
487
|
}
|
|
359
|
-
function
|
|
488
|
+
function B(e, t) {
|
|
360
489
|
if (t.error) throw t.error.value;
|
|
361
490
|
if (t.finished) return !1;
|
|
362
491
|
t.source ??= e[Symbol.iterator]();
|
|
@@ -368,31 +497,31 @@ function M(e, t) {
|
|
|
368
497
|
}
|
|
369
498
|
return n.done === !0 ? (t.finished = !0, t.source = void 0, !1) : (t.values.push(n.value), !0);
|
|
370
499
|
}
|
|
371
|
-
var
|
|
500
|
+
var V = class {
|
|
372
501
|
source;
|
|
373
|
-
cache =
|
|
502
|
+
cache = z();
|
|
374
503
|
constructor(e) {
|
|
375
504
|
this.source = e;
|
|
376
505
|
}
|
|
377
506
|
[Symbol.iterator]() {
|
|
378
|
-
return new
|
|
507
|
+
return new U(this.source, this.cache, !0);
|
|
379
508
|
}
|
|
380
509
|
changePartialMemoizationBehaviour() {
|
|
381
|
-
return new
|
|
510
|
+
return new H(this.source);
|
|
382
511
|
}
|
|
383
|
-
},
|
|
512
|
+
}, H = class {
|
|
384
513
|
source;
|
|
385
|
-
cache =
|
|
514
|
+
cache = z();
|
|
386
515
|
constructor(e) {
|
|
387
516
|
this.source = e;
|
|
388
517
|
}
|
|
389
518
|
[Symbol.iterator]() {
|
|
390
|
-
return new
|
|
519
|
+
return new U(this.source, this.cache, !1);
|
|
391
520
|
}
|
|
392
521
|
changePartialMemoizationBehaviour() {
|
|
393
|
-
return new
|
|
522
|
+
return new V(this.source);
|
|
394
523
|
}
|
|
395
|
-
},
|
|
524
|
+
}, U = class extends h {
|
|
396
525
|
source;
|
|
397
526
|
cache;
|
|
398
527
|
drainFirst;
|
|
@@ -401,28 +530,28 @@ var N = class {
|
|
|
401
530
|
super(), this.source = e, this.cache = t, this.drainFirst = n;
|
|
402
531
|
}
|
|
403
532
|
advance() {
|
|
404
|
-
if (this.drainFirst) for (;
|
|
405
|
-
return this.index < this.cache.values.length ||
|
|
533
|
+
if (this.drainFirst) for (; B(this.source, this.cache););
|
|
534
|
+
return this.index < this.cache.values.length || B(this.source, this.cache) ? o(this.cache.values[this.index++]) : s();
|
|
406
535
|
}
|
|
407
536
|
};
|
|
408
537
|
//#endregion
|
|
409
538
|
//#region src/functions/min.ts
|
|
410
|
-
function
|
|
411
|
-
return
|
|
539
|
+
function W(e, t) {
|
|
540
|
+
return l(e, "min"), a(e, i(t), -1);
|
|
412
541
|
}
|
|
413
542
|
//#endregion
|
|
414
543
|
//#region src/functions/range.ts
|
|
415
|
-
function
|
|
544
|
+
function G(e, t, n) {
|
|
416
545
|
let r = typeof t == "number", i = r ? e : 0, a = r ? t : e;
|
|
417
|
-
if (!r && n !== void 0) throw
|
|
546
|
+
if (!r && n !== void 0) throw c("range", "The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
418
547
|
let o = r ? n : t;
|
|
419
|
-
o !== void 0 &&
|
|
420
|
-
let { step: s = 1, reverse:
|
|
421
|
-
|
|
422
|
-
let
|
|
423
|
-
return
|
|
548
|
+
o !== void 0 && ne(o, "options", "range");
|
|
549
|
+
let { step: s = 1, reverse: l = !1 } = o ?? {};
|
|
550
|
+
te(s, "step", "range");
|
|
551
|
+
let u = ge(i, a, Math.abs(s), l);
|
|
552
|
+
return u.length > 0 ? new g(() => new _e(u.first, u.step, u.length)) : y();
|
|
424
553
|
}
|
|
425
|
-
function
|
|
554
|
+
function ge(e, t, n, r) {
|
|
426
555
|
let i = t < e ? -n : n, a = Math.ceil(Math.abs(t - e) / n);
|
|
427
556
|
return r ? {
|
|
428
557
|
first: e + (a - 1) * i,
|
|
@@ -434,7 +563,7 @@ function ce(e, t, n, r) {
|
|
|
434
563
|
length: a
|
|
435
564
|
};
|
|
436
565
|
}
|
|
437
|
-
var
|
|
566
|
+
var _e = class extends h {
|
|
438
567
|
first;
|
|
439
568
|
step;
|
|
440
569
|
length;
|
|
@@ -448,32 +577,32 @@ var le = class extends f {
|
|
|
448
577
|
};
|
|
449
578
|
//#endregion
|
|
450
579
|
//#region src/functions/reduce.ts
|
|
451
|
-
function
|
|
452
|
-
if (
|
|
580
|
+
function K(e, ...t) {
|
|
581
|
+
if (l(e, "reduce"), t.length === 1) return ve(e, t[0]);
|
|
453
582
|
let [n, r] = t;
|
|
454
|
-
|
|
583
|
+
u(r, "reducer", "reduce");
|
|
455
584
|
let i = n, a = 0;
|
|
456
585
|
for (let t of e) i = r(i, t, a++);
|
|
457
586
|
return i;
|
|
458
587
|
}
|
|
459
|
-
function
|
|
460
|
-
|
|
588
|
+
function ve(e, t) {
|
|
589
|
+
u(t, "reducer", "reduce");
|
|
461
590
|
let n, r = 0;
|
|
462
591
|
for (let i of e) n = r === 0 ? i : t(n, i, r), r++;
|
|
463
|
-
if (r === 0) throw
|
|
592
|
+
if (r === 0) throw c("reduce", "The \"sourceIterable\" must not be empty when \"reduce\" has no seed");
|
|
464
593
|
return n;
|
|
465
594
|
}
|
|
466
595
|
//#endregion
|
|
467
596
|
//#region src/functions/repeat.ts
|
|
468
|
-
function
|
|
469
|
-
return
|
|
597
|
+
function q(e, t) {
|
|
598
|
+
return d(t, "count", "repeat"), oe(t, (t) => t > 0 ? [e, t - 1] : void 0);
|
|
470
599
|
}
|
|
471
600
|
//#endregion
|
|
472
601
|
//#region src/functions/skip.ts
|
|
473
|
-
function
|
|
474
|
-
return
|
|
602
|
+
function J(e, t) {
|
|
603
|
+
return l(e, "skip"), d(t, "count", "skip"), new g(() => new ye(e, t));
|
|
475
604
|
}
|
|
476
|
-
var
|
|
605
|
+
var ye = class extends _ {
|
|
477
606
|
count;
|
|
478
607
|
constructor(e, t) {
|
|
479
608
|
super(e), this.count = t;
|
|
@@ -488,23 +617,48 @@ var H = class extends m {
|
|
|
488
617
|
}
|
|
489
618
|
};
|
|
490
619
|
//#endregion
|
|
620
|
+
//#region src/functions/skipWhile.ts
|
|
621
|
+
function Y(e, t) {
|
|
622
|
+
return l(e, "skipWhile"), u(t, "predicate", "skipWhile"), new g(() => new be(e, t));
|
|
623
|
+
}
|
|
624
|
+
var be = class extends _ {
|
|
625
|
+
predicate;
|
|
626
|
+
skipping = !0;
|
|
627
|
+
constructor(e, t) {
|
|
628
|
+
super(e), this.predicate = t;
|
|
629
|
+
}
|
|
630
|
+
advance() {
|
|
631
|
+
if (!this.skipping) return this.source.next();
|
|
632
|
+
for (let e = this.source.next();; e = this.source.next()) {
|
|
633
|
+
if (e.done === !0) return e;
|
|
634
|
+
let t;
|
|
635
|
+
try {
|
|
636
|
+
t = this.predicate(e.value, this.index++);
|
|
637
|
+
} catch (e) {
|
|
638
|
+
throw this.closeAfterCallbackError(), e;
|
|
639
|
+
}
|
|
640
|
+
if (!t) return this.skipping = !1, e;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
//#endregion
|
|
491
645
|
//#region src/functions/some.ts
|
|
492
|
-
function
|
|
493
|
-
if (
|
|
646
|
+
function xe(e, t) {
|
|
647
|
+
if (l(e, "some"), t === void 0) {
|
|
494
648
|
for (let t of e) return !0;
|
|
495
649
|
return !1;
|
|
496
650
|
}
|
|
497
|
-
|
|
651
|
+
u(t, "predicate", "some");
|
|
498
652
|
let n = 0;
|
|
499
653
|
for (let r of e) if (t(r, n++)) return !0;
|
|
500
654
|
return !1;
|
|
501
655
|
}
|
|
502
656
|
//#endregion
|
|
503
657
|
//#region src/functions/take.ts
|
|
504
|
-
function
|
|
505
|
-
return
|
|
658
|
+
function Se(e, t) {
|
|
659
|
+
return l(e, "take"), d(t, "count", "take"), new g(() => new Ce(e, t));
|
|
506
660
|
}
|
|
507
|
-
var
|
|
661
|
+
var Ce = class extends _ {
|
|
508
662
|
count;
|
|
509
663
|
constructor(e, t) {
|
|
510
664
|
super(e), this.count = t;
|
|
@@ -516,11 +670,33 @@ var ue = class extends m {
|
|
|
516
670
|
}
|
|
517
671
|
};
|
|
518
672
|
//#endregion
|
|
673
|
+
//#region src/functions/takeWhile.ts
|
|
674
|
+
function we(e, t) {
|
|
675
|
+
return l(e, "takeWhile"), u(t, "predicate", "takeWhile"), new g(() => new Te(e, t));
|
|
676
|
+
}
|
|
677
|
+
var Te = class extends _ {
|
|
678
|
+
predicate;
|
|
679
|
+
constructor(e, t) {
|
|
680
|
+
super(e), this.predicate = t;
|
|
681
|
+
}
|
|
682
|
+
advance() {
|
|
683
|
+
let e = this.source.next();
|
|
684
|
+
if (e.done === !0) return e;
|
|
685
|
+
let t;
|
|
686
|
+
try {
|
|
687
|
+
t = this.predicate(e.value, this.index++);
|
|
688
|
+
} catch (e) {
|
|
689
|
+
throw this.closeAfterCallbackError(), e;
|
|
690
|
+
}
|
|
691
|
+
return t ? e : (this.source.return?.(), s());
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
//#endregion
|
|
519
695
|
//#region src/functions/tap.ts
|
|
520
|
-
function
|
|
521
|
-
return
|
|
696
|
+
function Ee(e, t) {
|
|
697
|
+
return l(e, "tap"), u(t, "tapper", "tap"), new g(() => new De(e, t));
|
|
522
698
|
}
|
|
523
|
-
var
|
|
699
|
+
var De = class extends _ {
|
|
524
700
|
tapper;
|
|
525
701
|
constructor(e, t) {
|
|
526
702
|
super(e), this.tapper = t;
|
|
@@ -538,39 +714,52 @@ var de = class extends m {
|
|
|
538
714
|
};
|
|
539
715
|
//#endregion
|
|
540
716
|
//#region src/functions/tapChain.ts
|
|
541
|
-
function
|
|
542
|
-
return
|
|
717
|
+
function Oe(e, t) {
|
|
718
|
+
return l(e, "tapChain"), u(t, "tapper", "tapChain"), new g(() => (t(e, 0), e[Symbol.iterator]()));
|
|
543
719
|
}
|
|
544
720
|
//#endregion
|
|
545
721
|
//#region src/functions/index.ts
|
|
546
|
-
var
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
722
|
+
var ke = /* @__PURE__ */ t({
|
|
723
|
+
at: () => f,
|
|
724
|
+
collectToArray: () => p,
|
|
725
|
+
count: () => m,
|
|
726
|
+
distinct: () => v,
|
|
727
|
+
empty: () => y,
|
|
728
|
+
every: () => b,
|
|
729
|
+
filter: () => x,
|
|
730
|
+
find: () => S,
|
|
731
|
+
findIndex: () => C,
|
|
732
|
+
findLast: () => w,
|
|
733
|
+
findLastIndex: () => T,
|
|
734
|
+
flatMap: () => E,
|
|
735
|
+
forEach: () => k,
|
|
736
|
+
forEachAsync: () => A,
|
|
737
|
+
getMemoizeDefaultOptions: () => L,
|
|
738
|
+
includes: () => j,
|
|
739
|
+
indexOf: () => M,
|
|
740
|
+
lastIndexOf: () => N,
|
|
741
|
+
map: () => P,
|
|
742
|
+
materialize: () => F,
|
|
743
|
+
max: () => I,
|
|
744
|
+
memoize: () => R,
|
|
745
|
+
min: () => W,
|
|
746
|
+
range: () => G,
|
|
747
|
+
reduce: () => K,
|
|
748
|
+
repeat: () => q,
|
|
749
|
+
skip: () => J,
|
|
750
|
+
skipWhile: () => Y,
|
|
751
|
+
some: () => xe,
|
|
752
|
+
take: () => Se,
|
|
753
|
+
takeWhile: () => we,
|
|
754
|
+
tap: () => Ee,
|
|
755
|
+
tapChain: () => Oe
|
|
756
|
+
}), Ae = Symbol.for("iterable-linq-utility.IIterableLinq");
|
|
568
757
|
//#endregion
|
|
569
758
|
//#region src/linqIterable.ts
|
|
570
|
-
function
|
|
571
|
-
return new
|
|
759
|
+
function X(e) {
|
|
760
|
+
return new Z(e);
|
|
572
761
|
}
|
|
573
|
-
var
|
|
762
|
+
var Z = class {
|
|
574
763
|
iterable;
|
|
575
764
|
constructor(e) {
|
|
576
765
|
this.iterable = e;
|
|
@@ -578,61 +767,100 @@ var Y = class {
|
|
|
578
767
|
[Symbol.iterator]() {
|
|
579
768
|
return this.iterable[Symbol.iterator]();
|
|
580
769
|
}
|
|
770
|
+
at(e) {
|
|
771
|
+
return f(this.iterable, e);
|
|
772
|
+
}
|
|
581
773
|
collectToArray() {
|
|
582
|
-
return
|
|
774
|
+
return p(this.iterable);
|
|
775
|
+
}
|
|
776
|
+
count(e) {
|
|
777
|
+
return m(this.iterable, e);
|
|
778
|
+
}
|
|
779
|
+
distinct(e) {
|
|
780
|
+
return X(v(this.iterable, e));
|
|
781
|
+
}
|
|
782
|
+
every(e) {
|
|
783
|
+
return b(this.iterable, e);
|
|
583
784
|
}
|
|
584
785
|
filter(e) {
|
|
585
|
-
return
|
|
786
|
+
return X(x(this.iterable, e));
|
|
787
|
+
}
|
|
788
|
+
find(e) {
|
|
789
|
+
return S(this.iterable, e);
|
|
790
|
+
}
|
|
791
|
+
findIndex(e) {
|
|
792
|
+
return C(this.iterable, e);
|
|
793
|
+
}
|
|
794
|
+
findLast(e) {
|
|
795
|
+
return w(this.iterable, e);
|
|
796
|
+
}
|
|
797
|
+
findLastIndex(e) {
|
|
798
|
+
return T(this.iterable, e);
|
|
586
799
|
}
|
|
587
800
|
flatMap(e) {
|
|
588
|
-
return
|
|
801
|
+
return X(E(this.iterable, e));
|
|
589
802
|
}
|
|
590
803
|
forEach(e) {
|
|
591
|
-
return
|
|
804
|
+
return k(this.iterable, e);
|
|
592
805
|
}
|
|
593
806
|
forEachAsync(e) {
|
|
594
|
-
return
|
|
807
|
+
return A(this.iterable, e);
|
|
808
|
+
}
|
|
809
|
+
includes(e) {
|
|
810
|
+
return j(this.iterable, e);
|
|
811
|
+
}
|
|
812
|
+
indexOf(e) {
|
|
813
|
+
return M(this.iterable, e);
|
|
814
|
+
}
|
|
815
|
+
lastIndexOf(e) {
|
|
816
|
+
return N(this.iterable, e);
|
|
595
817
|
}
|
|
596
818
|
map(e) {
|
|
597
|
-
return
|
|
819
|
+
return X(P(this.iterable, e));
|
|
598
820
|
}
|
|
599
821
|
materialize() {
|
|
600
|
-
return
|
|
822
|
+
return X(F(this.iterable));
|
|
601
823
|
}
|
|
602
824
|
max(e) {
|
|
603
|
-
return
|
|
825
|
+
return I(this.iterable, e);
|
|
604
826
|
}
|
|
605
827
|
memoize(e) {
|
|
606
|
-
return
|
|
828
|
+
return X(R(this.iterable, e));
|
|
607
829
|
}
|
|
608
830
|
min(e) {
|
|
609
|
-
return
|
|
831
|
+
return W(this.iterable, e);
|
|
610
832
|
}
|
|
611
833
|
reduce(...e) {
|
|
612
|
-
return e.length === 1 ?
|
|
834
|
+
return e.length === 1 ? K(this.iterable, e[0]) : K(this.iterable, e[0], e[1]);
|
|
613
835
|
}
|
|
614
836
|
skip(e) {
|
|
615
|
-
return J(
|
|
837
|
+
return X(J(this.iterable, e));
|
|
838
|
+
}
|
|
839
|
+
skipWhile(e) {
|
|
840
|
+
return X(Y(this.iterable, e));
|
|
616
841
|
}
|
|
617
842
|
some(e) {
|
|
618
|
-
return
|
|
843
|
+
return xe(this.iterable, e);
|
|
619
844
|
}
|
|
620
845
|
take(e) {
|
|
621
|
-
return
|
|
846
|
+
return X(Se(this.iterable, e));
|
|
847
|
+
}
|
|
848
|
+
takeWhile(e) {
|
|
849
|
+
return X(we(this.iterable, e));
|
|
622
850
|
}
|
|
623
851
|
tap(e) {
|
|
624
|
-
return
|
|
852
|
+
return X(Ee(this.iterable, e));
|
|
625
853
|
}
|
|
626
854
|
tapChain(e) {
|
|
627
|
-
return
|
|
855
|
+
return X(Oe(this.iterable, e));
|
|
628
856
|
}
|
|
629
857
|
tapChainCreation(e) {
|
|
630
|
-
|
|
858
|
+
u(e, "chainCreationTapper", "tapChainCreation");
|
|
631
859
|
let t = this;
|
|
632
860
|
return e(t), t;
|
|
633
861
|
}
|
|
634
862
|
};
|
|
635
|
-
Object.defineProperty(
|
|
863
|
+
Object.defineProperty(Z.prototype, Ae, {
|
|
636
864
|
value: !0,
|
|
637
865
|
enumerable: !1,
|
|
638
866
|
writable: !1,
|
|
@@ -640,49 +868,49 @@ Object.defineProperty(Y.prototype, q, {
|
|
|
640
868
|
});
|
|
641
869
|
//#endregion
|
|
642
870
|
//#region src/extension.ts
|
|
643
|
-
function
|
|
644
|
-
return
|
|
871
|
+
function Q() {
|
|
872
|
+
return Z.prototype;
|
|
645
873
|
}
|
|
646
|
-
function
|
|
647
|
-
return typeof e == "object" && !!e && e[
|
|
874
|
+
function je(e) {
|
|
875
|
+
return typeof e == "object" && !!e && e[Ae] === !0;
|
|
648
876
|
}
|
|
649
|
-
function
|
|
650
|
-
let n = Object.getOwnPropertyDescriptor(
|
|
651
|
-
Object.defineProperty(
|
|
877
|
+
function Me(e, t) {
|
|
878
|
+
let n = Object.getOwnPropertyDescriptor(Q(), e);
|
|
879
|
+
Object.defineProperty(Q(), e, {
|
|
652
880
|
value: t,
|
|
653
881
|
enumerable: !1,
|
|
654
882
|
writable: n?.writable ?? !1,
|
|
655
883
|
configurable: !0
|
|
656
884
|
});
|
|
657
885
|
}
|
|
658
|
-
function
|
|
659
|
-
|
|
886
|
+
function Ne(e, t, n) {
|
|
887
|
+
re(t, "name", e), u(n, "implementation", e);
|
|
660
888
|
}
|
|
661
|
-
function
|
|
662
|
-
if (
|
|
663
|
-
|
|
889
|
+
function Pe(e, t) {
|
|
890
|
+
if (Ne("extend", e, t), e in X([])) throw c("extend", `"${e}" already exists on IIterableLinq: use override() to replace it`);
|
|
891
|
+
Me(e, t);
|
|
664
892
|
}
|
|
665
|
-
function
|
|
666
|
-
|
|
893
|
+
function Fe(e, t) {
|
|
894
|
+
Ne("override", e, t);
|
|
667
895
|
let n = e;
|
|
668
|
-
if (!(n !== "constructor" && Object.prototype.hasOwnProperty.call(
|
|
669
|
-
|
|
896
|
+
if (!(n !== "constructor" && Object.prototype.hasOwnProperty.call(Q(), n))) throw c("override", `"${n}" is not a method of IIterableLinq: use extend() to add it`);
|
|
897
|
+
Me(n, t);
|
|
670
898
|
}
|
|
671
899
|
//#endregion
|
|
672
900
|
//#region src/index.ts
|
|
673
|
-
function
|
|
674
|
-
return $(
|
|
901
|
+
function Ie() {
|
|
902
|
+
return $(y());
|
|
675
903
|
}
|
|
676
904
|
function $(e) {
|
|
677
|
-
return
|
|
905
|
+
return l(e, "from"), X(e);
|
|
678
906
|
}
|
|
679
|
-
function
|
|
680
|
-
if (typeof t == "number") return $(
|
|
681
|
-
if (n !== void 0) throw
|
|
682
|
-
return $(
|
|
907
|
+
function Le(e, t, n) {
|
|
908
|
+
if (typeof t == "number") return $(G(e, t, n));
|
|
909
|
+
if (n !== void 0) throw c("fromRange", "The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
910
|
+
return $(G(e, t));
|
|
683
911
|
}
|
|
684
|
-
function
|
|
685
|
-
return $(
|
|
912
|
+
function Re(e, t) {
|
|
913
|
+
return $(q(e, t));
|
|
686
914
|
}
|
|
687
915
|
//#endregion
|
|
688
|
-
export {
|
|
916
|
+
export { ke as Functions, D as Unit, Ie as empty, Pe as extend, $ as from, Le as fromRange, je as isIterableLinq, Fe as override, Re as repeat, O as unit };
|