iterable-linq-utility 0.5.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 +189 -0
- package/dist/index.d.ts +189 -0
- package/dist/iterable-linq-utility.js +286 -209
- package/dist/iterable-linq-utility.umd.cjs +1 -1
- package/package.json +1 -1
|
@@ -49,51 +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
|
|
81
103
|
//#region src/functions/count.ts
|
|
82
|
-
function
|
|
83
|
-
|
|
104
|
+
function m(e, t) {
|
|
105
|
+
l(e, "count");
|
|
84
106
|
let n = 0;
|
|
85
107
|
if (t === void 0) {
|
|
86
108
|
for (let t of e) n++;
|
|
87
109
|
return n;
|
|
88
110
|
}
|
|
89
|
-
|
|
111
|
+
u(t, "predicate", "count");
|
|
90
112
|
let r = 0;
|
|
91
113
|
for (let i of e) t(i, r++) && n++;
|
|
92
114
|
return n;
|
|
93
115
|
}
|
|
94
116
|
//#endregion
|
|
95
117
|
//#region src/iterators/baseIterator.ts
|
|
96
|
-
var
|
|
118
|
+
var h = class {
|
|
97
119
|
done = !1;
|
|
98
120
|
next() {
|
|
99
121
|
if (this.done) return s();
|
|
@@ -115,7 +137,7 @@ var f = class {
|
|
|
115
137
|
} catch {}
|
|
116
138
|
}
|
|
117
139
|
}
|
|
118
|
-
},
|
|
140
|
+
}, g = class {
|
|
119
141
|
createIterator;
|
|
120
142
|
constructor(e) {
|
|
121
143
|
this.createIterator = e;
|
|
@@ -123,7 +145,7 @@ var f = class {
|
|
|
123
145
|
[Symbol.iterator]() {
|
|
124
146
|
return this.createIterator();
|
|
125
147
|
}
|
|
126
|
-
},
|
|
148
|
+
}, _ = class extends h {
|
|
127
149
|
source;
|
|
128
150
|
index = 0;
|
|
129
151
|
constructor(e) {
|
|
@@ -135,10 +157,10 @@ var f = class {
|
|
|
135
157
|
};
|
|
136
158
|
//#endregion
|
|
137
159
|
//#region src/iterators/unfold.ts
|
|
138
|
-
function
|
|
139
|
-
return new
|
|
160
|
+
function oe(e, t) {
|
|
161
|
+
return new g(() => new se(e, t));
|
|
140
162
|
}
|
|
141
|
-
var
|
|
163
|
+
var se = class extends h {
|
|
142
164
|
state;
|
|
143
165
|
step;
|
|
144
166
|
constructor(e, t) {
|
|
@@ -151,10 +173,10 @@ var ie = class extends f {
|
|
|
151
173
|
};
|
|
152
174
|
//#endregion
|
|
153
175
|
//#region src/functions/distinct.ts
|
|
154
|
-
function
|
|
155
|
-
return
|
|
176
|
+
function v(e, t) {
|
|
177
|
+
return l(e, "distinct"), t !== void 0 && u(t, "keySelector", "distinct"), new g(() => new ce(e, t));
|
|
156
178
|
}
|
|
157
|
-
var
|
|
179
|
+
var ce = class extends _ {
|
|
158
180
|
keySelector;
|
|
159
181
|
seen = /* @__PURE__ */ new Set();
|
|
160
182
|
constructor(e, t) {
|
|
@@ -175,23 +197,23 @@ var ae = class extends m {
|
|
|
175
197
|
};
|
|
176
198
|
//#endregion
|
|
177
199
|
//#region src/functions/empty.ts
|
|
178
|
-
function
|
|
179
|
-
return
|
|
200
|
+
function y() {
|
|
201
|
+
return oe(void 0, () => void 0);
|
|
180
202
|
}
|
|
181
203
|
//#endregion
|
|
182
204
|
//#region src/functions/every.ts
|
|
183
|
-
function
|
|
184
|
-
|
|
205
|
+
function b(e, t) {
|
|
206
|
+
l(e, "every"), u(t, "predicate", "every");
|
|
185
207
|
let n = 0;
|
|
186
208
|
for (let r of e) if (!t(r, n++)) return !1;
|
|
187
209
|
return !0;
|
|
188
210
|
}
|
|
189
211
|
//#endregion
|
|
190
212
|
//#region src/functions/filter.ts
|
|
191
|
-
function
|
|
192
|
-
return
|
|
213
|
+
function x(e, t) {
|
|
214
|
+
return l(e, "filter"), u(t, "predicate", "filter"), new g(() => new le(e, t));
|
|
193
215
|
}
|
|
194
|
-
var
|
|
216
|
+
var le = class extends _ {
|
|
195
217
|
predicate;
|
|
196
218
|
constructor(e, t) {
|
|
197
219
|
super(e), this.predicate = t;
|
|
@@ -211,15 +233,15 @@ var se = class extends m {
|
|
|
211
233
|
};
|
|
212
234
|
//#endregion
|
|
213
235
|
//#region src/functions/find.ts
|
|
214
|
-
function
|
|
215
|
-
|
|
236
|
+
function S(e, t) {
|
|
237
|
+
l(e, "find"), u(t, "predicate", "find");
|
|
216
238
|
let n = 0;
|
|
217
239
|
for (let r of e) if (t(r, n++)) return r;
|
|
218
240
|
}
|
|
219
241
|
//#endregion
|
|
220
242
|
//#region src/functions/findIndex.ts
|
|
221
|
-
function
|
|
222
|
-
|
|
243
|
+
function C(e, t) {
|
|
244
|
+
l(e, "findIndex"), u(t, "predicate", "findIndex");
|
|
223
245
|
let n = 0;
|
|
224
246
|
for (let r of e) {
|
|
225
247
|
if (t(r, n)) return n;
|
|
@@ -228,11 +250,27 @@ function b(e, t) {
|
|
|
228
250
|
return -1;
|
|
229
251
|
}
|
|
230
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
|
|
231
269
|
//#region src/functions/flatMap.ts
|
|
232
|
-
function
|
|
233
|
-
return
|
|
270
|
+
function E(e, t) {
|
|
271
|
+
return l(e, "flatMap"), u(t, "mapper", "flatMap"), new g(() => new ue(e, t));
|
|
234
272
|
}
|
|
235
|
-
var
|
|
273
|
+
var ue = class e extends _ {
|
|
236
274
|
mapper;
|
|
237
275
|
static steps = {
|
|
238
276
|
outer: (t) => {
|
|
@@ -293,7 +331,7 @@ var ce = class e extends m {
|
|
|
293
331
|
throw e.inner = void 0, e.closeAfterCallbackError(), t;
|
|
294
332
|
}
|
|
295
333
|
}
|
|
296
|
-
},
|
|
334
|
+
}, D = class e {
|
|
297
335
|
static instance = e.createFrozen();
|
|
298
336
|
constructor() {}
|
|
299
337
|
static createFrozen() {
|
|
@@ -301,37 +339,56 @@ var ce = class e extends m {
|
|
|
301
339
|
return Object.freeze(t), t;
|
|
302
340
|
}
|
|
303
341
|
};
|
|
304
|
-
function
|
|
305
|
-
return
|
|
342
|
+
function O() {
|
|
343
|
+
return D.instance;
|
|
306
344
|
}
|
|
307
345
|
//#endregion
|
|
308
346
|
//#region src/functions/forEach.ts
|
|
309
|
-
function
|
|
310
|
-
|
|
347
|
+
function k(e, t) {
|
|
348
|
+
l(e, "forEach"), u(t, "action", "forEach");
|
|
311
349
|
let n = 0;
|
|
312
350
|
for (let r of e) t(r, n++);
|
|
313
|
-
return
|
|
351
|
+
return O();
|
|
314
352
|
}
|
|
315
|
-
async function
|
|
316
|
-
|
|
353
|
+
async function A(e, t) {
|
|
354
|
+
l(e, "forEachAsync"), u(t, "action", "forEachAsync");
|
|
317
355
|
let n = 0;
|
|
318
356
|
for (let r of e) await t(r, n++);
|
|
319
|
-
return
|
|
357
|
+
return O();
|
|
320
358
|
}
|
|
321
359
|
//#endregion
|
|
322
360
|
//#region src/functions/includes.ts
|
|
323
|
-
function
|
|
324
|
-
|
|
361
|
+
function j(e, t) {
|
|
362
|
+
l(e, "includes");
|
|
325
363
|
let n = t !== t;
|
|
326
364
|
for (let r of e) if (r === t || n && r !== r) return !0;
|
|
327
365
|
return !1;
|
|
328
366
|
}
|
|
329
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;
|
|
385
|
+
}
|
|
386
|
+
//#endregion
|
|
330
387
|
//#region src/functions/map.ts
|
|
331
|
-
function
|
|
332
|
-
return
|
|
388
|
+
function P(e, t) {
|
|
389
|
+
return l(e, "map"), u(t, "mapper", "map"), new g(() => new de(e, t));
|
|
333
390
|
}
|
|
334
|
-
var
|
|
391
|
+
var de = class extends _ {
|
|
335
392
|
mapper;
|
|
336
393
|
constructor(e, t) {
|
|
337
394
|
super(e), this.mapper = t;
|
|
@@ -350,18 +407,18 @@ var le = class extends m {
|
|
|
350
407
|
};
|
|
351
408
|
//#endregion
|
|
352
409
|
//#region src/collections/linkedList.ts
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
let t = new
|
|
410
|
+
function fe(e) {
|
|
411
|
+
l(e, "LinkedList.from");
|
|
412
|
+
let t = new pe();
|
|
356
413
|
for (let n of e) t.addLast(n);
|
|
357
414
|
return t;
|
|
358
415
|
}
|
|
359
|
-
var
|
|
416
|
+
var pe = class {
|
|
360
417
|
internalSize = 0;
|
|
361
418
|
head = null;
|
|
362
419
|
tail = null;
|
|
363
420
|
[Symbol.iterator]() {
|
|
364
|
-
return new
|
|
421
|
+
return new me(this.head);
|
|
365
422
|
}
|
|
366
423
|
addFirst(e) {
|
|
367
424
|
let t = {
|
|
@@ -380,7 +437,7 @@ var de = class {
|
|
|
380
437
|
size() {
|
|
381
438
|
return this.internalSize;
|
|
382
439
|
}
|
|
383
|
-
},
|
|
440
|
+
}, me = class extends h {
|
|
384
441
|
current;
|
|
385
442
|
constructor(e) {
|
|
386
443
|
super(), this.current = e;
|
|
@@ -392,13 +449,13 @@ var de = class {
|
|
|
392
449
|
};
|
|
393
450
|
//#endregion
|
|
394
451
|
//#region src/functions/materialize.ts
|
|
395
|
-
function
|
|
396
|
-
return
|
|
452
|
+
function F(e) {
|
|
453
|
+
return l(e, "materialize"), e instanceof he ? e : new he(e);
|
|
397
454
|
}
|
|
398
|
-
var
|
|
455
|
+
var he = class {
|
|
399
456
|
source;
|
|
400
457
|
constructor(e) {
|
|
401
|
-
this.source =
|
|
458
|
+
this.source = fe(e);
|
|
402
459
|
}
|
|
403
460
|
[Symbol.iterator]() {
|
|
404
461
|
return this.source[Symbol.iterator]();
|
|
@@ -406,29 +463,29 @@ var k = class {
|
|
|
406
463
|
};
|
|
407
464
|
//#endregion
|
|
408
465
|
//#region src/functions/max.ts
|
|
409
|
-
function
|
|
410
|
-
return
|
|
466
|
+
function I(e, t) {
|
|
467
|
+
return l(e, "max"), a(e, i(t), 1);
|
|
411
468
|
}
|
|
412
469
|
//#endregion
|
|
413
470
|
//#region src/functions/memoize.ts
|
|
414
|
-
function
|
|
471
|
+
function L() {
|
|
415
472
|
return { allowPartialMemoization: !0 };
|
|
416
473
|
}
|
|
417
|
-
function
|
|
418
|
-
|
|
474
|
+
function R(e, t) {
|
|
475
|
+
l(e, "memoize");
|
|
419
476
|
let n = {
|
|
420
|
-
...
|
|
477
|
+
...L(),
|
|
421
478
|
...t
|
|
422
479
|
}.allowPartialMemoization;
|
|
423
|
-
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);
|
|
424
481
|
}
|
|
425
|
-
function
|
|
482
|
+
function z() {
|
|
426
483
|
return {
|
|
427
484
|
values: [],
|
|
428
485
|
finished: !1
|
|
429
486
|
};
|
|
430
487
|
}
|
|
431
|
-
function
|
|
488
|
+
function B(e, t) {
|
|
432
489
|
if (t.error) throw t.error.value;
|
|
433
490
|
if (t.finished) return !1;
|
|
434
491
|
t.source ??= e[Symbol.iterator]();
|
|
@@ -440,31 +497,31 @@ function pe(e, t) {
|
|
|
440
497
|
}
|
|
441
498
|
return n.done === !0 ? (t.finished = !0, t.source = void 0, !1) : (t.values.push(n.value), !0);
|
|
442
499
|
}
|
|
443
|
-
var
|
|
500
|
+
var V = class {
|
|
444
501
|
source;
|
|
445
|
-
cache =
|
|
502
|
+
cache = z();
|
|
446
503
|
constructor(e) {
|
|
447
504
|
this.source = e;
|
|
448
505
|
}
|
|
449
506
|
[Symbol.iterator]() {
|
|
450
|
-
return new
|
|
507
|
+
return new U(this.source, this.cache, !0);
|
|
451
508
|
}
|
|
452
509
|
changePartialMemoizationBehaviour() {
|
|
453
|
-
return new
|
|
510
|
+
return new H(this.source);
|
|
454
511
|
}
|
|
455
|
-
},
|
|
512
|
+
}, H = class {
|
|
456
513
|
source;
|
|
457
|
-
cache =
|
|
514
|
+
cache = z();
|
|
458
515
|
constructor(e) {
|
|
459
516
|
this.source = e;
|
|
460
517
|
}
|
|
461
518
|
[Symbol.iterator]() {
|
|
462
|
-
return new
|
|
519
|
+
return new U(this.source, this.cache, !1);
|
|
463
520
|
}
|
|
464
521
|
changePartialMemoizationBehaviour() {
|
|
465
|
-
return new
|
|
522
|
+
return new V(this.source);
|
|
466
523
|
}
|
|
467
|
-
},
|
|
524
|
+
}, U = class extends h {
|
|
468
525
|
source;
|
|
469
526
|
cache;
|
|
470
527
|
drainFirst;
|
|
@@ -473,28 +530,28 @@ var P = class {
|
|
|
473
530
|
super(), this.source = e, this.cache = t, this.drainFirst = n;
|
|
474
531
|
}
|
|
475
532
|
advance() {
|
|
476
|
-
if (this.drainFirst) for (;
|
|
477
|
-
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();
|
|
478
535
|
}
|
|
479
536
|
};
|
|
480
537
|
//#endregion
|
|
481
538
|
//#region src/functions/min.ts
|
|
482
|
-
function
|
|
483
|
-
return
|
|
539
|
+
function W(e, t) {
|
|
540
|
+
return l(e, "min"), a(e, i(t), -1);
|
|
484
541
|
}
|
|
485
542
|
//#endregion
|
|
486
543
|
//#region src/functions/range.ts
|
|
487
|
-
function
|
|
544
|
+
function G(e, t, n) {
|
|
488
545
|
let r = typeof t == "number", i = r ? e : 0, a = r ? t : e;
|
|
489
|
-
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");
|
|
490
547
|
let o = r ? n : t;
|
|
491
|
-
o !== void 0 &&
|
|
492
|
-
let { step: s = 1, reverse:
|
|
493
|
-
|
|
494
|
-
let
|
|
495
|
-
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();
|
|
496
553
|
}
|
|
497
|
-
function
|
|
554
|
+
function ge(e, t, n, r) {
|
|
498
555
|
let i = t < e ? -n : n, a = Math.ceil(Math.abs(t - e) / n);
|
|
499
556
|
return r ? {
|
|
500
557
|
first: e + (a - 1) * i,
|
|
@@ -506,7 +563,7 @@ function me(e, t, n, r) {
|
|
|
506
563
|
length: a
|
|
507
564
|
};
|
|
508
565
|
}
|
|
509
|
-
var
|
|
566
|
+
var _e = class extends h {
|
|
510
567
|
first;
|
|
511
568
|
step;
|
|
512
569
|
length;
|
|
@@ -520,32 +577,32 @@ var he = class extends f {
|
|
|
520
577
|
};
|
|
521
578
|
//#endregion
|
|
522
579
|
//#region src/functions/reduce.ts
|
|
523
|
-
function
|
|
524
|
-
if (
|
|
580
|
+
function K(e, ...t) {
|
|
581
|
+
if (l(e, "reduce"), t.length === 1) return ve(e, t[0]);
|
|
525
582
|
let [n, r] = t;
|
|
526
|
-
|
|
583
|
+
u(r, "reducer", "reduce");
|
|
527
584
|
let i = n, a = 0;
|
|
528
585
|
for (let t of e) i = r(i, t, a++);
|
|
529
586
|
return i;
|
|
530
587
|
}
|
|
531
|
-
function
|
|
532
|
-
|
|
588
|
+
function ve(e, t) {
|
|
589
|
+
u(t, "reducer", "reduce");
|
|
533
590
|
let n, r = 0;
|
|
534
591
|
for (let i of e) n = r === 0 ? i : t(n, i, r), r++;
|
|
535
|
-
if (r === 0) throw
|
|
592
|
+
if (r === 0) throw c("reduce", "The \"sourceIterable\" must not be empty when \"reduce\" has no seed");
|
|
536
593
|
return n;
|
|
537
594
|
}
|
|
538
595
|
//#endregion
|
|
539
596
|
//#region src/functions/repeat.ts
|
|
540
|
-
function
|
|
541
|
-
return
|
|
597
|
+
function q(e, t) {
|
|
598
|
+
return d(t, "count", "repeat"), oe(t, (t) => t > 0 ? [e, t - 1] : void 0);
|
|
542
599
|
}
|
|
543
600
|
//#endregion
|
|
544
601
|
//#region src/functions/skip.ts
|
|
545
|
-
function
|
|
546
|
-
return
|
|
602
|
+
function J(e, t) {
|
|
603
|
+
return l(e, "skip"), d(t, "count", "skip"), new g(() => new ye(e, t));
|
|
547
604
|
}
|
|
548
|
-
var
|
|
605
|
+
var ye = class extends _ {
|
|
549
606
|
count;
|
|
550
607
|
constructor(e, t) {
|
|
551
608
|
super(e), this.count = t;
|
|
@@ -561,10 +618,10 @@ var _e = class extends m {
|
|
|
561
618
|
};
|
|
562
619
|
//#endregion
|
|
563
620
|
//#region src/functions/skipWhile.ts
|
|
564
|
-
function
|
|
565
|
-
return
|
|
621
|
+
function Y(e, t) {
|
|
622
|
+
return l(e, "skipWhile"), u(t, "predicate", "skipWhile"), new g(() => new be(e, t));
|
|
566
623
|
}
|
|
567
|
-
var
|
|
624
|
+
var be = class extends _ {
|
|
568
625
|
predicate;
|
|
569
626
|
skipping = !0;
|
|
570
627
|
constructor(e, t) {
|
|
@@ -586,22 +643,22 @@ var ve = class extends m {
|
|
|
586
643
|
};
|
|
587
644
|
//#endregion
|
|
588
645
|
//#region src/functions/some.ts
|
|
589
|
-
function
|
|
590
|
-
if (
|
|
646
|
+
function xe(e, t) {
|
|
647
|
+
if (l(e, "some"), t === void 0) {
|
|
591
648
|
for (let t of e) return !0;
|
|
592
649
|
return !1;
|
|
593
650
|
}
|
|
594
|
-
|
|
651
|
+
u(t, "predicate", "some");
|
|
595
652
|
let n = 0;
|
|
596
653
|
for (let r of e) if (t(r, n++)) return !0;
|
|
597
654
|
return !1;
|
|
598
655
|
}
|
|
599
656
|
//#endregion
|
|
600
657
|
//#region src/functions/take.ts
|
|
601
|
-
function
|
|
602
|
-
return
|
|
658
|
+
function Se(e, t) {
|
|
659
|
+
return l(e, "take"), d(t, "count", "take"), new g(() => new Ce(e, t));
|
|
603
660
|
}
|
|
604
|
-
var
|
|
661
|
+
var Ce = class extends _ {
|
|
605
662
|
count;
|
|
606
663
|
constructor(e, t) {
|
|
607
664
|
super(e), this.count = t;
|
|
@@ -614,10 +671,10 @@ var ye = class extends m {
|
|
|
614
671
|
};
|
|
615
672
|
//#endregion
|
|
616
673
|
//#region src/functions/takeWhile.ts
|
|
617
|
-
function
|
|
618
|
-
return
|
|
674
|
+
function we(e, t) {
|
|
675
|
+
return l(e, "takeWhile"), u(t, "predicate", "takeWhile"), new g(() => new Te(e, t));
|
|
619
676
|
}
|
|
620
|
-
var
|
|
677
|
+
var Te = class extends _ {
|
|
621
678
|
predicate;
|
|
622
679
|
constructor(e, t) {
|
|
623
680
|
super(e), this.predicate = t;
|
|
@@ -636,10 +693,10 @@ var be = class extends m {
|
|
|
636
693
|
};
|
|
637
694
|
//#endregion
|
|
638
695
|
//#region src/functions/tap.ts
|
|
639
|
-
function
|
|
640
|
-
return
|
|
696
|
+
function Ee(e, t) {
|
|
697
|
+
return l(e, "tap"), u(t, "tapper", "tap"), new g(() => new De(e, t));
|
|
641
698
|
}
|
|
642
|
-
var
|
|
699
|
+
var De = class extends _ {
|
|
643
700
|
tapper;
|
|
644
701
|
constructor(e, t) {
|
|
645
702
|
super(e), this.tapper = t;
|
|
@@ -657,47 +714,52 @@ var xe = class extends m {
|
|
|
657
714
|
};
|
|
658
715
|
//#endregion
|
|
659
716
|
//#region src/functions/tapChain.ts
|
|
660
|
-
function
|
|
661
|
-
return
|
|
717
|
+
function Oe(e, t) {
|
|
718
|
+
return l(e, "tapChain"), u(t, "tapper", "tapChain"), new g(() => (t(e, 0), e[Symbol.iterator]()));
|
|
662
719
|
}
|
|
663
720
|
//#endregion
|
|
664
721
|
//#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
|
-
|
|
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");
|
|
695
757
|
//#endregion
|
|
696
758
|
//#region src/linqIterable.ts
|
|
697
|
-
function
|
|
698
|
-
return new
|
|
759
|
+
function X(e) {
|
|
760
|
+
return new Z(e);
|
|
699
761
|
}
|
|
700
|
-
var
|
|
762
|
+
var Z = class {
|
|
701
763
|
iterable;
|
|
702
764
|
constructor(e) {
|
|
703
765
|
this.iterable = e;
|
|
@@ -705,85 +767,100 @@ var X = class {
|
|
|
705
767
|
[Symbol.iterator]() {
|
|
706
768
|
return this.iterable[Symbol.iterator]();
|
|
707
769
|
}
|
|
770
|
+
at(e) {
|
|
771
|
+
return f(this.iterable, e);
|
|
772
|
+
}
|
|
708
773
|
collectToArray() {
|
|
709
|
-
return
|
|
774
|
+
return p(this.iterable);
|
|
710
775
|
}
|
|
711
776
|
count(e) {
|
|
712
|
-
return
|
|
777
|
+
return m(this.iterable, e);
|
|
713
778
|
}
|
|
714
779
|
distinct(e) {
|
|
715
|
-
return
|
|
780
|
+
return X(v(this.iterable, e));
|
|
716
781
|
}
|
|
717
782
|
every(e) {
|
|
718
|
-
return
|
|
783
|
+
return b(this.iterable, e);
|
|
719
784
|
}
|
|
720
785
|
filter(e) {
|
|
721
|
-
return
|
|
786
|
+
return X(x(this.iterable, e));
|
|
722
787
|
}
|
|
723
788
|
find(e) {
|
|
724
|
-
return
|
|
789
|
+
return S(this.iterable, e);
|
|
725
790
|
}
|
|
726
791
|
findIndex(e) {
|
|
727
|
-
return
|
|
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);
|
|
728
799
|
}
|
|
729
800
|
flatMap(e) {
|
|
730
|
-
return
|
|
801
|
+
return X(E(this.iterable, e));
|
|
731
802
|
}
|
|
732
803
|
forEach(e) {
|
|
733
|
-
return
|
|
804
|
+
return k(this.iterable, e);
|
|
734
805
|
}
|
|
735
806
|
forEachAsync(e) {
|
|
736
|
-
return
|
|
807
|
+
return A(this.iterable, e);
|
|
737
808
|
}
|
|
738
809
|
includes(e) {
|
|
739
|
-
return
|
|
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);
|
|
740
817
|
}
|
|
741
818
|
map(e) {
|
|
742
|
-
return
|
|
819
|
+
return X(P(this.iterable, e));
|
|
743
820
|
}
|
|
744
821
|
materialize() {
|
|
745
|
-
return
|
|
822
|
+
return X(F(this.iterable));
|
|
746
823
|
}
|
|
747
824
|
max(e) {
|
|
748
|
-
return
|
|
825
|
+
return I(this.iterable, e);
|
|
749
826
|
}
|
|
750
827
|
memoize(e) {
|
|
751
|
-
return
|
|
828
|
+
return X(R(this.iterable, e));
|
|
752
829
|
}
|
|
753
830
|
min(e) {
|
|
754
|
-
return
|
|
831
|
+
return W(this.iterable, e);
|
|
755
832
|
}
|
|
756
833
|
reduce(...e) {
|
|
757
|
-
return e.length === 1 ?
|
|
834
|
+
return e.length === 1 ? K(this.iterable, e[0]) : K(this.iterable, e[0], e[1]);
|
|
758
835
|
}
|
|
759
836
|
skip(e) {
|
|
760
|
-
return
|
|
837
|
+
return X(J(this.iterable, e));
|
|
761
838
|
}
|
|
762
839
|
skipWhile(e) {
|
|
763
|
-
return Y(
|
|
840
|
+
return X(Y(this.iterable, e));
|
|
764
841
|
}
|
|
765
842
|
some(e) {
|
|
766
|
-
return
|
|
843
|
+
return xe(this.iterable, e);
|
|
767
844
|
}
|
|
768
845
|
take(e) {
|
|
769
|
-
return
|
|
846
|
+
return X(Se(this.iterable, e));
|
|
770
847
|
}
|
|
771
848
|
takeWhile(e) {
|
|
772
|
-
return
|
|
849
|
+
return X(we(this.iterable, e));
|
|
773
850
|
}
|
|
774
851
|
tap(e) {
|
|
775
|
-
return
|
|
852
|
+
return X(Ee(this.iterable, e));
|
|
776
853
|
}
|
|
777
854
|
tapChain(e) {
|
|
778
|
-
return
|
|
855
|
+
return X(Oe(this.iterable, e));
|
|
779
856
|
}
|
|
780
857
|
tapChainCreation(e) {
|
|
781
|
-
|
|
858
|
+
u(e, "chainCreationTapper", "tapChainCreation");
|
|
782
859
|
let t = this;
|
|
783
860
|
return e(t), t;
|
|
784
861
|
}
|
|
785
862
|
};
|
|
786
|
-
Object.defineProperty(
|
|
863
|
+
Object.defineProperty(Z.prototype, Ae, {
|
|
787
864
|
value: !0,
|
|
788
865
|
enumerable: !1,
|
|
789
866
|
writable: !1,
|
|
@@ -791,49 +868,49 @@ Object.defineProperty(X.prototype, J, {
|
|
|
791
868
|
});
|
|
792
869
|
//#endregion
|
|
793
870
|
//#region src/extension.ts
|
|
794
|
-
function
|
|
795
|
-
return
|
|
871
|
+
function Q() {
|
|
872
|
+
return Z.prototype;
|
|
796
873
|
}
|
|
797
|
-
function
|
|
798
|
-
return typeof e == "object" && !!e && e[
|
|
874
|
+
function je(e) {
|
|
875
|
+
return typeof e == "object" && !!e && e[Ae] === !0;
|
|
799
876
|
}
|
|
800
|
-
function
|
|
801
|
-
let n = Object.getOwnPropertyDescriptor(
|
|
802
|
-
Object.defineProperty(
|
|
877
|
+
function Me(e, t) {
|
|
878
|
+
let n = Object.getOwnPropertyDescriptor(Q(), e);
|
|
879
|
+
Object.defineProperty(Q(), e, {
|
|
803
880
|
value: t,
|
|
804
881
|
enumerable: !1,
|
|
805
882
|
writable: n?.writable ?? !1,
|
|
806
883
|
configurable: !0
|
|
807
884
|
});
|
|
808
885
|
}
|
|
809
|
-
function
|
|
810
|
-
|
|
886
|
+
function Ne(e, t, n) {
|
|
887
|
+
re(t, "name", e), u(n, "implementation", e);
|
|
811
888
|
}
|
|
812
|
-
function
|
|
813
|
-
if (
|
|
814
|
-
|
|
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);
|
|
815
892
|
}
|
|
816
|
-
function
|
|
817
|
-
|
|
893
|
+
function Fe(e, t) {
|
|
894
|
+
Ne("override", e, t);
|
|
818
895
|
let n = e;
|
|
819
|
-
if (!(n !== "constructor" && Object.prototype.hasOwnProperty.call(
|
|
820
|
-
|
|
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);
|
|
821
898
|
}
|
|
822
899
|
//#endregion
|
|
823
900
|
//#region src/index.ts
|
|
824
|
-
function
|
|
825
|
-
return $(
|
|
901
|
+
function Ie() {
|
|
902
|
+
return $(y());
|
|
826
903
|
}
|
|
827
904
|
function $(e) {
|
|
828
|
-
return
|
|
905
|
+
return l(e, "from"), X(e);
|
|
829
906
|
}
|
|
830
|
-
function
|
|
831
|
-
if (typeof t == "number") return $(
|
|
832
|
-
if (n !== void 0) throw
|
|
833
|
-
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));
|
|
834
911
|
}
|
|
835
|
-
function
|
|
836
|
-
return $(
|
|
912
|
+
function Re(e, t) {
|
|
913
|
+
return $(q(e, t));
|
|
837
914
|
}
|
|
838
915
|
//#endregion
|
|
839
|
-
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 };
|