iterable-linq-utility 0.1.0 → 0.2.0
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/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/iterable-linq-utility.js +100 -91
- package/dist/iterable-linq-utility.umd.cjs +1 -1
- package/package.json +8 -1
package/dist/index.d.cts
CHANGED
|
@@ -433,6 +433,19 @@ export declare interface IIterableLinqBase<T> {
|
|
|
433
433
|
* @since 0.0.8
|
|
434
434
|
*/
|
|
435
435
|
min(comparer?: Comparer<T>): T | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Runs the chain and accumulates its values into a single result, starting from the first value.
|
|
438
|
+
* @operation `Action`
|
|
439
|
+
* @param reducer - called with the accumulator, each value from the second one and its index (starting at 1); returns the new accumulator
|
|
440
|
+
* @returns the final accumulator; the only value when the chain has one value, without calling `reducer`
|
|
441
|
+
* @throws Error if the chain is empty or if `reducer` is not a function
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* IterableLinq.from([3, 7, 2]).reduce((acc, v) => (v > acc ? v : acc)); // 7
|
|
445
|
+
* ```
|
|
446
|
+
* @since 0.2.0
|
|
447
|
+
*/
|
|
448
|
+
reduce(reducer: Reducer<T, T>): T;
|
|
436
449
|
/**
|
|
437
450
|
* Runs the chain and accumulates its values into a single result.
|
|
438
451
|
* @operation `Action`
|
|
@@ -702,6 +715,21 @@ declare function range(end: number, options?: IRangeOptions): Iterable<number>;
|
|
|
702
715
|
*/
|
|
703
716
|
declare function range(start: number, end: number, options?: IRangeOptions): Iterable<number>;
|
|
704
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Accumulates the values of `iterable` into a single result, starting from the first value.
|
|
720
|
+
* @operation `Action`
|
|
721
|
+
* @param iterable - the source `Iterable`
|
|
722
|
+
* @param reducer - called with the accumulator, each value from the second one and its index (starting at 1); returns the new accumulator
|
|
723
|
+
* @returns the final accumulator; the only value when `iterable` has one value, without calling `reducer`
|
|
724
|
+
* @throws Error if `iterable` is missing, does not implement `[Symbol.iterator]` or is empty, or if `reducer` is not a function
|
|
725
|
+
* @example
|
|
726
|
+
* ```ts
|
|
727
|
+
* Functions.reduce([3, 7, 2], (acc, v) => (v > acc ? v : acc)); // 7
|
|
728
|
+
* ```
|
|
729
|
+
* @since 0.2.0
|
|
730
|
+
*/
|
|
731
|
+
declare function reduce<T>(iterable: Iterable<T>, reducer: Reducer<T, T>): T;
|
|
732
|
+
|
|
705
733
|
/**
|
|
706
734
|
* Accumulates the values of `iterable` into a single result.
|
|
707
735
|
* @operation `Action`
|
package/dist/index.d.ts
CHANGED
|
@@ -433,6 +433,19 @@ export declare interface IIterableLinqBase<T> {
|
|
|
433
433
|
* @since 0.0.8
|
|
434
434
|
*/
|
|
435
435
|
min(comparer?: Comparer<T>): T | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Runs the chain and accumulates its values into a single result, starting from the first value.
|
|
438
|
+
* @operation `Action`
|
|
439
|
+
* @param reducer - called with the accumulator, each value from the second one and its index (starting at 1); returns the new accumulator
|
|
440
|
+
* @returns the final accumulator; the only value when the chain has one value, without calling `reducer`
|
|
441
|
+
* @throws Error if the chain is empty or if `reducer` is not a function
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* IterableLinq.from([3, 7, 2]).reduce((acc, v) => (v > acc ? v : acc)); // 7
|
|
445
|
+
* ```
|
|
446
|
+
* @since 0.2.0
|
|
447
|
+
*/
|
|
448
|
+
reduce(reducer: Reducer<T, T>): T;
|
|
436
449
|
/**
|
|
437
450
|
* Runs the chain and accumulates its values into a single result.
|
|
438
451
|
* @operation `Action`
|
|
@@ -702,6 +715,21 @@ declare function range(end: number, options?: IRangeOptions): Iterable<number>;
|
|
|
702
715
|
*/
|
|
703
716
|
declare function range(start: number, end: number, options?: IRangeOptions): Iterable<number>;
|
|
704
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Accumulates the values of `iterable` into a single result, starting from the first value.
|
|
720
|
+
* @operation `Action`
|
|
721
|
+
* @param iterable - the source `Iterable`
|
|
722
|
+
* @param reducer - called with the accumulator, each value from the second one and its index (starting at 1); returns the new accumulator
|
|
723
|
+
* @returns the final accumulator; the only value when `iterable` has one value, without calling `reducer`
|
|
724
|
+
* @throws Error if `iterable` is missing, does not implement `[Symbol.iterator]` or is empty, or if `reducer` is not a function
|
|
725
|
+
* @example
|
|
726
|
+
* ```ts
|
|
727
|
+
* Functions.reduce([3, 7, 2], (acc, v) => (v > acc ? v : acc)); // 7
|
|
728
|
+
* ```
|
|
729
|
+
* @since 0.2.0
|
|
730
|
+
*/
|
|
731
|
+
declare function reduce<T>(iterable: Iterable<T>, reducer: Reducer<T, T>): T;
|
|
732
|
+
|
|
705
733
|
/**
|
|
706
734
|
* Accumulates the values of `iterable` into a single result.
|
|
707
735
|
* @operation `Action`
|
|
@@ -57,21 +57,21 @@ function c(e) {
|
|
|
57
57
|
function l(e, t) {
|
|
58
58
|
if (!n(e)) throw Error(`The "${t}" function must be provided`);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function ee(e, t) {
|
|
61
61
|
if (!Number.isInteger(e) || e < 0) throw Error(`The "${t}" parameter must be a non-negative integer`);
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function u(e, t) {
|
|
64
64
|
if (!Number.isFinite(e) || e === 0) throw Error(`The "${t}" parameter must be a finite number other than 0`);
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function te(e, t) {
|
|
67
67
|
if (typeof e != "object" || !e) throw Error(`The "${t}" parameter must be an object`);
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function ne(e, t) {
|
|
70
70
|
if (typeof e != "string" || e.length === 0) throw Error(`The "${t}" parameter must be a non-empty string`);
|
|
71
71
|
}
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/functions/collectToArray.ts
|
|
74
|
-
function
|
|
74
|
+
function d(e) {
|
|
75
75
|
if (c(e), Array.isArray(e) || e instanceof Set) return Array.from(e);
|
|
76
76
|
let t = [];
|
|
77
77
|
for (let n of e) t.push(n);
|
|
@@ -79,7 +79,7 @@ function f(e) {
|
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/iterators/baseIterator.ts
|
|
82
|
-
var
|
|
82
|
+
var f = class {
|
|
83
83
|
done = !1;
|
|
84
84
|
next() {
|
|
85
85
|
if (this.done) return s();
|
|
@@ -101,7 +101,7 @@ var p = class {
|
|
|
101
101
|
} catch {}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
},
|
|
104
|
+
}, p = class {
|
|
105
105
|
createIterator;
|
|
106
106
|
constructor(e) {
|
|
107
107
|
this.createIterator = e;
|
|
@@ -109,7 +109,7 @@ var p = class {
|
|
|
109
109
|
[Symbol.iterator]() {
|
|
110
110
|
return this.createIterator();
|
|
111
111
|
}
|
|
112
|
-
},
|
|
112
|
+
}, m = class extends f {
|
|
113
113
|
source;
|
|
114
114
|
index = 0;
|
|
115
115
|
constructor(e) {
|
|
@@ -121,10 +121,10 @@ var p = class {
|
|
|
121
121
|
};
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/iterators/unfold.ts
|
|
124
|
-
function
|
|
125
|
-
return new
|
|
124
|
+
function h(e, t) {
|
|
125
|
+
return new p(() => new g(e, t));
|
|
126
126
|
}
|
|
127
|
-
var
|
|
127
|
+
var g = class extends f {
|
|
128
128
|
state;
|
|
129
129
|
step;
|
|
130
130
|
constructor(e, t) {
|
|
@@ -138,14 +138,14 @@ var ne = class extends p {
|
|
|
138
138
|
//#endregion
|
|
139
139
|
//#region src/functions/empty.ts
|
|
140
140
|
function _() {
|
|
141
|
-
return
|
|
141
|
+
return h(void 0, () => void 0);
|
|
142
142
|
}
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region src/functions/filter.ts
|
|
145
145
|
function v(e, t) {
|
|
146
|
-
return c(e), l(t, "predicate"), new
|
|
146
|
+
return c(e), l(t, "predicate"), new p(() => new y(e, t));
|
|
147
147
|
}
|
|
148
|
-
var
|
|
148
|
+
var y = class extends m {
|
|
149
149
|
predicate;
|
|
150
150
|
constructor(e, t) {
|
|
151
151
|
super(e), this.predicate = t;
|
|
@@ -165,10 +165,10 @@ var re = class extends h {
|
|
|
165
165
|
};
|
|
166
166
|
//#endregion
|
|
167
167
|
//#region src/functions/flatMap.ts
|
|
168
|
-
function
|
|
169
|
-
return c(e), l(t, "mapper"), new
|
|
168
|
+
function b(e, t) {
|
|
169
|
+
return c(e), l(t, "mapper"), new p(() => new re(e, t));
|
|
170
170
|
}
|
|
171
|
-
var
|
|
171
|
+
var re = class e extends m {
|
|
172
172
|
mapper;
|
|
173
173
|
static steps = {
|
|
174
174
|
outer: (t) => {
|
|
@@ -257,9 +257,9 @@ async function w(e, t) {
|
|
|
257
257
|
//#endregion
|
|
258
258
|
//#region src/functions/map.ts
|
|
259
259
|
function T(e, t) {
|
|
260
|
-
return c(e), l(t, "mapper"), new
|
|
260
|
+
return c(e), l(t, "mapper"), new p(() => new E(e, t));
|
|
261
261
|
}
|
|
262
|
-
var
|
|
262
|
+
var E = class extends m {
|
|
263
263
|
mapper;
|
|
264
264
|
constructor(e, t) {
|
|
265
265
|
super(e), this.mapper = t;
|
|
@@ -278,18 +278,18 @@ var ie = class extends h {
|
|
|
278
278
|
};
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region src/collections/linkedList.ts
|
|
281
|
-
function
|
|
281
|
+
function D(e) {
|
|
282
282
|
c(e);
|
|
283
|
-
let t = new
|
|
283
|
+
let t = new ie();
|
|
284
284
|
for (let n of e) t.addLast(n);
|
|
285
285
|
return t;
|
|
286
286
|
}
|
|
287
|
-
var
|
|
287
|
+
var ie = class {
|
|
288
288
|
internalSize = 0;
|
|
289
289
|
head = null;
|
|
290
290
|
tail = null;
|
|
291
291
|
[Symbol.iterator]() {
|
|
292
|
-
return new
|
|
292
|
+
return new ae(this.head);
|
|
293
293
|
}
|
|
294
294
|
addFirst(e) {
|
|
295
295
|
let t = {
|
|
@@ -308,7 +308,7 @@ var D = class {
|
|
|
308
308
|
size() {
|
|
309
309
|
return this.internalSize;
|
|
310
310
|
}
|
|
311
|
-
},
|
|
311
|
+
}, ae = class extends f {
|
|
312
312
|
current;
|
|
313
313
|
constructor(e) {
|
|
314
314
|
super(), this.current = e;
|
|
@@ -320,13 +320,13 @@ var D = class {
|
|
|
320
320
|
};
|
|
321
321
|
//#endregion
|
|
322
322
|
//#region src/functions/materialize.ts
|
|
323
|
-
function
|
|
324
|
-
return c(e), e instanceof
|
|
323
|
+
function O(e) {
|
|
324
|
+
return c(e), e instanceof k ? e : new k(e);
|
|
325
325
|
}
|
|
326
|
-
var
|
|
326
|
+
var k = class {
|
|
327
327
|
source;
|
|
328
328
|
constructor(e) {
|
|
329
|
-
this.source =
|
|
329
|
+
this.source = D(e);
|
|
330
330
|
}
|
|
331
331
|
[Symbol.iterator]() {
|
|
332
332
|
return this.source[Symbol.iterator]();
|
|
@@ -334,29 +334,29 @@ var A = class {
|
|
|
334
334
|
};
|
|
335
335
|
//#endregion
|
|
336
336
|
//#region src/functions/max.ts
|
|
337
|
-
function
|
|
337
|
+
function A(e, t) {
|
|
338
338
|
return c(e), a(e, i(t), 1);
|
|
339
339
|
}
|
|
340
340
|
//#endregion
|
|
341
341
|
//#region src/functions/memoize.ts
|
|
342
|
-
function
|
|
342
|
+
function j() {
|
|
343
343
|
return { allowPartialMemoization: !0 };
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function M(e, t) {
|
|
346
346
|
c(e);
|
|
347
347
|
let n = {
|
|
348
|
-
...
|
|
348
|
+
...j(),
|
|
349
349
|
...t
|
|
350
350
|
}.allowPartialMemoization;
|
|
351
|
-
return e instanceof
|
|
351
|
+
return e instanceof F ? n ? e.changePartialMemoizationBehaviour() : e : e instanceof I ? n ? e : e.changePartialMemoizationBehaviour() : n ? new I(e) : new F(e);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function N() {
|
|
354
354
|
return {
|
|
355
355
|
values: [],
|
|
356
356
|
finished: !1
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function P(e, t) {
|
|
360
360
|
if (t.error) throw t.error.value;
|
|
361
361
|
if (t.finished) return !1;
|
|
362
362
|
t.source ??= e[Symbol.iterator]();
|
|
@@ -368,31 +368,31 @@ function F(e, t) {
|
|
|
368
368
|
}
|
|
369
369
|
return n.done === !0 ? (t.finished = !0, t.source = void 0, !1) : (t.values.push(n.value), !0);
|
|
370
370
|
}
|
|
371
|
-
var
|
|
371
|
+
var F = class {
|
|
372
372
|
source;
|
|
373
|
-
cache =
|
|
373
|
+
cache = N();
|
|
374
374
|
constructor(e) {
|
|
375
375
|
this.source = e;
|
|
376
376
|
}
|
|
377
377
|
[Symbol.iterator]() {
|
|
378
|
-
return new
|
|
378
|
+
return new L(this.source, this.cache, !0);
|
|
379
379
|
}
|
|
380
380
|
changePartialMemoizationBehaviour() {
|
|
381
|
-
return new
|
|
381
|
+
return new I(this.source);
|
|
382
382
|
}
|
|
383
|
-
},
|
|
383
|
+
}, I = class {
|
|
384
384
|
source;
|
|
385
|
-
cache =
|
|
385
|
+
cache = N();
|
|
386
386
|
constructor(e) {
|
|
387
387
|
this.source = e;
|
|
388
388
|
}
|
|
389
389
|
[Symbol.iterator]() {
|
|
390
|
-
return new
|
|
390
|
+
return new L(this.source, this.cache, !1);
|
|
391
391
|
}
|
|
392
392
|
changePartialMemoizationBehaviour() {
|
|
393
|
-
return new
|
|
393
|
+
return new F(this.source);
|
|
394
394
|
}
|
|
395
|
-
},
|
|
395
|
+
}, L = class extends f {
|
|
396
396
|
source;
|
|
397
397
|
cache;
|
|
398
398
|
drainFirst;
|
|
@@ -401,28 +401,28 @@ var I = class {
|
|
|
401
401
|
super(), this.source = e, this.cache = t, this.drainFirst = n;
|
|
402
402
|
}
|
|
403
403
|
advance() {
|
|
404
|
-
if (this.drainFirst) for (;
|
|
405
|
-
return this.index < this.cache.values.length ||
|
|
404
|
+
if (this.drainFirst) for (; P(this.source, this.cache););
|
|
405
|
+
return this.index < this.cache.values.length || P(this.source, this.cache) ? o(this.cache.values[this.index++]) : s();
|
|
406
406
|
}
|
|
407
407
|
};
|
|
408
408
|
//#endregion
|
|
409
409
|
//#region src/functions/min.ts
|
|
410
|
-
function
|
|
410
|
+
function R(e, t) {
|
|
411
411
|
return c(e), a(e, i(t), -1);
|
|
412
412
|
}
|
|
413
413
|
//#endregion
|
|
414
414
|
//#region src/functions/range.ts
|
|
415
|
-
function
|
|
415
|
+
function z(e, t, n) {
|
|
416
416
|
let r = typeof t == "number", i = r ? e : 0, a = r ? t : e;
|
|
417
417
|
if (!r && n !== void 0) throw Error("The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
418
418
|
let o = r ? n : t;
|
|
419
|
-
o !== void 0 &&
|
|
419
|
+
o !== void 0 && te(o, "options");
|
|
420
420
|
let { step: s = 1, reverse: c = !1 } = o ?? {};
|
|
421
|
-
|
|
422
|
-
let l =
|
|
423
|
-
return l.length > 0 ? new
|
|
421
|
+
u(s, "step");
|
|
422
|
+
let l = oe(i, a, Math.abs(s), c);
|
|
423
|
+
return l.length > 0 ? new p(() => new se(l.first, l.step, l.length)) : _();
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function oe(e, t, n, r) {
|
|
426
426
|
let i = t < e ? -n : n, a = Math.ceil(Math.abs(t - e) / n);
|
|
427
427
|
return r ? {
|
|
428
428
|
first: e + (a - 1) * i,
|
|
@@ -434,7 +434,7 @@ function ae(e, t, n, r) {
|
|
|
434
434
|
length: a
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
|
-
var
|
|
437
|
+
var se = class extends f {
|
|
438
438
|
first;
|
|
439
439
|
step;
|
|
440
440
|
length;
|
|
@@ -448,16 +448,25 @@ var oe = class extends p {
|
|
|
448
448
|
};
|
|
449
449
|
//#endregion
|
|
450
450
|
//#region src/functions/reduce.ts
|
|
451
|
-
function
|
|
452
|
-
c(e),
|
|
453
|
-
let r = t
|
|
454
|
-
|
|
455
|
-
|
|
451
|
+
function B(e, ...t) {
|
|
452
|
+
if (c(e), t.length === 1) return V(e, t[0]);
|
|
453
|
+
let [n, r] = t;
|
|
454
|
+
l(r, "reducer");
|
|
455
|
+
let i = n, a = 0;
|
|
456
|
+
for (let t of e) i = r(i, t, a++);
|
|
457
|
+
return i;
|
|
458
|
+
}
|
|
459
|
+
function V(e, t) {
|
|
460
|
+
l(t, "reducer");
|
|
461
|
+
let n, r = 0;
|
|
462
|
+
for (let i of e) n = r === 0 ? i : t(n, i, r), r++;
|
|
463
|
+
if (r === 0) throw Error("The \"sourceIterable\" must not be empty when \"reduce\" has no seed");
|
|
464
|
+
return n;
|
|
456
465
|
}
|
|
457
466
|
//#endregion
|
|
458
467
|
//#region src/functions/repeat.ts
|
|
459
468
|
function H(e, t) {
|
|
460
|
-
return
|
|
469
|
+
return ee(t, "count"), h(t, (t) => t > 0 ? [e, t - 1] : void 0);
|
|
461
470
|
}
|
|
462
471
|
//#endregion
|
|
463
472
|
//#region src/functions/some.ts
|
|
@@ -470,9 +479,9 @@ function U(e, t) {
|
|
|
470
479
|
//#endregion
|
|
471
480
|
//#region src/functions/tap.ts
|
|
472
481
|
function W(e, t) {
|
|
473
|
-
return c(e), l(t, "tapper"), new
|
|
482
|
+
return c(e), l(t, "tapper"), new p(() => new G(e, t));
|
|
474
483
|
}
|
|
475
|
-
var G = class extends
|
|
484
|
+
var G = class extends m {
|
|
476
485
|
tapper;
|
|
477
486
|
constructor(e, t) {
|
|
478
487
|
super(e), this.tapper = t;
|
|
@@ -491,25 +500,25 @@ var G = class extends h {
|
|
|
491
500
|
//#endregion
|
|
492
501
|
//#region src/functions/tapChain.ts
|
|
493
502
|
function K(e, t) {
|
|
494
|
-
return c(e), l(t, "tapper"), new
|
|
503
|
+
return c(e), l(t, "tapper"), new p(() => (t(e, 0), e[Symbol.iterator]()));
|
|
495
504
|
}
|
|
496
505
|
//#endregion
|
|
497
506
|
//#region src/functions/index.ts
|
|
498
|
-
var
|
|
499
|
-
collectToArray: () =>
|
|
507
|
+
var ce = /* @__PURE__ */ t({
|
|
508
|
+
collectToArray: () => d,
|
|
500
509
|
empty: () => _,
|
|
501
510
|
filter: () => v,
|
|
502
|
-
flatMap: () =>
|
|
511
|
+
flatMap: () => b,
|
|
503
512
|
forEach: () => C,
|
|
504
513
|
forEachAsync: () => w,
|
|
505
|
-
getMemoizeDefaultOptions: () =>
|
|
514
|
+
getMemoizeDefaultOptions: () => j,
|
|
506
515
|
map: () => T,
|
|
507
|
-
materialize: () =>
|
|
508
|
-
max: () =>
|
|
509
|
-
memoize: () =>
|
|
510
|
-
min: () =>
|
|
511
|
-
range: () =>
|
|
512
|
-
reduce: () =>
|
|
516
|
+
materialize: () => O,
|
|
517
|
+
max: () => A,
|
|
518
|
+
memoize: () => M,
|
|
519
|
+
min: () => R,
|
|
520
|
+
range: () => z,
|
|
521
|
+
reduce: () => B,
|
|
513
522
|
repeat: () => H,
|
|
514
523
|
some: () => U,
|
|
515
524
|
tap: () => W,
|
|
@@ -529,13 +538,13 @@ var Y = class {
|
|
|
529
538
|
return this.iterable[Symbol.iterator]();
|
|
530
539
|
}
|
|
531
540
|
collectToArray() {
|
|
532
|
-
return
|
|
541
|
+
return d(this.iterable);
|
|
533
542
|
}
|
|
534
543
|
filter(e) {
|
|
535
544
|
return J(v(this.iterable, e));
|
|
536
545
|
}
|
|
537
546
|
flatMap(e) {
|
|
538
|
-
return J(
|
|
547
|
+
return J(b(this.iterable, e));
|
|
539
548
|
}
|
|
540
549
|
forEach(e) {
|
|
541
550
|
return C(this.iterable, e);
|
|
@@ -547,19 +556,19 @@ var Y = class {
|
|
|
547
556
|
return J(T(this.iterable, e));
|
|
548
557
|
}
|
|
549
558
|
materialize() {
|
|
550
|
-
return J(
|
|
559
|
+
return J(O(this.iterable));
|
|
551
560
|
}
|
|
552
561
|
max(e) {
|
|
553
|
-
return
|
|
562
|
+
return A(this.iterable, e);
|
|
554
563
|
}
|
|
555
564
|
memoize(e) {
|
|
556
|
-
return J(
|
|
565
|
+
return J(M(this.iterable, e));
|
|
557
566
|
}
|
|
558
567
|
min(e) {
|
|
559
|
-
return
|
|
568
|
+
return R(this.iterable, e);
|
|
560
569
|
}
|
|
561
|
-
reduce(e
|
|
562
|
-
return
|
|
570
|
+
reduce(...e) {
|
|
571
|
+
return e.length === 1 ? B(this.iterable, e[0]) : B(this.iterable, e[0], e[1]);
|
|
563
572
|
}
|
|
564
573
|
some(e) {
|
|
565
574
|
return U(this.iterable, e);
|
|
@@ -587,7 +596,7 @@ Object.defineProperty(Y.prototype, q, {
|
|
|
587
596
|
function X() {
|
|
588
597
|
return Y.prototype;
|
|
589
598
|
}
|
|
590
|
-
function
|
|
599
|
+
function le(e) {
|
|
591
600
|
return typeof e == "object" && !!e && e[q] === !0;
|
|
592
601
|
}
|
|
593
602
|
function Z(e, t) {
|
|
@@ -600,13 +609,13 @@ function Z(e, t) {
|
|
|
600
609
|
});
|
|
601
610
|
}
|
|
602
611
|
function Q(e, t) {
|
|
603
|
-
|
|
612
|
+
ne(e, "name"), l(t, "implementation");
|
|
604
613
|
}
|
|
605
|
-
function
|
|
614
|
+
function ue(e, t) {
|
|
606
615
|
if (Q(e, t), e in J([])) throw Error(`"${e}" already exists on IIterableLinq: use override() to replace it`);
|
|
607
616
|
Z(e, t);
|
|
608
617
|
}
|
|
609
|
-
function
|
|
618
|
+
function de(e, t) {
|
|
610
619
|
Q(e, t);
|
|
611
620
|
let n = e;
|
|
612
621
|
if (!(n !== "constructor" && Object.prototype.hasOwnProperty.call(X(), n))) throw Error(`"${n}" is not a method of IIterableLinq: use extend() to add it`);
|
|
@@ -614,19 +623,19 @@ function ue(e, t) {
|
|
|
614
623
|
}
|
|
615
624
|
//#endregion
|
|
616
625
|
//#region src/index.ts
|
|
617
|
-
function
|
|
626
|
+
function fe() {
|
|
618
627
|
return $(_());
|
|
619
628
|
}
|
|
620
629
|
function $(e) {
|
|
621
630
|
return c(e), J(e);
|
|
622
631
|
}
|
|
623
|
-
function
|
|
624
|
-
if (typeof t == "number") return $(
|
|
632
|
+
function pe(e, t, n) {
|
|
633
|
+
if (typeof t == "number") return $(z(e, t, n));
|
|
625
634
|
if (n !== void 0) throw Error("The \"options\" parameter must be the second argument when \"start\" is omitted");
|
|
626
|
-
return $(
|
|
635
|
+
return $(z(e, t));
|
|
627
636
|
}
|
|
628
|
-
function
|
|
637
|
+
function me(e, t) {
|
|
629
638
|
return $(H(e, t));
|
|
630
639
|
}
|
|
631
640
|
//#endregion
|
|
632
|
-
export {
|
|
641
|
+
export { ce as Functions, x as Unit, fe as empty, ue as extend, $ as from, pe as fromRange, le as isIterableLinq, de as override, me as repeat, S as unit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.IterableLinq={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r};function r(e){return typeof e==`function`}function i(e,t){return e<t?-1:e===t?0:1}function a(e){if(e==null)return i;if(r(e))return e;let t=Array.isArray(e)?e:[e];return(e,n)=>{for(let r of t){let t=i(e[r],n[r]);if(t!==0)return t}return 0}}function o(e,t,n){let r,i=!1;for(let a of e)!i||r==null&&a!=null?(r=a,i=!0):a!=null&&n*t(r,a)<0&&(r=a);return r}function s(e){return{done:!1,value:e}}function c(e){return{done:!0,value:e}}function l(e){if(e==null)throw Error(`The "sourceIterable" must be provided`);if(!r(e[Symbol.iterator]))throw Error(`The provided "sourceIterable" does not conform to the iterator protocol https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol. It must implement the "[Symbol.iterator]" function.`)}function u(e,t){if(!r(e))throw Error(`The "${t}" function must be provided`)}function d(e,t){if(!Number.isInteger(e)||e<0)throw Error(`The "${t}" parameter must be a non-negative integer`)}function f(e,t){if(!Number.isFinite(e)||e===0)throw Error(`The "${t}" parameter must be a finite number other than 0`)}function p(e,t){if(typeof e!=`object`||!e)throw Error(`The "${t}" parameter must be an object`)}function ee(e,t){if(typeof e!=`string`||e.length===0)throw Error(`The "${t}" parameter must be a non-empty string`)}function m(e){if(l(e),Array.isArray(e)||e instanceof Set)return Array.from(e);let t=[];for(let n of e)t.push(n);return t}var h=class{done=!1;next(){if(this.done)return c();let e=this.advance();return e.done===!0&&(this.done=!0),e}return(e){return this.done||(this.done=!0,this.onReturn(e)),c(e)}[Symbol.iterator](){return this}onReturn(e){}closeAfterCallbackError(){if(!this.done){this.done=!0;try{this.onReturn()}catch{}}}},g=class{createIterator;constructor(e){this.createIterator=e}[Symbol.iterator](){return this.createIterator()}},_=class extends h{source;index=0;constructor(e){super(),this.source=e[Symbol.iterator]()}onReturn(e){this.source.return?.(e)}};function v(e,t){return new g(()=>new te(e,t))}var te=class extends h{state;step;constructor(e,t){super(),this.state=e,this.step=t}advance(){let e=this.step(this.state);return e===void 0?c():(this.state=e[1],s(e[0]))}};function y(){return v(void 0,()=>void 0)}function b(e,t){return l(e),u(t,`predicate`),new g(()=>new ne(e,t))}var ne=class extends _{predicate;constructor(e,t){super(e),this.predicate=t}advance(){for(let e=this.source.next();;e=this.source.next()){if(e.done===!0)return e;let t;try{t=this.predicate(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}if(t)return e}}};function x(e,t){return l(e),u(t,`mapper`),new g(()=>new S(e,t))}var S=class e extends _{mapper;static steps={outer:t=>{let n=t.source.next();if(n.done===!0)return n;let r=e.mapNext(t,n.value);if(r===void 0){t.state=`inner`;return}if(r.length!==0)return t.array=r,t.position=1,t.state=`array`,s(r[0])},inner:t=>{let n=e.nextInner(t);if(n.done!==!0)return n;t.inner=void 0,t.state=`outer`},array:e=>{if(e.position<e.array.length)return s(e.array[e.position++]);e.array=void 0,e.state=`outer`}};state=`outer`;inner;array;position=0;constructor(e,t){super(e),this.mapper=t}advance(){for(;;){let t=e.steps[this.state](this);if(t!==void 0)return t}}onReturn(e){this.array=void 0;try{this.inner?.return?.(e)}finally{super.onReturn(e)}}static mapNext(e,t){try{let n=e.mapper(t,e.index++);if(Array.isArray(n))return n;e.inner=n[Symbol.iterator]();return}catch(t){throw e.closeAfterCallbackError(),t}}static nextInner(e){try{return e.inner.next()}catch(t){throw e.inner=void 0,e.closeAfterCallbackError(),t}}},C=class e{static instance=e.createFrozen();constructor(){}static createFrozen(){let t=new e;return Object.freeze(t),t}};function w(){return C.instance}function T(e,t){l(e),u(t,`action`);let n=0;for(let r of e)t(r,n++);return w()}async function E(e,t){l(e),u(t,`action`);let n=0;for(let r of e)await t(r,n++);return w()}function D(e,t){return l(e),u(t,`mapper`),new g(()=>new O(e,t))}var O=class extends _{mapper;constructor(e,t){super(e),this.mapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;let t;try{t=this.mapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return s(t)}};function re(e){l(e);let t=new ie;for(let n of e)t.addLast(n);return t}var ie=class{internalSize=0;head=null;tail=null;[Symbol.iterator](){return new ae(this.head)}addFirst(e){let t={data:e,nextNode:this.head};return this.tail===null&&(this.tail=t),this.head=t,this.internalSize++,this}addLast(e){let t={data:e,nextNode:null};return this.tail===null?this.head=t:this.tail.nextNode=t,this.tail=t,this.internalSize++,this}size(){return this.internalSize}},ae=class extends h{current;constructor(e){super(),this.current=e}advance(){let e=this.current;return e===null?c():(this.current=e.nextNode,s(e.data))}};function k(e){return l(e),e instanceof A?e:new A(e)}var A=class{source;constructor(e){this.source=re(e)}[Symbol.iterator](){return this.source[Symbol.iterator]()}};function j(e,t){return l(e),o(e,a(t),1)}function M(){return{allowPartialMemoization:!0}}function N(e,t){l(e);let n={...M(),...t}.allowPartialMemoization;return e instanceof I?n?e.changePartialMemoizationBehaviour():e:e instanceof L?n?e:e.changePartialMemoizationBehaviour():n?new L(e):new I(e)}function P(){return{values:[],finished:!1}}function F(e,t){if(t.error)throw t.error.value;if(t.finished)return!1;t.source??=e[Symbol.iterator]();let n;try{n=t.source.next()}catch(e){throw t.error={value:e},t.source=void 0,e}return n.done===!0?(t.finished=!0,t.source=void 0,!1):(t.values.push(n.value),!0)}var I=class{source;cache=P();constructor(e){this.source=e}[Symbol.iterator](){return new R(this.source,this.cache,!0)}changePartialMemoizationBehaviour(){return new L(this.source)}},L=class{source;cache=P();constructor(e){this.source=e}[Symbol.iterator](){return new R(this.source,this.cache,!1)}changePartialMemoizationBehaviour(){return new I(this.source)}},R=class extends h{source;cache;drainFirst;index=0;constructor(e,t,n){super(),this.source=e,this.cache=t,this.drainFirst=n}advance(){if(this.drainFirst)for(;F(this.source,this.cache););return this.index<this.cache.values.length||F(this.source,this.cache)?s(this.cache.values[this.index++]):c()}};function z(e,t){return l(e),o(e,a(t),-1)}function B(e,t,n){let r=typeof t==`number`,i=r?e:0,a=r?t:e;if(!r&&n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);let o=r?n:t;o!==void 0&&p(o,`options`);let{step:s=1,reverse:c=!1}=o??{};f(s,`step`);let l=oe(i,a,Math.abs(s),c);return l.length>0?new g(()=>new se(l.first,l.step,l.length)):y()}function oe(e,t,n,r){let i=t<e?-n:n,a=Math.ceil(Math.abs(t-e)/n);return r?{first:e+(a-1)*i,step:-i,length:a}:{first:e,step:i,length:a}}var se=class extends h{first;step;length;index=0;constructor(e,t,n){super(),this.first=e,this.step=t,this.length=n}advance(){return this.index>=this.length?c():s(this.first+this.index++*this.step)}};function V(e,t,n){l(e),u(n,`reducer`);let r=t,i=0;for(let t of e)r=n(r,t,i++);return r}function H(e,t){return d(t,`count`),v(t,t=>t>0?[e,t-1]:void 0)}function U(e,t){l(e),u(t,`predicate`);let n=0;for(let r of e)if(t(r,n++))return!0;return!1}function W(e,t){return l(e),u(t,`tapper`),new g(()=>new G(e,t))}var G=class extends _{tapper;constructor(e,t){super(e),this.tapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;try{this.tapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return e}};function K(e,t){return l(e),u(t,`tapper`),new g(()=>(t(e,0),e[Symbol.iterator]()))}var ce=n({collectToArray:()=>m,empty:()=>y,filter:()=>b,flatMap:()=>x,forEach:()=>T,forEachAsync:()=>E,getMemoizeDefaultOptions:()=>M,map:()=>D,materialize:()=>k,max:()=>j,memoize:()=>N,min:()=>z,range:()=>B,reduce:()=>V,repeat:()=>H,some:()=>U,tap:()=>W,tapChain:()=>K}),q=Symbol.for(`iterable-linq-utility.IIterableLinq`);function J(e){return new Y(e)}var Y=class{iterable;constructor(e){this.iterable=e}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return m(this.iterable)}filter(e){return J(b(this.iterable,e))}flatMap(e){return J(x(this.iterable,e))}forEach(e){return T(this.iterable,e)}forEachAsync(e){return E(this.iterable,e)}map(e){return J(D(this.iterable,e))}materialize(){return J(k(this.iterable))}max(e){return j(this.iterable,e)}memoize(e){return J(N(this.iterable,e))}min(e){return z(this.iterable,e)}reduce(e,t){return V(this.iterable,e,t)}some(e){return U(this.iterable,e)}tap(e){return J(W(this.iterable,e))}tapChain(e){return J(K(this.iterable,e))}tapChainCreation(e){u(e,`chainCreationTapper`);let t=this;return e(t),t}};Object.defineProperty(Y.prototype,q,{value:!0,enumerable:!1,writable:!1,configurable:!1});function X(){return Y.prototype}function le(e){return typeof e==`object`&&!!e&&e[q]===!0}function Z(e,t){let n=Object.getOwnPropertyDescriptor(X(),e);Object.defineProperty(X(),e,{value:t,enumerable:!1,writable:n?.writable??!1,configurable:!0})}function Q(e,t){ee(e,`name`),u(t,`implementation`)}function ue(e,t){if(Q(e,t),e in J([]))throw Error(`"${e}" already exists on IIterableLinq: use override() to replace it`);Z(e,t)}function de(e,t){Q(e,t);let n=e;if(!(n!==`constructor`&&Object.prototype.hasOwnProperty.call(X(),n)))throw Error(`"${n}" is not a method of IIterableLinq: use extend() to add it`);Z(n,t)}function fe(){return $(y())}function $(e){return l(e),J(e)}function pe(e,t,n){if(typeof t==`number`)return $(B(e,t,n));if(n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);return $(B(e,t))}function me(e,t){return $(H(e,t))}Object.defineProperty(e,"Functions",{enumerable:!0,get:function(){return ce}}),e.Unit=C,e.empty=fe,e.extend=ue,e.from=$,e.fromRange=pe,e.isIterableLinq=le,e.override=de,e.repeat=me,e.unit=w});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.IterableLinq={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r};function r(e){return typeof e==`function`}function i(e,t){return e<t?-1:e===t?0:1}function a(e){if(e==null)return i;if(r(e))return e;let t=Array.isArray(e)?e:[e];return(e,n)=>{for(let r of t){let t=i(e[r],n[r]);if(t!==0)return t}return 0}}function o(e,t,n){let r,i=!1;for(let a of e)!i||r==null&&a!=null?(r=a,i=!0):a!=null&&n*t(r,a)<0&&(r=a);return r}function s(e){return{done:!1,value:e}}function c(e){return{done:!0,value:e}}function l(e){if(e==null)throw Error(`The "sourceIterable" must be provided`);if(!r(e[Symbol.iterator]))throw Error(`The provided "sourceIterable" does not conform to the iterator protocol https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol. It must implement the "[Symbol.iterator]" function.`)}function u(e,t){if(!r(e))throw Error(`The "${t}" function must be provided`)}function d(e,t){if(!Number.isInteger(e)||e<0)throw Error(`The "${t}" parameter must be a non-negative integer`)}function ee(e,t){if(!Number.isFinite(e)||e===0)throw Error(`The "${t}" parameter must be a finite number other than 0`)}function te(e,t){if(typeof e!=`object`||!e)throw Error(`The "${t}" parameter must be an object`)}function ne(e,t){if(typeof e!=`string`||e.length===0)throw Error(`The "${t}" parameter must be a non-empty string`)}function f(e){if(l(e),Array.isArray(e)||e instanceof Set)return Array.from(e);let t=[];for(let n of e)t.push(n);return t}var p=class{done=!1;next(){if(this.done)return c();let e=this.advance();return e.done===!0&&(this.done=!0),e}return(e){return this.done||(this.done=!0,this.onReturn(e)),c(e)}[Symbol.iterator](){return this}onReturn(e){}closeAfterCallbackError(){if(!this.done){this.done=!0;try{this.onReturn()}catch{}}}},m=class{createIterator;constructor(e){this.createIterator=e}[Symbol.iterator](){return this.createIterator()}},h=class extends p{source;index=0;constructor(e){super(),this.source=e[Symbol.iterator]()}onReturn(e){this.source.return?.(e)}};function g(e,t){return new m(()=>new re(e,t))}var re=class extends p{state;step;constructor(e,t){super(),this.state=e,this.step=t}advance(){let e=this.step(this.state);return e===void 0?c():(this.state=e[1],s(e[0]))}};function _(){return g(void 0,()=>void 0)}function v(e,t){return l(e),u(t,`predicate`),new m(()=>new ie(e,t))}var ie=class extends h{predicate;constructor(e,t){super(e),this.predicate=t}advance(){for(let e=this.source.next();;e=this.source.next()){if(e.done===!0)return e;let t;try{t=this.predicate(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}if(t)return e}}};function y(e,t){return l(e),u(t,`mapper`),new m(()=>new ae(e,t))}var ae=class e extends h{mapper;static steps={outer:t=>{let n=t.source.next();if(n.done===!0)return n;let r=e.mapNext(t,n.value);if(r===void 0){t.state=`inner`;return}if(r.length!==0)return t.array=r,t.position=1,t.state=`array`,s(r[0])},inner:t=>{let n=e.nextInner(t);if(n.done!==!0)return n;t.inner=void 0,t.state=`outer`},array:e=>{if(e.position<e.array.length)return s(e.array[e.position++]);e.array=void 0,e.state=`outer`}};state=`outer`;inner;array;position=0;constructor(e,t){super(e),this.mapper=t}advance(){for(;;){let t=e.steps[this.state](this);if(t!==void 0)return t}}onReturn(e){this.array=void 0;try{this.inner?.return?.(e)}finally{super.onReturn(e)}}static mapNext(e,t){try{let n=e.mapper(t,e.index++);if(Array.isArray(n))return n;e.inner=n[Symbol.iterator]();return}catch(t){throw e.closeAfterCallbackError(),t}}static nextInner(e){try{return e.inner.next()}catch(t){throw e.inner=void 0,e.closeAfterCallbackError(),t}}},b=class e{static instance=e.createFrozen();constructor(){}static createFrozen(){let t=new e;return Object.freeze(t),t}};function x(){return b.instance}function S(e,t){l(e),u(t,`action`);let n=0;for(let r of e)t(r,n++);return x()}async function C(e,t){l(e),u(t,`action`);let n=0;for(let r of e)await t(r,n++);return x()}function w(e,t){return l(e),u(t,`mapper`),new m(()=>new T(e,t))}var T=class extends h{mapper;constructor(e,t){super(e),this.mapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;let t;try{t=this.mapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return s(t)}};function E(e){l(e);let t=new D;for(let n of e)t.addLast(n);return t}var D=class{internalSize=0;head=null;tail=null;[Symbol.iterator](){return new oe(this.head)}addFirst(e){let t={data:e,nextNode:this.head};return this.tail===null&&(this.tail=t),this.head=t,this.internalSize++,this}addLast(e){let t={data:e,nextNode:null};return this.tail===null?this.head=t:this.tail.nextNode=t,this.tail=t,this.internalSize++,this}size(){return this.internalSize}},oe=class extends p{current;constructor(e){super(),this.current=e}advance(){let e=this.current;return e===null?c():(this.current=e.nextNode,s(e.data))}};function O(e){return l(e),e instanceof k?e:new k(e)}var k=class{source;constructor(e){this.source=E(e)}[Symbol.iterator](){return this.source[Symbol.iterator]()}};function A(e,t){return l(e),o(e,a(t),1)}function j(){return{allowPartialMemoization:!0}}function M(e,t){l(e);let n={...j(),...t}.allowPartialMemoization;return e instanceof F?n?e.changePartialMemoizationBehaviour():e:e instanceof I?n?e:e.changePartialMemoizationBehaviour():n?new I(e):new F(e)}function N(){return{values:[],finished:!1}}function P(e,t){if(t.error)throw t.error.value;if(t.finished)return!1;t.source??=e[Symbol.iterator]();let n;try{n=t.source.next()}catch(e){throw t.error={value:e},t.source=void 0,e}return n.done===!0?(t.finished=!0,t.source=void 0,!1):(t.values.push(n.value),!0)}var F=class{source;cache=N();constructor(e){this.source=e}[Symbol.iterator](){return new L(this.source,this.cache,!0)}changePartialMemoizationBehaviour(){return new I(this.source)}},I=class{source;cache=N();constructor(e){this.source=e}[Symbol.iterator](){return new L(this.source,this.cache,!1)}changePartialMemoizationBehaviour(){return new F(this.source)}},L=class extends p{source;cache;drainFirst;index=0;constructor(e,t,n){super(),this.source=e,this.cache=t,this.drainFirst=n}advance(){if(this.drainFirst)for(;P(this.source,this.cache););return this.index<this.cache.values.length||P(this.source,this.cache)?s(this.cache.values[this.index++]):c()}};function R(e,t){return l(e),o(e,a(t),-1)}function z(e,t,n){let r=typeof t==`number`,i=r?e:0,a=r?t:e;if(!r&&n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);let o=r?n:t;o!==void 0&&te(o,`options`);let{step:s=1,reverse:c=!1}=o??{};ee(s,`step`);let l=se(i,a,Math.abs(s),c);return l.length>0?new m(()=>new B(l.first,l.step,l.length)):_()}function se(e,t,n,r){let i=t<e?-n:n,a=Math.ceil(Math.abs(t-e)/n);return r?{first:e+(a-1)*i,step:-i,length:a}:{first:e,step:i,length:a}}var B=class extends p{first;step;length;index=0;constructor(e,t,n){super(),this.first=e,this.step=t,this.length=n}advance(){return this.index>=this.length?c():s(this.first+this.index++*this.step)}};function V(e,...t){if(l(e),t.length===1)return H(e,t[0]);let[n,r]=t;u(r,`reducer`);let i=n,a=0;for(let t of e)i=r(i,t,a++);return i}function H(e,t){u(t,`reducer`);let n,r=0;for(let i of e)n=r===0?i:t(n,i,r),r++;if(r===0)throw Error(`The "sourceIterable" must not be empty when "reduce" has no seed`);return n}function U(e,t){return d(t,`count`),g(t,t=>t>0?[e,t-1]:void 0)}function W(e,t){l(e),u(t,`predicate`);let n=0;for(let r of e)if(t(r,n++))return!0;return!1}function G(e,t){return l(e),u(t,`tapper`),new m(()=>new ce(e,t))}var ce=class extends h{tapper;constructor(e,t){super(e),this.tapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;try{this.tapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return e}};function K(e,t){return l(e),u(t,`tapper`),new m(()=>(t(e,0),e[Symbol.iterator]()))}var le=n({collectToArray:()=>f,empty:()=>_,filter:()=>v,flatMap:()=>y,forEach:()=>S,forEachAsync:()=>C,getMemoizeDefaultOptions:()=>j,map:()=>w,materialize:()=>O,max:()=>A,memoize:()=>M,min:()=>R,range:()=>z,reduce:()=>V,repeat:()=>U,some:()=>W,tap:()=>G,tapChain:()=>K}),q=Symbol.for(`iterable-linq-utility.IIterableLinq`);function J(e){return new Y(e)}var Y=class{iterable;constructor(e){this.iterable=e}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return f(this.iterable)}filter(e){return J(v(this.iterable,e))}flatMap(e){return J(y(this.iterable,e))}forEach(e){return S(this.iterable,e)}forEachAsync(e){return C(this.iterable,e)}map(e){return J(w(this.iterable,e))}materialize(){return J(O(this.iterable))}max(e){return A(this.iterable,e)}memoize(e){return J(M(this.iterable,e))}min(e){return R(this.iterable,e)}reduce(...e){return e.length===1?V(this.iterable,e[0]):V(this.iterable,e[0],e[1])}some(e){return W(this.iterable,e)}tap(e){return J(G(this.iterable,e))}tapChain(e){return J(K(this.iterable,e))}tapChainCreation(e){u(e,`chainCreationTapper`);let t=this;return e(t),t}};Object.defineProperty(Y.prototype,q,{value:!0,enumerable:!1,writable:!1,configurable:!1});function X(){return Y.prototype}function ue(e){return typeof e==`object`&&!!e&&e[q]===!0}function Z(e,t){let n=Object.getOwnPropertyDescriptor(X(),e);Object.defineProperty(X(),e,{value:t,enumerable:!1,writable:n?.writable??!1,configurable:!0})}function Q(e,t){ne(e,`name`),u(t,`implementation`)}function de(e,t){if(Q(e,t),e in J([]))throw Error(`"${e}" already exists on IIterableLinq: use override() to replace it`);Z(e,t)}function fe(e,t){Q(e,t);let n=e;if(!(n!==`constructor`&&Object.prototype.hasOwnProperty.call(X(),n)))throw Error(`"${n}" is not a method of IIterableLinq: use extend() to add it`);Z(n,t)}function pe(){return $(_())}function $(e){return l(e),J(e)}function me(e,t,n){if(typeof t==`number`)return $(z(e,t,n));if(n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);return $(z(e,t))}function he(e,t){return $(U(e,t))}Object.defineProperty(e,"Functions",{enumerable:!0,get:function(){return le}}),e.Unit=b,e.empty=pe,e.extend=de,e.from=$,e.fromRange=me,e.isIterableLinq=ue,e.override=fe,e.repeat=he,e.unit=x});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iterable-linq-utility",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "An Iterable mutation utility inspired by .net Linq and Javascript Array interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/iterable-linq-utility.umd.cjs",
|
|
@@ -24,9 +24,14 @@
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc -p tsconfig.build.json && vite build && cp dist/index.d.ts dist/index.d.cts",
|
|
26
26
|
"check:package": "attw --pack .",
|
|
27
|
+
"check:changeset": "changeset status --since=origin/main",
|
|
28
|
+
"check:since": "node scripts/check-since.ts",
|
|
29
|
+
"check:instructions": "node scripts/check-instructions.ts",
|
|
30
|
+
"check:structure": "node scripts/check-structure.ts",
|
|
27
31
|
"dev": "vite",
|
|
28
32
|
"lint": "eslint .",
|
|
29
33
|
"lint-fix": "eslint . --fix",
|
|
34
|
+
"release:version": "changeset version && node scripts/set-since.ts",
|
|
30
35
|
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
31
36
|
"test": "vitest run",
|
|
32
37
|
"bench": "vite build --logLevel error && vitest bench --run",
|
|
@@ -51,6 +56,8 @@
|
|
|
51
56
|
],
|
|
52
57
|
"devDependencies": {
|
|
53
58
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
59
|
+
"@changesets/changelog-github": "^1.0.1",
|
|
60
|
+
"@changesets/cli": "^3.0.3",
|
|
54
61
|
"@eslint/js": "^10.0.1",
|
|
55
62
|
"@microsoft/api-extractor": "^7.59.2",
|
|
56
63
|
"@stylistic/eslint-plugin": "^5.10.0",
|