iterable-linq-utility 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/combiners/predicate.d.ts +1 -1
- package/dist/functions/filter.d.ts +1 -1
- package/dist/functions/some.d.ts +1 -1
- package/dist/interable-linq-utility.js +89 -68
- package/dist/interable-linq-utility.umd.cjs +1 -1
- package/dist/linqIterable.d.ts +8 -6
- package/dist/types/predicate.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Predicate } from "../types";
|
|
2
|
-
export declare function combinePredicates<T>(p1: Predicate<T>, p2: Predicate<T>): Predicate<T>;
|
|
2
|
+
export declare function combinePredicates<T>(p1: typeof Predicate<T>, p2: typeof Predicate<T>): typeof Predicate<T>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Predicate } from "@/types";
|
|
2
|
-
export declare function filter<T>(iterable: Iterable<T>, predicate: Predicate<T>): Iterable<T>;
|
|
2
|
+
export declare function filter<T>(iterable: Iterable<T>, predicate: typeof Predicate<T>): Iterable<T>;
|
package/dist/functions/some.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Predicate } from "@/types";
|
|
2
|
-
export declare function some<T>(iterable: Iterable<T>, predicate: Predicate<T>): boolean;
|
|
2
|
+
export declare function some<T>(iterable: Iterable<T>, predicate: typeof Predicate<T>): boolean;
|
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (e, t, r) => (
|
|
4
|
-
function
|
|
5
|
-
return (r,
|
|
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);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return (r,
|
|
7
|
+
function k(e, t) {
|
|
8
|
+
return (r, n) => e(r, n) && t(r, n);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function S(e, t) {
|
|
11
11
|
return {
|
|
12
12
|
done: e,
|
|
13
13
|
value: t
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function w() {
|
|
17
17
|
return { done: !0, value: void 0 };
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function M(e) {
|
|
20
|
+
return typeof e == "function";
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
function L(e, t) {
|
|
23
|
+
return new m(e, t);
|
|
24
|
+
}
|
|
25
|
+
class m {
|
|
23
26
|
constructor(t, r) {
|
|
24
27
|
i(this, "predicate");
|
|
25
28
|
i(this, "source");
|
|
26
|
-
let
|
|
27
|
-
if (
|
|
28
|
-
const u =
|
|
29
|
-
|
|
29
|
+
let n = r, s = t;
|
|
30
|
+
if (s instanceof m) {
|
|
31
|
+
const u = s.predicate;
|
|
32
|
+
s = s.source, n = k(u, n);
|
|
30
33
|
}
|
|
31
|
-
this.source =
|
|
34
|
+
this.source = s, this.predicate = n;
|
|
32
35
|
}
|
|
33
36
|
[Symbol.iterator]() {
|
|
34
|
-
return new
|
|
37
|
+
return new v(this.source, this.predicate);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
|
-
class
|
|
40
|
+
class v {
|
|
38
41
|
constructor(t, r) {
|
|
39
42
|
i(this, "index", 0);
|
|
40
43
|
i(this, "sourceIterator");
|
|
@@ -49,25 +52,25 @@ class S {
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
|
-
function
|
|
53
|
-
return new
|
|
55
|
+
function N(e, t) {
|
|
56
|
+
return new I(e, t);
|
|
54
57
|
}
|
|
55
|
-
class
|
|
58
|
+
class I {
|
|
56
59
|
constructor(t, r) {
|
|
57
60
|
i(this, "mapper");
|
|
58
61
|
i(this, "source");
|
|
59
|
-
let
|
|
60
|
-
if (
|
|
61
|
-
const u =
|
|
62
|
-
|
|
62
|
+
let n = r, s = t;
|
|
63
|
+
if (s instanceof I) {
|
|
64
|
+
const u = s.mapper;
|
|
65
|
+
s = s.source, n = p(u, n);
|
|
63
66
|
}
|
|
64
|
-
this.source = t, this.mapper =
|
|
67
|
+
this.source = t, this.mapper = n;
|
|
65
68
|
}
|
|
66
69
|
[Symbol.iterator]() {
|
|
67
|
-
return new
|
|
70
|
+
return new A(this.source, this.mapper);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
class
|
|
73
|
+
class A {
|
|
71
74
|
constructor(t, r) {
|
|
72
75
|
i(this, "index", 0);
|
|
73
76
|
i(this, "sourceIterator");
|
|
@@ -76,33 +79,33 @@ class M {
|
|
|
76
79
|
}
|
|
77
80
|
next() {
|
|
78
81
|
const t = this.sourceIterator.next();
|
|
79
|
-
return t.done !== !0 ?
|
|
82
|
+
return t.done !== !0 ? S(!1, this.mapper(t.value, this.index++)) : w();
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
function
|
|
83
|
-
const t = e[Symbol.iterator](), r = new
|
|
84
|
-
for (let
|
|
85
|
-
r.addLast(
|
|
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);
|
|
86
89
|
return r;
|
|
87
90
|
}
|
|
88
|
-
class
|
|
91
|
+
class g {
|
|
89
92
|
constructor(t = null) {
|
|
90
93
|
i(this, "current", null);
|
|
91
94
|
this.current = t;
|
|
92
95
|
}
|
|
93
96
|
next() {
|
|
94
97
|
const t = this.current;
|
|
95
|
-
return t === null ?
|
|
98
|
+
return t === null ? w() : (this.current = t.nextNode, S(!1, t.data));
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
|
-
class
|
|
101
|
+
class d {
|
|
99
102
|
constructor() {
|
|
100
103
|
i(this, "internalSize", 0);
|
|
101
104
|
i(this, "head", null);
|
|
102
105
|
i(this, "tail", null);
|
|
103
106
|
}
|
|
104
107
|
[Symbol.iterator]() {
|
|
105
|
-
return new
|
|
108
|
+
return new g(this.head);
|
|
106
109
|
}
|
|
107
110
|
addFirst(t) {
|
|
108
111
|
const r = {
|
|
@@ -136,23 +139,23 @@ class a {
|
|
|
136
139
|
return this.internalSize;
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
function
|
|
140
|
-
return e instanceof
|
|
142
|
+
function P(e) {
|
|
143
|
+
return e instanceof x ? e : new x(e);
|
|
141
144
|
}
|
|
142
|
-
class
|
|
145
|
+
class x {
|
|
143
146
|
constructor(t) {
|
|
144
147
|
i(this, "source");
|
|
145
|
-
if (t instanceof
|
|
148
|
+
if (t instanceof d) {
|
|
146
149
|
this.source = t;
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
|
-
this.source =
|
|
152
|
+
this.source = F(t);
|
|
150
153
|
}
|
|
151
154
|
[Symbol.iterator]() {
|
|
152
|
-
return new
|
|
155
|
+
return new R(this.source);
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
class
|
|
158
|
+
class R {
|
|
156
159
|
constructor(t) {
|
|
157
160
|
i(this, "sourceIterator");
|
|
158
161
|
this.sourceIterator = t[Symbol.iterator]();
|
|
@@ -161,29 +164,29 @@ class N {
|
|
|
161
164
|
return this.sourceIterator.next();
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
|
-
function
|
|
165
|
-
return e instanceof
|
|
167
|
+
function D(e) {
|
|
168
|
+
return e instanceof z ? e : new z(e);
|
|
166
169
|
}
|
|
167
|
-
class
|
|
170
|
+
class z {
|
|
168
171
|
constructor(t) {
|
|
169
172
|
i(this, "isMemoized", !1);
|
|
170
173
|
i(this, "sourceIterator");
|
|
171
|
-
i(this, "linkedList", new
|
|
174
|
+
i(this, "linkedList", new d());
|
|
172
175
|
i(this, "source");
|
|
173
|
-
this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof
|
|
176
|
+
this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof d && (this.linkedList = t, this.isMemoized = !0);
|
|
174
177
|
}
|
|
175
178
|
[Symbol.iterator]() {
|
|
176
|
-
return this.isMemoized ? new
|
|
179
|
+
return this.isMemoized ? new $(this.linkedList) : new T(this.sourceIterator, this.linkedList, (t) => this.isMemoized = t.done === !0);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
|
-
class
|
|
180
|
-
constructor(t, r,
|
|
182
|
+
class T {
|
|
183
|
+
constructor(t, r, n) {
|
|
181
184
|
i(this, "index", 0);
|
|
182
185
|
i(this, "linkedList");
|
|
183
186
|
i(this, "linkedListIterator");
|
|
184
187
|
i(this, "setAsMemoized");
|
|
185
188
|
i(this, "sourceIterator");
|
|
186
|
-
this.linkedList = r, this.linkedListIterator = r[Symbol.iterator](), this.setAsMemoized =
|
|
189
|
+
this.linkedList = r, this.linkedListIterator = r[Symbol.iterator](), this.setAsMemoized = n, this.sourceIterator = t;
|
|
187
190
|
}
|
|
188
191
|
next() {
|
|
189
192
|
if (this.linkedList.size() > this.index++)
|
|
@@ -192,7 +195,7 @@ class A {
|
|
|
192
195
|
return this.setAsMemoized(t) || this.linkedList.addLast(t.value), t;
|
|
193
196
|
}
|
|
194
197
|
}
|
|
195
|
-
class
|
|
198
|
+
class $ {
|
|
196
199
|
constructor(t) {
|
|
197
200
|
i(this, "memoizedSourceIterator");
|
|
198
201
|
this.memoizedSourceIterator = t[Symbol.iterator]();
|
|
@@ -201,15 +204,30 @@ class g {
|
|
|
201
204
|
return this.memoizedSourceIterator.next();
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
|
-
function
|
|
207
|
+
function j(e, t) {
|
|
205
208
|
const r = e[Symbol.iterator]();
|
|
206
|
-
let s =
|
|
207
|
-
for (
|
|
208
|
-
|
|
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;
|
|
212
|
+
for (const h of t)
|
|
213
|
+
if (f = o[h] < a[h] ? -1 : o[h] === a[h] ? 0 : 1, f !== 0)
|
|
214
|
+
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;
|
|
219
|
+
}
|
|
220
|
+
return u == null ? null : u;
|
|
221
|
+
}
|
|
222
|
+
function B(e, t) {
|
|
223
|
+
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++))
|
|
209
227
|
return !0;
|
|
210
228
|
return !1;
|
|
211
229
|
}
|
|
212
|
-
class
|
|
230
|
+
class c {
|
|
213
231
|
constructor(t) {
|
|
214
232
|
i(this, "iterable");
|
|
215
233
|
this.iterable = t;
|
|
@@ -221,24 +239,27 @@ class o {
|
|
|
221
239
|
return [...this.iterable];
|
|
222
240
|
}
|
|
223
241
|
filter(t) {
|
|
224
|
-
return new
|
|
242
|
+
return new c(L(this.iterable, t));
|
|
225
243
|
}
|
|
226
244
|
map(t) {
|
|
227
|
-
return new
|
|
245
|
+
return new c(N(this.iterable, t));
|
|
228
246
|
}
|
|
229
247
|
materialize() {
|
|
230
|
-
return new
|
|
248
|
+
return new c(P(this.iterable));
|
|
231
249
|
}
|
|
232
250
|
memoize() {
|
|
233
|
-
return new
|
|
251
|
+
return new c(D(this.iterable));
|
|
252
|
+
}
|
|
253
|
+
min(t) {
|
|
254
|
+
return j(this.iterable, t);
|
|
234
255
|
}
|
|
235
256
|
some(t) {
|
|
236
|
-
return
|
|
257
|
+
return B(this.iterable, t);
|
|
237
258
|
}
|
|
238
259
|
}
|
|
239
|
-
function
|
|
240
|
-
return new
|
|
260
|
+
function E(e) {
|
|
261
|
+
return new c(e);
|
|
241
262
|
}
|
|
242
263
|
export {
|
|
243
|
-
|
|
264
|
+
E as from
|
|
244
265
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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"}})});
|
package/dist/linqIterable.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { Mapper, Predicate } from '@/types';
|
|
1
|
+
import { Comparer, Mapper, Predicate } from '@/types';
|
|
2
2
|
export interface ILinqIterable<T> {
|
|
3
3
|
[Symbol.iterator](): Iterator<T, any, undefined>;
|
|
4
4
|
collectToArray(): T[];
|
|
5
|
-
filter(predicate: Predicate<T>): ILinqIterable<T>;
|
|
5
|
+
filter(predicate: typeof Predicate<T>): ILinqIterable<T>;
|
|
6
6
|
map<R>(mapper: Mapper<T, R>): ILinqIterable<R>;
|
|
7
7
|
materialize(): ILinqIterable<T>;
|
|
8
8
|
memoize(): ILinqIterable<T>;
|
|
9
|
-
|
|
9
|
+
min(comparer?: Comparer<T>): T | null | undefined;
|
|
10
|
+
some(predicate: typeof Predicate<T>): boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare class
|
|
12
|
+
export declare class LinqIterableWrapper<T> implements ILinqIterable<T> {
|
|
12
13
|
constructor(iterable: Iterable<T>);
|
|
13
14
|
[Symbol.iterator](): Iterator<T, any, undefined>;
|
|
14
15
|
private iterable;
|
|
15
16
|
collectToArray(): T[];
|
|
16
|
-
filter(predicate: Predicate<T>): ILinqIterable<T>;
|
|
17
|
+
filter(predicate: typeof Predicate<T>): ILinqIterable<T>;
|
|
17
18
|
map<R>(mapper: Mapper<T, R>): ILinqIterable<R>;
|
|
18
19
|
materialize(): ILinqIterable<T>;
|
|
19
20
|
memoize(): ILinqIterable<T>;
|
|
20
|
-
|
|
21
|
+
min(comparer?: Comparer<T>): T | null | undefined;
|
|
22
|
+
some(predicate: typeof Predicate<T>): boolean;
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function Predicate<T>(value: T, index: number): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iterable-linq-utility",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
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",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dev": "vite",
|
|
21
21
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --ignore-path .eslintignore",
|
|
22
22
|
"lint-fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix --ignore-path .eslintignore",
|
|
23
|
-
"test": "vitest",
|
|
23
|
+
"test": "vitest run",
|
|
24
24
|
"test:coverage": "vitest run --coverage",
|
|
25
25
|
"test:ui": "vitest --ui"
|
|
26
26
|
},
|