iterable-linq-utility 0.0.11 → 0.0.13
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.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IterableLinqWrapper, type IIterableLinq } from
|
|
2
|
-
import * as Functions from '
|
|
3
|
-
import * as Types from '@/types';
|
|
1
|
+
import { IterableLinqWrapper, type IIterableLinq } from './linqIterable';
|
|
2
|
+
import * as Functions from './functions';
|
|
4
3
|
export declare function empty<T>(): IIterableLinq<T>;
|
|
5
4
|
export declare function from<T>(iterable: Iterable<T>): IIterableLinq<T>;
|
|
6
5
|
export declare function fromRange(end: number): IIterableLinq<number>;
|
|
@@ -11,4 +10,5 @@ export declare function fromRange(start: number, end: number, reverse: boolean):
|
|
|
11
10
|
export declare function fromRange(start: number, end: number, step: number, reverse: boolean): IIterableLinq<number>;
|
|
12
11
|
export declare function fromRange(start: number, end?: number | boolean, step?: number | boolean, reverse?: boolean): Iterable<number>;
|
|
13
12
|
export declare function repeat<T>(value: T, count: number): IIterableLinq<T>;
|
|
14
|
-
export { Functions, IIterableLinq, IterableLinqWrapper,
|
|
13
|
+
export { Functions, IIterableLinq, IterableLinqWrapper, };
|
|
14
|
+
export * from './types';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (e, t, r) => (
|
|
4
|
-
function
|
|
1
|
+
var $ = Object.defineProperty;
|
|
2
|
+
var B = (e, t, r) => t in e ? $(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var n = (e, t, r) => (B(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
+
function D(e) {
|
|
5
5
|
if (e == null)
|
|
6
6
|
throw 'The source "iterable" must be provided';
|
|
7
7
|
return Array.from(e);
|
|
@@ -12,7 +12,7 @@ function m(e, t) {
|
|
|
12
12
|
value: t
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function U(e) {
|
|
16
16
|
return { done: !1, value: e };
|
|
17
17
|
}
|
|
18
18
|
function l(e) {
|
|
@@ -21,7 +21,7 @@ function l(e) {
|
|
|
21
21
|
function d(e) {
|
|
22
22
|
return typeof e == "function";
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function y() {
|
|
25
25
|
return new G();
|
|
26
26
|
}
|
|
27
27
|
class G {
|
|
@@ -37,7 +37,7 @@ class H {
|
|
|
37
37
|
return l(t);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function S(e, t) {
|
|
41
41
|
if (e == null)
|
|
42
42
|
throw 'The source "iterable" must be provided';
|
|
43
43
|
if (!d(t))
|
|
@@ -75,7 +75,7 @@ class K {
|
|
|
75
75
|
return this.internalNext = l, l(t);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function N(e, t) {
|
|
79
79
|
if (e == null)
|
|
80
80
|
throw 'The source "iterable" must be provided';
|
|
81
81
|
if (!d(t))
|
|
@@ -108,7 +108,7 @@ class X {
|
|
|
108
108
|
});
|
|
109
109
|
n(this, "fmNext", () => {
|
|
110
110
|
const t = this.fmIterator.next();
|
|
111
|
-
return t.done !== !0 ?
|
|
111
|
+
return t.done !== !0 ? U(t.value) : (this.internalNext = this.sourceNext, this.internalNext());
|
|
112
112
|
});
|
|
113
113
|
n(this, "internalNext", this.sourceNext);
|
|
114
114
|
this.sourceIterator = t[Symbol.iterator](), this.mapper = r;
|
|
@@ -120,19 +120,14 @@ class X {
|
|
|
120
120
|
return this.internalNext = l, l(t);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
class
|
|
123
|
+
class Y {
|
|
124
124
|
}
|
|
125
|
-
const
|
|
126
|
-
Object.freeze(
|
|
127
|
-
function
|
|
128
|
-
return
|
|
125
|
+
const g = new Y();
|
|
126
|
+
Object.freeze(g);
|
|
127
|
+
function z() {
|
|
128
|
+
return g;
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
__proto__: null,
|
|
132
|
-
Unit: z,
|
|
133
|
-
unit: b
|
|
134
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
135
|
-
function T(e, t) {
|
|
130
|
+
function M(e, t) {
|
|
136
131
|
if (e == null)
|
|
137
132
|
throw 'The source "iterable" must be provided';
|
|
138
133
|
if (!d(t))
|
|
@@ -140,9 +135,9 @@ function T(e, t) {
|
|
|
140
135
|
const r = e[Symbol.iterator]();
|
|
141
136
|
for (let i = r.next(), s = 0; i.done !== !0; i = r.next(), s++)
|
|
142
137
|
t(i.value, s);
|
|
143
|
-
return
|
|
138
|
+
return z();
|
|
144
139
|
}
|
|
145
|
-
async function
|
|
140
|
+
async function T(e, t) {
|
|
146
141
|
if (e == null)
|
|
147
142
|
throw 'The source "iterable" must be provided';
|
|
148
143
|
if (!d(t))
|
|
@@ -150,26 +145,26 @@ async function A(e, t) {
|
|
|
150
145
|
const r = [], i = e[Symbol.iterator]();
|
|
151
146
|
for (let s = i.next(), u = 0; s.done !== !0; s = i.next(), u++)
|
|
152
147
|
r.push(t(s.value, u));
|
|
153
|
-
return await Promise.all(r),
|
|
148
|
+
return await Promise.all(r), z();
|
|
154
149
|
}
|
|
155
|
-
function
|
|
150
|
+
function A(e, t) {
|
|
156
151
|
if (e == null)
|
|
157
152
|
throw 'The source "iterable" must be provided';
|
|
158
153
|
if (!d(t))
|
|
159
154
|
throw '"mapper" function must be provided';
|
|
160
|
-
return new
|
|
155
|
+
return new Z(e, t);
|
|
161
156
|
}
|
|
162
|
-
class
|
|
157
|
+
class Z {
|
|
163
158
|
constructor(t, r) {
|
|
164
159
|
n(this, "mapper");
|
|
165
160
|
n(this, "source");
|
|
166
161
|
this.source = t, this.mapper = r;
|
|
167
162
|
}
|
|
168
163
|
[Symbol.iterator]() {
|
|
169
|
-
return new
|
|
164
|
+
return new _(this.source, this.mapper);
|
|
170
165
|
}
|
|
171
166
|
}
|
|
172
|
-
class
|
|
167
|
+
class _ {
|
|
173
168
|
constructor(t, r) {
|
|
174
169
|
n(this, "index", 0);
|
|
175
170
|
n(this, "sourceIterator");
|
|
@@ -248,10 +243,10 @@ class W {
|
|
|
248
243
|
return t === null ? l() : (this.current = t.nextNode, m(!1, t.data));
|
|
249
244
|
}
|
|
250
245
|
}
|
|
251
|
-
function
|
|
252
|
-
return e instanceof
|
|
246
|
+
function R(e) {
|
|
247
|
+
return e instanceof v ? e : new v(e);
|
|
253
248
|
}
|
|
254
|
-
class
|
|
249
|
+
class v {
|
|
255
250
|
constructor(t) {
|
|
256
251
|
n(this, "source");
|
|
257
252
|
this.source = q(t);
|
|
@@ -269,7 +264,7 @@ class tt {
|
|
|
269
264
|
return this.sourceIterator.next();
|
|
270
265
|
}
|
|
271
266
|
}
|
|
272
|
-
function
|
|
267
|
+
function k(e, t) {
|
|
273
268
|
if (e == null)
|
|
274
269
|
throw 'The source "iterable" must be provided';
|
|
275
270
|
const r = e[Symbol.iterator]();
|
|
@@ -286,10 +281,10 @@ function L(e, t) {
|
|
|
286
281
|
}
|
|
287
282
|
return s == null ? null : s;
|
|
288
283
|
}
|
|
289
|
-
function
|
|
290
|
-
return e instanceof
|
|
284
|
+
function L(e) {
|
|
285
|
+
return e instanceof I ? e : new I(e);
|
|
291
286
|
}
|
|
292
|
-
class
|
|
287
|
+
class I {
|
|
293
288
|
constructor(t) {
|
|
294
289
|
n(this, "isMemoized", !1);
|
|
295
290
|
n(this, "sourceIterator");
|
|
@@ -326,7 +321,7 @@ class rt {
|
|
|
326
321
|
return this.memoizedSourceIterator.next();
|
|
327
322
|
}
|
|
328
323
|
}
|
|
329
|
-
function
|
|
324
|
+
function F(e, t) {
|
|
330
325
|
if (e == null)
|
|
331
326
|
throw 'The source "iterable" must be provided';
|
|
332
327
|
const r = e[Symbol.iterator]();
|
|
@@ -343,9 +338,9 @@ function E(e, t) {
|
|
|
343
338
|
}
|
|
344
339
|
return s == null ? null : s;
|
|
345
340
|
}
|
|
346
|
-
function
|
|
347
|
-
const s = t == null || t === !0 || t === !1 ? e : t, u = t == null || t === !0 || t === !1 ? 0 : e, o = u < s, a = r !== !0 && r !== !1 && r != null && r !== 0 ? r : o ? 1 : -1, c = o && a < 0 || !o && a > 0 ? -1 * a : a, h = Math.ceil(Math.abs(s - u) / Math.abs(c)),
|
|
348
|
-
return u === s ? new ut(p, 0, 0) :
|
|
341
|
+
function E(e, t, r, i) {
|
|
342
|
+
const s = t == null || t === !0 || t === !1 ? e : t, u = t == null || t === !0 || t === !1 ? 0 : e, o = u < s, a = r !== !0 && r !== !1 && r != null && r !== 0 ? r : o ? 1 : -1, c = o && a < 0 || !o && a > 0 ? -1 * a : a, h = Math.ceil(Math.abs(s - u) / Math.abs(c)), w = !!(t === !0 || r === !0 || i != null && i), p = w ? h * c + u : u;
|
|
343
|
+
return u === s ? new ut(p, 0, 0) : w ? new st(p, h, c) : new nt(p, h, c);
|
|
349
344
|
}
|
|
350
345
|
class nt {
|
|
351
346
|
constructor(t, r, i) {
|
|
@@ -415,7 +410,7 @@ class at {
|
|
|
415
410
|
return l();
|
|
416
411
|
}
|
|
417
412
|
}
|
|
418
|
-
function
|
|
413
|
+
function V(e, t, r) {
|
|
419
414
|
if (e == null)
|
|
420
415
|
throw 'The source "iterable" must be provided';
|
|
421
416
|
if (!d(r))
|
|
@@ -456,7 +451,7 @@ class ht {
|
|
|
456
451
|
return this.internalNext = l, l(t);
|
|
457
452
|
}
|
|
458
453
|
}
|
|
459
|
-
function
|
|
454
|
+
function j(e, t) {
|
|
460
455
|
if (e == null)
|
|
461
456
|
throw 'The source "iterable" must be provided';
|
|
462
457
|
if (!d(t))
|
|
@@ -468,7 +463,7 @@ function O(e, t) {
|
|
|
468
463
|
return !0;
|
|
469
464
|
return !1;
|
|
470
465
|
}
|
|
471
|
-
function
|
|
466
|
+
function O(e, t) {
|
|
472
467
|
if (e == null)
|
|
473
468
|
throw 'The source "iterable" must be provided';
|
|
474
469
|
if (!d(t))
|
|
@@ -503,7 +498,7 @@ class dt {
|
|
|
503
498
|
return this.internalNext = l, l(t);
|
|
504
499
|
}
|
|
505
500
|
}
|
|
506
|
-
function
|
|
501
|
+
function P(e, t) {
|
|
507
502
|
if (e == null)
|
|
508
503
|
throw 'The source "iterable" must be provided';
|
|
509
504
|
if (!d(t))
|
|
@@ -520,25 +515,25 @@ class ft {
|
|
|
520
515
|
return this.tapper(this.source, 0), this.source[Symbol.iterator]();
|
|
521
516
|
}
|
|
522
517
|
}
|
|
523
|
-
const
|
|
518
|
+
const pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
524
519
|
__proto__: null,
|
|
525
|
-
collectToArray:
|
|
526
|
-
empty:
|
|
527
|
-
filter:
|
|
528
|
-
flatMap:
|
|
529
|
-
forEach:
|
|
530
|
-
forEachAsync:
|
|
531
|
-
map:
|
|
532
|
-
materialize:
|
|
533
|
-
max:
|
|
534
|
-
memoize:
|
|
535
|
-
min:
|
|
536
|
-
range:
|
|
537
|
-
reduce:
|
|
520
|
+
collectToArray: D,
|
|
521
|
+
empty: y,
|
|
522
|
+
filter: S,
|
|
523
|
+
flatMap: N,
|
|
524
|
+
forEach: M,
|
|
525
|
+
forEachAsync: T,
|
|
526
|
+
map: A,
|
|
527
|
+
materialize: R,
|
|
528
|
+
max: k,
|
|
529
|
+
memoize: L,
|
|
530
|
+
min: F,
|
|
531
|
+
range: E,
|
|
532
|
+
reduce: V,
|
|
538
533
|
repeat: C,
|
|
539
|
-
some:
|
|
540
|
-
tap:
|
|
541
|
-
tapChain:
|
|
534
|
+
some: j,
|
|
535
|
+
tap: O,
|
|
536
|
+
tapChain: P
|
|
542
537
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
543
538
|
class f {
|
|
544
539
|
constructor(t) {
|
|
@@ -552,43 +547,43 @@ class f {
|
|
|
552
547
|
return Array.from(this.iterable);
|
|
553
548
|
}
|
|
554
549
|
filter(t) {
|
|
555
|
-
return new f(
|
|
550
|
+
return new f(S(this.iterable, t));
|
|
556
551
|
}
|
|
557
552
|
flatMap(t) {
|
|
558
|
-
return new f(
|
|
553
|
+
return new f(N(this.iterable, t));
|
|
559
554
|
}
|
|
560
555
|
forEach(t) {
|
|
561
|
-
return
|
|
556
|
+
return M(this.iterable, t);
|
|
562
557
|
}
|
|
563
558
|
forEachAsync(t) {
|
|
564
|
-
return
|
|
559
|
+
return T(this.iterable, t);
|
|
565
560
|
}
|
|
566
561
|
map(t) {
|
|
567
|
-
return new f(
|
|
562
|
+
return new f(A(this.iterable, t));
|
|
568
563
|
}
|
|
569
564
|
materialize() {
|
|
570
|
-
return new f(
|
|
565
|
+
return new f(R(this.iterable));
|
|
571
566
|
}
|
|
572
567
|
max(t) {
|
|
573
|
-
return
|
|
568
|
+
return k(this.iterable, t);
|
|
574
569
|
}
|
|
575
570
|
memoize() {
|
|
576
|
-
return new f(
|
|
571
|
+
return new f(L(this.iterable));
|
|
577
572
|
}
|
|
578
573
|
min(t) {
|
|
579
|
-
return
|
|
574
|
+
return F(this.iterable, t);
|
|
580
575
|
}
|
|
581
576
|
reduce(t, r) {
|
|
582
|
-
return
|
|
577
|
+
return V(this.iterable, t, r);
|
|
583
578
|
}
|
|
584
579
|
some(t) {
|
|
585
|
-
return
|
|
580
|
+
return j(this.iterable, t);
|
|
586
581
|
}
|
|
587
582
|
tap(t) {
|
|
588
|
-
return new f(
|
|
583
|
+
return new f(O(this.iterable, t));
|
|
589
584
|
}
|
|
590
585
|
tapChain(t) {
|
|
591
|
-
return new f(
|
|
586
|
+
return new f(P(this.iterable, t));
|
|
592
587
|
}
|
|
593
588
|
tapChainCreation(t) {
|
|
594
589
|
if (!d(t))
|
|
@@ -596,26 +591,27 @@ class f {
|
|
|
596
591
|
return t(this), this;
|
|
597
592
|
}
|
|
598
593
|
}
|
|
599
|
-
function
|
|
600
|
-
return
|
|
594
|
+
function xt() {
|
|
595
|
+
return b(y());
|
|
601
596
|
}
|
|
602
|
-
function
|
|
597
|
+
function b(e) {
|
|
603
598
|
if (e == null)
|
|
604
599
|
throw 'The source "iterable" must be provided';
|
|
605
600
|
return new f(e);
|
|
606
601
|
}
|
|
607
|
-
function
|
|
608
|
-
return
|
|
602
|
+
function bt(e, t, r, i) {
|
|
603
|
+
return b(E(e, t, r, i));
|
|
609
604
|
}
|
|
610
|
-
function
|
|
611
|
-
return
|
|
605
|
+
function wt(e, t) {
|
|
606
|
+
return b(C(e, t));
|
|
612
607
|
}
|
|
613
608
|
export {
|
|
614
|
-
|
|
609
|
+
pt as Functions,
|
|
615
610
|
f as IterableLinqWrapper,
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
611
|
+
Y as Unit,
|
|
612
|
+
xt as empty,
|
|
613
|
+
b as from,
|
|
614
|
+
bt as fromRange,
|
|
615
|
+
wt as repeat,
|
|
616
|
+
z as unit
|
|
621
617
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(h=typeof globalThis<"u"?globalThis:h||self,c(h["interable-linq-utility"]={}))})(this,function(h){"use strict";var wt=Object.defineProperty;var vt=(h,c,p)=>c in h?wt(h,c,{enumerable:!0,configurable:!0,writable:!0,value:p}):h[c]=p;var n=(h,c,p)=>(vt(h,typeof c!="symbol"?c+"":c,p),p);function c(e){if(e==null)throw'The source "iterable" must be provided';return Array.from(e)}function p(e,t){return{done:e,value:t}}function D(e){return{done:!1,value:e}}function u(e){return{done:!0,value:e}}function yt(e){return e}function f(e){return typeof e=="function"}function I(){return new U}class U{[Symbol.iterator](){return new G}}class G{next(){return u()}return(t){return u(t)}}function S(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"predicate" function must be provided';return new H(e,t)}class H{constructor(t,r){n(this,"predicate");n(this,"source");this.source=t,this.predicate=r}[Symbol.iterator](){return new J(this.source,this.predicate)}}class J{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"predicate");n(this,"internalNext",()=>{for(;;){const t=this.sourceIterator.next();if(t.done===!0||this.predicate(t.value,this.index++))return t}});this.sourceIterator=t[Symbol.iterator](),this.predicate=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function N(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"mapper" function must be provided';return new K(e,t)}class K{constructor(t,r){n(this,"mapper");n(this,"source");this.source=t,this.mapper=r}[Symbol.iterator](){return new Q(this.source,this.mapper)}}class Q{constructor(t,r){n(this,"index",0);n(this,"mapper");n(this,"sourceIterator");n(this,"fmIterator");n(this,"sourceNext",()=>{const t=this.sourceIterator.next();if(t.done!==!0){const r=this.mapper(t.value,this.index++);return this.fmIterator=r[Symbol.iterator](),this.internalNext=this.fmNext,this.internalNext()}return this.internalNext=u,this.internalNext()});n(this,"fmNext",()=>{const t=this.fmIterator.next();return t.done!==!0?D(t.value):(this.internalNext=this.sourceNext,this.internalNext())});n(this,"internalNext",this.sourceNext);this.sourceIterator=t[Symbol.iterator](),this.mapper=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}class g{}const z=new g;Object.freeze(z);function w(){return z}const X=Object.freeze(Object.defineProperty({__proto__:null,Unit:g,unit:w},Symbol.toStringTag,{value:"Module"}));function M(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"action" function must be provided';const r=e[Symbol.iterator]();for(let i=r.next(),s=0;i.done!==!0;i=r.next(),s++)t(i.value,s);return w()}async function T(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"action" function must be provided';const r=[],i=e[Symbol.iterator]();for(let s=i.next(),a=0;s.done!==!0;s=i.next(),a++)r.push(t(s.value,a));return await Promise.all(r),w()}function R(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"mapper" function must be provided';return new Y(e,t)}class Y{constructor(t,r){n(this,"mapper");n(this,"source");this.source=t,this.mapper=r}[Symbol.iterator](){return new Z(this.source,this.mapper)}}class Z{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"mapper");n(this,"internalNext",()=>{const t=this.sourceIterator.next();return t.done!==!0?p(!1,this.mapper(t.value,this.index++)):(this.internalNext=u,this.internalNext())});this.sourceIterator=t[Symbol.iterator](),this.mapper=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function q(e){const t=e[Symbol.iterator](),r=new v;for(let i=t.next();i.done!==!0;i=t.next())r.addLast(i.value);return r}class v{constructor(){n(this,"internalSize",0);n(this,"head",null);n(this,"tail",null);n(this,"internalAddFirst",t=>{const r={data:t,nextNode:null};return this.head=r,this.tail=r,this.internalSize++,this.internalAddFirst=i=>{const s={data:i,nextNode:null};return s.nextNode=this.head,this.head=s,this.internalSize++,this},this});n(this,"internalAddLast",t=>{const r={data:t,nextNode:null};return this.head=r,this.tail=r,this.internalSize++,this.internalAddLast=i=>{const s={data:i,nextNode:null};return this.tail.nextNode=s,this.tail=s,this.internalSize++,this},this})}[Symbol.iterator](){return new W(this.head)}addFirst(t){return this.internalAddFirst(t)}addLast(t){return this.internalAddLast(t)}size(){return this.internalSize}}class W{constructor(t=null){n(this,"current",null);this.current=t}next(){const t=this.current;return t===null?u():(this.current=t.nextNode,p(!1,t.data))}}function A(e){return e instanceof k?e:new k(e)}class k{constructor(t){n(this,"source");this.source=q(t)}[Symbol.iterator](){return new tt(this.source)}}class tt{constructor(t){n(this,"sourceIterator");this.sourceIterator=t[Symbol.iterator]()}next(){return this.sourceIterator.next()}}function L(e,t){if(e==null)throw'The source "iterable" must be provided';const r=e[Symbol.iterator]();let i=r.next(),s=i.value,a=null;for(t==null?a=(o,l)=>o<l?-1:o===l?0:1:f(t)?a=t:Array.isArray(t)?a=(o,l)=>{let m=0;for(const d of t)if(m=o[d]<l[d]?-1:o[d]===l[d]?0:1,m!==0)break;return m}:a=(o,l)=>o[t]<l[t]?-1:o[t]===l[t]?0:1,i=r.next();i.done!==!0;i=r.next()){const o=a(s,i.value);s=o>0||o===0?s:i.value}return s==null?null:s}function F(e){return e instanceof E?e:new E(e)}class E{constructor(t){n(this,"isMemoized",!1);n(this,"sourceIterator");n(this,"linkedList",new v);n(this,"source");this.source=t,this.sourceIterator=t[Symbol.iterator](),t instanceof v&&(this.linkedList=t,this.isMemoized=!0)}[Symbol.iterator](){return this.isMemoized?new rt(this.linkedList):new et(this.sourceIterator,this.linkedList,t=>this.isMemoized=t.done===!0)}}class et{constructor(t,r,i){n(this,"index",0);n(this,"linkedList");n(this,"linkedListIterator");n(this,"setAsMemoized");n(this,"sourceIterator");this.linkedList=r,this.linkedListIterator=r[Symbol.iterator](),this.setAsMemoized=i,this.sourceIterator=t}next(){if(this.linkedList.size()>this.index++)return this.linkedListIterator.next();const t=this.sourceIterator.next();return this.setAsMemoized(t)||this.linkedList.addLast(t.value),t}}class rt{constructor(t){n(this,"memoizedSourceIterator");this.memoizedSourceIterator=t[Symbol.iterator]()}next(){return this.memoizedSourceIterator.next()}}function V(e,t){if(e==null)throw'The source "iterable" must be provided';const r=e[Symbol.iterator]();let i=r.next(),s=i.value,a=null;for(t==null?a=(o,l)=>o<l?-1:o===l?0:1:f(t)?a=t:Array.isArray(t)?a=(o,l)=>{let m=0;for(const d of t)if(m=o[d]<l[d]?-1:o[d]===l[d]?0:1,m!==0)break;return m}:a=(o,l)=>o[t]<l[t]?-1:o[t]===l[t]?0:1,i=r.next();i.done!==!0;i=r.next()){const o=a(s,i.value);s=o<0||o===0?s:i.value}return s==null?null:s}function j(e,t,r,i){const s=t==null||t===!0||t===!1?e:t,a=t==null||t===!0||t===!1?0:e,o=a<s,l=r!==!0&&r!==!1&&r!=null&&r!==0?r:o?1:-1,m=o&&l<0||!o&&l>0?-1*l:l,d=Math.ceil(Math.abs(s-a)/Math.abs(m)),B=!!(t===!0||r===!0||i!=null&&i),y=B?d*m+a:a;return a===s?new ut(y,0,0):B?new st(y,d,m):new nt(y,d,m)}class nt{constructor(t,r,i){n(this,"initialValue");n(this,"length");n(this,"step");this.initialValue=t,this.length=r,this.step=i}[Symbol.iterator](){return new it(this.initialValue,this.length,this.step)}}class it{constructor(t,r,i){n(this,"value");n(this,"length");n(this,"step");this.value=t,this.length=r,this.step=i}next(){const t=this.value;return this.value+=this.step,this.length--?p(!1,t):u()}}class st{constructor(t,r,i){n(this,"initialValue");n(this,"length");n(this,"step");this.initialValue=t-i,this.length=r,this.step=i}[Symbol.iterator](){return new ot(this.initialValue,this.length,this.step)}}class ot{constructor(t,r,i){n(this,"value");n(this,"length");n(this,"step");this.value=t,this.length=r,this.step=i}next(){const t=this.value;return this.value-=this.step,this.length--?p(!1,t):u()}}class ut{constructor(t,r,i){n(this,"initialValue");n(this,"length");n(this,"step");this.initialValue=t,this.length=r,this.step=i}[Symbol.iterator](){return new at(this.initialValue,this.length,this.step)}}class at{constructor(t,r,i){n(this,"value");n(this,"length");n(this,"step");this.value=t,this.length=r,this.step=i}next(){return u()}}function O(e,t,r){if(e==null)throw'The source "iterable" must be provided';if(!f(r))throw'"reducer" function must be provided';const i=e[Symbol.iterator]();let s=t,a=0;for(let o=i.next();o.done!==!0;o=i.next())s=r(s,o.value,a),a++;return s}function C(e,t){if(t<0)throw'"count" parameter must be greater or equal then 0';return new lt(e,t)}class lt{constructor(t,r){n(this,"value");n(this,"count");this.value=t,this.count=r}[Symbol.iterator](){return new ht(this.value,this.count)}}class ht{constructor(t,r){n(this,"leftToRepeat",0);n(this,"value");n(this,"count");n(this,"internalNext",()=>this.leftToRepeat--?p(!1,this.value):(this.internalNext=u,u()));this.value=t,this.count=r,this.leftToRepeat=r,r===0&&(this.internalNext=u)}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function P(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"predicate" function must be provided';const r=e[Symbol.iterator]();let i=0;for(let s=r.next();s.done!==!0;s=r.next())if(t(s.value,i++))return!0;return!1}function $(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"tapper" function must be provided';return new ct(e,t)}class ct{constructor(t,r){n(this,"tapper");n(this,"source");this.source=t,this.tapper=r}[Symbol.iterator](){return new dt(this.source,this.tapper)}}class dt{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"tapper");n(this,"internalNext",()=>{const t=this.sourceIterator.next();return t.done!==!0?(this.tapper(t.value,this.index++),t):(this.internalNext=u,u())});this.sourceIterator=t[Symbol.iterator](),this.tapper=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function _(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"tapper" function must be provided';return new ft(e,t)}class ft{constructor(t,r){n(this,"tapper");n(this,"source");this.source=t,this.tapper=r}[Symbol.iterator](){return this.tapper(this.source,0),this.source[Symbol.iterator]()}}const mt=Object.freeze(Object.defineProperty({__proto__:null,collectToArray:c,empty:I,filter:S,flatMap:N,forEach:M,forEachAsync:T,map:R,materialize:A,max:L,memoize:F,min:V,range:j,reduce:O,repeat:C,some:P,tap:$,tapChain:_},Symbol.toStringTag,{value:"Module"}));class b{constructor(t){n(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return Array.from(this.iterable)}filter(t){return new b(S(this.iterable,t))}flatMap(t){return new b(N(this.iterable,t))}forEach(t){return M(this.iterable,t)}forEachAsync(t){return T(this.iterable,t)}map(t){return new b(R(this.iterable,t))}materialize(){return new b(A(this.iterable))}max(t){return L(this.iterable,t)}memoize(){return new b(F(this.iterable))}min(t){return V(this.iterable,t)}reduce(t,r){return O(this.iterable,t,r)}some(t){return P(this.iterable,t)}tap(t){return new b($(this.iterable,t))}tapChain(t){return new b(_(this.iterable,t))}tapChainCreation(t){if(!f(t))throw'"tapper" function must be provided';return t(this),this}}function pt(){return x(I())}function x(e){if(e==null)throw'The source "iterable" must be provided';return new b(e)}function bt(e,t,r,i){return x(j(e,t,r,i))}function xt(e,t){return x(C(e,t))}h.Functions=mt,h.IterableLinqWrapper=b,h.Types=X,h.empty=pt,h.from=x,h.fromRange=bt,h.repeat=xt,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(h,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(h=typeof globalThis<"u"?globalThis:h||self,c(h["interable-linq-utility"]={}))})(this,function(h){"use strict";var xt=Object.defineProperty;var wt=(h,c,p)=>c in h?xt(h,c,{enumerable:!0,configurable:!0,writable:!0,value:p}):h[c]=p;var n=(h,c,p)=>(wt(h,typeof c!="symbol"?c+"":c,p),p);function c(e){if(e==null)throw'The source "iterable" must be provided';return Array.from(e)}function p(e,t){return{done:e,value:t}}function D(e){return{done:!1,value:e}}function u(e){return{done:!0,value:e}}function vt(e){return e}function f(e){return typeof e=="function"}function y(){return new G}class G{[Symbol.iterator](){return new H}}class H{next(){return u()}return(t){return u(t)}}function S(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"predicate" function must be provided';return new J(e,t)}class J{constructor(t,r){n(this,"predicate");n(this,"source");this.source=t,this.predicate=r}[Symbol.iterator](){return new K(this.source,this.predicate)}}class K{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"predicate");n(this,"internalNext",()=>{for(;;){const t=this.sourceIterator.next();if(t.done===!0||this.predicate(t.value,this.index++))return t}});this.sourceIterator=t[Symbol.iterator](),this.predicate=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function N(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"mapper" function must be provided';return new Q(e,t)}class Q{constructor(t,r){n(this,"mapper");n(this,"source");this.source=t,this.mapper=r}[Symbol.iterator](){return new X(this.source,this.mapper)}}class X{constructor(t,r){n(this,"index",0);n(this,"mapper");n(this,"sourceIterator");n(this,"fmIterator");n(this,"sourceNext",()=>{const t=this.sourceIterator.next();if(t.done!==!0){const r=this.mapper(t.value,this.index++);return this.fmIterator=r[Symbol.iterator](),this.internalNext=this.fmNext,this.internalNext()}return this.internalNext=u,this.internalNext()});n(this,"fmNext",()=>{const t=this.fmIterator.next();return t.done!==!0?D(t.value):(this.internalNext=this.sourceNext,this.internalNext())});n(this,"internalNext",this.sourceNext);this.sourceIterator=t[Symbol.iterator](),this.mapper=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}class g{}const z=new g;Object.freeze(z);function w(){return z}function M(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"action" function must be provided';const r=e[Symbol.iterator]();for(let i=r.next(),s=0;i.done!==!0;i=r.next(),s++)t(i.value,s);return w()}async function T(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"action" function must be provided';const r=[],i=e[Symbol.iterator]();for(let s=i.next(),a=0;s.done!==!0;s=i.next(),a++)r.push(t(s.value,a));return await Promise.all(r),w()}function R(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"mapper" function must be provided';return new Y(e,t)}class Y{constructor(t,r){n(this,"mapper");n(this,"source");this.source=t,this.mapper=r}[Symbol.iterator](){return new Z(this.source,this.mapper)}}class Z{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"mapper");n(this,"internalNext",()=>{const t=this.sourceIterator.next();return t.done!==!0?p(!1,this.mapper(t.value,this.index++)):(this.internalNext=u,this.internalNext())});this.sourceIterator=t[Symbol.iterator](),this.mapper=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function _(e){const t=e[Symbol.iterator](),r=new v;for(let i=t.next();i.done!==!0;i=t.next())r.addLast(i.value);return r}class v{constructor(){n(this,"internalSize",0);n(this,"head",null);n(this,"tail",null);n(this,"internalAddFirst",t=>{const r={data:t,nextNode:null};return this.head=r,this.tail=r,this.internalSize++,this.internalAddFirst=i=>{const s={data:i,nextNode:null};return s.nextNode=this.head,this.head=s,this.internalSize++,this},this});n(this,"internalAddLast",t=>{const r={data:t,nextNode:null};return this.head=r,this.tail=r,this.internalSize++,this.internalAddLast=i=>{const s={data:i,nextNode:null};return this.tail.nextNode=s,this.tail=s,this.internalSize++,this},this})}[Symbol.iterator](){return new q(this.head)}addFirst(t){return this.internalAddFirst(t)}addLast(t){return this.internalAddLast(t)}size(){return this.internalSize}}class q{constructor(t=null){n(this,"current",null);this.current=t}next(){const t=this.current;return t===null?u():(this.current=t.nextNode,p(!1,t.data))}}function A(e){return e instanceof k?e:new k(e)}class k{constructor(t){n(this,"source");this.source=_(t)}[Symbol.iterator](){return new W(this.source)}}class W{constructor(t){n(this,"sourceIterator");this.sourceIterator=t[Symbol.iterator]()}next(){return this.sourceIterator.next()}}function L(e,t){if(e==null)throw'The source "iterable" must be provided';const r=e[Symbol.iterator]();let i=r.next(),s=i.value,a=null;for(t==null?a=(o,l)=>o<l?-1:o===l?0:1:f(t)?a=t:Array.isArray(t)?a=(o,l)=>{let m=0;for(const d of t)if(m=o[d]<l[d]?-1:o[d]===l[d]?0:1,m!==0)break;return m}:a=(o,l)=>o[t]<l[t]?-1:o[t]===l[t]?0:1,i=r.next();i.done!==!0;i=r.next()){const o=a(s,i.value);s=o>0||o===0?s:i.value}return s==null?null:s}function F(e){return e instanceof E?e:new E(e)}class E{constructor(t){n(this,"isMemoized",!1);n(this,"sourceIterator");n(this,"linkedList",new v);n(this,"source");this.source=t,this.sourceIterator=t[Symbol.iterator](),t instanceof v&&(this.linkedList=t,this.isMemoized=!0)}[Symbol.iterator](){return this.isMemoized?new et(this.linkedList):new tt(this.sourceIterator,this.linkedList,t=>this.isMemoized=t.done===!0)}}class tt{constructor(t,r,i){n(this,"index",0);n(this,"linkedList");n(this,"linkedListIterator");n(this,"setAsMemoized");n(this,"sourceIterator");this.linkedList=r,this.linkedListIterator=r[Symbol.iterator](),this.setAsMemoized=i,this.sourceIterator=t}next(){if(this.linkedList.size()>this.index++)return this.linkedListIterator.next();const t=this.sourceIterator.next();return this.setAsMemoized(t)||this.linkedList.addLast(t.value),t}}class et{constructor(t){n(this,"memoizedSourceIterator");this.memoizedSourceIterator=t[Symbol.iterator]()}next(){return this.memoizedSourceIterator.next()}}function V(e,t){if(e==null)throw'The source "iterable" must be provided';const r=e[Symbol.iterator]();let i=r.next(),s=i.value,a=null;for(t==null?a=(o,l)=>o<l?-1:o===l?0:1:f(t)?a=t:Array.isArray(t)?a=(o,l)=>{let m=0;for(const d of t)if(m=o[d]<l[d]?-1:o[d]===l[d]?0:1,m!==0)break;return m}:a=(o,l)=>o[t]<l[t]?-1:o[t]===l[t]?0:1,i=r.next();i.done!==!0;i=r.next()){const o=a(s,i.value);s=o<0||o===0?s:i.value}return s==null?null:s}function j(e,t,r,i){const s=t==null||t===!0||t===!1?e:t,a=t==null||t===!0||t===!1?0:e,o=a<s,l=r!==!0&&r!==!1&&r!=null&&r!==0?r:o?1:-1,m=o&&l<0||!o&&l>0?-1*l:l,d=Math.ceil(Math.abs(s-a)/Math.abs(m)),B=!!(t===!0||r===!0||i!=null&&i),I=B?d*m+a:a;return a===s?new ot(I,0,0):B?new it(I,d,m):new rt(I,d,m)}class rt{constructor(t,r,i){n(this,"initialValue");n(this,"length");n(this,"step");this.initialValue=t,this.length=r,this.step=i}[Symbol.iterator](){return new nt(this.initialValue,this.length,this.step)}}class nt{constructor(t,r,i){n(this,"value");n(this,"length");n(this,"step");this.value=t,this.length=r,this.step=i}next(){const t=this.value;return this.value+=this.step,this.length--?p(!1,t):u()}}class it{constructor(t,r,i){n(this,"initialValue");n(this,"length");n(this,"step");this.initialValue=t-i,this.length=r,this.step=i}[Symbol.iterator](){return new st(this.initialValue,this.length,this.step)}}class st{constructor(t,r,i){n(this,"value");n(this,"length");n(this,"step");this.value=t,this.length=r,this.step=i}next(){const t=this.value;return this.value-=this.step,this.length--?p(!1,t):u()}}class ot{constructor(t,r,i){n(this,"initialValue");n(this,"length");n(this,"step");this.initialValue=t,this.length=r,this.step=i}[Symbol.iterator](){return new ut(this.initialValue,this.length,this.step)}}class ut{constructor(t,r,i){n(this,"value");n(this,"length");n(this,"step");this.value=t,this.length=r,this.step=i}next(){return u()}}function C(e,t,r){if(e==null)throw'The source "iterable" must be provided';if(!f(r))throw'"reducer" function must be provided';const i=e[Symbol.iterator]();let s=t,a=0;for(let o=i.next();o.done!==!0;o=i.next())s=r(s,o.value,a),a++;return s}function O(e,t){if(t<0)throw'"count" parameter must be greater or equal then 0';return new at(e,t)}class at{constructor(t,r){n(this,"value");n(this,"count");this.value=t,this.count=r}[Symbol.iterator](){return new lt(this.value,this.count)}}class lt{constructor(t,r){n(this,"leftToRepeat",0);n(this,"value");n(this,"count");n(this,"internalNext",()=>this.leftToRepeat--?p(!1,this.value):(this.internalNext=u,u()));this.value=t,this.count=r,this.leftToRepeat=r,r===0&&(this.internalNext=u)}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function P(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"predicate" function must be provided';const r=e[Symbol.iterator]();let i=0;for(let s=r.next();s.done!==!0;s=r.next())if(t(s.value,i++))return!0;return!1}function $(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"tapper" function must be provided';return new ht(e,t)}class ht{constructor(t,r){n(this,"tapper");n(this,"source");this.source=t,this.tapper=r}[Symbol.iterator](){return new ct(this.source,this.tapper)}}class ct{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"tapper");n(this,"internalNext",()=>{const t=this.sourceIterator.next();return t.done!==!0?(this.tapper(t.value,this.index++),t):(this.internalNext=u,u())});this.sourceIterator=t[Symbol.iterator](),this.tapper=r}next(){return this.internalNext()}return(t){return this.internalNext=u,u(t)}}function U(e,t){if(e==null)throw'The source "iterable" must be provided';if(!f(t))throw'"tapper" function must be provided';return new dt(e,t)}class dt{constructor(t,r){n(this,"tapper");n(this,"source");this.source=t,this.tapper=r}[Symbol.iterator](){return this.tapper(this.source,0),this.source[Symbol.iterator]()}}const ft=Object.freeze(Object.defineProperty({__proto__:null,collectToArray:c,empty:y,filter:S,flatMap:N,forEach:M,forEachAsync:T,map:R,materialize:A,max:L,memoize:F,min:V,range:j,reduce:C,repeat:O,some:P,tap:$,tapChain:U},Symbol.toStringTag,{value:"Module"}));class b{constructor(t){n(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return Array.from(this.iterable)}filter(t){return new b(S(this.iterable,t))}flatMap(t){return new b(N(this.iterable,t))}forEach(t){return M(this.iterable,t)}forEachAsync(t){return T(this.iterable,t)}map(t){return new b(R(this.iterable,t))}materialize(){return new b(A(this.iterable))}max(t){return L(this.iterable,t)}memoize(){return new b(F(this.iterable))}min(t){return V(this.iterable,t)}reduce(t,r){return C(this.iterable,t,r)}some(t){return P(this.iterable,t)}tap(t){return new b($(this.iterable,t))}tapChain(t){return new b(U(this.iterable,t))}tapChainCreation(t){if(!f(t))throw'"tapper" function must be provided';return t(this),this}}function mt(){return x(y())}function x(e){if(e==null)throw'The source "iterable" must be provided';return new b(e)}function pt(e,t,r,i){return x(j(e,t,r,i))}function bt(e,t){return x(O(e,t))}h.Functions=ft,h.IterableLinqWrapper=b,h.Unit=g,h.empty=mt,h.from=x,h.fromRange=pt,h.repeat=bt,h.unit=w,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED