iterable-linq-utility 0.0.8 → 0.0.10

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 @@
1
+ export declare function collectToArray<T>(iterable: Iterable<T>): T[];
@@ -0,0 +1 @@
1
+ export declare function empty<T>(): Iterable<T>;
@@ -1,2 +1,9 @@
1
1
  import { Predicate } from "@/types";
2
- export declare function filter<T>(iterable: Iterable<T>, predicate: typeof Predicate<T>): Iterable<T>;
2
+ /**
3
+ *
4
+ * @operation `Transformation`
5
+ * @param iterable
6
+ * @param predicate
7
+ * @returns
8
+ */
9
+ export declare function filter<T>(iterable: Iterable<T>, predicate: Predicate<T>): Iterable<T>;
@@ -1,8 +1,21 @@
1
- export * from './filter';
2
- export * from './map';
3
- export * from './materialize';
4
- export * from './max';
5
- export * from './memoize';
6
- export * from './min';
7
- export * from './range';
8
- export * from './some';
1
+ import { collectToArray } from './collectToArray';
2
+ export { collectToArray };
3
+ import { empty } from './empty';
4
+ export { empty };
5
+ import { filter } from './filter';
6
+ export { filter };
7
+ import { map } from './map';
8
+ import { materialize } from './materialize';
9
+ import { max } from './max';
10
+ import { memoize } from './memoize';
11
+ import { min } from './min';
12
+ export { map, materialize, max, memoize, min };
13
+ import { range } from './range';
14
+ import { reduce } from './reduce';
15
+ import { repeat } from './repeat';
16
+ export { range, reduce, repeat };
17
+ import { some } from './some';
18
+ export { some };
19
+ import { tap } from './tap';
20
+ import { tapChain } from './tapChain';
21
+ export { tap, tapChain };
@@ -1,2 +1,9 @@
1
1
  import { Mapper } from "@/types";
2
+ /**
3
+ *
4
+ * @operation `Transformation`
5
+ * @param iterable
6
+ * @param mapper
7
+ * @returns
8
+ */
2
9
  export declare function map<T, R>(iterable: Iterable<T>, mapper: Mapper<T, R>): Iterable<R>;
@@ -1 +1,7 @@
1
+ /**
2
+ *
3
+ * @operation `Action`
4
+ * @param iterable
5
+ * @returns
6
+ */
1
7
  export declare function materialize<T>(iterable: Iterable<T>): Iterable<T>;
@@ -1 +1,9 @@
1
- export declare function max<T>(iterable: Iterable<T>, comparer?: (a: T, b: T, index: number) => boolean): T | null | undefined;
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;
@@ -1 +1,7 @@
1
+ /**
2
+ *
3
+ * @operation `Transformation`
4
+ * @param iterable
5
+ * @returns
6
+ */
1
7
  export declare function memoize<T>(iterable: Iterable<T>): Iterable<T>;
@@ -1,2 +1,9 @@
1
1
  import type { Comparer } from "@/types";
2
+ /**
3
+ *
4
+ * @operation `Action`
5
+ * @param iterable
6
+ * @param comparer
7
+ * @returns
8
+ */
2
9
  export declare function min<T>(iterable: Iterable<T>, comparer?: Comparer<T>): T | null | undefined;
@@ -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>;
@@ -1,2 +1,9 @@
1
1
  import { Predicate } from "@/types";
