iterable-linq-utility 0.0.4 → 0.0.6

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.
@@ -1 +1,2 @@
1
- export declare function some<T>(iterable: Iterable<T>, predicate: (value: T, index: number) => boolean): boolean;
1
+ import { Predicate } from "@/types";
2
+ export declare function some<T>(iterable: Iterable<T>, predicate: Predicate<T>): boolean;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,3 @@
1
- import { Mapper, Predicate } from '@/types';
2
- export interface ILinqIterable<T> {
3
- [Symbol.iterator](): Iterator<T, any, undefined>;
4
- collectToArray(): T[];
5
- filter(predicate: Predicate<T>): ILinqIterable<T>;
6
- map<R>(mapper: Mapper<T, R>): ILinqIterable<R>;
7
- materialize(): ILinqIterable<T>;
8
- memoize(): ILinqIterable<T>;
9
- some(predicate: (value: T, index: number) => boolean): boolean;
10
- }
11
- declare module "./linqIterable" {
12
- interface LinqIterable<T> extends ILinqIterable<T> {
13
- }
14
- }
1
+ import { type ILinqIterable } from "./linqIterable";
15
2
  export declare function from<T>(iterable: Iterable<T>): ILinqIterable<T>;
3
+ export { ILinqIterable };
@@ -1,55 +1,40 @@
1
1
  var I = Object.defineProperty;
