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