iterable-linq-utility 0.0.2 → 0.0.3
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/README.md +1 -1
- package/dist/combiners/index.d.ts +2 -0
- package/dist/combiners/mapper.d.ts +2 -0
- package/dist/combiners/predicate.d.ts +2 -0
- package/dist/filter.d.ts +2 -1
- package/dist/interable-linq-utility.js +21 -21
- package/dist/interable-linq-utility.umd.cjs +1 -1
- package/dist/map.d.ts +2 -1
- package/dist/{types.d.ts → types/comparer.d.ts} +0 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/mapper.d.ts +1 -0
- package/dist/types/predicate.d.ts +1 -0
- package/dist/utils/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/min.d.ts +0 -2
- package/dist/utils/combiners.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Work in Progress
|
package/dist/filter.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Predicate } from "./types";
|
|
2
|
+
export declare function filter<T>(iterable: Iterable<T>, predicate: Predicate<T>): Iterable<T>;
|
|
@@ -20,10 +20,7 @@ function b(e, t) {
|
|
|
20
20
|
return (r, i) => t(e(r, i), i);
|
|
21
21
|
}
|
|
22
22
|
function w(e, t) {
|
|
23
|
-
return (r, i) =>
|
|
24
|
-
}
|
|
25
|
-
function L(e) {
|
|
26
|
-
return typeof e == "function";
|
|
23
|
+
return (r, i) => e(r, i) && t(r, i);
|
|
27
24
|
}
|
|
28
25
|
function f(e, t) {
|
|
29
26
|
return {
|
|
@@ -34,7 +31,7 @@ function f(e, t) {
|
|
|
34
31
|
function p() {
|
|
35
32
|
return { done: !0, value: void 0 };
|
|
36
33
|
}
|
|
37
|
-
function
|
|
34
|
+
function L(e, t) {
|
|
38
35
|
return new l(e, t);
|
|
39
36
|
}
|
|
40
37
|
class l {
|
|
@@ -49,10 +46,10 @@ class l {
|
|
|
49
46
|
this.source = n, this.predicate = i;
|
|
50
47
|
}
|
|
51
48
|
[Symbol.iterator]() {
|
|
52
|
-
return new
|
|
49
|
+
return new M(this.source, this.predicate);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
class
|
|
52
|
+
class M {
|
|
56
53
|
constructor(t, r) {
|
|
57
54
|
o(this, "index", 0);
|
|
58
55
|
o(this, "sourceIterator");
|
|
@@ -67,7 +64,7 @@ class k {
|
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
function
|
|
67
|
+
function k(e, t) {
|
|
71
68
|
return new h(e, t);
|
|
72
69
|
}
|
|
73
70
|
class h {
|
|
@@ -82,10 +79,10 @@ class h {
|
|
|
82
79
|
this.source = t, this.mapper = i;
|
|
83
80
|
}
|
|
84
81
|
[Symbol.iterator]() {
|
|
85
|
-
return new
|
|
82
|
+
return new v(this.source, this.mapper);
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
|
-
class
|
|
85
|
+
class v {
|
|
89
86
|
constructor(t, r) {
|
|
90
87
|
o(this, "index", 0);
|
|
91
88
|
o(this, "sourceIterator");
|
|
@@ -97,13 +94,13 @@ class N {
|
|
|
97
94
|
return t.done !== !0 ? f(!1, this.mapper(t.value, this.index++)) : p();
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
function
|
|
97
|
+
function N(e) {
|
|
101
98
|
const t = e[Symbol.iterator](), r = new a();
|
|
102
99
|
for (let i = t.next(); i.done !== !0; i = t.next())
|
|
103
100
|
r.addLast(i.value);
|
|
104
101
|
return r;
|
|
105
102
|
}
|
|
106
|
-
class
|
|
103
|
+
class A {
|
|
107
104
|
constructor(t = null) {
|
|
108
105
|
o(this, "current", null);
|
|
109
106
|
this.current = t;
|
|
@@ -120,7 +117,7 @@ class a {
|
|
|
120
117
|
o(this, "tail", null);
|
|
121
118
|
}
|
|
122
119
|
[Symbol.iterator]() {
|
|
123
|
-
return new
|
|
120
|
+
return new A(this.head);
|
|
124
121
|
}
|
|
125
122
|
addFirst(t) {
|
|
126
123
|
const r = {
|
|
@@ -154,7 +151,7 @@ class a {
|
|
|
154
151
|
return this.internalSize;
|
|
155
152
|
}
|
|
156
153
|
}
|
|
157
|
-
function
|
|
154
|
+
function F(e) {
|
|
158
155
|
return e instanceof d ? e : new d(e);
|
|
159
156
|
}
|
|
160
157
|
class d {
|
|
@@ -164,13 +161,13 @@ class d {
|
|
|
164
161
|
this.source = t;
|
|
165
162
|
return;
|
|
166
163
|
}
|
|
167
|
-
this.source =
|
|
164
|
+
this.source = N(t);
|
|
168
165
|
}
|
|
169
166
|
[Symbol.iterator]() {
|
|
170
|
-
return new
|
|
167
|
+
return new g(this.source);
|
|
171
168
|
}
|
|
172
169
|
}
|
|
173
|
-
class
|
|
170
|
+
class g {
|
|
174
171
|
constructor(t) {
|
|
175
172
|
o(this, "sourceIterator");
|
|
176
173
|
this.sourceIterator = t[Symbol.iterator]();
|
|
@@ -179,10 +176,13 @@ class P {
|
|
|
179
176
|
return this.sourceIterator.next();
|
|
180
177
|
}
|
|
181
178
|
}
|
|
179
|
+
function P(e) {
|
|
180
|
+
return typeof e == "function";
|
|
181
|
+
}
|
|
182
182
|
function R(e, t) {
|
|
183
183
|
const r = e[Symbol.iterator]();
|
|
184
184
|
let i = 0, n = r.next(), s = n.value;
|
|
185
|
-
const I =
|
|
185
|
+
const I = P(t) ? t : (x, z) => x > z;
|
|
186
186
|
for (n = r.next(); n.done !== !0; n = r.next())
|
|
187
187
|
s = I(s, n.value, i++) ? s : n.value;
|
|
188
188
|
return s == null ? null : s;
|
|
@@ -239,13 +239,13 @@ function c(e) {
|
|
|
239
239
|
return new u(e);
|
|
240
240
|
}
|
|
241
241
|
u.prototype.filter = function(e) {
|
|
242
|
-
return c(
|
|
242
|
+
return c(L(this.source(), e));
|
|
243
243
|
};
|
|
244
244
|
u.prototype.map = function(e) {
|
|
245
|
-
return c(
|
|
245
|
+
return c(k(this.source(), e));
|
|
246
246
|
};
|
|
247
247
|
u.prototype.materialize = function() {
|
|
248
|
-
return c(
|
|
248
|
+
return c(F(this.source()));
|
|
249
249
|
};
|
|
250
250
|
u.prototype.max = function(e) {
|
|
251
251
|
return R(this.source(), e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u["interable-linq-utility"]={}))})(this,function(u){"use strict";var D=Object.defineProperty;var O=(u,s,c)=>s in u?D(u,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):u[s]=c;var i=(u,s,c)=>(O(u,typeof s!="symbol"?s+"":s,c),c);class s{constructor(t){i(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}source(){return this.iterable}collectToArray(){return[...this.source()]}}function c(e,t){return(r,n)=>t(e(r,n),n)}function y(e,t){return(r,n)=>
|
|
1
|
+
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u["interable-linq-utility"]={}))})(this,function(u){"use strict";var D=Object.defineProperty;var O=(u,s,c)=>s in u?D(u,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):u[s]=c;var i=(u,s,c)=>(O(u,typeof s!="symbol"?s+"":s,c),c);class s{constructor(t){i(this,"iterable");this.iterable=t}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}source(){return this.iterable}collectToArray(){return[...this.source()]}}function c(e,t){return(r,n)=>t(e(r,n),n)}function y(e,t){return(r,n)=>e(r,n)&&t(r,n)}function m(e,t){return{done:e,value:t}}function p(){return{done:!0,value:void 0}}function $(e){return e}function z(e,t){return new h(e,t)}class h{constructor(t,r){i(this,"predicate");i(this,"source");let n=r,o=t;if(o instanceof h){const a=o.predicate;o=o.source,n=y(a,n)}this.source=o,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 f(e,t)}class f{constructor(t,r){i(this,"mapper");i(this,"source");let n=r,o=t;if(o instanceof f){const a=o.mapper;o=o.source,n=c(a,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?m(!1,this.mapper(t.value,this.index++)):p()}}function L(e){const t=e[Symbol.iterator](),r=new d;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,m(!1,t.data))}}class d{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 d){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 typeof e=="function"}function g(e,t){const r=e[Symbol.iterator]();let n=0,o=r.next(),a=o.value;const R=N(t)?t:(j,q)=>j>q;for(o=r.next();o.done!==!0;o=r.next())a=R(a,o.value,n++)?a:o.value;return a==null?null:a}function A(e){return e instanceof x?e:new x(e)}class x{constructor(t){i(this,"isMemoized",!1);i(this,"sourceIterator");i(this,"linkedList",new d);i(this,"source");this.source=t,this.sourceIterator=t[Symbol.iterator](),t instanceof d&&(this.linkedList=t,this.isMemoized=!0)}[Symbol.iterator](){return this.isMemoized?new P(this.linkedList):new F(this.sourceIterator,this.linkedList,t=>this.isMemoized=t.done===!0)}}class F{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 P{constructor(t){i(this,"memoizedSourceIterator");this.memoizedSourceIterator=t[Symbol.iterator]()}next(){return this.memoizedSourceIterator.next()}}function T(e,t){const r=e[Symbol.iterator]();let n=0;for(let o=r.next();o.done!==!0;o=r.next())if(t(o.value,n++))return!0;return!1}function l(e){return new s(e)}s.prototype.filter=function(e){return l(z(this.source(),e))},s.prototype.map=function(e){return l(b(this.source(),e))},s.prototype.materialize=function(){return l(k(this.source()))},s.prototype.max=function(e){return g(this.source(),e)},s.prototype.memoize=function(){return l(A(this.source()))},s.prototype.some=function(e){return T(this.source(),e)},u.from=l,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/map.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Mapper } from "./types";
|
|
2
|
+
export declare function map<T, R>(iterable: Iterable<T>, mapper: Mapper<T, R>): Iterable<R>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
declare type ComparerFunction<T> = (a: T, b: T, index: number) => number;
|
|
2
2
|
declare type ComparingProps<T> = keyof T | Array<keyof T>;
|
|
3
3
|
export declare type Comparer<T> = ComparerFunction<T> | ComparingProps<T>;
|
|
4
|
-
export declare type Mapper<T, R> = (value: T, index: number) => R;
|
|
5
4
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Mapper<T, R> = (value: T, index: number) => R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Predicate<T> = (value: T, index: number) => boolean;
|
package/dist/utils/index.d.ts
CHANGED
package/package.json
CHANGED
package/dist/min.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare function combineMappers<T, R, RR>(m1: (value: T, index: number) => R, m2: (value: R, index: number) => RR): (value: T, index: number) => RR;
|
|
2
|
-
export declare function combinePredicates<T>(m1: (value: T, index: number) => boolean, m2: (value: T, index: number) => boolean): (value: T, index: number) => boolean;
|