2
- var z = (e, t, r) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var i = (e, t, r) => (z(e, typeof t != "symbol" ? t + "" : t, r), r);
4
- class n {
5
- constructor(t) {
6
- i(this, "iterable");
7
- this.iterable = t;
8
- }
9
- [Symbol.iterator]() {
10
- return this.iterable[Symbol.iterator]();
11
- }
12
- collectToArray() {
13
- return [...this.source];
14
- }
15
- get source() {
16
- return this.iterable;
17
- }
2
+ var p = (e, t, r) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var i = (e, t, r) => (p(e, typeof t != "symbol" ? t + "" : t, r), r);
4
+ function z(e, t) {
5
+ return (r, s) => t(e(r, s), s);
18
6
  }
19
7
  function x(e, t) {
20
- return (r, o) => t(e(r, o), o);
21
- }
22
- function S(e, t) {
23
- return (r, o) => e(r, o) && t(r, o);
8
+ return (r, s) => e(r, s) && t(r, s);
24
9
  }
25
- function f(e, t) {
10
+ function m(e, t) {
26
11
  return {
27
12
  done: e,
28
13
  value: t
29
14
  };
30
15
  }
31
- function p() {
16
+ function f() {
32
17
  return { done: !0, value: void 0 };
33
18
  }
34
- function y(e, t) {
35
- return new l(e, t);
19
+ function w(e, t) {
20
+ return new c(e, t);
36
21
  }
37
- class l {
22
+ class c {
38
23
  constructor(t, r) {
39
24
  i(this, "predicate");
40
25
  i(this, "source");
41
- let o = r, s = t;
42
- if (s instanceof l) {
43
- const c = s.predicate;
44
- s = s.source, o = S(c, o);
26
+ let s = r, n = t;
27
+ if (n instanceof c) {
28
+ const u = n.predicate;
29
+ n = n.source, s = x(u, s);
45
30
  }
46
- this.source = s, this.predicate = o;
31
+ this.source = n, this.predicate = s;
47
32
  }
48
33
  [Symbol.iterator]() {
49
- return new b(this.source, this.predicate);
34
+ return new S(this.source, this.predicate);
50
35
  }
51
36
  }
52
- class b {
37
+ class S {
53
38
  constructor(t, r) {
54
39
  i(this, "index", 0);
55
40
  i(this, "sourceIterator");
@@ -64,25 +49,25 @@ class b {
64
49
  }
65
50
  }
66
51
  }
67
- function w(e, t) {
68
- return new h(e, t);
52
+ function b(e, t) {
53
+ return new l(e, t);
69
54
  }
70
- class h {
55
+ class l {
71
56
  constructor(t, r) {
72
57
  i(this, "mapper");
73
58
  i(this, "source");
74
- let o = r, s = t;
75
- if (s instanceof h) {
76
- const c = s.mapper;
77
- s = s.source, o = x(c, o);
59
+ let s = r, n = t;
60
+ if (n instanceof l) {
61
+ const u = n.mapper;
62
+ n = n.source, s = z(u, s);
78
63
  }
79
- this.source = t, this.mapper = o;
64
+ this.source = t, this.mapper = s;
80
65
  }
81
66
  [Symbol.iterator]() {
82
- return new L(this.source, this.mapper);
67
+ return new M(this.source, this.mapper);
83
68
  }
84
69
  }
85
- class L {
70
+ class M {
86
71
  constructor(t, r) {
87
72
  i(this, "index", 0);
88
73
  i(this, "sourceIterator");
@@ -91,13 +76,13 @@ class L {
91
76
  }
92
77
  next() {
93
78
  const t = this.sourceIterator.next();
94
- return t.done !== !0 ? f(!1, this.mapper(t.value, this.index++)) : p();
79
+ return t.done !== !0 ? m(!1, this.mapper(t.value, this.index++)) : f();
95
80
  }
96
81
  }
97
- function M(e) {
82
+ function y(e) {
98
83
  const t = e[Symbol.iterator](), r = new a();
99
- for (let o = t.next(); o.done !== !0; o = t.next())
100
- r.addLast(o.value);
84
+ for (let s = t.next(); s.done !== !0; s = t.next())
85
+ r.addLast(s.value);
101
86
  return r;
102
87
  }
103
88
  class k {
@@ -107,7 +92,7 @@ class k {
107
92
  }
108
93
  next() {
109
94
  const t = this.current;
110
- return t === null ? p() : (this.current = t.nextNode, f(!1, t.data));
95
+ return t === null ? f() : (this.current = t.nextNode, m(!1, t.data));
111
96
  }
112
97
  }
113
98
  class a {
@@ -151,23 +136,23 @@ class a {
151
136
  return this.internalSize;
152
137
  }
153
138
  }
154
- function N(e) {
155
- return e instanceof d ? e : new d(e);
139
+ function L(e) {
140
+ return e instanceof h ? e : new h(e);
156
141
  }
157
- class d {
142
+ class h {
158
143
  constructor(t) {
159
144
  i(this, "source");
160
145
  if (t instanceof a) {
161
146
  this.source = t;
162
147
  return;
163
148
  }
164
- this.source = M(t);
149
+ this.source = y(t);
165
150
  }
166
151
  [Symbol.iterator]() {
167
- return new v(this.source);
152
+ return new N(this.source);
168
153
  }
169
154
  }
170
- class v {
155
+ class N {
171
156
  constructor(t) {
172
157
  i(this, "sourceIterator");
173
158
  this.sourceIterator = t[Symbol.iterator]();
@@ -176,10 +161,10 @@ class v {
176
161
  return this.sourceIterator.next();
177
162
  }
178
163
  }
179
- function g(e) {
180
- return e instanceof m ? e : new m(e);
164
+ function v(e) {
165
+ return e instanceof d ? e : new d(e);
181
166
  }
182
- class m {
167
+ class d {
183
168
  constructor(t) {
184
169
  i(this, "isMemoized", !1);
185
170
  i(this, "sourceIterator");
@@ -188,17 +173,17 @@ class m {
188
173
  this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof a && (this.linkedList = t, this.isMemoized = !0);
189
174
  }
190
175
  [Symbol.iterator]() {
191
- return this.isMemoized ? new F(this.linkedList) : new A(this.sourceIterator, this.linkedList, (t) => this.isMemoized = t.done === !0);
176
+ return this.isMemoized ? new g(this.linkedList) : new A(this.sourceIterator, this.linkedList, (t) => this.isMemoized = t.done === !0);
192
177
  }
193
178
  }
194
179
  class A {
195
- constructor(t, r, o) {
180
+ constructor(t, r, s) {
196
181
  i(this, "index", 0);
197
182
  i(this, "linkedList");
198
183
  i(this, "linkedListIterator");
199
184
  i(this, "setAsMemoized");
200
185
  i(this, "sourceIterator");
201
- this.linkedList = r, this.linkedListIterator = r[Symbol.iterator](), this.setAsMemoized = o, this.sourceIterator = t;
186
+ this.linkedList = r, this.linkedListIterator = r[Symbol.iterator](), this.setAsMemoized = s, this.sourceIterator = t;
202
187
  }
203
188
  next() {
204
189
  if (this.linkedList.size() > this.index++)
@@ -207,7 +192,7 @@ class A {
207
192
  return this.setAsMemoized(t) || this.linkedList.addLast(t.value), t;
208
193
  }
209
194
  }
210
- class F {
195
+ class g {
211
196
  constructor(t) {
212
197
  i(this, "memoizedSourceIterator");
213
198
  this.memoizedSourceIterator = t[Symbol.iterator]();
@@ -216,32 +201,44 @@ class F {
216
201
  return this.memoizedSourceIterator.next();
217
202
  }
218
203
  }
219
- function P(e, t) {
204
+ function F(e, t) {
220
205
  const r = e[Symbol.iterator]();
221
- let o = 0;
222
- for (let s = r.next(); s.done !== !0; s = r.next())
223
- if (t(s.value, o++))
206
+ let s = 0;
207
+ for (let n = r.next(); n.done !== !0; n = r.next())
208
+ if (t(n.value, s++))
224
209
  return !0;
225
210
  return !1;
226
211
  }
227
- function u(e) {
228
- return new n(e);
212
+ class o {
213
+ constructor(t) {
214
+ i(this, "iterable");
215
+ this.iterable = t;
216
+ }
217
+ [Symbol.iterator]() {
218
+ return this.iterable[Symbol.iterator]();
219
+ }
220
+ collectToArray() {
221
+ return [...this.iterable];
222
+ }
223
+ filter(t) {
224
+ return new o(w(this.iterable, t));
225
+ }
226
+ map(t) {
227
+ return new o(b(this.iterable, t));
228
+ }
229
+ materialize() {
230
+ return new o(L(this.iterable));
231
+ }
232
+ memoize() {
233
+ return new o(v(this.iterable));
234
+ }
235
+ some(t) {
236
+ return F(this.iterable, t);
237
+ }
238
+ }
239
+ function R(e) {
240
+ return new o(e);
229
241
  }
230
- n.prototype.filter = function(e) {
231
- return u(y(this.source, e));
232
- };
233
- n.prototype.map = function(e) {
234
- return u(w(this.source, e));
235
- };
236
- n.prototype.materialize = function() {
237
- return u(N(this.source));
238
- };
239
- n.prototype.memoize = function() {
240
- return u(g(this.source));
241
- };
242
- n.prototype.some = function(e) {
243
- return P(this.source, e);
244
- };
245
242
  export {
246
- u as from
243
+ R as from
247
244
  };
@@ -1 +1 @@
1
- (function(u,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(u=typeof globalThis<"u"?globalThis:u||self,n(u["interable-linq-utility"]={}))})(this,function(u){"use strict";var T=Object.defineProperty;var F=(u,n,a)=>n in u?T(u,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):u[n]=a;var i=(u,n,a)=>(F(u,typeof n!="symbol"?n+"":n,a),a);class n{constructor(t){i(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return[...this.source]}get source(){return this.iterable}}function a(e,t){return(r,o)=>t(e(r,o),o)}function x(e,t){return(r,o)=>e(r,o)&&t(r,o)}function m(e,t){return{done:e,value:t}}function p(){return{done:!0,value:void 0}}function R(e){return e}function S(e,t){return new d(e,t)}class d{constructor(t,r){i(this,"predicate");i(this,"source");let o=r,s=t;if(s instanceof d){const f=s.predicate;s=s.source,o=x(f,o)}this.source=s,this.predicate=o}[Symbol.iterator](){return new y(this.source,this.predicate)}}class y{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 b(e,t){return new h(e,t)}class h{constructor(t,r){i(this,"mapper");i(this,"source");let o=r,s=t;if(s instanceof h){const f=s.mapper;s=s.source,o=a(f,o)}this.source=t,this.mapper=o}[Symbol.iterator](){return new w(this.source,this.mapper)}}class w{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?m(!1,this.mapper(t.value,this.index++)):p()}}function L(e){const t=e[Symbol.iterator](),r=new l;for(let o=t.next();o.done!==!0;o=t.next())r.addLast(o.value);return r}class M{constructor(t=null){i(this,"current",null);this.current=t}next(){const t=this.current;return t===null?p():(this.current=t.nextNode,m(!1,t.data))}}class l{constructor(){i(this,"internalSize",0);i(this,"head",null);i(this,"tail",null)}[Symbol.iterator](){return new M(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 k(e){return e instanceof I?e:new I(e)}class I{constructor(t){i(this,"source");if(t instanceof l){this.source=t;return}this.source=L(t)}[Symbol.iterator](){return new v(this.source)}}class v{constructor(t){i(this,"sourceIterator");this.sourceIterator=t[Symbol.iterator]()}next(){return this.sourceIterator.next()}}function N(e){return e instanceof z?e:new z(e)}class z{constructor(t){i(this,"isMemoized",!1);i(this,"sourceIterator");i(this,"linkedList",new l);i(this,"source");this.source=t,this.sourceIterator=t[Symbol.iterator](),t instanceof l&&(this.linkedList=t,this.isMemoized=!0)}[Symbol.iterator](){return this.isMemoized?new A(this.linkedList):new g(this.sourceIterator,this.linkedList,t=>this.isMemoized=t.done===!0)}}class g{constructor(t,r,o){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=o,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 A{constructor(t){i(this,"memoizedSourceIterator");this.memoizedSourceIterator=t[Symbol.iterator]()}next(){return this.memoizedSourceIterator.next()}}function P(e,t){const r=e[Symbol.iterator]();let o=0;for(let s=r.next();s.done!==!0;s=r.next())if(t(s.value,o++))return!0;return!1}function c(e){return new n(e)}n.prototype.filter=function(e){return c(S(this.source,e))},n.prototype.map=function(e){return c(b(this.source,e))},n.prototype.materialize=function(){return c(k(this.source))},n.prototype.memoize=function(){return c(N(this.source))},n.prototype.some=function(e){return P(this.source,e)},u.from=c,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a["interable-linq-utility"]={}))})(this,function(a){"use strict";var T=Object.defineProperty;var F=(a,o,u)=>o in a?T(a,o,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[o]=u;var i=(a,o,u)=>(F(a,typeof o!="symbol"?o+"":o,u),u);function o(e,t){return(r,n)=>t(e(r,n),n)}function u(e,t){return(r,n)=>e(r,n)&&t(r,n)}function f(e,t){return{done:e,value:t}}function p(){return{done:!0,value:void 0}}function R(e){return e}function x(e,t){return new d(e,t)}class d{constructor(t,r){i(this,"predicate");i(this,"source");let n=r,s=t;if(s instanceof d){const m=s.predicate;s=s.source,n=u(m,n)}this.source=s,this.predicate=n}[Symbol.iterator](){return new S(this.source,this.predicate)}}class S{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 b(e,t){return new h(e,t)}class h{constructor(t,r){i(this,"mapper");i(this,"source");let n=r,s=t;if(s instanceof h){const m=s.mapper;s=s.source,n=o(m,n)}this.source=t,this.mapper=n}[Symbol.iterator](){return new w(this.source,this.mapper)}}class w{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?f(!1,this.mapper(t.value,this.index++)):p()}}function y(e){const t=e[Symbol.iterator](),r=new l;for(let n=t.next();n.done!==!0;n=t.next())r.addLast(n.value);return r}class M{constructor(t=null){i(this,"current",null);this.current=t}next(){const t=this.current;return t===null?p():(this.current=t.nextNode,f(!1,t.data))}}class l{constructor(){i(this,"internalSize",0);i(this,"head",null);i(this,"tail",null)}[Symbol.iterator](){return new M(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 k(e){return e instanceof I?e:new I(e)}class I{constructor(t){i(this,"source");if(t instanceof l){this.source=t;return}this.source=y(t)}[Symbol.iterator](){return new L(this.source)}}class L{constructor(t){i(this,"sourceIterator");this.sourceIterator=t[Symbol.iterator]()}next(){return this.sourceIterator.next()}}function v(e){return e instanceof z?e:new z(e)}class z{constructor(t){i(this,"isMemoized",!1);i(this,"sourceIterator");i(this,"linkedList",new l);i(this,"source");this.source=t,this.sourceIterator=t[Symbol.iterator](),t instanceof l&&(this.linkedList=t,this.isMemoized=!0)}[Symbol.iterator](){return this.isMemoized?new g(this.linkedList):new N(this.sourceIterator,this.linkedList,t=>this.isMemoized=t.done===!0)}}class N{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 g{constructor(t){i(this,"memoizedSourceIterator");this.memoizedSourceIterator=t[Symbol.iterator]()}next(){return this.memoizedSourceIterator.next()}}function A(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 c{constructor(t){i(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return[...this.iterable]}filter(t){return new c(x(this.iterable,t))}map(t){return new c(b(this.iterable,t))}materialize(){return new c(k(this.iterable))}memoize(){return new c(v(this.iterable))}some(t){return A(this.iterable,t)}}function P(e){return new c(e)}a.from=P,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,7 +1,21 @@
1
- export declare class LinqIterable<T> implements Iterable<T> {
1
+ import { Mapper, Predicate } from '@/types';
2
+ export interface ILinqIterable<T> {
3
+ [Symbol.iterator](): Iterator<T, any, undefined>;
4
+ collectToArray(): T[];
5
+ filter(predicate: Predicate<T>): ILinqIterable<T>;
6
+ map<R>(mapper: Mapper<T, R>): ILinqIterable<R>;
7
+ materialize(): ILinqIterable<T>;
8
+ memoize(): ILinqIterable<T>;
9
+ some(predicate: Predicate<T>): boolean;
10
+ }
11
+ export declare class LinqIterable<T> implements ILinqIterable<T> {
2
12
  constructor(iterable: Iterable<T>);
3
13
  [Symbol.iterator](): Iterator<T, any, undefined>;
4
14
  private iterable;
5
15
  collectToArray(): T[];
6
- get source(): Iterable<T>;
16
+ filter(predicate: Predicate<T>): ILinqIterable<T>;
17
+ map<R>(mapper: Mapper<T, R>): ILinqIterable<R>;
18
+ materialize(): ILinqIterable<T>;
19
+ memoize(): ILinqIterable<T>;
20
+ some(predicate: Predicate<T>): boolean;
7
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iterable-linq-utility",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "An Iterable mutation utility inspired by .net Linq and Javascript Array interface",
5
5
  "type": "module",
6
6
  "main": "./dist/my-lib.umd.cjs",