2
- export declare function some<T>(iterable: Iterable<T>, predicate: typeof Predicate<T>): boolean;
2
+ /**
3
+ *
4
+ * @operation `Action`
5
+ * @param iterable
6
+ * @param predicate
7
+ * @returns
8
+ */
9
+ export declare function some<T>(iterable: Iterable<T>, predicate: Predicate<T>): boolean;
@@ -0,0 +1,9 @@
1
+ import { Tapper } from "@/types";
2
+ /**
3
+ *
4
+ * @operation `Tap`
5
+ * @param iterable
6
+ * @param tapper
7
+ * @returns
8
+ */
9
+ export declare function tap<T>(iterable: Iterable<T>, tapper: Tapper<T>): Iterable<T>;
@@ -0,0 +1,9 @@
1
+ import { Tapper } from "@/types";
2
+ /**
3
+ *
4
+ * @operation `Tap`
5
+ * @param iterable
6
+ * @param tapper
7
+ * @returns
8
+ */
9
+ export declare function tapChain<T>(iterable: Iterable<T>, tapper: Tapper<Iterable<T>>): Iterable<T>;
@@ -1 +1,2 @@
1
- export * from './linkedList';
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,13 @@
1
- import { type ILinqIterable } from "./linqIterable";
2
- export declare function from<T>(iterable: Iterable<T>): ILinqIterable<T>;
3
- export { ILinqIterable };
1
+ import { IterableLinqWrapper, type IIterableLinq } from "./linqIterable";
2
+ import * as Functions from '@/functions';
3
+ export declare function empty<T>(): IIterableLinq<T>;
4
+ export declare function from<T>(iterable: Iterable<T>): IIterableLinq<T>;
5
+ export declare function fromRange(end: number): IIterableLinq<number>;
6
+ export declare function fromRange(end: number, reverse?: boolean): IIterableLinq<number>;
7
+ export declare function fromRange(start: number, end: number): IIterableLinq<number>;
8
+ export declare function fromRange(start: number, end: number, step: number): IIterableLinq<number>;
9
+ export declare function fromRange(start: number, end: number, reverse: boolean): IIterableLinq<number>;
10
+ export declare function fromRange(start: number, end: number, step: number, reverse: boolean): IIterableLinq<number>;
11
+ export declare function fromRange(start: number, end?: number | boolean, step?: number | boolean, reverse?: boolean): Iterable<number>;
12
+ export declare function repeat<T>(value: T, count: number): IIterableLinq<T>;
13
+ export { Functions, IIterableLinq, IterableLinqWrapper };
@@ -1,47 +1,57 @@
1
- var b = Object.defineProperty;
2
- var y = (e, t, r) => t in e ? b(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var i = (e, t, r) => (y(e, typeof t != "symbol" ? t + "" : t, r), r);
4
- function p(e, t) {
5
- return (r, n) => t(e(r, n), n);
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) {
5
+ return Array.from(e);
6
6
  }
7
- function k(e, t) {
8
- return (r, n) => e(r, n) && t(r, n);
9
- }
10
- function S(e, t) {
7
+ function f(e, t) {
11
8
  return {
12
9
  done: e,
13
10
  value: t
14
11
  };
15
12
  }
16
- function w() {
17
- return { done: !0, value: void 0 };
13
+ function l(e) {
14
+ return { done: !0, value: e };
18
15
  }
19
- function M(e) {
16
+ function m(e) {
20
17
  return typeof e == "function";
21
18
  }
22
- function L(e, t) {
23
- return new m(e, t);
19
+ function w() {
20
+ return new j();
21
+ }
22
+ class j {
23
+ [Symbol.iterator]() {
24
+ return new O();
25
+ }
24
26
  }
25
- class m {
27
+ class O {
28
+ next() {
29
+ return l();
30
+ }
31
+ return(t) {
32
+ return l(t);
33
+ }
34
+ }
35
+ function v(e, t) {
36
+ if (!m(t))
37
+ throw '"predicate" function must be provided';
38
+ return new B(e, t);
39
+ }
40
+ class B {
26
41
  constructor(t, r) {
27
- i(this, "predicate");
28
- i(this, "source");
29
- let n = r, s = t;
30
- if (s instanceof m) {
31
- const u = s.predicate;
32
- s = s.source, n = k(u, n);
33
- }
34
- this.source = s, this.predicate = n;
42
+ n(this, "predicate");
43
+ n(this, "source");
44
+ this.source = t, this.predicate = r;
35
45
  }
36
46
  [Symbol.iterator]() {
37
- return new v(this.source, this.predicate);
47
+ return new D(this.source, this.predicate);
38
48
  }
39
49
  }
40
- class v {
50
+ class D {
41
51
  constructor(t, r) {
42
- i(this, "index", 0);
43
- i(this, "sourceIterator");
44
- i(this, "predicate");
52
+ n(this, "index", 0);
53
+ n(this, "sourceIterator");
54
+ n(this, "predicate");
45
55
  this.sourceIterator = t[Symbol.iterator](), this.predicate = r;
46
56
  }
47
57
  next() {
@@ -52,141 +62,153 @@ class v {
52
62
  }
53
63
  }
54
64
  }
55
- function N(e, t) {
56
- return new I(e, t);
65
+ function g(e, t) {
66
+ if (!m(t))
67
+ throw '"mapper" function must be provided';
68
+ return new P(e, t);
57
69
  }
58
- class I {
70
+ class P {
59
71
  constructor(t, r) {
60
- i(this, "mapper");
61
- i(this, "source");
62
- let n = r, s = t;
63
- if (s instanceof I) {
64
- const u = s.mapper;
65
- s = s.source, n = p(u, n);
66
- }
67
- this.source = t, this.mapper = n;
72
+ n(this, "mapper");
73
+ n(this, "source");
74
+ this.source = t, this.mapper = r;
68
75
  }
69
76
  [Symbol.iterator]() {
70
- return new A(this.source, this.mapper);
77
+ return new G(this.source, this.mapper);
71
78
  }
72
79
  }
73
- class A {
80
+ class G {
74
81
  constructor(t, r) {
75
- i(this, "index", 0);
76
- i(this, "sourceIterator");
77
- i(this, "mapper");
82
+ n(this, "index", 0);
83
+ n(this, "sourceIterator");
84
+ n(this, "mapper");
78
85
  this.sourceIterator = t[Symbol.iterator](), this.mapper = r;
79
86
  }
80
87
  next() {
81
88
  const t = this.sourceIterator.next();
82
- return t.done !== !0 ? S(!1, this.mapper(t.value, this.index++)) : w();
89
+ return t.done !== !0 ? f(!1, this.mapper(t.value, this.index++)) : l();
83
90
  }
84
91
  }
85
- function F(e) {
86
- const t = e[Symbol.iterator](), r = new d();
87
- for (let n = t.next(); n.done !== !0; n = t.next())
88
- r.addLast(n.value);
92
+ function H(e) {
93
+ const t = e[Symbol.iterator](), r = new x();
94
+ for (let i = t.next(); i.done !== !0; i = t.next())
95
+ r.addLast(i.value);
89
96
  return r;
90
97
  }
91
- class g {
92
- constructor(t = null) {
93
- i(this, "current", null);
94
- this.current = t;
95
- }
96
- next() {
97
- const t = this.current;
98
- return t === null ? w() : (this.current = t.nextNode, S(!1, t.data));
99
- }
100
- }
101
- class d {
98
+ class x {
102
99
  constructor() {
103
- i(this, "internalSize", 0);
104
- i(this, "head", null);
105
- i(this, "tail", null);
100
+ n(this, "internalSize", 0);
101
+ n(this, "head", null);
102
+ n(this, "tail", null);
103
+ n(this, "internalAddFirst", (t) => {
104
+ const r = {
105
+ data: t,
106
+ nextNode: null
107
+ };
108
+ return this.head = r, this.tail = r, this.internalSize++, this.internalAddFirst = (i) => {
109
+ const o = {
110
+ data: i,
111
+ nextNode: null
112
+ };
113
+ return o.nextNode = this.head, this.head = o, this.internalSize++, this;
114
+ }, this;
115
+ });
116
+ n(this, "internalAddLast", (t) => {
117
+ const r = {
118
+ data: t,
119
+ nextNode: null
120
+ };
121
+ return this.head = r, this.tail = r, this.internalSize++, this.internalAddLast = (i) => {
122
+ const o = {
123
+ data: i,
124
+ nextNode: null
125
+ };
126
+ return this.tail.nextNode = o, this.tail = o, this.internalSize++, this;
127
+ }, this;
128
+ });
106
129
  }
107
130
  [Symbol.iterator]() {
108
- return new g(this.head);
131
+ return new J(this.head);
109
132
  }
110
133
  addFirst(t) {
111
- const r = {
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;
134
+ return this.internalAddFirst(t);
123
135
  }
124
136
  addLast(t) {
125
- const r = {
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;
137
+ return this.internalAddLast(t);
137
138
  }
138
139
  size() {
139
140
  return this.internalSize;
140
141
  }
141
142
  }
142
- function P(e) {
143
- return e instanceof x ? e : new x(e);
143
+ class J {
144
+ constructor(t = null) {
145
+ n(this, "current", null);
146
+ this.current = t;
147
+ }
148
+ next() {
149
+ const t = this.current;
150
+ return t === null ? l() : (this.current = t.nextNode, f(!1, t.data));
151
+ }
152
+ }
153
+ function z(e) {
154
+ return e instanceof y ? e : new y(e);
144
155
  }
145
- class x {
156
+ class y {
146
157
  constructor(t) {
147
- i(this, "source");
148
- if (t instanceof d) {
149
- this.source = t;
150
- return;
151
- }
152
- this.source = F(t);
158
+ n(this, "source");
159
+ this.source = H(t);
153
160
  }
154
161
  [Symbol.iterator]() {
155
- return new R(this.source);
162
+ return new K(this.source);
156
163
  }
157
164
  }
158
- class R {
165
+ class K {
159
166
  constructor(t) {
160
- i(this, "sourceIterator");
167
+ n(this, "sourceIterator");
161
168
  this.sourceIterator = t[Symbol.iterator]();
162
169
  }
163
170
  next() {
164
171
  return this.sourceIterator.next();
165
172
  }
166
173
  }
167
- function D(e) {
168
- return e instanceof z ? e : new z(e);
174
+ function N(e, t) {
175
+ 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) => {
178
+ let c = 0;
179
+ for (const h of t)
180
+ if (c = s[h] < a[h] ? -1 : s[h] === a[h] ? 0 : 1, c !== 0)
181
+ break;
182
+ 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;
186
+ }
187
+ return o == null ? null : o;
188
+ }
189
+ function M(e) {
190
+ return e instanceof S ? e : new S(e);
169
191
  }
170
- class z {
192
+ class S {
171
193
  constructor(t) {
172
- i(this, "isMemoized", !1);
173
- i(this, "sourceIterator");
174
- i(this, "linkedList", new d());
175
- i(this, "source");
176
- this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof d && (this.linkedList = t, this.isMemoized = !0);
194
+ n(this, "isMemoized", !1);
195
+ n(this, "sourceIterator");
196
+ n(this, "linkedList", new x());
197
+ n(this, "source");
198
+ this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof x && (this.linkedList = t, this.isMemoized = !0);
177
199
  }
178
200
  [Symbol.iterator]() {
179
- return this.isMemoized ? new $(this.linkedList) : new T(this.sourceIterator, this.linkedList, (t) => this.isMemoized = t.done === !0);
201
+ return this.isMemoized ? new U(this.linkedList) : new Q(this.sourceIterator, this.linkedList, (t) => this.isMemoized = t.done === !0);
180
202
  }
181
203
  }
182
- class T {
183
- constructor(t, r, n) {
184
- i(this, "index", 0);
185
- i(this, "linkedList");
186
- i(this, "linkedListIterator");
187
- i(this, "setAsMemoized");
188
- i(this, "sourceIterator");
189
- this.linkedList = r, this.linkedListIterator = r[Symbol.iterator](), this.setAsMemoized = n, this.sourceIterator = t;
204
+ class Q {
205
+ constructor(t, r, i) {
206
+ n(this, "index", 0);
207
+ n(this, "linkedList");
208
+ n(this, "linkedListIterator");
209
+ n(this, "setAsMemoized");
210
+ n(this, "sourceIterator");
211
+ this.linkedList = r, this.linkedListIterator = r[Symbol.iterator](), this.setAsMemoized = i, this.sourceIterator = t;
190
212
  }
191
213
  next() {
192
214
  if (this.linkedList.size() > this.index++)
@@ -195,71 +217,272 @@ class T {
195
217
  return this.setAsMemoized(t) || this.linkedList.addLast(t.value), t;
196
218
  }
197
219
  }
198
- class $ {
220
+ class U {
199
221
  constructor(t) {
200
- i(this, "memoizedSourceIterator");
222
+ n(this, "memoizedSourceIterator");
201
223
  this.memoizedSourceIterator = t[Symbol.iterator]();
202
224
  }
203
225
  next() {
204
226
  return this.memoizedSourceIterator.next();
205
227
  }
206
228
  }
207
- function j(e, t) {
229
+ function R(e, t) {
208
230
  const r = e[Symbol.iterator]();
209
- let n = 0, s = r.next(), u = s.value, l = null;
210
- for (t == null ? l = (o, a) => o < a ? -1 : o === a ? 0 : 1 : M(t) ? l = t : Array.isArray(t) ? l = (o, a) => {
211
- let f = 0;
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) => {
233
+ let c = 0;
212
234
  for (const h of t)
213
- if (f = o[h] < a[h] ? -1 : o[h] === a[h] ? 0 : 1, f !== 0)
235
+ if (c = s[h] < a[h] ? -1 : s[h] === a[h] ? 0 : 1, c !== 0)
214
236
  break;
215
- return f;
216
- } : l = (o, a) => o[t] < a[t] ? -1 : o[t] === a[t] ? 0 : 1, s = r.next(); s.done !== !0; s = r.next()) {
217
- const o = l(u, s.value, n++);
218
- u = o < 0 || o === 0 ? u : s.value;
237
+ 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;
241
+ }
242
+ return o == null ? null : o;
243
+ }
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);
247
+ }
248
+ class X {
249
+ constructor(t, r, i) {
250
+ n(this, "initialValue");
251
+ n(this, "length");
252
+ n(this, "step");
253
+ this.initialValue = t, this.length = r, this.step = i;
254
+ }
255
+ [Symbol.iterator]() {
256
+ return new Y(this.initialValue, this.length, this.step);
257
+ }
258
+ }
259
+ class Y {
260
+ constructor(t, r, i) {
261
+ n(this, "value");
262
+ n(this, "length");
263
+ n(this, "step");
264
+ this.value = t, this.length = r, this.step = i;
265
+ }
266
+ next() {
267
+ const t = this.value;
268
+ return this.value += this.step, this.length-- ? f(!1, t) : l();
269
+ }
270
+ }
271
+ class Z {
272
+ constructor(t, r, i) {
273
+ n(this, "initialValue");
274
+ n(this, "length");
275
+ n(this, "step");
276
+ this.initialValue = t - i, this.length = r, this.step = i;
277
+ }
278
+ [Symbol.iterator]() {
279
+ return new _(this.initialValue, this.length, this.step);
280
+ }
281
+ }
282
+ class _ {
283
+ constructor(t, r, i) {
284
+ n(this, "value");
285
+ n(this, "length");
286
+ n(this, "step");
287
+ this.value = t, this.length = r, this.step = i;
288
+ }
289
+ next() {
290
+ const t = this.value;
291
+ return this.value -= this.step, this.length-- ? f(!1, t) : l();
292
+ }
293
+ }
294
+ class q {
295
+ constructor(t, r, i) {
296
+ n(this, "initialValue");
297
+ n(this, "length");
298
+ n(this, "step");
299
+ this.initialValue = t, this.length = r, this.step = i;
300
+ }
301
+ [Symbol.iterator]() {
302
+ return new W(this.initialValue, this.length, this.step);
303
+ }
304
+ }
305
+ class W {
306
+ constructor(t, r, i) {
307
+ n(this, "value");
308
+ n(this, "length");
309
+ n(this, "step");
310
+ this.value = t, this.length = r, this.step = i;
311
+ }
312
+ next() {
313
+ return l();
314
+ }
315
+ }
316
+ function A(e, t, r) {
317
+ if (!m(r))
318
+ throw '"reducer" function must be provided';
319
+ 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;
324
+ }
325
+ function L(e, t) {
326
+ if (t < 0)
327
+ throw '"count" parameter must be greater or equal then 0';
328
+ return new tt(e, t);
329
+ }
330
+ class tt {
331
+ constructor(t, r) {
332
+ n(this, "value");
333
+ n(this, "count");
334
+ this.value = t, this.count = r;
335
+ }
336
+ [Symbol.iterator]() {
337
+ return new et(this.value, this.count);
338
+ }
339
+ }
340
+ class et {
341
+ constructor(t, r) {
342
+ n(this, "leftToRepeat", 0);
343
+ n(this, "value");
344
+ 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());
347
+ }
348
+ next() {
349
+ return this.internalNext();
350
+ }
351
+ return(t) {
352
+ return this.internalNext = () => l(), l(t);
219
353
  }
220
- return u == null ? null : u;
221
354
  }
222
- function B(e, t) {
355
+ function V(e, t) {
223
356
  const r = e[Symbol.iterator]();
224
- let n = 0;
225
- for (let s = r.next(); s.done !== !0; s = r.next())
226
- if (t(s.value, n++))
357
+ let i = 0;
358
+ for (let o = r.next(); o.done !== !0; o = r.next())
359
+ if (t(o.value, i++))
227
360
  return !0;
228
361
  return !1;
229
362
  }
230
- class c {
363
+ function F(e, t) {
364
+ return new rt(e, t);
365
+ }
366
+ class rt {
367
+ constructor(t, r) {
368
+ n(this, "tapper");
369
+ n(this, "source");
370
+ this.source = t, this.tapper = r;
371
+ }
372
+ [Symbol.iterator]() {
373
+ return new nt(this.source, this.tapper);
374
+ }
375
+ }
376
+ class nt {
377
+ constructor(t, r) {
378
+ n(this, "index", 0);
379
+ n(this, "sourceIterator");
380
+ n(this, "tapper");
381
+ n(this, "innerNext", () => {
382
+ const t = this.sourceIterator.next();
383
+ return t.done !== !0 ? (this.tapper(t.value, this.index++), t) : (this.innerNext = l, l());
384
+ });
385
+ this.sourceIterator = t[Symbol.iterator](), this.tapper = r;
386
+ }
387
+ next() {
388
+ return this.innerNext();
389
+ }
390
+ return(t) {
391
+ return this.innerNext = l, l(t);
392
+ }
393
+ }
394
+ function T(e, t) {
395
+ return new it(e, t);
396
+ }
397
+ class it {
398
+ constructor(t, r) {
399
+ n(this, "tapper");
400
+ n(this, "source");
401
+ this.source = t, this.tapper = r;
402
+ }
403
+ [Symbol.iterator]() {
404
+ return this.tapper(this.source, 0), this.source[Symbol.iterator]();
405
+ }
406
+ }
407
+ const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
408
+ __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
423
+ }, Symbol.toStringTag, { value: "Module" }));
424
+ class d {
231
425
  constructor(t) {
232
- i(this, "iterable");
426
+ n(this, "iterable");
233
427
  this.iterable = t;
234
428
  }
235
429
  [Symbol.iterator]() {
236
430
  return this.iterable[Symbol.iterator]();
237
431
  }
238
432
  collectToArray() {
239
- return [...this.iterable];
433
+ return Array.from(this.iterable);
240
434
  }
241
435
  filter(t) {
242
- return new c(L(this.iterable, t));
436
+ return new d(v(this.iterable, t));
243
437
  }
244
438
  map(t) {
245
- return new c(N(this.iterable, t));
439
+ return new d(g(this.iterable, t));
246
440
  }
247
441
  materialize() {
248
- return new c(P(this.iterable));
442
+ return new d(z(this.iterable));
443
+ }
444
+ max(t) {
445
+ return N(this.iterable, t);
249
446
  }
250
447
  memoize() {
251
- return new c(D(this.iterable));
448
+ return new d(M(this.iterable));
252
449
  }
253
450
  min(t) {
254
- return j(this.iterable, t);
451
+ return R(this.iterable, t);
452
+ }
453
+ reduce(t, r) {
454
+ return A(this.iterable, t, r);
255
455
  }
256
456
  some(t) {
257
- return B(this.iterable, t);
457
+ return V(this.iterable, t);
458
+ }
459
+ tap(t) {
460
+ return new d(F(this.iterable, t));
461
+ }
462
+ tapChain(t) {
463
+ return new d(T(this.iterable, t));
464
+ }
465
+ tapChainCreation(t) {
466
+ return t(this), this;
258
467
  }
259
468
  }
260
- function E(e) {
261
- return new c(e);
469
+ function at() {
470
+ return b(w());
471
+ }
472
+ function b(e) {
473
+ return new d(e);
474
+ }
475
+ function ut(e, t, r, i) {
476
+ return b(k(e, t, r, i));
477
+ }
478
+ function lt(e, t) {
479
+ return b(L(e, t));
262
480
  }
263
481
  export {
264
- E as from
482
+ ot as Functions,
483
+ d as IterableLinqWrapper,
484
+ at as empty,
485
+ b as from,
486
+ ut as fromRange,
487
+ lt as repeat
265
488
  };
@@ -1 +1 @@
1
- (function(u,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(u=typeof globalThis<"u"?globalThis:u||self,o(u["interable-linq-utility"]={}))})(this,function(u){"use strict";var B=Object.defineProperty;var C=(u,o,d)=>o in u?B(u,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):u[o]=d;var i=(u,o,d)=>(C(u,typeof o!="symbol"?o+"":o,d),d);function o(e,t){return(r,n)=>t(e(r,n),n)}function d(e,t){return(r,n)=>e(r,n)&&t(r,n)}function b(e,t){return{done:e,value:t}}function p(){return{done:!0,value:void 0}}function E(e){return e}function M(e){return typeof e=="function"}function k(e,t){return new x(e,t)}class x{constructor(t,r){i(this,"predicate");i(this,"source");let n=r,s=t;if(s instanceof x){const l=s.predicate;s=s.source,n=d(l,n)}this.source=s,this.predicate=n}[Symbol.iterator](){return new L(this.source,this.predicate)}}class L{constructor(t,r){i(this,"index",0);i(this,"sourceIterator");i(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){return new z(e,t)}class z{constructor(t,r){i(this,"mapper");i(this,"source");let n=r,s=t;if(s instanceof z){const l=s.mapper;s=s.source,n=o(l,n)}this.source=t,this.mapper=n}[Symbol.iterator](){return new N(this.source,this.mapper)}}class N{constructor(t,r){i(this,"index",0);i(this,"sourceIterator");i(this,"mapper");this.sourceIterator=t[Symbol.iterator](),this.mapper=r}next(){const t=this.sourceIterator.next();return t.done!==!0?b(!1,this.mapper(t.value,this.index++)):p()}}function A(e){const t=e[Symbol.iterator](),r=new m;for(let n=t.next();n.done!==!0;n=t.next())r.addLast(n.value);return r}class g{constructor(t=null){i(this,"current",null);this.current=t}next(){const t=this.current;return t===null?p():(this.current=t.nextNode,b(!1,t.data))}}class m{constructor(){i(this,"internalSize",0);i(this,"head",null);i(this,"tail",null)}[Symbol.iterator](){return new g(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 F(e){return e instanceof y?e:new y(e)}class y{constructor(t){i(this,"source");if(t instanceof m){this.source=t;return}this.source=A(t)}[Symbol.iterator](){return new P(this.source)}}class P{constructor(t){i(this,"sourceIterator");this.sourceIterator=t[Symbol.iterator]()}next(){return this.sourceIterator.next()}}function T(e){return e instanceof w?e:new w(e)}class w{constructor(t){i(this,"isMemoized",!1);i(this,"sourceIterator");i(this,"linkedList",new m);i(this,"source");this.source=t,this.sourceIterator=t[Symbol.iterator](),t instanceof m&&(this.linkedList=t,this.isMemoized=!0)}[Symbol.iterator](){return this.isMemoized?new j(this.linkedList):new R(this.sourceIterator,this.linkedList,t=>this.isMemoized=t.done===!0)}}class R{constructor(t,r,n){i(this,"index",0);i(this,"linkedList");i(this,"linkedListIterator");i(this,"setAsMemoized");i(this,"sourceIterator");this.linkedList=r,this.linkedListIterator=r[Symbol.iterator](),this.setAsMemoized=n,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 j{constructor(t){i(this,"memoizedSourceIterator");this.memoizedSourceIterator=t[Symbol.iterator]()}next(){return this.memoizedSourceIterator.next()}}function D(e,t){const r=e[Symbol.iterator]();let n=0,s=r.next(),l=s.value,f=null;for(t==null?f=(a,c)=>a<c?-1:a===c?0:1:M(t)?f=t:Array.isArray(t)?f=(a,c)=>{let S=0;for(const I of t)if(S=a[I]<c[I]?-1:a[I]===c[I]?0:1,S!==0)break;return S}:f=(a,c)=>a[t]<c[t]?-1:a[t]===c[t]?0:1,s=r.next();s.done!==!0;s=r.next()){const a=f(l,s.value,n++);l=a<0||a===0?l:s.value}return l==null?null:l}function O(e,t){const r=e[Symbol.iterator]();let n=0;for(let s=r.next();s.done!==!0;s=r.next())if(t(s.value,n++))return!0;return!1}class h{constructor(t){i(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return[...this.iterable]}filter(t){return new h(k(this.iterable,t))}map(t){return new h(v(this.iterable,t))}materialize(){return new h(F(this.iterable))}memoize(){return new h(T(this.iterable))}min(t){return D(this.iterable,t)}some(t){return O(this.iterable,t)}}function $(e){return new h(e)}u.from=$,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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,23 +1,38 @@
1
- import { Comparer, Mapper, Predicate } from '@/types';
2
- export interface ILinqIterable<T> {
1
+ import { Comparer, Mapper, Reducer, Predicate, Tapper } from '@/types';
2
+ export interface IIterableLinq<T> {
3
3
  [Symbol.iterator](): Iterator<T, any, undefined>;
4
4
  collectToArray(): T[];
5
- filter(predicate: typeof Predicate<T>): ILinqIterable<T>;
6
- map<R>(mapper: Mapper<T, R>): ILinqIterable<R>;
7
- materialize(): ILinqIterable<T>;
8
- memoize(): ILinqIterable<T>;
5
+ filter(predicate: Predicate<T>): IIterableLinq<T>;
6
+ map<R>(mapper: Mapper<T, R>): IIterableLinq<R>;
7
+ materialize(): IIterableLinq<T>;
8
+ max(comparer?: Comparer<T>): T | null | undefined;
9
+ memoize(): IIterableLinq<T>;
9
10
  min(comparer?: Comparer<T>): T | null | undefined;
10
- some(predicate: typeof Predicate<T>): boolean;
11
+ reduce<R>(neutralElement: R, reducer: Reducer<T, R>): R;
12
+ some(predicate: Predicate<T>): boolean;
13
+ tap(tapper: Tapper<T>): IIterableLinq<T>;
14
+ tapChain(tapper: Tapper<Iterable<T>>): IIterableLinq<T>;
15
+ /**
16
+ *
17
+ * @operation `Tap`
18
+ * @param chainCreationTapper
19
+ */
20
+ tapChainCreation(chainCreationTapper: (iterableLinqWrapper: IIterableLinq<T>) => void): IIterableLinq<T>;
11
21
  }
12
- export declare class LinqIterableWrapper<T> implements ILinqIterable<T> {
22
+ export declare class IterableLinqWrapper<T> implements IIterableLinq<T> {
13
23
  constructor(iterable: Iterable<T>);
14
24
  [Symbol.iterator](): Iterator<T, any, undefined>;
15
25
  private iterable;
16
26
  collectToArray(): T[];
17
- filter(predicate: typeof Predicate<T>): ILinqIterable<T>;
18
- map<R>(mapper: Mapper<T, R>): ILinqIterable<R>;
19
- materialize(): ILinqIterable<T>;
20
- memoize(): ILinqIterable<T>;
27
+ filter(predicate: Predicate<T>): IIterableLinq<T>;
28
+ map<R>(mapper: Mapper<T, R>): IIterableLinq<R>;
29
+ materialize(): IIterableLinq<T>;
30
+ max(comparer?: Comparer<T>): T | null | undefined;
31
+ memoize(): IIterableLinq<T>;
21
32
  min(comparer?: Comparer<T>): T | null | undefined;
22
- some(predicate: typeof Predicate<T>): boolean;
33
+ reduce<R>(neutralElement: R, reducer: Reducer<T, R>): R;
34
+ some(predicate: Predicate<T>): boolean;
35
+ tap(tapper: Tapper<T>): IIterableLinq<T>;
36
+ tapChain(tapper: Tapper<Iterable<T>>): IIterableLinq<T>;
37
+ tapChainCreation(chainCreationTapper: (iterableLinqWrapper: IIterableLinq<T>) => void): IIterableLinq<T>;
23
38
  }
@@ -1,4 +1,4 @@
1
- declare type ComparerFunction<T> = (a: T, b: T, index: number) => number;
1
+ declare type ComparerFunction<T> = (a: T, b: T) => number;
2
2
  declare type ComparingProps<T> = keyof T | Array<keyof T>;
3
3
  export declare type Comparer<T> = ComparerFunction<T> | ComparingProps<T>;
4
4
  export {};
@@ -1,3 +1,6 @@
1
1
  export * from './comparer';
2
2
  export * from './mapper';
3
3
  export * from './predicate';
4
+ export * from './reducer';
5
+ export * from './tapper';
6
+ export * from './unit';
@@ -1 +1 @@
1
- export declare function Predicate<T>(value: T, index: number): boolean;
1
+ export declare type Predicate<T> = (value: T, index: number) => boolean;
@@ -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;
@@ -0,0 +1,3 @@
1
+ export declare class Unit {
2
+ }
3
+ export declare function unit(): Unit;
@@ -1,3 +1,3 @@
1
1
  export declare function getIteratorResult<T>(done: boolean, value?: T): IteratorResult<T>;
2
- export declare function getDoneIteratorResult<T>(): IteratorResult<T>;
2
+ export declare function getDoneIteratorResult<T>(value?: T): IteratorResult<T>;
3
3
  export declare function getFlatIteratorResult<T>(result: IteratorResult<T>): IteratorResult<T>;
@@ -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
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iterable-linq-utility",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
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": "ISC",
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": ["linq", "itearable", "utility"],
37
+ "keywords": [
38
+ "linq",
39
+ "itearable",
40
+ "utility"
41
+ ],
38
42
  "devDependencies": {
39
- "@rushstack/eslint-patch": "^1.1.4",
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",
@@ -1,2 +0,0 @@
1
- export * from './mapper';
2
- export * from './predicate';
@@ -1,2 +0,0 @@
1
- import { Mapper } from "../types";
2
- export declare function combineMappers<T, R, RR>(m1: Mapper<T, R>, m2: Mapper<R, RR>): Mapper<T, RR>;
@@ -1,2 +0,0 @@
1
- import { Predicate } from "../types";
2
- export declare function combinePredicates<T>(p1: typeof Predicate<T>, p2: typeof Predicate<T>): typeof Predicate<T>;