iterable-linq-utility 0.6.0 → 0.7.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 +281 -0
- package/dist/index.d.ts +281 -0
- package/dist/iterable-linq-utility.js +256 -166
- package/dist/iterable-linq-utility.umd.cjs +1 -1
- package/package.json +1 -1
|
@@ -92,8 +92,20 @@ function ae(e, t) {
|
|
|
92
92
|
return i ? n[r] : void 0;
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
|
+
//#region src/functions/average.ts
|
|
96
|
+
function p(e, t) {
|
|
97
|
+
l(e, "average");
|
|
98
|
+
let n = 0, r = 0;
|
|
99
|
+
if (t === void 0) for (let t of e) n += t, r++;
|
|
100
|
+
else {
|
|
101
|
+
u(t, "selector", "average");
|
|
102
|
+
for (let i of e) n += t(i, r++);
|
|
103
|
+
}
|
|
104
|
+
return r === 0 ? void 0 : n / r;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
95
107
|
//#region src/functions/collectToArray.ts
|
|
96
|
-
function
|
|
108
|
+
function m(e) {
|
|
97
109
|
if (l(e, "collectToArray"), Array.isArray(e) || e instanceof Set) return Array.from(e);
|
|
98
110
|
let t = [];
|
|
99
111
|
for (let n of e) t.push(n);
|
|
@@ -101,7 +113,7 @@ function p(e) {
|
|
|
101
113
|
}
|
|
102
114
|
//#endregion
|
|
103
115
|
//#region src/functions/count.ts
|
|
104
|
-
function
|
|
116
|
+
function oe(e, t) {
|
|
105
117
|
l(e, "count");
|
|
106
118
|
let n = 0;
|
|
107
119
|
if (t === void 0) {
|
|
@@ -157,10 +169,10 @@ var h = class {
|
|
|
157
169
|
};
|
|
158
170
|
//#endregion
|
|
159
171
|
//#region src/iterators/unfold.ts
|
|
160
|
-
function
|
|
161
|
-
return new g(() => new
|
|
172
|
+
function se(e, t) {
|
|
173
|
+
return new g(() => new ce(e, t));
|
|
162
174
|
}
|
|
163
|
-
var
|
|
175
|
+
var ce = class extends h {
|
|
164
176
|
state;
|
|
165
177
|
step;
|
|
166
178
|
constructor(e, t) {
|
|
@@ -174,9 +186,9 @@ var se = class extends h {
|
|
|
174
186
|
//#endregion
|
|
175
187
|
//#region src/functions/distinct.ts
|
|
176
188
|
function v(e, t) {
|
|
177
|
-
return l(e, "distinct"), t !== void 0 && u(t, "keySelector", "distinct"), new g(() => new
|
|
189
|
+
return l(e, "distinct"), t !== void 0 && u(t, "keySelector", "distinct"), new g(() => new le(e, t));
|
|
178
190
|
}
|
|
179
|
-
var
|
|
191
|
+
var le = class extends _ {
|
|
180
192
|
keySelector;
|
|
181
193
|
seen = /* @__PURE__ */ new Set();
|
|
182
194
|
constructor(e, t) {
|
|
@@ -198,11 +210,11 @@ var ce = class extends _ {
|
|
|
198
210
|
//#endregion
|
|
199
211
|
//#region src/functions/empty.ts
|
|
200
212
|
function y() {
|
|
201
|
-
return
|
|
213
|
+
return se(void 0, () => void 0);
|
|
202
214
|
}
|
|
203
215
|
//#endregion
|
|
204
216
|
//#region src/functions/every.ts
|
|
205
|
-
function
|
|
217
|
+
function ue(e, t) {
|
|
206
218
|
l(e, "every"), u(t, "predicate", "every");
|
|
207
219
|
let n = 0;
|
|
208
220
|
for (let r of e) if (!t(r, n++)) return !1;
|
|
@@ -210,10 +222,10 @@ function b(e, t) {
|
|
|
210
222
|
}
|
|
211
223
|
//#endregion
|
|
212
224
|
//#region src/functions/filter.ts
|
|
213
|
-
function
|
|
214
|
-
return l(e, "filter"), u(t, "predicate", "filter"), new g(() => new
|
|
225
|
+
function b(e, t) {
|
|
226
|
+
return l(e, "filter"), u(t, "predicate", "filter"), new g(() => new de(e, t));
|
|
215
227
|
}
|
|
216
|
-
var
|
|
228
|
+
var de = class extends _ {
|
|
217
229
|
predicate;
|
|
218
230
|
constructor(e, t) {
|
|
219
231
|
super(e), this.predicate = t;
|
|
@@ -233,14 +245,14 @@ var le = class extends _ {
|
|
|
233
245
|
};
|
|
234
246
|
//#endregion
|
|
235
247
|
//#region src/functions/find.ts
|
|
236
|
-
function
|
|
248
|
+
function x(e, t) {
|
|
237
249
|
l(e, "find"), u(t, "predicate", "find");
|
|
238
250
|
let n = 0;
|
|
239
251
|
for (let r of e) if (t(r, n++)) return r;
|
|
240
252
|
}
|
|
241
253
|
//#endregion
|
|
242
254
|
//#region src/functions/findIndex.ts
|
|
243
|
-
function
|
|
255
|
+
function S(e, t) {
|
|
244
256
|
l(e, "findIndex"), u(t, "predicate", "findIndex");
|
|
245
257
|
let n = 0;
|
|
246
258
|
for (let r of e) {
|
|
@@ -251,7 +263,7 @@ function C(e, t) {
|
|
|
251
263
|
}
|
|
252
264
|
//#endregion
|
|
253
265
|
//#region src/functions/findLast.ts
|
|
254
|
-
function
|
|
266
|
+
function C(e, t) {
|
|
255
267
|
l(e, "findLast"), u(t, "predicate", "findLast");
|
|
256
268
|
let n, r = 0;
|
|
257
269
|
for (let i of e) t(i, r++) && (n = i);
|
|
@@ -259,7 +271,7 @@ function w(e, t) {
|
|
|
259
271
|
}
|
|
260
272
|
//#endregion
|
|
261
273
|
//#region src/functions/findLastIndex.ts
|
|
262
|
-
function
|
|
274
|
+
function w(e, t) {
|
|
263
275
|
l(e, "findLastIndex"), u(t, "predicate", "findLastIndex");
|
|
264
276
|
let n = -1, r = 0;
|
|
265
277
|
for (let i of e) t(i, r) && (n = r), r++;
|
|
@@ -267,10 +279,10 @@ function T(e, t) {
|
|
|
267
279
|
}
|
|
268
280
|
//#endregion
|
|
269
281
|
//#region src/functions/flatMap.ts
|
|
270
|
-
function
|
|
271
|
-
return l(e, "flatMap"), u(t, "mapper", "flatMap"), new g(() => new
|
|
282
|
+
function T(e, t) {
|
|
283
|
+
return l(e, "flatMap"), u(t, "mapper", "flatMap"), new g(() => new fe(e, t));
|
|
272
284
|
}
|
|
273
|
-
var
|
|
285
|
+
var fe = class e extends _ {
|
|
274
286
|
mapper;
|
|
275
287
|
static steps = {
|
|
276
288
|
outer: (t) => {
|
|
@@ -331,7 +343,7 @@ var ue = class e extends _ {
|
|
|
331
343
|
throw e.inner = void 0, e.closeAfterCallbackError(), t;
|
|
332
344
|
}
|
|
333
345
|
}
|
|
334
|
-
},
|
|
346
|
+
}, E = class e {
|
|
335
347
|
static instance = e.createFrozen();
|
|
336
348
|
constructor() {}
|
|
337
349
|
static createFrozen() {
|
|
@@ -339,26 +351,26 @@ var ue = class e extends _ {
|
|
|
339
351
|
return Object.freeze(t), t;
|
|
340
352
|
}
|
|
341
353
|
};
|
|
342
|
-
function
|
|
343
|
-
return
|
|
354
|
+
function D() {
|
|
355
|
+
return E.instance;
|
|
344
356
|
}
|
|
345
357
|
//#endregion
|
|
346
358
|
//#region src/functions/forEach.ts
|
|
347
|
-
function
|
|
359
|
+
function O(e, t) {
|
|
348
360
|
l(e, "forEach"), u(t, "action", "forEach");
|
|
349
361
|
let n = 0;
|
|
350
362
|
for (let r of e) t(r, n++);
|
|
351
|
-
return
|
|
363
|
+
return D();
|
|
352
364
|
}
|
|
353
|
-
async function
|
|
365
|
+
async function k(e, t) {
|
|
354
366
|
l(e, "forEachAsync"), u(t, "action", "forEachAsync");
|
|
355
367
|
let n = 0;
|
|
356
368
|
for (let r of e) await t(r, n++);
|
|
357
|
-
return
|
|
369
|
+
return D();
|
|
358
370
|
}
|
|
359
371
|
//#endregion
|
|
360
372
|
//#region src/functions/includes.ts
|
|
361
|
-
function
|
|
373
|
+
function A(e, t) {
|
|
362
374
|
l(e, "includes");
|
|
363
375
|
let n = t !== t;
|
|
364
376
|
for (let r of e) if (r === t || n && r !== r) return !0;
|
|
@@ -366,7 +378,7 @@ function j(e, t) {
|
|
|
366
378
|
}
|
|
367
379
|
//#endregion
|
|
368
380
|
//#region src/functions/indexOf.ts
|
|
369
|
-
function
|
|
381
|
+
function j(e, t) {
|
|
370
382
|
l(e, "indexOf");
|
|
371
383
|
let n = 0;
|
|
372
384
|
for (let r of e) {
|
|
@@ -376,6 +388,11 @@ function M(e, t) {
|
|
|
376
388
|
return -1;
|
|
377
389
|
}
|
|
378
390
|
//#endregion
|
|
391
|
+
//#region src/functions/join.ts
|
|
392
|
+
function M(e, t) {
|
|
393
|
+
return l(e, "join"), Array.from(e).join(t);
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
379
396
|
//#region src/functions/lastIndexOf.ts
|
|
380
397
|
function N(e, t) {
|
|
381
398
|
l(e, "lastIndexOf");
|
|
@@ -386,9 +403,9 @@ function N(e, t) {
|
|
|
386
403
|
//#endregion
|
|
387
404
|
//#region src/functions/map.ts
|
|
388
405
|
function P(e, t) {
|
|
389
|
-
return l(e, "map"), u(t, "mapper", "map"), new g(() => new
|
|
406
|
+
return l(e, "map"), u(t, "mapper", "map"), new g(() => new pe(e, t));
|
|
390
407
|
}
|
|
391
|
-
var
|
|
408
|
+
var pe = class extends _ {
|
|
392
409
|
mapper;
|
|
393
410
|
constructor(e, t) {
|
|
394
411
|
super(e), this.mapper = t;
|
|
@@ -407,18 +424,18 @@ var de = class extends _ {
|
|
|
407
424
|
};
|
|
408
425
|
//#endregion
|
|
409
426
|
//#region src/collections/linkedList.ts
|
|
410
|
-
function
|
|
427
|
+
function me(e) {
|
|
411
428
|
l(e, "LinkedList.from");
|
|
412
|
-
let t = new
|
|
429
|
+
let t = new he();
|
|
413
430
|
for (let n of e) t.addLast(n);
|
|
414
431
|
return t;
|
|
415
432
|
}
|
|
416
|
-
var
|
|
433
|
+
var he = class {
|
|
417
434
|
internalSize = 0;
|
|
418
435
|
head = null;
|
|
419
436
|
tail = null;
|
|
420
437
|
[Symbol.iterator]() {
|
|
421
|
-
return new
|
|
438
|
+
return new ge(this.head);
|
|
422
439
|
}
|
|
423
440
|
addFirst(e) {
|
|
424
441
|
let t = {
|
|
@@ -437,7 +454,7 @@ var pe = class {
|
|
|
437
454
|
size() {
|
|
438
455
|
return this.internalSize;
|
|
439
456
|
}
|
|
440
|
-
},
|
|
457
|
+
}, ge = class extends h {
|
|
441
458
|
current;
|
|
442
459
|
constructor(e) {
|
|
443
460
|
super(), this.current = e;
|
|
@@ -450,12 +467,12 @@ var pe = class {
|
|
|
450
467
|
//#endregion
|
|
451
468
|
//#region src/functions/materialize.ts
|
|
452
469
|
function F(e) {
|
|
453
|
-
return l(e, "materialize"), e instanceof
|
|
470
|
+
return l(e, "materialize"), e instanceof I ? e : new I(e);
|
|
454
471
|
}
|
|
455
|
-
var
|
|
472
|
+
var I = class {
|
|
456
473
|
source;
|
|
457
474
|
constructor(e) {
|
|
458
|
-
this.source =
|
|
475
|
+
this.source = me(e);
|
|
459
476
|
}
|
|
460
477
|
[Symbol.iterator]() {
|
|
461
478
|
return this.source[Symbol.iterator]();
|
|
@@ -463,29 +480,29 @@ var he = class {
|
|
|
463
480
|
};
|
|
464
481
|
//#endregion
|
|
465
482
|
//#region src/functions/max.ts
|
|
466
|
-
function
|
|
483
|
+
function L(e, t) {
|
|
467
484
|
return l(e, "max"), a(e, i(t), 1);
|
|
468
485
|
}
|
|
469
486
|
//#endregion
|
|
470
487
|
//#region src/functions/memoize.ts
|
|
471
|
-
function
|
|
488
|
+
function R() {
|
|
472
489
|
return { allowPartialMemoization: !0 };
|
|
473
490
|
}
|
|
474
|
-
function
|
|
491
|
+
function z(e, t) {
|
|
475
492
|
l(e, "memoize");
|
|
476
493
|
let n = {
|
|
477
|
-
...
|
|
494
|
+
...R(),
|
|
478
495
|
...t
|
|
479
496
|
}.allowPartialMemoization;
|
|
480
|
-
return e instanceof
|
|
497
|
+
return e instanceof H ? n ? e.changePartialMemoizationBehaviour() : e : e instanceof U ? n ? e : e.changePartialMemoizationBehaviour() : n ? new U(e) : new H(e);
|
|
481
498
|
}
|
|
482
|
-
function
|
|
499
|
+
function B() {
|
|
483
500
|
return {
|
|
484
501
|
values: [],
|
|
485
502
|
finished: !1
|
|
486
503
|
};
|
|
487
504
|
}
|
|
488
|
-
function
|
|
505
|
+
function V(e, t) {
|
|
489
506
|
if (t.error) throw t.error.value;
|
|
490
507
|
if (t.finished) return !1;
|
|
491
508
|
t.source ??= e[Symbol.iterator]();
|
|
@@ -497,31 +514,31 @@ function B(e, t) {
|
|
|
497
514
|
}
|
|
498
515
|
return n.done === !0 ? (t.finished = !0, t.source = void 0, !1) : (t.values.push(n.value), !0);
|
|
499
516
|
}
|
|
500
|
-
var
|
|
517
|
+
var H = class {
|
|
501
518
|
source;
|
|
502
|
-
cache =
|
|
519
|
+
cache = B();
|
|
503
520
|
constructor(e) {
|
|
504
521
|
this.source = e;
|
|
505
522
|
}
|
|
506
523
|
[Symbol.iterator]() {
|
|
507
|
-
return new
|
|
524
|
+
return new W(this.source, this.cache, !0);
|
|
508
525
|
}
|
|
509
526
|
changePartialMemoizationBehaviour() {
|
|
510
|
-
return new
|
|
527
|
+
return new U(this.source);
|
|
511
528
|
}
|
|
512
|
-
},
|
|
529
|
+
}, U = class {
|
|
513
530
|
source;
|
|
514
|
-
cache =
|
|
531
|
+
cache = B();
|
|
515
532
|
constructor(e) {
|
|
516
533
|
this.source = e;
|
|
517
534
|
}
|
|
518
535
|
[Symbol.iterator]() {
|
|
519
|
-
return new
|
|
536
|
+
return new W(this.source, this.cache, !1);
|
|
520
537
|
}
|
|
521
538
|
changePartialMemoizationBehaviour() {
|
|
522
|
-
return new
|
|
539
|
+
return new H(this.source);
|
|
523
540
|
}
|
|
524
|
-
},
|
|
541
|
+
}, W = class extends h {
|
|
525
542
|
source;
|
|
526
543
|
cache;
|
|
527
544
|
drainFirst;
|
|
@@ -530,28 +547,28 @@ var V = class {
|
|
|
530
547
|
super(), this.source = e, this.cache = t, this.drainFirst = n;
|
|
531
548
|
}
|
|
532
549
|
advance() {
|
|
533
|
-
if (this.drainFirst) for (;
|
|
534
|
-
return this.index < this.cache.values.length ||
|
|
550
|
+
if (this.drainFirst) for (; V(this.source, this.cache););
|
|
551
|
+
return this.index < this.cache.values.length || V(this.source, this.cache) ? o(this.cache.values[this.index++]) : s();
|
|
535
552
|
}
|
|
536
553
|
};
|
|
537
554
|
//#endregion
|
|
538
555
|
//#region src/functions/min.ts
|
|
539
|
-
function
|
|
556
|
+
function G(e, t) {
|
|
540
557
|
return l(e, "min"), a(e, i(t), -1);
|
|
541
558
|
}
|
|
542
559
|
//#endregion
|
|
543
560
|
//#region src/functions/range.ts
|
|
544
|
-
function
|
|
561
|
+
function K(e, t, n) {
|
|
545
562
|
let r = typeof t == "number", i = r ? e : 0, a = r ? t : e;
|
|
546
563
|
if (!r && n !== void 0) throw c("range", "The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
547
564
|
let o = r ? n : t;
|
|
548
565
|
o !== void 0 && ne(o, "options", "range");
|
|
549
566
|
let { step: s = 1, reverse: l = !1 } = o ?? {};
|
|
550
567
|
te(s, "step", "range");
|
|
551
|
-
let u =
|
|
552
|
-
return u.length > 0 ? new g(() => new
|
|
568
|
+
let u = _e(i, a, Math.abs(s), l);
|
|
569
|
+
return u.length > 0 ? new g(() => new ve(u.first, u.step, u.length)) : y();
|
|
553
570
|
}
|
|
554
|
-
function
|
|
571
|
+
function _e(e, t, n, r) {
|
|
555
572
|
let i = t < e ? -n : n, a = Math.ceil(Math.abs(t - e) / n);
|
|
556
573
|
return r ? {
|
|
557
574
|
first: e + (a - 1) * i,
|
|
@@ -563,7 +580,7 @@ function ge(e, t, n, r) {
|
|
|
563
580
|
length: a
|
|
564
581
|
};
|
|
565
582
|
}
|
|
566
|
-
var
|
|
583
|
+
var ve = class extends h {
|
|
567
584
|
first;
|
|
568
585
|
step;
|
|
569
586
|
length;
|
|
@@ -577,15 +594,15 @@ var _e = class extends h {
|
|
|
577
594
|
};
|
|
578
595
|
//#endregion
|
|
579
596
|
//#region src/functions/reduce.ts
|
|
580
|
-
function
|
|
581
|
-
if (l(e, "reduce"), t.length === 1) return
|
|
597
|
+
function q(e, ...t) {
|
|
598
|
+
if (l(e, "reduce"), t.length === 1) return ye(e, t[0]);
|
|
582
599
|
let [n, r] = t;
|
|
583
600
|
u(r, "reducer", "reduce");
|
|
584
601
|
let i = n, a = 0;
|
|
585
602
|
for (let t of e) i = r(i, t, a++);
|
|
586
603
|
return i;
|
|
587
604
|
}
|
|
588
|
-
function
|
|
605
|
+
function ye(e, t) {
|
|
589
606
|
u(t, "reducer", "reduce");
|
|
590
607
|
let n, r = 0;
|
|
591
608
|
for (let i of e) n = r === 0 ? i : t(n, i, r), r++;
|
|
@@ -594,15 +611,54 @@ function ve(e, t) {
|
|
|
594
611
|
}
|
|
595
612
|
//#endregion
|
|
596
613
|
//#region src/functions/repeat.ts
|
|
597
|
-
function
|
|
598
|
-
return d(t, "count", "repeat"),
|
|
614
|
+
function J(e, t) {
|
|
615
|
+
return d(t, "count", "repeat"), se(t, (t) => t > 0 ? [e, t - 1] : void 0);
|
|
616
|
+
}
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region src/functions/sequenceEqual.ts
|
|
619
|
+
function be(e, t) {
|
|
620
|
+
return e === t;
|
|
621
|
+
}
|
|
622
|
+
function xe(e, t, n) {
|
|
623
|
+
l(e, "sequenceEqual"), l(t, "sequenceEqual"), n !== void 0 && u(n, "equals", "sequenceEqual");
|
|
624
|
+
let r = n ?? be, i = t[Symbol.iterator](), a = !0;
|
|
625
|
+
try {
|
|
626
|
+
for (let t of e) {
|
|
627
|
+
a = !1;
|
|
628
|
+
let e = i.next();
|
|
629
|
+
if (e.done === !0 || (a = !0, !r(t, e.value))) return !1;
|
|
630
|
+
}
|
|
631
|
+
return a = !1, i.next().done === !0 || (a = !0, !1);
|
|
632
|
+
} finally {
|
|
633
|
+
a && i.return?.();
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/functions/single.ts
|
|
638
|
+
function Se(e, t) {
|
|
639
|
+
l(e, "single");
|
|
640
|
+
let n = !1, r;
|
|
641
|
+
if (t === void 0) {
|
|
642
|
+
for (let t of e) {
|
|
643
|
+
if (n) throw c("single", "The iterable contains more than one value");
|
|
644
|
+
n = !0, r = t;
|
|
645
|
+
}
|
|
646
|
+
return r;
|
|
647
|
+
}
|
|
648
|
+
u(t, "predicate", "single");
|
|
649
|
+
let i = 0;
|
|
650
|
+
for (let a of e) if (t(a, i++)) {
|
|
651
|
+
if (n) throw c("single", "More than one value satisfies the predicate");
|
|
652
|
+
n = !0, r = a;
|
|
653
|
+
}
|
|
654
|
+
return r;
|
|
599
655
|
}
|
|
600
656
|
//#endregion
|
|
601
657
|
//#region src/functions/skip.ts
|
|
602
|
-
function
|
|
603
|
-
return l(e, "skip"), d(t, "count", "skip"), new g(() => new
|
|
658
|
+
function Ce(e, t) {
|
|
659
|
+
return l(e, "skip"), d(t, "count", "skip"), new g(() => new we(e, t));
|
|
604
660
|
}
|
|
605
|
-
var
|
|
661
|
+
var we = class extends _ {
|
|
606
662
|
count;
|
|
607
663
|
constructor(e, t) {
|
|
608
664
|
super(e), this.count = t;
|
|
@@ -618,10 +674,10 @@ var ye = class extends _ {
|
|
|
618
674
|
};
|
|
619
675
|
//#endregion
|
|
620
676
|
//#region src/functions/skipWhile.ts
|
|
621
|
-
function
|
|
622
|
-
return l(e, "skipWhile"), u(t, "predicate", "skipWhile"), new g(() => new
|
|
677
|
+
function Te(e, t) {
|
|
678
|
+
return l(e, "skipWhile"), u(t, "predicate", "skipWhile"), new g(() => new Ee(e, t));
|
|
623
679
|
}
|
|
624
|
-
var
|
|
680
|
+
var Ee = class extends _ {
|
|
625
681
|
predicate;
|
|
626
682
|
skipping = !0;
|
|
627
683
|
constructor(e, t) {
|
|
@@ -643,7 +699,7 @@ var be = class extends _ {
|
|
|
643
699
|
};
|
|
644
700
|
//#endregion
|
|
645
701
|
//#region src/functions/some.ts
|
|
646
|
-
function
|
|
702
|
+
function De(e, t) {
|
|
647
703
|
if (l(e, "some"), t === void 0) {
|
|
648
704
|
for (let t of e) return !0;
|
|
649
705
|
return !1;
|
|
@@ -654,11 +710,25 @@ function xe(e, t) {
|
|
|
654
710
|
return !1;
|
|
655
711
|
}
|
|
656
712
|
//#endregion
|
|
713
|
+
//#region src/functions/sum.ts
|
|
714
|
+
function Oe(e, t) {
|
|
715
|
+
l(e, "sum");
|
|
716
|
+
let n = 0;
|
|
717
|
+
if (t === void 0) {
|
|
718
|
+
for (let t of e) n += t;
|
|
719
|
+
return n;
|
|
720
|
+
}
|
|
721
|
+
u(t, "selector", "sum");
|
|
722
|
+
let r = 0;
|
|
723
|
+
for (let i of e) n += t(i, r++);
|
|
724
|
+
return n;
|
|
725
|
+
}
|
|
726
|
+
//#endregion
|
|
657
727
|
//#region src/functions/take.ts
|
|
658
|
-
function
|
|
659
|
-
return l(e, "take"), d(t, "count", "take"), new g(() => new
|
|
728
|
+
function ke(e, t) {
|
|
729
|
+
return l(e, "take"), d(t, "count", "take"), new g(() => new Ae(e, t));
|
|
660
730
|
}
|
|
661
|
-
var
|
|
731
|
+
var Ae = class extends _ {
|
|
662
732
|
count;
|
|
663
733
|
constructor(e, t) {
|
|
664
734
|
super(e), this.count = t;
|
|
@@ -671,10 +741,10 @@ var Ce = class extends _ {
|
|
|
671
741
|
};
|
|
672
742
|
//#endregion
|
|
673
743
|
//#region src/functions/takeWhile.ts
|
|
674
|
-
function
|
|
675
|
-
return l(e, "takeWhile"), u(t, "predicate", "takeWhile"), new g(() => new
|
|
744
|
+
function je(e, t) {
|
|
745
|
+
return l(e, "takeWhile"), u(t, "predicate", "takeWhile"), new g(() => new Me(e, t));
|
|
676
746
|
}
|
|
677
|
-
var
|
|
747
|
+
var Me = class extends _ {
|
|
678
748
|
predicate;
|
|
679
749
|
constructor(e, t) {
|
|
680
750
|
super(e), this.predicate = t;
|
|
@@ -693,10 +763,10 @@ var Te = class extends _ {
|
|
|
693
763
|
};
|
|
694
764
|
//#endregion
|
|
695
765
|
//#region src/functions/tap.ts
|
|
696
|
-
function
|
|
697
|
-
return l(e, "tap"), u(t, "tapper", "tap"), new g(() => new
|
|
766
|
+
function Ne(e, t) {
|
|
767
|
+
return l(e, "tap"), u(t, "tapper", "tap"), new g(() => new Pe(e, t));
|
|
698
768
|
}
|
|
699
|
-
var
|
|
769
|
+
var Pe = class extends _ {
|
|
700
770
|
tapper;
|
|
701
771
|
constructor(e, t) {
|
|
702
772
|
super(e), this.tapper = t;
|
|
@@ -714,52 +784,57 @@ var De = class extends _ {
|
|
|
714
784
|
};
|
|
715
785
|
//#endregion
|
|
716
786
|
//#region src/functions/tapChain.ts
|
|
717
|
-
function
|
|
787
|
+
function Fe(e, t) {
|
|
718
788
|
return l(e, "tapChain"), u(t, "tapper", "tapChain"), new g(() => (t(e, 0), e[Symbol.iterator]()));
|
|
719
789
|
}
|
|
720
790
|
//#endregion
|
|
721
791
|
//#region src/functions/index.ts
|
|
722
|
-
var
|
|
792
|
+
var Ie = /* @__PURE__ */ t({
|
|
723
793
|
at: () => f,
|
|
724
|
-
|
|
725
|
-
|
|
794
|
+
average: () => p,
|
|
795
|
+
collectToArray: () => m,
|
|
796
|
+
count: () => oe,
|
|
726
797
|
distinct: () => v,
|
|
727
798
|
empty: () => y,
|
|
728
|
-
every: () =>
|
|
729
|
-
filter: () =>
|
|
730
|
-
find: () =>
|
|
731
|
-
findIndex: () =>
|
|
732
|
-
findLast: () =>
|
|
733
|
-
findLastIndex: () =>
|
|
734
|
-
flatMap: () =>
|
|
735
|
-
forEach: () =>
|
|
736
|
-
forEachAsync: () =>
|
|
737
|
-
getMemoizeDefaultOptions: () =>
|
|
738
|
-
includes: () =>
|
|
739
|
-
indexOf: () =>
|
|
799
|
+
every: () => ue,
|
|
800
|
+
filter: () => b,
|
|
801
|
+
find: () => x,
|
|
802
|
+
findIndex: () => S,
|
|
803
|
+
findLast: () => C,
|
|
804
|
+
findLastIndex: () => w,
|
|
805
|
+
flatMap: () => T,
|
|
806
|
+
forEach: () => O,
|
|
807
|
+
forEachAsync: () => k,
|
|
808
|
+
getMemoizeDefaultOptions: () => R,
|
|
809
|
+
includes: () => A,
|
|
810
|
+
indexOf: () => j,
|
|
811
|
+
join: () => M,
|
|
740
812
|
lastIndexOf: () => N,
|
|
741
813
|
map: () => P,
|
|
742
814
|
materialize: () => F,
|
|
743
|
-
max: () =>
|
|
744
|
-
memoize: () =>
|
|
745
|
-
min: () =>
|
|
746
|
-
range: () =>
|
|
747
|
-
reduce: () =>
|
|
748
|
-
repeat: () =>
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
815
|
+
max: () => L,
|
|
816
|
+
memoize: () => z,
|
|
817
|
+
min: () => G,
|
|
818
|
+
range: () => K,
|
|
819
|
+
reduce: () => q,
|
|
820
|
+
repeat: () => J,
|
|
821
|
+
sequenceEqual: () => xe,
|
|
822
|
+
single: () => Se,
|
|
823
|
+
skip: () => Ce,
|
|
824
|
+
skipWhile: () => Te,
|
|
825
|
+
some: () => De,
|
|
826
|
+
sum: () => Oe,
|
|
827
|
+
take: () => ke,
|
|
828
|
+
takeWhile: () => je,
|
|
829
|
+
tap: () => Ne,
|
|
830
|
+
tapChain: () => Fe
|
|
831
|
+
}), Le = Symbol.for("iterable-linq-utility.IIterableLinq");
|
|
757
832
|
//#endregion
|
|
758
833
|
//#region src/linqIterable.ts
|
|
759
|
-
function
|
|
760
|
-
return new
|
|
834
|
+
function Y(e) {
|
|
835
|
+
return new X(e);
|
|
761
836
|
}
|
|
762
|
-
var
|
|
837
|
+
var X = class {
|
|
763
838
|
iterable;
|
|
764
839
|
constructor(e) {
|
|
765
840
|
this.iterable = e;
|
|
@@ -770,89 +845,104 @@ var Z = class {
|
|
|
770
845
|
at(e) {
|
|
771
846
|
return f(this.iterable, e);
|
|
772
847
|
}
|
|
848
|
+
average(e) {
|
|
849
|
+
return p(this.iterable, e);
|
|
850
|
+
}
|
|
773
851
|
collectToArray() {
|
|
774
|
-
return
|
|
852
|
+
return m(this.iterable);
|
|
775
853
|
}
|
|
776
854
|
count(e) {
|
|
777
|
-
return
|
|
855
|
+
return oe(this.iterable, e);
|
|
778
856
|
}
|
|
779
857
|
distinct(e) {
|
|
780
|
-
return
|
|
858
|
+
return Y(v(this.iterable, e));
|
|
781
859
|
}
|
|
782
860
|
every(e) {
|
|
783
|
-
return
|
|
861
|
+
return ue(this.iterable, e);
|
|
784
862
|
}
|
|
785
863
|
filter(e) {
|
|
786
|
-
return
|
|
864
|
+
return Y(b(this.iterable, e));
|
|
787
865
|
}
|
|
788
866
|
find(e) {
|
|
789
|
-
return
|
|
867
|
+
return x(this.iterable, e);
|
|
790
868
|
}
|
|
791
869
|
findIndex(e) {
|
|
792
|
-
return
|
|
870
|
+
return S(this.iterable, e);
|
|
793
871
|
}
|
|
794
872
|
findLast(e) {
|
|
795
|
-
return
|
|
873
|
+
return C(this.iterable, e);
|
|
796
874
|
}
|
|
797
875
|
findLastIndex(e) {
|
|
798
|
-
return
|
|
876
|
+
return w(this.iterable, e);
|
|
799
877
|
}
|
|
800
878
|
flatMap(e) {
|
|
801
|
-
return
|
|
879
|
+
return Y(T(this.iterable, e));
|
|
802
880
|
}
|
|
803
881
|
forEach(e) {
|
|
804
|
-
return
|
|
882
|
+
return O(this.iterable, e);
|
|
805
883
|
}
|
|
806
884
|
forEachAsync(e) {
|
|
807
|
-
return
|
|
885
|
+
return k(this.iterable, e);
|
|
808
886
|
}
|
|
809
887
|
includes(e) {
|
|
810
|
-
return
|
|
888
|
+
return A(this.iterable, e);
|
|
811
889
|
}
|
|
812
890
|
indexOf(e) {
|
|
891
|
+
return j(this.iterable, e);
|
|
892
|
+
}
|
|
893
|
+
join(e) {
|
|
813
894
|
return M(this.iterable, e);
|
|
814
895
|
}
|
|
815
896
|
lastIndexOf(e) {
|
|
816
897
|
return N(this.iterable, e);
|
|
817
898
|
}
|
|
818
899
|
map(e) {
|
|
819
|
-
return
|
|
900
|
+
return Y(P(this.iterable, e));
|
|
820
901
|
}
|
|
821
902
|
materialize() {
|
|
822
|
-
return
|
|
903
|
+
return Y(F(this.iterable));
|
|
823
904
|
}
|
|
824
905
|
max(e) {
|
|
825
|
-
return
|
|
906
|
+
return L(this.iterable, e);
|
|
826
907
|
}
|
|
827
908
|
memoize(e) {
|
|
828
|
-
return
|
|
909
|
+
return Y(z(this.iterable, e));
|
|
829
910
|
}
|
|
830
911
|
min(e) {
|
|
831
|
-
return
|
|
912
|
+
return G(this.iterable, e);
|
|
832
913
|
}
|
|
833
914
|
reduce(...e) {
|
|
834
|
-
return e.length === 1 ?
|
|
915
|
+
return e.length === 1 ? q(this.iterable, e[0]) : q(this.iterable, e[0], e[1]);
|
|
916
|
+
}
|
|
917
|
+
sequenceEqual(e, t) {
|
|
918
|
+
return xe(this.iterable, e, t);
|
|
919
|
+
}
|
|
920
|
+
single(e) {
|
|
921
|
+
return Se(this.iterable, e);
|
|
835
922
|
}
|
|
836
923
|
skip(e) {
|
|
837
|
-
return
|
|
924
|
+
return Y(Ce(this.iterable, e));
|
|
838
925
|
}
|
|
839
926
|
skipWhile(e) {
|
|
840
|
-
return
|
|
927
|
+
return Y(Te(this.iterable, e));
|
|
841
928
|
}
|
|
842
929
|
some(e) {
|
|
843
|
-
return
|
|
930
|
+
return De(this.iterable, e);
|
|
931
|
+
}
|
|
932
|
+
sum(e) {
|
|
933
|
+
return Oe(this.iterable, e);
|
|
844
934
|
}
|
|
845
935
|
take(e) {
|
|
846
|
-
return
|
|
936
|
+
return Y(ke(this.iterable, e));
|
|
847
937
|
}
|
|
848
938
|
takeWhile(e) {
|
|
849
|
-
return
|
|
939
|
+
return Y(je(this.iterable, e));
|
|
850
940
|
}
|
|
851
941
|
tap(e) {
|
|
852
|
-
return
|
|
942
|
+
return Y(Ne(this.iterable, e));
|
|
853
943
|
}
|
|
854
944
|
tapChain(e) {
|
|
855
|
-
return
|
|
945
|
+
return Y(Fe(this.iterable, e));
|
|
856
946
|
}
|
|
857
947
|
tapChainCreation(e) {
|
|
858
948
|
u(e, "chainCreationTapper", "tapChainCreation");
|
|
@@ -860,7 +950,7 @@ var Z = class {
|
|
|
860
950
|
return e(t), t;
|
|
861
951
|
}
|
|
862
952
|
};
|
|
863
|
-
Object.defineProperty(
|
|
953
|
+
Object.defineProperty(X.prototype, Le, {
|
|
864
954
|
value: !0,
|
|
865
955
|
enumerable: !1,
|
|
866
956
|
writable: !1,
|
|
@@ -868,49 +958,49 @@ Object.defineProperty(Z.prototype, Ae, {
|
|
|
868
958
|
});
|
|
869
959
|
//#endregion
|
|
870
960
|
//#region src/extension.ts
|
|
871
|
-
function
|
|
872
|
-
return
|
|
961
|
+
function Z() {
|
|
962
|
+
return X.prototype;
|
|
873
963
|
}
|
|
874
|
-
function
|
|
875
|
-
return typeof e == "object" && !!e && e[
|
|
964
|
+
function Re(e) {
|
|
965
|
+
return typeof e == "object" && !!e && e[Le] === !0;
|
|
876
966
|
}
|
|
877
|
-
function
|
|
878
|
-
let n = Object.getOwnPropertyDescriptor(
|
|
879
|
-
Object.defineProperty(
|
|
967
|
+
function Q(e, t) {
|
|
968
|
+
let n = Object.getOwnPropertyDescriptor(Z(), e);
|
|
969
|
+
Object.defineProperty(Z(), e, {
|
|
880
970
|
value: t,
|
|
881
971
|
enumerable: !1,
|
|
882
972
|
writable: n?.writable ?? !1,
|
|
883
973
|
configurable: !0
|
|
884
974
|
});
|
|
885
975
|
}
|
|
886
|
-
function
|
|
976
|
+
function ze(e, t, n) {
|
|
887
977
|
re(t, "name", e), u(n, "implementation", e);
|
|
888
978
|
}
|
|
889
|
-
function
|
|
890
|
-
if (
|
|
891
|
-
|
|
979
|
+
function Be(e, t) {
|
|
980
|
+
if (ze("extend", e, t), e in Y([])) throw c("extend", `"${e}" already exists on IIterableLinq: use override() to replace it`);
|
|
981
|
+
Q(e, t);
|
|
892
982
|
}
|
|
893
|
-
function
|
|
894
|
-
|
|
983
|
+
function Ve(e, t) {
|
|
984
|
+
ze("override", e, t);
|
|
895
985
|
let n = e;
|
|
896
|
-
if (!(n !== "constructor" && Object.prototype.hasOwnProperty.call(
|
|
897
|
-
|
|
986
|
+
if (!(n !== "constructor" && Object.prototype.hasOwnProperty.call(Z(), n))) throw c("override", `"${n}" is not a method of IIterableLinq: use extend() to add it`);
|
|
987
|
+
Q(n, t);
|
|
898
988
|
}
|
|
899
989
|
//#endregion
|
|
900
990
|
//#region src/index.ts
|
|
901
|
-
function
|
|
991
|
+
function He() {
|
|
902
992
|
return $(y());
|
|
903
993
|
}
|
|
904
994
|
function $(e) {
|
|
905
|
-
return l(e, "from"),
|
|
995
|
+
return l(e, "from"), Y(e);
|
|
906
996
|
}
|
|
907
|
-
function
|
|
908
|
-
if (typeof t == "number") return $(
|
|
997
|
+
function Ue(e, t, n) {
|
|
998
|
+
if (typeof t == "number") return $(K(e, t, n));
|
|
909
999
|
if (n !== void 0) throw c("fromRange", "The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
910
|
-
return $(
|
|
1000
|
+
return $(K(e, t));
|
|
911
1001
|
}
|
|
912
|
-
function
|
|
913
|
-
return $(
|
|
1002
|
+
function We(e, t) {
|
|
1003
|
+
return $(J(e, t));
|
|
914
1004
|
}
|
|
915
1005
|
//#endregion
|
|
916
|
-
export {
|
|
1006
|
+
export { Ie as Functions, E as Unit, He as empty, Be as extend, $ as from, Ue as fromRange, Re as isIterableLinq, Ve as override, We as repeat, D as unit };
|