iterable-linq-utility 0.5.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 +470 -0
- package/dist/index.d.ts +470 -0
- package/dist/iterable-linq-utility.js +369 -202
- package/dist/iterable-linq-utility.umd.cjs +1 -1
- package/package.json +1 -1
|
@@ -49,51 +49,85 @@ 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`);
|
|
59
64
|
}
|
|
60
|
-
function
|
|
61
|
-
if (!Number.isInteger(e)
|
|
65
|
+
function ee(e, t, n) {
|
|
66
|
+
if (!Number.isInteger(e)) throw c(n, `The "${t}" parameter must be an integer`);
|
|
62
67
|
}
|
|
63
|
-
function
|
|
64
|
-
if (!Number.
|
|
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`);
|
|
65
70
|
}
|
|
66
|
-
function te(e, t) {
|
|
67
|
-
if (
|
|
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`);
|
|
68
73
|
}
|
|
69
|
-
function ne(e, t) {
|
|
70
|
-
if (typeof e != "
|
|
74
|
+
function ne(e, t, n) {
|
|
75
|
+
if (typeof e != "object" || !e) throw c(n, `The "${t}" parameter must be an object`);
|
|
76
|
+
}
|
|
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`);
|
|
79
|
+
}
|
|
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);
|
|
84
|
+
}
|
|
85
|
+
function ie(e, t) {
|
|
86
|
+
let n = 0;
|
|
87
|
+
for (let r of e) if (n++ === t) return r;
|
|
88
|
+
}
|
|
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;
|
|
93
|
+
}
|
|
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;
|
|
71
105
|
}
|
|
72
106
|
//#endregion
|
|
73
107
|
//#region src/functions/collectToArray.ts
|
|
74
|
-
function
|
|
75
|
-
if (
|
|
108
|
+
function m(e) {
|
|
109
|
+
if (l(e, "collectToArray"), Array.isArray(e) || e instanceof Set) return Array.from(e);
|
|
76
110
|
let t = [];
|
|
77
111
|
for (let n of e) t.push(n);
|
|
78
112
|
return t;
|
|
79
113
|
}
|
|
80
114
|
//#endregion
|
|
81
115
|
//#region src/functions/count.ts
|
|
82
|
-
function
|
|
83
|
-
|
|
116
|
+
function oe(e, t) {
|
|
117
|
+
l(e, "count");
|
|
84
118
|
let n = 0;
|
|
85
119
|
if (t === void 0) {
|
|
86
120
|
for (let t of e) n++;
|
|
87
121
|
return n;
|
|
88
122
|
}
|
|
89
|
-
|
|
123
|
+
u(t, "predicate", "count");
|
|
90
124
|
let r = 0;
|
|
91
125
|
for (let i of e) t(i, r++) && n++;
|
|
92
126
|
return n;
|
|
93
127
|
}
|
|
94
128
|
//#endregion
|
|
95
129
|
//#region src/iterators/baseIterator.ts
|
|
96
|
-
var
|
|
130
|
+
var h = class {
|
|
97
131
|
done = !1;
|
|
98
132
|
next() {
|
|
99
133
|
if (this.done) return s();
|
|
@@ -115,7 +149,7 @@ var f = class {
|
|
|
115
149
|
} catch {}
|
|
116
150
|
}
|
|
117
151
|
}
|
|
118
|
-
},
|
|
152
|
+
}, g = class {
|
|
119
153
|
createIterator;
|
|
120
154
|
constructor(e) {
|
|
121
155
|
this.createIterator = e;
|
|
@@ -123,7 +157,7 @@ var f = class {
|
|
|
123
157
|
[Symbol.iterator]() {
|
|
124
158
|
return this.createIterator();
|
|
125
159
|
}
|
|
126
|
-
},
|
|
160
|
+
}, _ = class extends h {
|
|
127
161
|
source;
|
|
128
162
|
index = 0;
|
|
129
163
|
constructor(e) {
|
|
@@ -135,10 +169,10 @@ var f = class {
|
|
|
135
169
|
};
|
|
136
170
|
//#endregion
|
|
137
171
|
//#region src/iterators/unfold.ts
|
|
138
|
-
function
|
|
139
|
-
return new
|
|
172
|
+
function se(e, t) {
|
|
173
|
+
return new g(() => new ce(e, t));
|
|
140
174
|
}
|
|
141
|
-
var
|
|
175
|
+
var ce = class extends h {
|
|
142
176
|
state;
|
|
143
177
|
step;
|
|
144
178
|
constructor(e, t) {
|
|
@@ -151,10 +185,10 @@ var ie = class extends f {
|
|
|
151
185
|
};
|
|
152
186
|
//#endregion
|
|
153
187
|
//#region src/functions/distinct.ts
|
|
154
|
-
function
|
|
155
|
-
return
|
|
188
|
+
function v(e, t) {
|
|
189
|
+
return l(e, "distinct"), t !== void 0 && u(t, "keySelector", "distinct"), new g(() => new le(e, t));
|
|
156
190
|
}
|
|
157
|
-
var
|
|
191
|
+
var le = class extends _ {
|
|
158
192
|
keySelector;
|
|
159
193
|
seen = /* @__PURE__ */ new Set();
|
|
160
194
|
constructor(e, t) {
|
|
@@ -175,23 +209,23 @@ var ae = class extends m {
|
|
|
175
209
|
};
|
|
176
210
|
//#endregion
|
|
177
211
|
//#region src/functions/empty.ts
|
|
178
|
-
function
|
|
179
|
-
return
|
|
212
|
+
function y() {
|
|
213
|
+
return se(void 0, () => void 0);
|
|
180
214
|
}
|
|
181
215
|
//#endregion
|
|
182
216
|
//#region src/functions/every.ts
|
|
183
|
-
function
|
|
184
|
-
|
|
217
|
+
function ue(e, t) {
|
|
218
|
+
l(e, "every"), u(t, "predicate", "every");
|
|
185
219
|
let n = 0;
|
|
186
220
|
for (let r of e) if (!t(r, n++)) return !1;
|
|
187
221
|
return !0;
|
|
188
222
|
}
|
|
189
223
|
//#endregion
|
|
190
224
|
//#region src/functions/filter.ts
|
|
191
|
-
function
|
|
192
|
-
return
|
|
225
|
+
function b(e, t) {
|
|
226
|
+
return l(e, "filter"), u(t, "predicate", "filter"), new g(() => new de(e, t));
|
|
193
227
|
}
|
|
194
|
-
var
|
|
228
|
+
var de = class extends _ {
|
|
195
229
|
predicate;
|
|
196
230
|
constructor(e, t) {
|
|
197
231
|
super(e), this.predicate = t;
|
|
@@ -211,15 +245,15 @@ var se = class extends m {
|
|
|
211
245
|
};
|
|
212
246
|
//#endregion
|
|
213
247
|
//#region src/functions/find.ts
|
|
214
|
-
function
|
|
215
|
-
|
|
248
|
+
function x(e, t) {
|
|
249
|
+
l(e, "find"), u(t, "predicate", "find");
|
|
216
250
|
let n = 0;
|
|
217
251
|
for (let r of e) if (t(r, n++)) return r;
|
|
218
252
|
}
|
|
219
253
|
//#endregion
|
|
220
254
|
//#region src/functions/findIndex.ts
|
|
221
|
-
function
|
|
222
|
-
|
|
255
|
+
function S(e, t) {
|
|
256
|
+
l(e, "findIndex"), u(t, "predicate", "findIndex");
|
|
223
257
|
let n = 0;
|
|
224
258
|
for (let r of e) {
|
|
225
259
|
if (t(r, n)) return n;
|
|
@@ -228,11 +262,27 @@ function b(e, t) {
|
|
|
228
262
|
return -1;
|
|
229
263
|
}
|
|
230
264
|
//#endregion
|
|
265
|
+
//#region src/functions/findLast.ts
|
|
266
|
+
function C(e, t) {
|
|
267
|
+
l(e, "findLast"), u(t, "predicate", "findLast");
|
|
268
|
+
let n, r = 0;
|
|
269
|
+
for (let i of e) t(i, r++) && (n = i);
|
|
270
|
+
return n;
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/functions/findLastIndex.ts
|
|
274
|
+
function w(e, t) {
|
|
275
|
+
l(e, "findLastIndex"), u(t, "predicate", "findLastIndex");
|
|
276
|
+
let n = -1, r = 0;
|
|
277
|
+
for (let i of e) t(i, r) && (n = r), r++;
|
|
278
|
+
return n;
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
231
281
|
//#region src/functions/flatMap.ts
|
|
232
|
-
function
|
|
233
|
-
return
|
|
282
|
+
function T(e, t) {
|
|
283
|
+
return l(e, "flatMap"), u(t, "mapper", "flatMap"), new g(() => new fe(e, t));
|
|
234
284
|
}
|
|
235
|
-
var
|
|
285
|
+
var fe = class e extends _ {
|
|
236
286
|
mapper;
|
|
237
287
|
static steps = {
|
|
238
288
|
outer: (t) => {
|
|
@@ -293,7 +343,7 @@ var ce = class e extends m {
|
|
|
293
343
|
throw e.inner = void 0, e.closeAfterCallbackError(), t;
|
|
294
344
|
}
|
|
295
345
|
}
|
|
296
|
-
},
|
|
346
|
+
}, E = class e {
|
|
297
347
|
static instance = e.createFrozen();
|
|
298
348
|
constructor() {}
|
|
299
349
|
static createFrozen() {
|
|
@@ -301,37 +351,61 @@ var ce = class e extends m {
|
|
|
301
351
|
return Object.freeze(t), t;
|
|
302
352
|
}
|
|
303
353
|
};
|
|
304
|
-
function
|
|
305
|
-
return
|
|
354
|
+
function D() {
|
|
355
|
+
return E.instance;
|
|
306
356
|
}
|
|
307
357
|
//#endregion
|
|
308
358
|
//#region src/functions/forEach.ts
|
|
309
|
-
function
|
|
310
|
-
|
|
359
|
+
function O(e, t) {
|
|
360
|
+
l(e, "forEach"), u(t, "action", "forEach");
|
|
311
361
|
let n = 0;
|
|
312
362
|
for (let r of e) t(r, n++);
|
|
313
|
-
return
|
|
363
|
+
return D();
|
|
314
364
|
}
|
|
315
|
-
async function
|
|
316
|
-
|
|
365
|
+
async function k(e, t) {
|
|
366
|
+
l(e, "forEachAsync"), u(t, "action", "forEachAsync");
|
|
317
367
|
let n = 0;
|
|
318
368
|
for (let r of e) await t(r, n++);
|
|
319
|
-
return
|
|
369
|
+
return D();
|
|
320
370
|
}
|
|
321
371
|
//#endregion
|
|
322
372
|
//#region src/functions/includes.ts
|
|
323
|
-
function
|
|
324
|
-
|
|
373
|
+
function A(e, t) {
|
|
374
|
+
l(e, "includes");
|
|
325
375
|
let n = t !== t;
|
|
326
376
|
for (let r of e) if (r === t || n && r !== r) return !0;
|
|
327
377
|
return !1;
|
|
328
378
|
}
|
|
329
379
|
//#endregion
|
|
380
|
+
//#region src/functions/indexOf.ts
|
|
381
|
+
function j(e, t) {
|
|
382
|
+
l(e, "indexOf");
|
|
383
|
+
let n = 0;
|
|
384
|
+
for (let r of e) {
|
|
385
|
+
if (r === t) return n;
|
|
386
|
+
n++;
|
|
387
|
+
}
|
|
388
|
+
return -1;
|
|
389
|
+
}
|
|
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
|
|
396
|
+
//#region src/functions/lastIndexOf.ts
|
|
397
|
+
function N(e, t) {
|
|
398
|
+
l(e, "lastIndexOf");
|
|
399
|
+
let n = -1, r = 0;
|
|
400
|
+
for (let i of e) i === t && (n = r), r++;
|
|
401
|
+
return n;
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
330
404
|
//#region src/functions/map.ts
|
|
331
|
-
function
|
|
332
|
-
return
|
|
405
|
+
function P(e, t) {
|
|
406
|
+
return l(e, "map"), u(t, "mapper", "map"), new g(() => new pe(e, t));
|
|
333
407
|
}
|
|
334
|
-
var
|
|
408
|
+
var pe = class extends _ {
|
|
335
409
|
mapper;
|
|
336
410
|
constructor(e, t) {
|
|
337
411
|
super(e), this.mapper = t;
|
|
@@ -350,18 +424,18 @@ var le = class extends m {
|
|
|
350
424
|
};
|
|
351
425
|
//#endregion
|
|
352
426
|
//#region src/collections/linkedList.ts
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
let t = new
|
|
427
|
+
function me(e) {
|
|
428
|
+
l(e, "LinkedList.from");
|
|
429
|
+
let t = new he();
|
|
356
430
|
for (let n of e) t.addLast(n);
|
|
357
431
|
return t;
|
|
358
432
|
}
|
|
359
|
-
var
|
|
433
|
+
var he = class {
|
|
360
434
|
internalSize = 0;
|
|
361
435
|
head = null;
|
|
362
436
|
tail = null;
|
|
363
437
|
[Symbol.iterator]() {
|
|
364
|
-
return new
|
|
438
|
+
return new ge(this.head);
|
|
365
439
|
}
|
|
366
440
|
addFirst(e) {
|
|
367
441
|
let t = {
|
|
@@ -380,7 +454,7 @@ var de = class {
|
|
|
380
454
|
size() {
|
|
381
455
|
return this.internalSize;
|
|
382
456
|
}
|
|
383
|
-
},
|
|
457
|
+
}, ge = class extends h {
|
|
384
458
|
current;
|
|
385
459
|
constructor(e) {
|
|
386
460
|
super(), this.current = e;
|
|
@@ -392,13 +466,13 @@ var de = class {
|
|
|
392
466
|
};
|
|
393
467
|
//#endregion
|
|
394
468
|
//#region src/functions/materialize.ts
|
|
395
|
-
function
|
|
396
|
-
return
|
|
469
|
+
function F(e) {
|
|
470
|
+
return l(e, "materialize"), e instanceof I ? e : new I(e);
|
|
397
471
|
}
|
|
398
|
-
var
|
|
472
|
+
var I = class {
|
|
399
473
|
source;
|
|
400
474
|
constructor(e) {
|
|
401
|
-
this.source =
|
|
475
|
+
this.source = me(e);
|
|
402
476
|
}
|
|
403
477
|
[Symbol.iterator]() {
|
|
404
478
|
return this.source[Symbol.iterator]();
|
|
@@ -406,29 +480,29 @@ var k = class {
|
|
|
406
480
|
};
|
|
407
481
|
//#endregion
|
|
408
482
|
//#region src/functions/max.ts
|
|
409
|
-
function
|
|
410
|
-
return
|
|
483
|
+
function L(e, t) {
|
|
484
|
+
return l(e, "max"), a(e, i(t), 1);
|
|
411
485
|
}
|
|
412
486
|
//#endregion
|
|
413
487
|
//#region src/functions/memoize.ts
|
|
414
|
-
function
|
|
488
|
+
function R() {
|
|
415
489
|
return { allowPartialMemoization: !0 };
|
|
416
490
|
}
|
|
417
|
-
function
|
|
418
|
-
|
|
491
|
+
function z(e, t) {
|
|
492
|
+
l(e, "memoize");
|
|
419
493
|
let n = {
|
|
420
|
-
...
|
|
494
|
+
...R(),
|
|
421
495
|
...t
|
|
422
496
|
}.allowPartialMemoization;
|
|
423
|
-
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);
|
|
424
498
|
}
|
|
425
|
-
function
|
|
499
|
+
function B() {
|
|
426
500
|
return {
|
|
427
501
|
values: [],
|
|
428
502
|
finished: !1
|
|
429
503
|
};
|
|
430
504
|
}
|
|
431
|
-
function
|
|
505
|
+
function V(e, t) {
|
|
432
506
|
if (t.error) throw t.error.value;
|
|
433
507
|
if (t.finished) return !1;
|
|
434
508
|
t.source ??= e[Symbol.iterator]();
|
|
@@ -440,31 +514,31 @@ function pe(e, t) {
|
|
|
440
514
|
}
|
|
441
515
|
return n.done === !0 ? (t.finished = !0, t.source = void 0, !1) : (t.values.push(n.value), !0);
|
|
442
516
|
}
|
|
443
|
-
var
|
|
517
|
+
var H = class {
|
|
444
518
|
source;
|
|
445
|
-
cache =
|
|
519
|
+
cache = B();
|
|
446
520
|
constructor(e) {
|
|
447
521
|
this.source = e;
|
|
448
522
|
}
|
|
449
523
|
[Symbol.iterator]() {
|
|
450
|
-
return new
|
|
524
|
+
return new W(this.source, this.cache, !0);
|
|
451
525
|
}
|
|
452
526
|
changePartialMemoizationBehaviour() {
|
|
453
|
-
return new
|
|
527
|
+
return new U(this.source);
|
|
454
528
|
}
|
|
455
|
-
},
|
|
529
|
+
}, U = class {
|
|
456
530
|
source;
|
|
457
|
-
cache =
|
|
531
|
+
cache = B();
|
|
458
532
|
constructor(e) {
|
|
459
533
|
this.source = e;
|
|
460
534
|
}
|
|
461
535
|
[Symbol.iterator]() {
|
|
462
|
-
return new
|
|
536
|
+
return new W(this.source, this.cache, !1);
|
|
463
537
|
}
|
|
464
538
|
changePartialMemoizationBehaviour() {
|
|
465
|
-
return new
|
|
539
|
+
return new H(this.source);
|
|
466
540
|
}
|
|
467
|
-
},
|
|
541
|
+
}, W = class extends h {
|
|
468
542
|
source;
|
|
469
543
|
cache;
|
|
470
544
|
drainFirst;
|
|
@@ -473,28 +547,28 @@ var P = class {
|
|
|
473
547
|
super(), this.source = e, this.cache = t, this.drainFirst = n;
|
|
474
548
|
}
|
|
475
549
|
advance() {
|
|
476
|
-
if (this.drainFirst) for (;
|
|
477
|
-
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();
|
|
478
552
|
}
|
|
479
553
|
};
|
|
480
554
|
//#endregion
|
|
481
555
|
//#region src/functions/min.ts
|
|
482
|
-
function
|
|
483
|
-
return
|
|
556
|
+
function G(e, t) {
|
|
557
|
+
return l(e, "min"), a(e, i(t), -1);
|
|
484
558
|
}
|
|
485
559
|
//#endregion
|
|
486
560
|
//#region src/functions/range.ts
|
|
487
|
-
function
|
|
561
|
+
function K(e, t, n) {
|
|
488
562
|
let r = typeof t == "number", i = r ? e : 0, a = r ? t : e;
|
|
489
|
-
if (!r && n !== void 0) throw
|
|
563
|
+
if (!r && n !== void 0) throw c("range", "The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
490
564
|
let o = r ? n : t;
|
|
491
|
-
o !== void 0 &&
|
|
492
|
-
let { step: s = 1, reverse:
|
|
493
|
-
|
|
494
|
-
let
|
|
495
|
-
return
|
|
565
|
+
o !== void 0 && ne(o, "options", "range");
|
|
566
|
+
let { step: s = 1, reverse: l = !1 } = o ?? {};
|
|
567
|
+
te(s, "step", "range");
|
|
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();
|
|
496
570
|
}
|
|
497
|
-
function
|
|
571
|
+
function _e(e, t, n, r) {
|
|
498
572
|
let i = t < e ? -n : n, a = Math.ceil(Math.abs(t - e) / n);
|
|
499
573
|
return r ? {
|
|
500
574
|
first: e + (a - 1) * i,
|
|
@@ -506,7 +580,7 @@ function me(e, t, n, r) {
|
|
|
506
580
|
length: a
|
|
507
581
|
};
|
|
508
582
|
}
|
|
509
|
-
var
|
|
583
|
+
var ve = class extends h {
|
|
510
584
|
first;
|
|
511
585
|
step;
|
|
512
586
|
length;
|
|
@@ -520,32 +594,71 @@ var he = class extends f {
|
|
|
520
594
|
};
|
|
521
595
|
//#endregion
|
|
522
596
|
//#region src/functions/reduce.ts
|
|
523
|
-
function
|
|
524
|
-
if (
|
|
597
|
+
function q(e, ...t) {
|
|
598
|
+
if (l(e, "reduce"), t.length === 1) return ye(e, t[0]);
|
|
525
599
|
let [n, r] = t;
|
|
526
|
-
|
|
600
|
+
u(r, "reducer", "reduce");
|
|
527
601
|
let i = n, a = 0;
|
|
528
602
|
for (let t of e) i = r(i, t, a++);
|
|
529
603
|
return i;
|
|
530
604
|
}
|
|
531
|
-
function
|
|
532
|
-
|
|
605
|
+
function ye(e, t) {
|
|
606
|
+
u(t, "reducer", "reduce");
|
|
533
607
|
let n, r = 0;
|
|
534
608
|
for (let i of e) n = r === 0 ? i : t(n, i, r), r++;
|
|
535
|
-
if (r === 0) throw
|
|
609
|
+
if (r === 0) throw c("reduce", "The \"sourceIterable\" must not be empty when \"reduce\" has no seed");
|
|
536
610
|
return n;
|
|
537
611
|
}
|
|
538
612
|
//#endregion
|
|
539
613
|
//#region src/functions/repeat.ts
|
|
540
|
-
function
|
|
541
|
-
return
|
|
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;
|
|
542
655
|
}
|
|
543
656
|
//#endregion
|
|
544
657
|
//#region src/functions/skip.ts
|
|
545
|
-
function
|
|
546
|
-
return
|
|
658
|
+
function Ce(e, t) {
|
|
659
|
+
return l(e, "skip"), d(t, "count", "skip"), new g(() => new we(e, t));
|
|
547
660
|
}
|
|
548
|
-
var
|
|
661
|
+
var we = class extends _ {
|
|
549
662
|
count;
|
|
550
663
|
constructor(e, t) {
|
|
551
664
|
super(e), this.count = t;
|
|
@@ -561,10 +674,10 @@ var _e = class extends m {
|
|
|
561
674
|
};
|
|
562
675
|
//#endregion
|
|
563
676
|
//#region src/functions/skipWhile.ts
|
|
564
|
-
function
|
|
565
|
-
return
|
|
677
|
+
function Te(e, t) {
|
|
678
|
+
return l(e, "skipWhile"), u(t, "predicate", "skipWhile"), new g(() => new Ee(e, t));
|
|
566
679
|
}
|
|
567
|
-
var
|
|
680
|
+
var Ee = class extends _ {
|
|
568
681
|
predicate;
|
|
569
682
|
skipping = !0;
|
|
570
683
|
constructor(e, t) {
|
|
@@ -586,22 +699,36 @@ var ve = class extends m {
|
|
|
586
699
|
};
|
|
587
700
|
//#endregion
|
|
588
701
|
//#region src/functions/some.ts
|
|
589
|
-
function
|
|
590
|
-
if (
|
|
702
|
+
function De(e, t) {
|
|
703
|
+
if (l(e, "some"), t === void 0) {
|
|
591
704
|
for (let t of e) return !0;
|
|
592
705
|
return !1;
|
|
593
706
|
}
|
|
594
|
-
|
|
707
|
+
u(t, "predicate", "some");
|
|
595
708
|
let n = 0;
|
|
596
709
|
for (let r of e) if (t(r, n++)) return !0;
|
|
597
710
|
return !1;
|
|
598
711
|
}
|
|
599
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
|
|
600
727
|
//#region src/functions/take.ts
|
|
601
|
-
function
|
|
602
|
-
return
|
|
728
|
+
function ke(e, t) {
|
|
729
|
+
return l(e, "take"), d(t, "count", "take"), new g(() => new Ae(e, t));
|
|
603
730
|
}
|
|
604
|
-
var
|
|
731
|
+
var Ae = class extends _ {
|
|
605
732
|
count;
|
|
606
733
|
constructor(e, t) {
|
|
607
734
|
super(e), this.count = t;
|
|
@@ -614,10 +741,10 @@ var ye = class extends m {
|
|
|
614
741
|
};
|
|
615
742
|
//#endregion
|
|
616
743
|
//#region src/functions/takeWhile.ts
|
|
617
|
-
function
|
|
618
|
-
return
|
|
744
|
+
function je(e, t) {
|
|
745
|
+
return l(e, "takeWhile"), u(t, "predicate", "takeWhile"), new g(() => new Me(e, t));
|
|
619
746
|
}
|
|
620
|
-
var
|
|
747
|
+
var Me = class extends _ {
|
|
621
748
|
predicate;
|
|
622
749
|
constructor(e, t) {
|
|
623
750
|
super(e), this.predicate = t;
|
|
@@ -636,10 +763,10 @@ var be = class extends m {
|
|
|
636
763
|
};
|
|
637
764
|
//#endregion
|
|
638
765
|
//#region src/functions/tap.ts
|
|
639
|
-
function
|
|
640
|
-
return
|
|
766
|
+
function Ne(e, t) {
|
|
767
|
+
return l(e, "tap"), u(t, "tapper", "tap"), new g(() => new Pe(e, t));
|
|
641
768
|
}
|
|
642
|
-
var
|
|
769
|
+
var Pe = class extends _ {
|
|
643
770
|
tapper;
|
|
644
771
|
constructor(e, t) {
|
|
645
772
|
super(e), this.tapper = t;
|
|
@@ -657,41 +784,51 @@ var xe = class extends m {
|
|
|
657
784
|
};
|
|
658
785
|
//#endregion
|
|
659
786
|
//#region src/functions/tapChain.ts
|
|
660
|
-
function
|
|
661
|
-
return
|
|
787
|
+
function Fe(e, t) {
|
|
788
|
+
return l(e, "tapChain"), u(t, "tapper", "tapChain"), new g(() => (t(e, 0), e[Symbol.iterator]()));
|
|
662
789
|
}
|
|
663
790
|
//#endregion
|
|
664
791
|
//#region src/functions/index.ts
|
|
665
|
-
var
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
792
|
+
var Ie = /* @__PURE__ */ t({
|
|
793
|
+
at: () => f,
|
|
794
|
+
average: () => p,
|
|
795
|
+
collectToArray: () => m,
|
|
796
|
+
count: () => oe,
|
|
797
|
+
distinct: () => v,
|
|
798
|
+
empty: () => y,
|
|
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,
|
|
812
|
+
lastIndexOf: () => N,
|
|
813
|
+
map: () => P,
|
|
814
|
+
materialize: () => F,
|
|
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");
|
|
695
832
|
//#endregion
|
|
696
833
|
//#region src/linqIterable.ts
|
|
697
834
|
function Y(e) {
|
|
@@ -705,85 +842,115 @@ var X = class {
|
|
|
705
842
|
[Symbol.iterator]() {
|
|
706
843
|
return this.iterable[Symbol.iterator]();
|
|
707
844
|
}
|
|
845
|
+
at(e) {
|
|
846
|
+
return f(this.iterable, e);
|
|
847
|
+
}
|
|
848
|
+
average(e) {
|
|
849
|
+
return p(this.iterable, e);
|
|
850
|
+
}
|
|
708
851
|
collectToArray() {
|
|
709
|
-
return
|
|
852
|
+
return m(this.iterable);
|
|
710
853
|
}
|
|
711
854
|
count(e) {
|
|
712
|
-
return
|
|
855
|
+
return oe(this.iterable, e);
|
|
713
856
|
}
|
|
714
857
|
distinct(e) {
|
|
715
|
-
return Y(
|
|
858
|
+
return Y(v(this.iterable, e));
|
|
716
859
|
}
|
|
717
860
|
every(e) {
|
|
718
|
-
return
|
|
861
|
+
return ue(this.iterable, e);
|
|
719
862
|
}
|
|
720
863
|
filter(e) {
|
|
721
|
-
return Y(
|
|
864
|
+
return Y(b(this.iterable, e));
|
|
722
865
|
}
|
|
723
866
|
find(e) {
|
|
724
|
-
return
|
|
867
|
+
return x(this.iterable, e);
|
|
725
868
|
}
|
|
726
869
|
findIndex(e) {
|
|
727
|
-
return
|
|
870
|
+
return S(this.iterable, e);
|
|
871
|
+
}
|
|
872
|
+
findLast(e) {
|
|
873
|
+
return C(this.iterable, e);
|
|
874
|
+
}
|
|
875
|
+
findLastIndex(e) {
|
|
876
|
+
return w(this.iterable, e);
|
|
728
877
|
}
|
|
729
878
|
flatMap(e) {
|
|
730
|
-
return Y(
|
|
879
|
+
return Y(T(this.iterable, e));
|
|
731
880
|
}
|
|
732
881
|
forEach(e) {
|
|
733
|
-
return
|
|
882
|
+
return O(this.iterable, e);
|
|
734
883
|
}
|
|
735
884
|
forEachAsync(e) {
|
|
736
|
-
return
|
|
885
|
+
return k(this.iterable, e);
|
|
737
886
|
}
|
|
738
887
|
includes(e) {
|
|
739
|
-
return
|
|
888
|
+
return A(this.iterable, e);
|
|
889
|
+
}
|
|
890
|
+
indexOf(e) {
|
|
891
|
+
return j(this.iterable, e);
|
|
892
|
+
}
|
|
893
|
+
join(e) {
|
|
894
|
+
return M(this.iterable, e);
|
|
895
|
+
}
|
|
896
|
+
lastIndexOf(e) {
|
|
897
|
+
return N(this.iterable, e);
|
|
740
898
|
}
|
|
741
899
|
map(e) {
|
|
742
|
-
return Y(
|
|
900
|
+
return Y(P(this.iterable, e));
|
|
743
901
|
}
|
|
744
902
|
materialize() {
|
|
745
|
-
return Y(
|
|
903
|
+
return Y(F(this.iterable));
|
|
746
904
|
}
|
|
747
905
|
max(e) {
|
|
748
|
-
return
|
|
906
|
+
return L(this.iterable, e);
|
|
749
907
|
}
|
|
750
908
|
memoize(e) {
|
|
751
|
-
return Y(
|
|
909
|
+
return Y(z(this.iterable, e));
|
|
752
910
|
}
|
|
753
911
|
min(e) {
|
|
754
|
-
return
|
|
912
|
+
return G(this.iterable, e);
|
|
755
913
|
}
|
|
756
914
|
reduce(...e) {
|
|
757
|
-
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);
|
|
758
922
|
}
|
|
759
923
|
skip(e) {
|
|
760
|
-
return Y(
|
|
924
|
+
return Y(Ce(this.iterable, e));
|
|
761
925
|
}
|
|
762
926
|
skipWhile(e) {
|
|
763
|
-
return Y(
|
|
927
|
+
return Y(Te(this.iterable, e));
|
|
764
928
|
}
|
|
765
929
|
some(e) {
|
|
766
|
-
return
|
|
930
|
+
return De(this.iterable, e);
|
|
931
|
+
}
|
|
932
|
+
sum(e) {
|
|
933
|
+
return Oe(this.iterable, e);
|
|
767
934
|
}
|
|
768
935
|
take(e) {
|
|
769
|
-
return Y(
|
|
936
|
+
return Y(ke(this.iterable, e));
|
|
770
937
|
}
|
|
771
938
|
takeWhile(e) {
|
|
772
|
-
return Y(
|
|
939
|
+
return Y(je(this.iterable, e));
|
|
773
940
|
}
|
|
774
941
|
tap(e) {
|
|
775
|
-
return Y(
|
|
942
|
+
return Y(Ne(this.iterable, e));
|
|
776
943
|
}
|
|
777
944
|
tapChain(e) {
|
|
778
|
-
return Y(
|
|
945
|
+
return Y(Fe(this.iterable, e));
|
|
779
946
|
}
|
|
780
947
|
tapChainCreation(e) {
|
|
781
|
-
|
|
948
|
+
u(e, "chainCreationTapper", "tapChainCreation");
|
|
782
949
|
let t = this;
|
|
783
950
|
return e(t), t;
|
|
784
951
|
}
|
|
785
952
|
};
|
|
786
|
-
Object.defineProperty(X.prototype,
|
|
953
|
+
Object.defineProperty(X.prototype, Le, {
|
|
787
954
|
value: !0,
|
|
788
955
|
enumerable: !1,
|
|
789
956
|
writable: !1,
|
|
@@ -794,10 +961,10 @@ Object.defineProperty(X.prototype, J, {
|
|
|
794
961
|
function Z() {
|
|
795
962
|
return X.prototype;
|
|
796
963
|
}
|
|
797
|
-
function
|
|
798
|
-
return typeof e == "object" && !!e && e[
|
|
964
|
+
function Re(e) {
|
|
965
|
+
return typeof e == "object" && !!e && e[Le] === !0;
|
|
799
966
|
}
|
|
800
|
-
function
|
|
967
|
+
function Q(e, t) {
|
|
801
968
|
let n = Object.getOwnPropertyDescriptor(Z(), e);
|
|
802
969
|
Object.defineProperty(Z(), e, {
|
|
803
970
|
value: t,
|
|
@@ -806,34 +973,34 @@ function we(e, t) {
|
|
|
806
973
|
configurable: !0
|
|
807
974
|
});
|
|
808
975
|
}
|
|
809
|
-
function
|
|
810
|
-
|
|
811
|
-
}
|
|
812
|
-
function Te(e, t) {
|
|
813
|
-
if (Q(e, t), e in Y([])) throw Error(`"${e}" already exists on IIterableLinq: use override() to replace it`);
|
|
814
|
-
we(e, t);
|
|
976
|
+
function ze(e, t, n) {
|
|
977
|
+
re(t, "name", e), u(n, "implementation", e);
|
|
815
978
|
}
|
|
816
|
-
function
|
|
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`);
|
|
817
981
|
Q(e, t);
|
|
982
|
+
}
|
|
983
|
+
function Ve(e, t) {
|
|
984
|
+
ze("override", e, t);
|
|
818
985
|
let n = e;
|
|
819
|
-
if (!(n !== "constructor" && Object.prototype.hasOwnProperty.call(Z(), n))) throw
|
|
820
|
-
|
|
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);
|
|
821
988
|
}
|
|
822
989
|
//#endregion
|
|
823
990
|
//#region src/index.ts
|
|
824
|
-
function
|
|
825
|
-
return $(
|
|
991
|
+
function He() {
|
|
992
|
+
return $(y());
|
|
826
993
|
}
|
|
827
994
|
function $(e) {
|
|
828
|
-
return
|
|
995
|
+
return l(e, "from"), Y(e);
|
|
829
996
|
}
|
|
830
|
-
function
|
|
831
|
-
if (typeof t == "number") return $(
|
|
832
|
-
if (n !== void 0) throw
|
|
833
|
-
return $(
|
|
997
|
+
function Ue(e, t, n) {
|
|
998
|
+
if (typeof t == "number") return $(K(e, t, n));
|
|
999
|
+
if (n !== void 0) throw c("fromRange", "The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
1000
|
+
return $(K(e, t));
|
|
834
1001
|
}
|
|
835
|
-
function
|
|
836
|
-
return $(
|
|
1002
|
+
function We(e, t) {
|
|
1003
|
+
return $(J(e, t));
|
|
837
1004
|
}
|
|
838
1005
|
//#endregion
|
|
839
|
-
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 };
|