iterable-linq-utility 0.0.1
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/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/filter.d.ts +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/interable-linq-utility.js +261 -0
- package/dist/interable-linq-utility.umd.cjs +1 -0
- package/dist/iteratorResults.d.ts +3 -0
- package/dist/linkedList.d.ts +20 -0
- package/dist/linqIterable.d.ts +7 -0
- package/dist/map.d.ts +1 -0
- package/dist/materialize.d.ts +1 -0
- package/dist/max.d.ts +1 -0
- package/dist/memoize.d.ts +1 -0
- package/dist/min.d.ts +2 -0
- package/dist/some.d.ts +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/utils/combiners.d.ts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/utils.d.ts +74 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2022] [Federico Maria Ceruti]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
package/dist/filter.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function filter<T>(iterable: Iterable<T>, predicate: (value: T, index: number) => boolean): Iterable<T>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ILinqIterable<T> {
|
|
2
|
+
[Symbol.iterator](): Iterator<T, any, undefined>;
|
|
3
|
+
collectToArray(): T[];
|
|
4
|
+
filter(predicate: (value: T, index: number) => boolean): ILinqIterable<T>;
|
|
5
|
+
map<R>(mapper: (value: T, index: number) => R): ILinqIterable<R>;
|
|
6
|
+
materialize(): ILinqIterable<T>;
|
|
7
|
+
max<T>(comparer?: (a: T, b: T, index: number) => boolean): T | null | undefined;
|
|
8
|
+
memoize(): ILinqIterable<T>;
|
|
9
|
+
some(predicate: (value: T, index: number) => boolean): boolean;
|
|
10
|
+
}
|
|
11
|
+
declare module "./linqIterable" {
|
|
12
|
+
interface LinqIterable<T> {
|
|
13
|
+
filter(predicate: (value: T, index: number) => boolean): ILinqIterable<T>;
|
|
14
|
+
map<R>(mapper: (value: T, index: number) => R): ILinqIterable<R>;
|
|
15
|
+
materialize(): ILinqIterable<T>;
|
|
16
|
+
max<T>(comparer?: (a: T, b: T, index: number) => boolean): T | null | undefined;
|
|
17
|
+
memoize(): ILinqIterable<T>;
|
|
18
|
+
some(predicate: (value: T, index: number) => boolean): boolean;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export declare function from<T>(iterable: Iterable<T>): ILinqIterable<T>;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
var S = Object.defineProperty;
|
|
2
|
+
var y = (e, t, r) => t in e ? S(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var o = (e, t, r) => (y(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
+
class u {
|
|
5
|
+
constructor(t) {
|
|
6
|
+
o(this, "iterable");
|
|
7
|
+
this.iterable = t;
|
|
8
|
+
}
|
|
9
|
+
[Symbol.iterator]() {
|
|
10
|
+
return this.iterable[Symbol.iterator]();
|
|
11
|
+
}
|
|
12
|
+
source() {
|
|
13
|
+
return this.iterable;
|
|
14
|
+
}
|
|
15
|
+
collectToArray() {
|
|
16
|
+
return [...this.source()];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function b(e, t) {
|
|
20
|
+
return (r, i) => t(e(r, i), i);
|
|
21
|
+
}
|
|
22
|
+
function w(e, t) {
|
|
23
|
+
return (r, i) => t(r, i) && e(r, i);
|
|
24
|
+
}
|
|
25
|
+
function L(e) {
|
|
26
|
+
return typeof e == "function";
|
|
27
|
+
}
|
|
28
|
+
function f(e, t) {
|
|
29
|
+
return {
|
|
30
|
+
done: e,
|
|
31
|
+
value: t
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function p() {
|
|
35
|
+
return { done: !0, value: void 0 };
|
|
36
|
+
}
|
|
37
|
+
function M(e, t) {
|
|
38
|
+
return new l(e, t);
|
|
39
|
+
}
|
|
40
|
+
class l {
|
|
41
|
+
constructor(t, r) {
|
|
42
|
+
o(this, "predicate");
|
|
43
|
+
o(this, "source");
|
|
44
|
+
let i = r, n = t;
|
|
45
|
+
if (n instanceof l) {
|
|
46
|
+
const s = n.predicate;
|
|
47
|
+
n = n.source, i = w(s, i);
|
|
48
|
+
}
|
|
49
|
+
this.source = n, this.predicate = i;
|
|
50
|
+
}
|
|
51
|
+
[Symbol.iterator]() {
|
|
52
|
+
return new k(this.source, this.predicate);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
class k {
|
|
56
|
+
constructor(t, r) {
|
|
57
|
+
o(this, "index", 0);
|
|
58
|
+
o(this, "sourceIterator");
|
|
59
|
+
o(this, "predicate");
|
|
60
|
+
this.sourceIterator = t[Symbol.iterator](), this.predicate = r;
|
|
61
|
+
}
|
|
62
|
+
next() {
|
|
63
|
+
for (; ; ) {
|
|
64
|
+
const t = this.sourceIterator.next();
|
|
65
|
+
if (t.done === !0 || this.predicate(t.value, this.index++))
|
|
66
|
+
return t;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function v(e, t) {
|
|
71
|
+
return new h(e, t);
|
|
72
|
+
}
|
|
73
|
+
class h {
|
|
74
|
+
constructor(t, r) {
|
|
75
|
+
o(this, "mapper");
|
|
76
|
+
o(this, "source");
|
|
77
|
+
let i = r, n = t;
|
|
78
|
+
if (n instanceof h) {
|
|
79
|
+
const s = n.mapper;
|
|
80
|
+
n = n.source, i = b(s, i);
|
|
81
|
+
}
|
|
82
|
+
this.source = t, this.mapper = i;
|
|
83
|
+
}
|
|
84
|
+
[Symbol.iterator]() {
|
|
85
|
+
return new N(this.source, this.mapper);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
class N {
|
|
89
|
+
constructor(t, r) {
|
|
90
|
+
o(this, "index", 0);
|
|
91
|
+
o(this, "sourceIterator");
|
|
92
|
+
o(this, "mapper");
|
|
93
|
+
this.sourceIterator = t[Symbol.iterator](), this.mapper = r;
|
|
94
|
+
}
|
|
95
|
+
next() {
|
|
96
|
+
const t = this.sourceIterator.next();
|
|
97
|
+
return t.done !== !0 ? f(!1, this.mapper(t.value, this.index++)) : p();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function A(e) {
|
|
101
|
+
const t = e[Symbol.iterator](), r = new a();
|
|
102
|
+
for (let i = t.next(); i.done !== !0; i = t.next())
|
|
103
|
+
r.addLast(i.value);
|
|
104
|
+
return r;
|
|
105
|
+
}
|
|
106
|
+
class F {
|
|
107
|
+
constructor(t = null) {
|
|
108
|
+
o(this, "current", null);
|
|
109
|
+
this.current = t;
|
|
110
|
+
}
|
|
111
|
+
next() {
|
|
112
|
+
const t = this.current;
|
|
113
|
+
return t === null ? p() : (this.current = t.nextNode, f(!1, t.data));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
class a {
|
|
117
|
+
constructor() {
|
|
118
|
+
o(this, "internalSize", 0);
|
|
119
|
+
o(this, "head", null);
|
|
120
|
+
o(this, "tail", null);
|
|
121
|
+
}
|
|
122
|
+
[Symbol.iterator]() {
|
|
123
|
+
return new F(this.head);
|
|
124
|
+
}
|
|
125
|
+
addFirst(t) {
|
|
126
|
+
const r = {
|
|
127
|
+
data: t,
|
|
128
|
+
nextNode: null
|
|
129
|
+
};
|
|
130
|
+
switch (this.internalSize) {
|
|
131
|
+
case 0:
|
|
132
|
+
this.head = r, this.tail = r;
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
r.nextNode = this.head, this.head = r;
|
|
136
|
+
}
|
|
137
|
+
return this.internalSize++, this;
|
|
138
|
+
}
|
|
139
|
+
addLast(t) {
|
|
140
|
+
const r = {
|
|
141
|
+
data: t,
|
|
142
|
+
nextNode: null
|
|
143
|
+
};
|
|
144
|
+
switch (this.internalSize) {
|
|
145
|
+
case 0:
|
|
146
|
+
this.head = r, this.tail = r;
|
|
147
|
+
break;
|
|
148
|
+
default:
|
|
149
|
+
this.tail.nextNode = r, this.tail = r;
|
|
150
|
+
}
|
|
151
|
+
return this.internalSize++, this;
|
|
152
|
+
}
|
|
153
|
+
size() {
|
|
154
|
+
return this.internalSize;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function g(e) {
|
|
158
|
+
return e instanceof d ? e : new d(e);
|
|
159
|
+
}
|
|
160
|
+
class d {
|
|
161
|
+
constructor(t) {
|
|
162
|
+
o(this, "source");
|
|
163
|
+
if (t instanceof a) {
|
|
164
|
+
this.source = t;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.source = A(t);
|
|
168
|
+
}
|
|
169
|
+
[Symbol.iterator]() {
|
|
170
|
+
return new P(this.source);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
class P {
|
|
174
|
+
constructor(t) {
|
|
175
|
+
o(this, "sourceIterator");
|
|
176
|
+
this.sourceIterator = t[Symbol.iterator]();
|
|
177
|
+
}
|
|
178
|
+
next() {
|
|
179
|
+
return this.sourceIterator.next();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function R(e, t) {
|
|
183
|
+
const r = e[Symbol.iterator]();
|
|
184
|
+
let i = 0, n = r.next(), s = n.value;
|
|
185
|
+
const I = L(t) ? t : (x, z) => x > z;
|
|
186
|
+
for (n = r.next(); n.done !== !0; n = r.next())
|
|
187
|
+
s = I(s, n.value, i++) ? s : n.value;
|
|
188
|
+
return s == null ? null : s;
|
|
189
|
+
}
|
|
190
|
+
function q(e) {
|
|
191
|
+
return e instanceof m ? e : new m(e);
|
|
192
|
+
}
|
|
193
|
+
class m {
|
|
194
|
+
constructor(t) {
|
|
195
|
+
o(this, "isMemoized", !1);
|
|
196
|
+
o(this, "sourceIterator");
|
|
197
|
+
o(this, "linkedList", new a());
|
|
198
|
+
o(this, "source");
|
|
199
|
+
this.source = t, this.sourceIterator = t[Symbol.iterator](), t instanceof a && (this.linkedList = t, this.isMemoized = !0);
|
|
200
|
+
}
|
|
201
|
+
[Symbol.iterator]() {
|
|
202
|
+
return this.isMemoized ? new T(this.linkedList) : new D(this.sourceIterator, this.linkedList, (t) => this.isMemoized = t.done === !0);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
class D {
|
|
206
|
+
constructor(t, r, i) {
|
|
207
|
+
o(this, "index", 0);
|
|
208
|
+
o(this, "linkedList");
|
|
209
|
+
o(this, "linkedListIterator");
|
|
210
|
+
o(this, "setAsMemoized");
|
|
211
|
+
o(this, "sourceIterator");
|
|
212
|
+
this.linkedList = r, this.linkedListIterator = r[Symbol.iterator](), this.setAsMemoized = i, this.sourceIterator = t;
|
|
213
|
+
}
|
|
214
|
+
next() {
|
|
215
|
+
if (this.linkedList.size() > this.index++)
|
|
216
|
+
return this.linkedListIterator.next();
|
|
217
|
+
const t = this.sourceIterator.next();
|
|
218
|
+
return this.setAsMemoized(t) || this.linkedList.addLast(t.value), t;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
class T {
|
|
222
|
+
constructor(t) {
|
|
223
|
+
o(this, "memoizedSourceIterator");
|
|
224
|
+
this.memoizedSourceIterator = t[Symbol.iterator]();
|
|
225
|
+
}
|
|
226
|
+
next() {
|
|
227
|
+
return this.memoizedSourceIterator.next();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function $(e, t) {
|
|
231
|
+
const r = e[Symbol.iterator]();
|
|
232
|
+
let i = 0;
|
|
233
|
+
for (let n = r.next(); n.done !== !0; n = r.next())
|
|
234
|
+
if (t(n.value, i++))
|
|
235
|
+
return !0;
|
|
236
|
+
return !1;
|
|
237
|
+
}
|
|
238
|
+
function c(e) {
|
|
239
|
+
return new u(e);
|
|
240
|
+
}
|
|
241
|
+
u.prototype.filter = function(e) {
|
|
242
|
+
return c(M(this.source(), e));
|
|
243
|
+
};
|
|
244
|
+
u.prototype.map = function(e) {
|
|
245
|
+
return c(v(this.source(), e));
|
|
246
|
+
};
|
|
247
|
+
u.prototype.materialize = function() {
|
|
248
|
+
return c(g(this.source()));
|
|
249
|
+
};
|
|
250
|
+
u.prototype.max = function(e) {
|
|
251
|
+
return R(this.source(), e);
|
|
252
|
+
};
|
|
253
|
+
u.prototype.memoize = function() {
|
|
254
|
+
return c(q(this.source()));
|
|
255
|
+
};
|
|
256
|
+
u.prototype.some = function(e) {
|
|
257
|
+
return $(this.source(), e);
|
|
258
|
+
};
|
|
259
|
+
export {
|
|
260
|
+
c as from
|
|
261
|
+
};
|
|
@@ -0,0 +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)=>t(r,n)&&e(r,n)}function z(e){return typeof e=="function"}function m(e,t){return{done:e,value:t}}function p(){return{done:!0,value:void 0}}function $(e){return e}function S(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 b(this.source,this.predicate)}}class b{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 w(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 L(this.source,this.mapper)}}class L{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 M(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 k{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 k(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 v(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=M(t)}[Symbol.iterator](){return new N(this.source)}}class N{constructor(t){i(this,"sourceIterator");this.sourceIterator=t[Symbol.iterator]()}next(){return this.sourceIterator.next()}}function g(e,t){const r=e[Symbol.iterator]();let n=0,o=r.next(),a=o.value;const R=z(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(S(this.source(),e))},s.prototype.map=function(e){return l(w(this.source(),e))},s.prototype.materialize=function(){return l(v(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"}})});
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export declare class LinkedList<T> implements Iterable<T> {
|
|
8
|
+
private internalSize;
|
|
9
|
+
private head;
|
|
10
|
+
private tail;
|
|
11
|
+
[Symbol.iterator](): Iterator<T>;
|
|
12
|
+
addFirst(value: T): this;
|
|
13
|
+
addLast(value: T): this;
|
|
14
|
+
size(): number;
|
|
15
|
+
}
|
|
16
|
+
interface IListNode<T> {
|
|
17
|
+
data: T;
|
|
18
|
+
nextNode: IListNode<T> | null;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/dist/map.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function map<T, R>(iterable: Iterable<T>, mapper: (value: T, index: number) => R): Iterable<R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function materialize<T>(iterable: Iterable<T>): Iterable<T>;
|
package/dist/max.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function max<T>(iterable: Iterable<T>, comparer?: (a: T, b: T, index: number) => boolean): T | null | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function memoize<T>(iterable: Iterable<T>): Iterable<T>;
|
package/dist/min.d.ts
ADDED
package/dist/some.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function some<T>(iterable: Iterable<T>, predicate: (value: T, index: number) => boolean): boolean;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare type ComparerFunction<T> = (a: T, b: T, index: number) => number;
|
|
2
|
+
declare type ComparingProps<T> = keyof T | Array<keyof T>;
|
|
3
|
+
export declare type Comparer<T> = ComparerFunction<T> | ComparingProps<T>;
|
|
4
|
+
export declare type Mapper<T, R> = (value: T, index: number) => R;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
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;
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
/**
|
|
28
|
+
* Checks if `value` is classified as a `Function` object.
|
|
29
|
+
*
|
|
30
|
+
* From [LoDash isFunction](https://github.com/lodash/lodash/blob/2f79053d7bc7c9c9561a30dda202b3dcd2b72b90/isFunction.js)
|
|
31
|
+
*
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
* @category Lang
|
|
34
|
+
* @param {*} value The value to check.
|
|
35
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* isFunction(class Any{})
|
|
39
|
+
* // => true
|
|
40
|
+
*
|
|
41
|
+
* isFunction(() => {})
|
|
42
|
+
* // => true
|
|
43
|
+
*
|
|
44
|
+
* isFunction(async () => {})
|
|
45
|
+
* // => true
|
|
46
|
+
*
|
|
47
|
+
* isFunction(function * Any() {})
|
|
48
|
+
* // => true
|
|
49
|
+
*
|
|
50
|
+
* isFunction(Math.round)
|
|
51
|
+
* // => true
|
|
52
|
+
*
|
|
53
|
+
* isFunction(/abc/)
|
|
54
|
+
* // => false
|
|
55
|
+
*/
|
|
56
|
+
export declare function isFunction(value?: any): value is (...args: any[]) => any;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* Checks if `value` is classified as a `String` primitive or object.
|
|
60
|
+
*
|
|
61
|
+
* From [LoDash isString](https://github.com/lodash/lodash/blob/master/isString.js)
|
|
62
|
+
*
|
|
63
|
+
* @since 1.0.0
|
|
64
|
+
* @param {*} value The value to check.
|
|
65
|
+
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
|
|
66
|
+
* @example
|
|
67
|
+
*
|
|
68
|
+
* isString('abc')
|
|
69
|
+
* // => true
|
|
70
|
+
*
|
|
71
|
+
* isString(1)
|
|
72
|
+
* // => false
|
|
73
|
+
*/
|
|
74
|
+
export declare function isString(value?: any): value is string;
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "iterable-linq-utility",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An Iterable mutation utility inspired by .net Linq and Javascript Array interface",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/my-lib.umd.cjs",
|
|
7
|
+
"module": "./dist/my-lib.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/my-lib.js",
|
|
12
|
+
"require": "./dist/my-lib.umd.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc && vite build",
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --ignore-path .eslintignore",
|
|
22
|
+
"lint-fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix --ignore-path .eslintignore",
|
|
23
|
+
"test": "vitest",
|
|
24
|
+
"test:coverage": "vitest run --coverage",
|
|
25
|
+
"test:ui": "vitest --ui"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/Amebus/iterable-linq-utility.git"
|
|
30
|
+
},
|
|
31
|
+
"author": "Amebus",
|
|
32
|
+
"license": "ISC",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/Amebus/iterable-linq-utility/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/Amebus/iterable-linq-utility#readme",
|
|
37
|
+
"keywords": ["linq", "itearable", "utility"],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@rushstack/eslint-patch": "^1.1.4",
|
|
40
|
+
"@types/node": "18.11.10",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "5.36.2",
|
|
42
|
+
"@typescript-eslint/parser": "5.36.2",
|
|
43
|
+
"@vitest/ui": "0.25.2",
|
|
44
|
+
"eslint": "8.22.0",
|
|
45
|
+
"eslint-plugin-import": "2.26.0",
|
|
46
|
+
"eslint-plugin-node": "11.1.0",
|
|
47
|
+
"eslint-plugin-promise": "6.0.1",
|
|
48
|
+
"eslint-plugin-standard": "5.0.0",
|
|
49
|
+
"typescript": "4.9.3",
|
|
50
|
+
"vite": "3.2.4",
|
|
51
|
+
"vite-plugin-dts": "1.7.1",
|
|
52
|
+
"vitest": "0.25.3"
|
|
53
|
+
}
|
|
54
|
+
}
|