iterable-linq-utility 0.0.9 → 0.0.11
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/functions/collectToArray.d.ts +1 -0
- package/dist/functions/empty.d.ts +1 -0
- package/dist/functions/filter.d.ts +7 -0
- package/dist/functions/flatMap.d.ts +8 -0
- package/dist/functions/forEach.d.ts +3 -0
- package/dist/functions/index.d.ts +23 -8
- package/dist/functions/map.d.ts +7 -0
- package/dist/functions/materialize.d.ts +6 -0
- package/dist/functions/max.d.ts +9 -1
- package/dist/functions/memoize.d.ts +6 -0
- package/dist/functions/min.d.ts +7 -0
- package/dist/functions/range.d.ts +1 -0
- package/dist/functions/reduce.d.ts +10 -0
- package/dist/functions/repeat.d.ts +1 -0
- package/dist/functions/some.d.ts +7 -0
- package/dist/functions/tap.d.ts +9 -0
- package/dist/functions/tapChain.d.ts +9 -0
- package/dist/genericCollections/index.d.ts +2 -1
- package/dist/genericCollections/linkedList.d.ts +7 -5
- package/dist/index.d.ts +14 -3
- package/dist/interable-linq-utility.js +468 -113
- package/dist/interable-linq-utility.umd.cjs +1 -1
- package/dist/linqIterable.d.ts +32 -11
- package/dist/types/action.d.ts +3 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/reducer.d.ts +1 -0
- package/dist/types/tapper.d.ts +1 -0
- package/dist/types/unit.d.ts +3 -0
- package/dist/utils/iteratorResults.d.ts +2 -1
- package/dist/utils/utils.d.ts +9 -27
- package/package.json +9 -4
- package/dist/combiners/index.d.ts +0 -2
- package/dist/combiners/mapper.d.ts +0 -2
- package/dist/combiners/predicate.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function collectToArray<T>(iterable: Iterable<T>): T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function empty<T>(): Iterable<T>;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
1
|
+
import { collectToArray } from './collectToArray';
|
|
2
|
+
export { collectToArray };
|
|
3
|
+
import { empty } from './empty';
|
|
4
|
+
export { empty };
|
|
5
|
+
import { filter } from './filter';
|
|
6
|
+
import { flatMap } from './flatMap';
|
|
7
|
+
import { forEach, forEachAsync } from './forEach';
|
|
8
|
+
export { filter, flatMap, forEach, forEachAsync };
|
|
9
|
+
import { map } from './map';
|
|
10
|
+
import { materialize } from './materialize';
|
|
11
|
+
import { max } from './max';
|
|
12
|
+
import { memoize } from './memoize';
|
|
13
|
+
import { min } from './min';
|
|
14
|
+
export { map, materialize, max, memoize, min };
|
|
15
|
+
import { range } from './range';
|
|
16
|
+
import { reduce } from './reduce';
|
|
17
|
+
import { repeat } from './repeat';
|
|
18
|
+
export { range, reduce, repeat };
|
|
19
|
+
import { some } from './some';
|
|
20
|
+
export { some };
|
|
21
|
+
import { tap } from './tap';
|
|
22
|
+
import { tapChain } from './tapChain';
|
|
23
|
+
export { tap, tapChain };
|
package/dist/functions/map.d.ts
CHANGED
package/dist/functions/max.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Comparer } from "@/types";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @operation `Action`
|
|
5
|
+
* @param iterable
|
|
6
|
+
* @param comparer
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function max<T>(iterable: Iterable<T>, comparer?: Comparer<T>): T | null | undefined;
|
package/dist/functions/min.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare function range(start: number, end: number): Iterable<number>;
|
|
|
4
4
|
export declare function range(start: number, end: number, step: number): Iterable<number>;
|
|
5
5
|
export declare function range(start: number, end: number, reverse: boolean): Iterable<number>;
|
|
6
6
|
export declare function range(start: number, end: number, step: number, reverse: boolean): Iterable<number>;
|
|
7
|
+
export declare function range(start: number, end?: number | boolean, step?: number | boolean, reverse?: boolean): Iterable<number>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Reducer } from "@/types";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @operation `Action`
|
|
5
|
+
* @param iterable
|
|
6
|
+
* @param neutralElement
|
|
7
|
+
* @param reducer
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function reduce<T, R>(iterable: Iterable<T>, neutralElement: R, reducer: Reducer<T, R>): R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function repeat<T>(value: T, count: number): Iterable<T>;
|
package/dist/functions/some.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as LinkedListCollection from './linkedList';
|
|
2
|
+
export { LinkedListCollection };
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
export declare function from<T>(iterable: Iterable<T>): LinkedList<T>;
|
|
2
|
-
export declare class LinkedListIterator<T> implements Iterator<T> {
|
|
3
|
-
private current;
|
|
4
|
-
constructor(current?: IListNode<T> | null);
|
|
5
|
-
next(): IteratorResult<T, any>;
|
|
6
|
-
}
|
|
7
2
|
export declare class LinkedList<T> implements Iterable<T> {
|
|
8
3
|
private internalSize;
|
|
9
4
|
private head;
|
|
10
5
|
private tail;
|
|
11
6
|
[Symbol.iterator](): Iterator<T>;
|
|
7
|
+
private internalAddFirst;
|
|
12
8
|
addFirst(value: T): this;
|
|
9
|
+
private internalAddLast;
|
|
13
10
|
addLast(value: T): this;
|
|
14
11
|
size(): number;
|
|
15
12
|
}
|
|
13
|
+
export declare class LinkedListIterator<T> implements Iterator<T> {
|
|
14
|
+
private current;
|
|
15
|
+
constructor(current?: IListNode<T> | null);
|
|
16
|
+
next(): IteratorResult<T, any>;
|
|
17
|
+
}
|
|
16
18
|
interface IListNode<T> {
|
|
17
19
|
data: T;
|
|
18
20
|
nextNode: IListNode<T> | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { IterableLinqWrapper, type IIterableLinq } from "./linqIterable";
|
|
2
|
+
import * as Functions from '@/functions';
|
|
3
|
+
import * as Types from '@/types';
|
|
4
|
+
export declare function empty<T>(): IIterableLinq<T>;
|
|
5
|
+
export declare function from<T>(iterable: Iterable<T>): IIterableLinq<T>;
|
|
6
|
+
export declare function fromRange(end: number): IIterableLinq<number>;
|
|
7
|
+
export declare function fromRange(end: number, reverse?: boolean): IIterableLinq<number>;
|
|
8
|
+
export declare function fromRange(start: number, end: number): IIterableLinq<number>;
|
|
9
|
+
export declare function fromRange(start: number, end: number, step: number): IIterableLinq<number>;
|
|
10
|
+
export declare function fromRange(start: number, end: number, reverse: boolean): IIterableLinq<number>;
|
|
11
|
+
export declare function fromRange(start: number, end: number, step: number, reverse: boolean): IIterableLinq<number>;
|
|
12
|
+
export declare function fromRange(start: number, end?: number | boolean, step?: number | boolean, reverse?: boolean): Iterable<number>;
|
|
13
|
+
export declare function repeat<T>(value: T, count: number): IIterableLinq<T>;
|
|
14
|
+
export { Functions, IIterableLinq, IterableLinqWrapper, Types };
|
|
@@ -1,161 +1,266 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (e, t, r) => (
|
|
4
|
-
function
|
|
5
|
-
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var D = (e, t, r) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var n = (e, t, r) => (D(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
+
function U(e) {
|
|
5
|
+
if (e == null)
|
|
6
|
+
throw 'The source "iterable" must be provided';
|
|
7
|
+
return Array.from(e);
|
|
6
8
|
}
|
|
7
|
-
function
|
|
8
|
-
return (r, i) => e(r, i) && t(r, i);
|
|
9
|
-
}
|
|
10
|
-
function z(e, t) {
|
|
9
|
+
function m(e, t) {
|
|
11
10
|
return {
|
|
12
11
|
done: e,
|
|
13
12
|
value: t
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
function
|
|
17
|
-
return { done: !
|
|
15
|
+
function _(e) {
|
|
16
|
+
return { done: !1, value: e };
|
|
18
17
|
}
|
|
19
|
-
function
|
|
18
|
+
function l(e) {
|
|
19
|
+
return { done: !0, value: e };
|
|
20
|
+
}
|
|
21
|
+
function d(e) {
|
|
20
22
|
return typeof e == "function";
|
|
21
23
|
}
|
|
22
|
-
function
|
|
23
|
-
return new
|
|
24
|
+
function S() {
|
|
25
|
+
return new G();
|
|
26
|
+
}
|
|
27
|
+
class G {
|
|
28
|
+
[Symbol.iterator]() {
|
|
29
|
+
return new H();
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
|
-
class
|
|
32
|
+
class H {
|
|
33
|
+
next() {
|
|
34
|
+
return l();
|
|
35
|
+
}
|
|
36
|
+
return(t) {
|
|
37
|
+
return l(t);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function N(e, t) {
|
|
41
|
+
if (e == null)
|
|
42
|
+
throw 'The source "iterable" must be provided';
|
|
43
|
+
if (!d(t))
|
|
44
|
+
throw '"predicate" function must be provided';
|
|
45
|
+
return new J(e, t);
|
|
46
|
+
}
|
|
47
|
+
class J {
|
|
26
48
|
constructor(t, r) {
|
|
27
49
|
n(this, "predicate");
|
|
28
50
|
n(this, "source");
|
|
29
|
-
|
|
30
|
-
if (s instanceof f) {
|
|
31
|
-
const u = s.predicate;
|
|
32
|
-
s = s.source, i = p(u, i);
|
|
33
|
-
}
|
|
34
|
-
this.source = s, this.predicate = i;
|
|
51
|
+
this.source = t, this.predicate = r;
|
|
35
52
|
}
|
|
36
53
|
[Symbol.iterator]() {
|
|
37
|
-
return new
|
|
54
|
+
return new K(this.source, this.predicate);
|
|
38
55
|
}
|
|
39
56
|
}
|
|
40
|
-
class
|
|
57
|
+
class K {
|
|
41
58
|
constructor(t, r) {
|
|
42
59
|
n(this, "index", 0);
|
|
43
60
|
n(this, "sourceIterator");
|
|
44
61
|
n(this, "predicate");
|
|
62
|
+
n(this, "internalNext", () => {
|
|
63
|
+
for (; ; ) {
|
|
64
|
+
const t = this.sourceIterator.next();
|
|
65
|
+
if (t.done === !0 || this.predicate(t.value, this.index++))
|
|
66
|
+
return t;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
45
69
|
this.sourceIterator = t[Symbol.iterator](), this.predicate = r;
|
|
46
70
|
}
|
|
47
71
|
next() {
|
|
48
|
-
|
|
72
|
+
return this.internalNext();
|
|
73
|
+
}
|
|
74
|
+
return(t) {
|
|
75
|
+
return this.internalNext = l, l(t);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function g(e, t) {
|
|
79
|
+
if (e == null)
|
|
80
|
+
throw 'The source "iterable" must be provided';
|
|
81
|
+
if (!d(t))
|
|
82
|
+
throw '"mapper" function must be provided';
|
|
83
|
+
return new Q(e, t);
|
|
84
|
+
}
|
|
85
|
+
class Q {
|
|
86
|
+
constructor(t, r) {
|
|
87
|
+
n(this, "mapper");
|
|
88
|
+
n(this, "source");
|
|
89
|
+
this.source = t, this.mapper = r;
|
|
90
|
+
}
|
|
91
|
+
[Symbol.iterator]() {
|
|
92
|
+
return new X(this.source, this.mapper);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
class X {
|
|
96
|
+
constructor(t, r) {
|
|
97
|
+
n(this, "index", 0);
|
|
98
|
+
n(this, "mapper");
|
|
99
|
+
n(this, "sourceIterator");
|
|
100
|
+
n(this, "fmIterator");
|
|
101
|
+
n(this, "sourceNext", () => {
|
|
49
102
|
const t = this.sourceIterator.next();
|
|
50
|
-
if (t.done
|
|
51
|
-
|
|
52
|
-
|
|
103
|
+
if (t.done !== !0) {
|
|
104
|
+
const r = this.mapper(t.value, this.index++);
|
|
105
|
+
return this.fmIterator = r[Symbol.iterator](), this.internalNext = this.fmNext, this.internalNext();
|
|
106
|
+
}
|
|
107
|
+
return this.internalNext = l, this.internalNext();
|
|
108
|
+
});
|
|
109
|
+
n(this, "fmNext", () => {
|
|
110
|
+
const t = this.fmIterator.next();
|
|
111
|
+
return t.done !== !0 ? _(t.value) : (this.internalNext = this.sourceNext, this.internalNext());
|
|
112
|
+
});
|
|
113
|
+
n(this, "internalNext", this.sourceNext);
|
|
114
|
+
this.sourceIterator = t[Symbol.iterator](), this.mapper = r;
|
|
115
|
+
}
|
|
116
|
+
next() {
|
|
117
|
+
return this.internalNext();
|
|
53
118
|
}
|
|
119
|
+
return(t) {
|
|
120
|
+
return this.internalNext = l, l(t);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
class z {
|
|
124
|
+
}
|
|
125
|
+
const M = new z();
|
|
126
|
+
Object.freeze(M);
|
|
127
|
+
function b() {
|
|
128
|
+
return M;
|
|
129
|
+
}
|
|
130
|
+
const pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
131
|
+
__proto__: null,
|
|
132
|
+
Unit: z,
|
|
133
|
+
unit: b
|
|
134
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
135
|
+
function T(e, t) {
|
|
136
|
+
if (e == null)
|
|
137
|
+
throw 'The source "iterable" must be provided';
|
|
138
|
+
if (!d(t))
|
|
139
|
+
throw '"action" function must be provided';
|
|
140
|
+
const r = e[Symbol.iterator]();
|
|
141
|
+
for (let i = r.next(), s = 0; i.done !== !0; i = r.next(), s++)
|
|
142
|
+
t(i.value, s);
|
|
143
|
+
return b();
|
|
144
|
+
}
|
|
145
|
+
async function A(e, t) {
|
|
146
|
+
if (e == null)
|
|
147
|
+
throw 'The source "iterable" must be provided';
|
|
148
|
+
if (!d(t))
|
|
149
|
+
throw '"action" function must be provided';
|
|
150
|
+
const r = [], i = e[Symbol.iterator]();
|
|
151
|
+
for (let s = i.next(), u = 0; s.done !== !0; s = i.next(), u++)
|
|
152
|
+
r.push(t(s.value, u));
|
|
153
|
+
return await Promise.all(r), b();
|
|
54
154
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
155
|
+
function R(e, t) {
|
|
156
|
+
if (e == null)
|
|
157
|
+
throw 'The source "iterable" must be provided';
|
|
158
|
+
if (!d(t))
|
|
159
|
+
throw '"mapper" function must be provided';
|
|
160
|
+
return new Y(e, t);
|
|
57
161
|
}
|
|
58
|
-
class
|
|
162
|
+
class Y {
|
|
59
163
|
constructor(t, r) {
|
|
60
164
|
n(this, "mapper");
|
|
61
165
|
n(this, "source");
|
|
62
|
-
|
|
63
|
-
if (s instanceof m) {
|
|
64
|
-
const u = s.mapper;
|
|
65
|
-
s = s.source, i = y(u, i);
|
|
66
|
-
}
|
|
67
|
-
this.source = t, this.mapper = i;
|
|
166
|
+
this.source = t, this.mapper = r;
|
|
68
167
|
}
|
|
69
168
|
[Symbol.iterator]() {
|
|
70
|
-
return new
|
|
169
|
+
return new Z(this.source, this.mapper);
|
|
71
170
|
}
|
|
72
171
|
}
|
|
73
|
-
class
|
|
172
|
+
class Z {
|
|
74
173
|
constructor(t, r) {
|
|
75
174
|
n(this, "index", 0);
|
|
76
175
|
n(this, "sourceIterator");
|
|
77
176
|
n(this, "mapper");
|
|
177
|
+
n(this, "internalNext", () => {
|
|
178
|
+
const t = this.sourceIterator.next();
|
|
179
|
+
return t.done !== !0 ? m(!1, this.mapper(t.value, this.index++)) : (this.internalNext = l, this.internalNext());
|
|
180
|
+
});
|
|
78
181
|
this.sourceIterator = t[Symbol.iterator](), this.mapper = r;
|
|
79
182
|
}
|
|
80
183
|
next() {
|
|
81
|
-
|
|
82
|
-
|
|
184
|
+
return this.internalNext();
|
|
185
|
+
}
|
|
186
|
+
return(t) {
|
|
187
|
+
return this.internalNext = l, l(t);
|
|
83
188
|
}
|
|
84
189
|
}
|
|
85
|
-
function
|
|
86
|
-
const t = e[Symbol.iterator](), r = new
|
|
190
|
+
function q(e) {
|
|
191
|
+
const t = e[Symbol.iterator](), r = new x();
|
|
87
192
|
for (let i = t.next(); i.done !== !0; i = t.next())
|
|
88
193
|
r.addLast(i.value);
|
|
89
194
|
return r;
|
|
90
195
|
}
|
|
91
|
-
class
|
|
92
|
-
constructor(t = null) {
|
|
93
|
-
n(this, "current", null);
|
|
94
|
-
this.current = t;
|
|
95
|
-
}
|
|
96
|
-
next() {
|
|
97
|
-
const t = this.current;
|
|
98
|
-
return t === null ? S() : (this.current = t.nextNode, z(!1, t.data));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
class h {
|
|
196
|
+
class x {
|
|
102
197
|
constructor() {
|
|
103
198
|
n(this, "internalSize", 0);
|
|
104
199
|
n(this, "head", null);
|
|
105
200
|
n(this, "tail", null);
|
|
201
|
+
n(this, "internalAddFirst", (t) => {
|
|
202
|
+
const r = {
|
|
203
|
+
data: t,
|
|
204
|
+
nextNode: null
|
|
205
|
+
};
|
|
206
|
+
return this.head = r, this.tail = r, this.internalSize++, this.internalAddFirst = (i) => {
|
|
207
|
+
const s = {
|
|
208
|
+
data: i,
|
|
209
|
+
nextNode: null
|
|
210
|
+
};
|
|
211
|
+
return s.nextNode = this.head, this.head = s, this.internalSize++, this;
|
|
212
|
+
}, this;
|
|
213
|
+
});
|
|
214
|
+
n(this, "internalAddLast", (t) => {
|
|
215
|
+
const r = {
|
|
216
|
+
data: t,
|
|
217
|
+
nextNode: null
|
|
218
|
+
};
|
|
219
|
+
return this.head = r, this.tail = r, this.internalSize++, this.internalAddLast = (i) => {
|
|
220
|
+
const s = {
|
|
221
|
+
data: i,
|
|
222
|
+
nextNode: null
|
|
223
|
+
};
|
|
224
|
+
return this.tail.nextNode = s, this.tail = s, this.internalSize++, this;
|
|
225
|
+
}, this;
|
|
226
|
+
});
|
|
106
227
|
}
|
|
107
228
|
[Symbol.iterator]() {
|
|
108
|
-
return new
|
|
229
|
+
return new W(this.head);
|
|
109
230
|
}
|
|
110
231
|
addFirst(t) {
|
|
111
|
-
|
|
112
|
-
data: t,
|
|
113
|
-
nextNode: null
|
|
114
|
-
};
|
|
115
|
-
switch (this.internalSize) {
|
|
116
|
-
case 0:
|
|
117
|
-
this.head = r, this.tail = r;
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
r.nextNode = this.head, this.head = r;
|
|
121
|
-
}
|
|
122
|
-
return this.internalSize++, this;
|
|
232
|
+
return this.internalAddFirst(t);
|
|
123
233
|
}
|
|
124
234
|
addLast(t) {
|
|
125
|
-
|
|
126
|
-
data: t,
|
|
127
|
-
nextNode: null
|
|
128
|
-
};
|
|
129
|
-
switch (this.internalSize) {
|
|
130
|
-
case 0:
|
|
131
|
-
this.head = r, this.tail = r;
|
|
132
|
-
break;
|
|
133
|
-
default:
|
|
134
|
-
this.tail.nextNode = r, this.tail = r;
|
|
135
|
-
}
|
|
136
|
-
return this.internalSize++, this;
|
|
235
|
+
return this.internalAddLast(t);
|
|
137
236
|
}
|
|
138
237
|
size() {
|
|
139
238
|
return this.internalSize;
|
|
140
239
|
}
|
|
141
240
|
}
|
|
142
|
-
|
|
241
|
+
class W {
|
|
242
|
+
constructor(t = null) {
|
|
243
|
+
n(this, "current", null);
|
|
244
|
+
this.current = t;
|
|
245
|
+
}
|
|
246
|
+
next() {
|
|
247
|
+
const t = this.current;
|
|
248
|
+
return t === null ? l() : (this.current = t.nextNode, m(!1, t.data));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function k(e) {
|
|
143
252
|
return e instanceof I ? e : new I(e);
|
|
144
253
|
}
|
|
145
254
|
class I {
|
|
146
255
|
constructor(t) {
|
|
147
256
|
n(this, "source");
|
|
148
|
-
|
|
149
|
-
this.source = t;
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
this.source = A(t);
|
|
257
|
+
this.source = q(t);
|
|
153
258
|
}
|
|
154
259
|
[Symbol.iterator]() {
|
|
155
|
-
return new
|
|
260
|
+
return new tt(this.source);
|
|
156
261
|
}
|
|
157
262
|
}
|
|
158
|
-
class
|
|
263
|
+
class tt {
|
|
159
264
|
constructor(t) {
|
|
160
265
|
n(this, "sourceIterator");
|
|
161
266
|
this.sourceIterator = t[Symbol.iterator]();
|
|
@@ -164,22 +269,39 @@ class P {
|
|
|
164
269
|
return this.sourceIterator.next();
|
|
165
270
|
}
|
|
166
271
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
272
|
+
function L(e, t) {
|
|
273
|
+
if (e == null)
|
|
274
|
+
throw 'The source "iterable" must be provided';
|
|
275
|
+
const r = e[Symbol.iterator]();
|
|
276
|
+
let i = r.next(), s = i.value, u = null;
|
|
277
|
+
for (t == null ? u = (o, a) => o < a ? -1 : o === a ? 0 : 1 : d(t) ? u = t : Array.isArray(t) ? u = (o, a) => {
|
|
278
|
+
let c = 0;
|
|
279
|
+
for (const h of t)
|
|
280
|
+
if (c = o[h] < a[h] ? -1 : o[h] === a[h] ? 0 : 1, c !== 0)
|
|
281
|
+
break;
|
|
282
|
+
return c;
|
|
283
|
+
} : u = (o, a) => o[t] < a[t] ? -1 : o[t] === a[t] ? 0 : 1, i = r.next(); i.done !== !0; i = r.next()) {
|
|
284
|
+
const o = u(s, i.value);
|
|
285
|
+
s = o > 0 || o === 0 ? s : i.value;
|
|
286
|
+
}
|
|
287
|
+
return s == null ? null : s;
|
|
169
288
|
}
|
|
170
|
-
|
|
289
|
+
function F(e) {
|
|
290
|
+
return e instanceof y ? e : new y(e);
|
|
291
|
+
}
|
|
292
|
+
class y {
|
|
171
293
|
constructor(t) {
|
|
172
294
|
n(this, "isMemoized", !1);
|
|
173
295
|
n(this, "sourceIterator");
|
|
174
|
-
n(this, "linkedList", new
|
|
296
|
+
n(this, "linkedList", new x());
|
|
175
297
|
n(this, "source");
|
|
176
|
-
this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof
|
|
298
|
+
this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof x && (this.linkedList = t, this.isMemoized = !0);
|
|
177
299
|
}
|
|
178
300
|
[Symbol.iterator]() {
|
|
179
|
-
return this.isMemoized ? new
|
|
301
|
+
return this.isMemoized ? new rt(this.linkedList) : new et(this.sourceIterator, this.linkedList, (t) => this.isMemoized = t.done === !0);
|
|
180
302
|
}
|
|
181
303
|
}
|
|
182
|
-
class
|
|
304
|
+
class et {
|
|
183
305
|
constructor(t, r, i) {
|
|
184
306
|
n(this, "index", 0);
|
|
185
307
|
n(this, "linkedList");
|
|
@@ -195,7 +317,7 @@ class D {
|
|
|
195
317
|
return this.setAsMemoized(t) || this.linkedList.addLast(t.value), t;
|
|
196
318
|
}
|
|
197
319
|
}
|
|
198
|
-
class
|
|
320
|
+
class rt {
|
|
199
321
|
constructor(t) {
|
|
200
322
|
n(this, "memoizedSourceIterator");
|
|
201
323
|
this.memoizedSourceIterator = t[Symbol.iterator]();
|
|
@@ -204,22 +326,141 @@ class T {
|
|
|
204
326
|
return this.memoizedSourceIterator.next();
|
|
205
327
|
}
|
|
206
328
|
}
|
|
207
|
-
function
|
|
329
|
+
function E(e, t) {
|
|
330
|
+
if (e == null)
|
|
331
|
+
throw 'The source "iterable" must be provided';
|
|
208
332
|
const r = e[Symbol.iterator]();
|
|
209
333
|
let i = r.next(), s = i.value, u = null;
|
|
210
|
-
for (t == null ? u = (o, a) => o < a ? -1 : o === a ? 0 : 1 :
|
|
211
|
-
let
|
|
212
|
-
for (const
|
|
213
|
-
if (
|
|
334
|
+
for (t == null ? u = (o, a) => o < a ? -1 : o === a ? 0 : 1 : d(t) ? u = t : Array.isArray(t) ? u = (o, a) => {
|
|
335
|
+
let c = 0;
|
|
336
|
+
for (const h of t)
|
|
337
|
+
if (c = o[h] < a[h] ? -1 : o[h] === a[h] ? 0 : 1, c !== 0)
|
|
214
338
|
break;
|
|
215
|
-
return
|
|
339
|
+
return c;
|
|
216
340
|
} : u = (o, a) => o[t] < a[t] ? -1 : o[t] === a[t] ? 0 : 1, i = r.next(); i.done !== !0; i = r.next()) {
|
|
217
341
|
const o = u(s, i.value);
|
|
218
342
|
s = o < 0 || o === 0 ? s : i.value;
|
|
219
343
|
}
|
|
220
344
|
return s == null ? null : s;
|
|
221
345
|
}
|
|
222
|
-
function
|
|
346
|
+
function V(e, t, r, i) {
|
|
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)), v = !!(t === !0 || r === !0 || i != null && i), p = v ? h * c + u : u;
|
|
348
|
+
return u === s ? new ut(p, 0, 0) : v ? new st(p, h, c) : new nt(p, h, c);
|
|
349
|
+
}
|
|
350
|
+
class nt {
|
|
351
|
+
constructor(t, r, i) {
|
|
352
|
+
n(this, "initialValue");
|
|
353
|
+
n(this, "length");
|
|
354
|
+
n(this, "step");
|
|
355
|
+
this.initialValue = t, this.length = r, this.step = i;
|
|
356
|
+
}
|
|
357
|
+
[Symbol.iterator]() {
|
|
358
|
+
return new it(this.initialValue, this.length, this.step);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
class it {
|
|
362
|
+
constructor(t, r, i) {
|
|
363
|
+
n(this, "value");
|
|
364
|
+
n(this, "length");
|
|
365
|
+
n(this, "step");
|
|
366
|
+
this.value = t, this.length = r, this.step = i;
|
|
367
|
+
}
|
|
368
|
+
next() {
|
|
369
|
+
const t = this.value;
|
|
370
|
+
return this.value += this.step, this.length-- ? m(!1, t) : l();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
class st {
|
|
374
|
+
constructor(t, r, i) {
|
|
375
|
+
n(this, "initialValue");
|
|
376
|
+
n(this, "length");
|
|
377
|
+
n(this, "step");
|
|
378
|
+
this.initialValue = t - i, this.length = r, this.step = i;
|
|
379
|
+
}
|
|
380
|
+
[Symbol.iterator]() {
|
|
381
|
+
return new ot(this.initialValue, this.length, this.step);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
class ot {
|
|
385
|
+
constructor(t, r, i) {
|
|
386
|
+
n(this, "value");
|
|
387
|
+
n(this, "length");
|
|
388
|
+
n(this, "step");
|
|
389
|
+
this.value = t, this.length = r, this.step = i;
|
|
390
|
+
}
|
|
391
|
+
next() {
|
|
392
|
+
const t = this.value;
|
|
393
|
+
return this.value -= this.step, this.length-- ? m(!1, t) : l();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class ut {
|
|
397
|
+
constructor(t, r, i) {
|
|
398
|
+
n(this, "initialValue");
|
|
399
|
+
n(this, "length");
|
|
400
|
+
n(this, "step");
|
|
401
|
+
this.initialValue = t, this.length = r, this.step = i;
|
|
402
|
+
}
|
|
403
|
+
[Symbol.iterator]() {
|
|
404
|
+
return new at(this.initialValue, this.length, this.step);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
class at {
|
|
408
|
+
constructor(t, r, i) {
|
|
409
|
+
n(this, "value");
|
|
410
|
+
n(this, "length");
|
|
411
|
+
n(this, "step");
|
|
412
|
+
this.value = t, this.length = r, this.step = i;
|
|
413
|
+
}
|
|
414
|
+
next() {
|
|
415
|
+
return l();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function j(e, t, r) {
|
|
419
|
+
if (e == null)
|
|
420
|
+
throw 'The source "iterable" must be provided';
|
|
421
|
+
if (!d(r))
|
|
422
|
+
throw '"reducer" function must be provided';
|
|
423
|
+
const i = e[Symbol.iterator]();
|
|
424
|
+
let s = t, u = 0;
|
|
425
|
+
for (let o = i.next(); o.done !== !0; o = i.next())
|
|
426
|
+
s = r(s, o.value, u), u++;
|
|
427
|
+
return s;
|
|
428
|
+
}
|
|
429
|
+
function C(e, t) {
|
|
430
|
+
if (t < 0)
|
|
431
|
+
throw '"count" parameter must be greater or equal then 0';
|
|
432
|
+
return new lt(e, t);
|
|
433
|
+
}
|
|
434
|
+
class lt {
|
|
435
|
+
constructor(t, r) {
|
|
436
|
+
n(this, "value");
|
|
437
|
+
n(this, "count");
|
|
438
|
+
this.value = t, this.count = r;
|
|
439
|
+
}
|
|
440
|
+
[Symbol.iterator]() {
|
|
441
|
+
return new ht(this.value, this.count);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
class ht {
|
|
445
|
+
constructor(t, r) {
|
|
446
|
+
n(this, "leftToRepeat", 0);
|
|
447
|
+
n(this, "value");
|
|
448
|
+
n(this, "count");
|
|
449
|
+
n(this, "internalNext", () => this.leftToRepeat-- ? m(!1, this.value) : (this.internalNext = l, l()));
|
|
450
|
+
this.value = t, this.count = r, this.leftToRepeat = r, r === 0 && (this.internalNext = l);
|
|
451
|
+
}
|
|
452
|
+
next() {
|
|
453
|
+
return this.internalNext();
|
|
454
|
+
}
|
|
455
|
+
return(t) {
|
|
456
|
+
return this.internalNext = l, l(t);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function O(e, t) {
|
|
460
|
+
if (e == null)
|
|
461
|
+
throw 'The source "iterable" must be provided';
|
|
462
|
+
if (!d(t))
|
|
463
|
+
throw '"predicate" function must be provided';
|
|
223
464
|
const r = e[Symbol.iterator]();
|
|
224
465
|
let i = 0;
|
|
225
466
|
for (let s = r.next(); s.done !== !0; s = r.next())
|
|
@@ -227,7 +468,79 @@ function j(e, t) {
|
|
|
227
468
|
return !0;
|
|
228
469
|
return !1;
|
|
229
470
|
}
|
|
230
|
-
|
|
471
|
+
function P(e, t) {
|
|
472
|
+
if (e == null)
|
|
473
|
+
throw 'The source "iterable" must be provided';
|
|
474
|
+
if (!d(t))
|
|
475
|
+
throw '"tapper" function must be provided';
|
|
476
|
+
return new ct(e, t);
|
|
477
|
+
}
|
|
478
|
+
class ct {
|
|
479
|
+
constructor(t, r) {
|
|
480
|
+
n(this, "tapper");
|
|
481
|
+
n(this, "source");
|
|
482
|
+
this.source = t, this.tapper = r;
|
|
483
|
+
}
|
|
484
|
+
[Symbol.iterator]() {
|
|
485
|
+
return new dt(this.source, this.tapper);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
class dt {
|
|
489
|
+
constructor(t, r) {
|
|
490
|
+
n(this, "index", 0);
|
|
491
|
+
n(this, "sourceIterator");
|
|
492
|
+
n(this, "tapper");
|
|
493
|
+
n(this, "internalNext", () => {
|
|
494
|
+
const t = this.sourceIterator.next();
|
|
495
|
+
return t.done !== !0 ? (this.tapper(t.value, this.index++), t) : (this.internalNext = l, l());
|
|
496
|
+
});
|
|
497
|
+
this.sourceIterator = t[Symbol.iterator](), this.tapper = r;
|
|
498
|
+
}
|
|
499
|
+
next() {
|
|
500
|
+
return this.internalNext();
|
|
501
|
+
}
|
|
502
|
+
return(t) {
|
|
503
|
+
return this.internalNext = l, l(t);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function $(e, t) {
|
|
507
|
+
if (e == null)
|
|
508
|
+
throw 'The source "iterable" must be provided';
|
|
509
|
+
if (!d(t))
|
|
510
|
+
throw '"tapper" function must be provided';
|
|
511
|
+
return new ft(e, t);
|
|
512
|
+
}
|
|
513
|
+
class ft {
|
|
514
|
+
constructor(t, r) {
|
|
515
|
+
n(this, "tapper");
|
|
516
|
+
n(this, "source");
|
|
517
|
+
this.source = t, this.tapper = r;
|
|
518
|
+
}
|
|
519
|
+
[Symbol.iterator]() {
|
|
520
|
+
return this.tapper(this.source, 0), this.source[Symbol.iterator]();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
const xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
524
|
+
__proto__: null,
|
|
525
|
+
collectToArray: U,
|
|
526
|
+
empty: S,
|
|
527
|
+
filter: N,
|
|
528
|
+
flatMap: g,
|
|
529
|
+
forEach: T,
|
|
530
|
+
forEachAsync: A,
|
|
531
|
+
map: R,
|
|
532
|
+
materialize: k,
|
|
533
|
+
max: L,
|
|
534
|
+
memoize: F,
|
|
535
|
+
min: E,
|
|
536
|
+
range: V,
|
|
537
|
+
reduce: j,
|
|
538
|
+
repeat: C,
|
|
539
|
+
some: O,
|
|
540
|
+
tap: P,
|
|
541
|
+
tapChain: $
|
|
542
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
543
|
+
class f {
|
|
231
544
|
constructor(t) {
|
|
232
545
|
n(this, "iterable");
|
|
233
546
|
this.iterable = t;
|
|
@@ -236,31 +549,73 @@ class c {
|
|
|
236
549
|
return this.iterable[Symbol.iterator]();
|
|
237
550
|
}
|
|
238
551
|
collectToArray() {
|
|
239
|
-
return
|
|
552
|
+
return Array.from(this.iterable);
|
|
240
553
|
}
|
|
241
554
|
filter(t) {
|
|
242
|
-
return new
|
|
555
|
+
return new f(N(this.iterable, t));
|
|
556
|
+
}
|
|
557
|
+
flatMap(t) {
|
|
558
|
+
return new f(g(this.iterable, t));
|
|
559
|
+
}
|
|
560
|
+
forEach(t) {
|
|
561
|
+
return T(this.iterable, t);
|
|
562
|
+
}
|
|
563
|
+
forEachAsync(t) {
|
|
564
|
+
return A(this.iterable, t);
|
|
243
565
|
}
|
|
244
566
|
map(t) {
|
|
245
|
-
return new
|
|
567
|
+
return new f(R(this.iterable, t));
|
|
246
568
|
}
|
|
247
569
|
materialize() {
|
|
248
|
-
return new
|
|
570
|
+
return new f(k(this.iterable));
|
|
571
|
+
}
|
|
572
|
+
max(t) {
|
|
573
|
+
return L(this.iterable, t);
|
|
249
574
|
}
|
|
250
575
|
memoize() {
|
|
251
|
-
return new
|
|
576
|
+
return new f(F(this.iterable));
|
|
252
577
|
}
|
|
253
578
|
min(t) {
|
|
254
|
-
return
|
|
579
|
+
return E(this.iterable, t);
|
|
580
|
+
}
|
|
581
|
+
reduce(t, r) {
|
|
582
|
+
return j(this.iterable, t, r);
|
|
255
583
|
}
|
|
256
584
|
some(t) {
|
|
257
|
-
return
|
|
585
|
+
return O(this.iterable, t);
|
|
586
|
+
}
|
|
587
|
+
tap(t) {
|
|
588
|
+
return new f(P(this.iterable, t));
|
|
589
|
+
}
|
|
590
|
+
tapChain(t) {
|
|
591
|
+
return new f($(this.iterable, t));
|
|
258
592
|
}
|
|
593
|
+
tapChainCreation(t) {
|
|
594
|
+
if (!d(t))
|
|
595
|
+
throw '"tapper" function must be provided';
|
|
596
|
+
return t(this), this;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function bt() {
|
|
600
|
+
return w(S());
|
|
601
|
+
}
|
|
602
|
+
function w(e) {
|
|
603
|
+
if (e == null)
|
|
604
|
+
throw 'The source "iterable" must be provided';
|
|
605
|
+
return new f(e);
|
|
606
|
+
}
|
|
607
|
+
function wt(e, t, r, i) {
|
|
608
|
+
return w(V(e, t, r, i));
|
|
259
609
|
}
|
|
260
|
-
function
|
|
261
|
-
return
|
|
610
|
+
function vt(e, t) {
|
|
611
|
+
return w(C(e, t));
|
|
262
612
|
}
|
|
263
613
|
export {
|
|
264
|
-
|
|
265
|
-
|
|
614
|
+
xt as Functions,
|
|
615
|
+
f as IterableLinqWrapper,
|
|
616
|
+
pt as Types,
|
|
617
|
+
bt as empty,
|
|
618
|
+
w as from,
|
|
619
|
+
wt as fromRange,
|
|
620
|
+
vt as repeat
|
|
266
621
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(o=typeof globalThis<"u"?globalThis:o||self,u(o["interable-linq-utility"]={}))})(this,function(o){"use strict";var $=Object.defineProperty;var B=(o,u,d)=>u in o?$(o,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):o[u]=d;var n=(o,u,d)=>(B(o,typeof u!="symbol"?u+"":u,d),d);function u(e,t){return(r,i)=>t(e(r,i),i)}function d(e,t){return(r,i)=>e(r,i)&&t(r,i)}function S(e,t){return{done:e,value:t}}function b(){return{done:!0,value:void 0}}function C(e){return e}function w(e){return typeof e=="function"}function M(e,t){return new I(e,t)}class I{constructor(t,r){n(this,"predicate");n(this,"source");let i=r,s=t;if(s instanceof I){const l=s.predicate;s=s.source,i=d(l,i)}this.source=s,this.predicate=i}[Symbol.iterator](){return new k(this.source,this.predicate)}}class k{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"predicate");this.sourceIterator=t[Symbol.iterator](),this.predicate=r}next(){for(;;){const t=this.sourceIterator.next();if(t.done===!0||this.predicate(t.value,this.index++))return t}}}function L(e,t){return new x(e,t)}class x{constructor(t,r){n(this,"mapper");n(this,"source");let i=r,s=t;if(s instanceof x){const l=s.mapper;s=s.source,i=u(l,i)}this.source=t,this.mapper=i}[Symbol.iterator](){return new v(this.source,this.mapper)}}class v{constructor(t,r){n(this,"index",0);n(this,"sourceIterator");n(this,"mapper");this.sourceIterator=t[Symbol.iterator](),this.mapper=r}next(){const t=this.sourceIterator.next();return t.done!==!0?S(!1,this.mapper(t.value,this.index++)):b()}}function N(e){const t=e[Symbol.iterator](),r=new f;for(let i=t.next();i.done!==!0;i=t.next())r.addLast(i.value);return r}class A{constructor(t=null){n(this,"current",null);this.current=t}next(){const t=this.current;return t===null?b():(this.current=t.nextNode,S(!1,t.data))}}class f{constructor(){n(this,"internalSize",0);n(this,"head",null);n(this,"tail",null)}[Symbol.iterator](){return new A(this.head)}addFirst(t){const r={data:t,nextNode:null};switch(this.internalSize){case 0:this.head=r,this.tail=r;break;default:r.nextNode=this.head,this.head=r}return this.internalSize++,this}addLast(t){const r={data:t,nextNode:null};switch(this.internalSize){case 0:this.head=r,this.tail=r;break;default:this.tail.nextNode=r,this.tail=r}return this.internalSize++,this}size(){return this.internalSize}}function g(e){return e instanceof p?e:new p(e)}class p{constructor(t){n(this,"source");if(t instanceof f){this.source=t;return}this.source=N(t)}[Symbol.iterator](){return new F(this.source)}}class F{constructor(t){n(this,"sourceIterator");this.sourceIterator=t[Symbol.iterator]()}next(){return this.sourceIterator.next()}}function P(e){return e instanceof y?e:new y(e)}class y{constructor(t){n(this,"isMemoized",!1);n(this,"sourceIterator");n(this,"linkedList",new f);n(this,"source");this.source=t,this.sourceIterator=t[Symbol.iterator](),t instanceof f&&(this.linkedList=t,this.isMemoized=!0)}[Symbol.iterator](){return this.isMemoized?new R(this.linkedList):new T(this.sourceIterator,this.linkedList,t=>this.isMemoized=t.done===!0)}}class T{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 R{constructor(t){n(this,"memoizedSourceIterator");this.memoizedSourceIterator=t[Symbol.iterator]()}next(){return this.memoizedSourceIterator.next()}}function j(e,t){const r=e[Symbol.iterator]();let i=r.next(),s=i.value,l=null;for(t==null?l=(a,c)=>a<c?-1:a===c?0:1:w(t)?l=t:Array.isArray(t)?l=(a,c)=>{let z=0;for(const m of t)if(z=a[m]<c[m]?-1:a[m]===c[m]?0:1,z!==0)break;return z}:l=(a,c)=>a[t]<c[t]?-1:a[t]===c[t]?0:1,i=r.next();i.done!==!0;i=r.next()){const a=l(s,i.value);s=a<0||a===0?s:i.value}return s==null?null:s}function D(e,t){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}class h{constructor(t){n(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return[...this.iterable]}filter(t){return new h(M(this.iterable,t))}map(t){return new h(L(this.iterable,t))}materialize(){return new h(g(this.iterable))}memoize(){return new h(P(this.iterable))}min(t){return j(this.iterable,t)}some(t){return D(this.iterable,t)}}function O(e){return new h(e)}o.LinqIterableWrapper=h,o.from=O,Object.defineProperties(o,{__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 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"}})});
|
package/dist/linqIterable.d.ts
CHANGED
|
@@ -1,23 +1,44 @@
|
|
|
1
|
-
import { Comparer, Mapper, Predicate } from '@/types';
|
|
2
|
-
export interface
|
|
1
|
+
import { Action, AsyncAction, Comparer, Mapper, Reducer, Predicate, Tapper, Unit } from '@/types';
|
|
2
|
+
export interface IIterableLinq<T> {
|
|
3
3
|
[Symbol.iterator](): Iterator<T, any, undefined>;
|
|
4
4
|
collectToArray(): T[];
|
|
5
|
-
filter(predicate: Predicate<T>):
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
filter(predicate: Predicate<T>): IIterableLinq<T>;
|
|
6
|
+
flatMap<R>(mapper: Mapper<T, Iterable<R>>): IIterableLinq<R>;
|
|
7
|
+
forEach(action: Action<T>): Unit;
|
|
8
|
+
forEachAsync(action: AsyncAction<T>): Promise<Unit>;
|
|
9
|
+
map<R>(mapper: Mapper<T, R>): IIterableLinq<R>;
|
|
10
|
+
materialize(): IIterableLinq<T>;
|
|
11
|
+
max(comparer?: Comparer<T>): T | null | undefined;
|
|
12
|
+
memoize(): IIterableLinq<T>;
|
|
9
13
|
min(comparer?: Comparer<T>): T | null | undefined;
|
|
14
|
+
reduce<R>(neutralElement: R, reducer: Reducer<T, R>): R;
|
|
10
15
|
some(predicate: Predicate<T>): boolean;
|
|
16
|
+
tap(tapper: Tapper<T>): IIterableLinq<T>;
|
|
17
|
+
tapChain(tapper: Tapper<Iterable<T>>): IIterableLinq<T>;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @operation `Tap`
|
|
21
|
+
* @param chainCreationTapper
|
|
22
|
+
*/
|
|
23
|
+
tapChainCreation(chainCreationTapper: (iterableLinqWrapper: IIterableLinq<T>) => void): IIterableLinq<T>;
|
|
11
24
|
}
|
|
12
|
-
export declare class
|
|
25
|
+
export declare class IterableLinqWrapper<T> implements IIterableLinq<T> {
|
|
13
26
|
constructor(iterable: Iterable<T>);
|
|
14
27
|
[Symbol.iterator](): Iterator<T, any, undefined>;
|
|
15
28
|
private iterable;
|
|
16
29
|
collectToArray(): T[];
|
|
17
|
-
filter(predicate: Predicate<T>):
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
filter(predicate: Predicate<T>): IIterableLinq<T>;
|
|
31
|
+
flatMap<R>(mapper: Mapper<T, Iterable<R>>): IIterableLinq<R>;
|
|
32
|
+
forEach(action: Action<T>): Unit;
|
|
33
|
+
forEachAsync(action: AsyncAction<T>): Promise<Unit>;
|
|
34
|
+
map<R>(mapper: Mapper<T, R>): IIterableLinq<R>;
|
|
35
|
+
materialize(): IIterableLinq<T>;
|
|
36
|
+
max(comparer?: Comparer<T>): T | null | undefined;
|
|
37
|
+
memoize(): IIterableLinq<T>;
|
|
21
38
|
min(comparer?: Comparer<T>): T | null | undefined;
|
|
39
|
+
reduce<R>(neutralElement: R, reducer: Reducer<T, R>): R;
|
|
22
40
|
some(predicate: Predicate<T>): boolean;
|
|
41
|
+
tap(tapper: Tapper<T>): IIterableLinq<T>;
|
|
42
|
+
tapChain(tapper: Tapper<Iterable<T>>): IIterableLinq<T>;
|
|
43
|
+
tapChainCreation(chainCreationTapper: (iterableLinqWrapper: IIterableLinq<T>) => void): IIterableLinq<T>;
|
|
23
44
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Reducer<T, R> = (acc: R, value: T, index: number) => R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Tapper<T> = (value: T, index: number) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare function getIteratorResult<T>(done: boolean, value?: T): IteratorResult<T>;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function getContinueIteratorResult<T>(value: T): IteratorResult<T>;
|
|
3
|
+
export declare function getDoneIteratorResult<T>(value?: T): IteratorResult<T>;
|
|
3
4
|
export declare function getFlatIteratorResult<T>(result: IteratorResult<T>): IteratorResult<T>;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
export declare type BooleanComparePredicate<T> = (current: T, other: T) => boolean;
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @since 1.0.0
|
|
5
|
-
* @param {*} value The value to check.
|
|
6
|
-
* @returns {boolean} Returns `true` if `value` is `null`, `undefined` or `NaN`, else false.
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* isNullOrUndefined(null)
|
|
10
|
-
* // => true
|
|
11
|
-
*
|
|
12
|
-
* isNullOrUndefined(undefined)
|
|
13
|
-
* // => true
|
|
14
|
-
*
|
|
15
|
-
* isNullOrUndefined()
|
|
16
|
-
* // => true
|
|
17
|
-
*
|
|
18
|
-
* const myVariable = undefined
|
|
19
|
-
* isNullOrUndefined(myVariable)
|
|
20
|
-
* // => true
|
|
21
|
-
*
|
|
22
|
-
* isNullOrUndefined('')
|
|
23
|
-
* // => false
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
export declare function isNullOrUndefined(value?: any): value is null | undefined;
|
|
27
1
|
/**
|
|
28
2
|
* Checks if `value` is classified as a `Function` object.
|
|
29
3
|
*
|
|
@@ -71,4 +45,12 @@ export declare function isFunction(value?: any): value is (...args: any[]) => an
|
|
|
71
45
|
* isString(1)
|
|
72
46
|
* // => false
|
|
73
47
|
*/
|
|
74
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Gets the `toStringTag` of `value`.
|
|
50
|
+
*
|
|
51
|
+
* From [LoDash internal getTag](https://github.com/lodash/lodash/blob/master/.internal/getTag.js)
|
|
52
|
+
*
|
|
53
|
+
* @private
|
|
54
|
+
* @param {*} value The value to query.
|
|
55
|
+
* @returns {string} Returns the `toStringTag`.
|
|
56
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iterable-linq-utility",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "An Iterable mutation utility inspired by .net Linq and Javascript Array interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/interable-linq-utility.umd.cjs",
|
|
@@ -29,17 +29,22 @@
|
|
|
29
29
|
"url": "git+https://github.com/Amebus/iterable-linq-utility.git"
|
|
30
30
|
},
|
|
31
31
|
"author": "Amebus",
|
|
32
|
-
"license": "
|
|
32
|
+
"license": "MIT",
|
|
33
33
|
"bugs": {
|
|
34
34
|
"url": "https://github.com/Amebus/iterable-linq-utility/issues"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/Amebus/iterable-linq-utility#readme",
|
|
37
|
-
"keywords": [
|
|
37
|
+
"keywords": [
|
|
38
|
+
"linq",
|
|
39
|
+
"itearable",
|
|
40
|
+
"utility"
|
|
41
|
+
],
|
|
38
42
|
"devDependencies": {
|
|
39
|
-
"@rushstack/eslint-patch": "
|
|
43
|
+
"@rushstack/eslint-patch": "1.1.4",
|
|
40
44
|
"@types/node": "18.11.10",
|
|
41
45
|
"@typescript-eslint/eslint-plugin": "5.36.2",
|
|
42
46
|
"@typescript-eslint/parser": "5.36.2",
|
|
47
|
+
"@vitest/coverage-c8": "0.25.8",
|
|
43
48
|
"@vitest/ui": "0.25.2",
|
|
44
49
|
"eslint": "8.22.0",
|
|
45
50
|
"eslint-plugin-import": "2.26.0",
|