@develia/commons 0.4.25 → 0.5.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/array.d.ts +10 -0
- package/dist/array.d.ts.map +1 -1
- package/dist/array.js +18 -0
- package/dist/array.js.map +1 -1
- package/dist/async-pool-executor.d.ts +3 -5
- package/dist/async-pool-executor.d.ts.map +1 -1
- package/dist/async-pool-executor.js +9 -9
- package/dist/async-pool-executor.js.map +1 -1
- package/dist/browser/form-utilities.d.ts +0 -2
- package/dist/browser/form-utilities.d.ts.map +1 -1
- package/dist/browser/form-utilities.js +3 -23
- package/dist/browser/form-utilities.js.map +1 -1
- package/dist/browser/geo-location.js +3 -3
- package/dist/browser/geo-location.js.map +1 -1
- package/dist/browser/native-bridge.d.ts +1 -1
- package/dist/browser/native-bridge.d.ts.map +1 -1
- package/dist/browser/native-bridge.js +2 -2
- package/dist/browser/native-bridge.js.map +1 -1
- package/dist/cancellable-promise.d.ts +8 -2
- package/dist/cancellable-promise.d.ts.map +1 -1
- package/dist/cancellable-promise.js +9 -3
- package/dist/cancellable-promise.js.map +1 -1
- package/dist/clean-url-search-params.js +3 -3
- package/dist/clean-url-search-params.js.map +1 -1
- package/dist/collections/from.d.ts +31 -11
- package/dist/collections/from.d.ts.map +1 -1
- package/dist/collections/from.js +73 -48
- package/dist/collections/from.js.map +1 -1
- package/dist/draft.d.ts +2 -2
- package/dist/draft.d.ts.map +1 -1
- package/dist/draft.js +2 -2
- package/dist/draft.js.map +1 -1
- package/dist/functions.d.ts +2 -2
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +1 -1
- package/dist/functions.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/math.d.ts +14 -5
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +16 -5
- package/dist/math.js.map +1 -1
- package/dist/string.d.ts +5 -0
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +8 -3
- package/dist/string.js.map +1 -1
- package/dist/timespan.d.ts +5 -5
- package/dist/timespan.d.ts.map +1 -1
- package/dist/timespan.js +5 -5
- package/dist/timespan.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities.d.ts +11 -9
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +23 -23
- package/dist/utilities.js.map +1 -1
- package/dist/uuid.d.ts +73 -0
- package/dist/uuid.d.ts.map +1 -0
- package/dist/uuid.js +129 -0
- package/dist/uuid.js.map +1 -0
- package/package.json +5 -1
- package/src/array.ts +19 -0
- package/src/async-pool-executor.ts +9 -9
- package/src/browser/form-utilities.ts +3 -32
- package/src/browser/geo-location.ts +3 -3
- package/src/browser/native-bridge.ts +2 -2
- package/src/cancellable-promise.ts +9 -3
- package/src/clean-url-search-params.ts +3 -3
- package/src/collections/from.ts +91 -49
- package/src/draft.ts +3 -3
- package/src/functions.ts +3 -3
- package/src/index.ts +2 -1
- package/src/math.ts +17 -5
- package/src/string.ts +9 -3
- package/src/timespan.ts +5 -5
- package/src/types.ts +0 -1
- package/src/utilities.ts +27 -29
- package/src/uuid.ts +153 -0
|
@@ -2,13 +2,21 @@ import type { Consumer, EqualityComparer, UnaryFunction, Predicate, Supplier } f
|
|
|
2
2
|
import KeyValuePair from "../key-value-pair.js";
|
|
3
3
|
import Order from "../order.js";
|
|
4
4
|
/**
|
|
5
|
-
* Creates a new From instance from an Iterable
|
|
5
|
+
* Creates a new From instance from an Iterable, a Supplier of an Iterable, or the entries of a plain object.
|
|
6
6
|
* @template T - The type of elements in the source.
|
|
7
7
|
* @param {Iterable<T> | Supplier<Iterable<T>>} source - The source data.
|
|
8
|
-
* @returns {From<T>
|
|
8
|
+
* @returns {From<T>} A new From instance.
|
|
9
9
|
* @throws {Error} If source is null or invalid.
|
|
10
10
|
*/
|
|
11
|
-
export default function from<T>(source: Iterable<T> | Supplier<Iterable<T>>): From<T
|
|
11
|
+
export default function from<T>(source: Iterable<T> | Supplier<Iterable<T>>): From<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new From instance from the enumerable own and inherited properties of a plain object.
|
|
14
|
+
* @template TValue - The type of the property values.
|
|
15
|
+
* @param {Record<string, TValue>} source - The source object.
|
|
16
|
+
* @returns {From<KeyValuePair<string, TValue>>} A From instance of key-value pairs.
|
|
17
|
+
* @throws {Error} If source is null or invalid.
|
|
18
|
+
*/
|
|
19
|
+
export default function from<TValue>(source: Record<string, TValue>): From<KeyValuePair<string, TValue>>;
|
|
12
20
|
/**
|
|
13
21
|
* A LINQ-like wrapper for iterables that provides various transformation and query methods.
|
|
14
22
|
* @template T - The type of elements in the sequence.
|
|
@@ -16,10 +24,11 @@ export default function from<T>(source: Iterable<T> | Supplier<Iterable<T>>): Fr
|
|
|
16
24
|
export declare class From<T> implements Iterable<T> {
|
|
17
25
|
/**
|
|
18
26
|
* Creates a From instance from an object's entries.
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
27
|
+
* @template TValue - The type of the property values.
|
|
28
|
+
* @param {Record<string, TValue>} obj - The object to convert to pairs.
|
|
29
|
+
* @returns {From<KeyValuePair<string, TValue>>} A From instance of key-value pairs.
|
|
21
30
|
*/
|
|
22
|
-
static object(obj:
|
|
31
|
+
static object<TValue>(obj: Record<string, TValue>): From<KeyValuePair<string, TValue>>;
|
|
23
32
|
private readonly _fn;
|
|
24
33
|
protected constructor(fn: Supplier<Iterable<T>>);
|
|
25
34
|
/**
|
|
@@ -258,13 +267,22 @@ export declare class From<T> implements Iterable<T> {
|
|
|
258
267
|
*/
|
|
259
268
|
skip(n: number): From<T>;
|
|
260
269
|
/**
|
|
261
|
-
*
|
|
270
|
+
* The elements of this sequence followed by those of the other, duplicates included, as LINQ's Concat.
|
|
271
|
+
* @param {Iterable<T>} other - The other sequence.
|
|
272
|
+
* @returns {From<T>} A new From instance.
|
|
273
|
+
*/
|
|
274
|
+
concat(other: Iterable<T>): From<T>;
|
|
275
|
+
/**
|
|
276
|
+
* The set union, as LINQ's Union: the elements of this sequence and then those of the other, each one once (the
|
|
277
|
+
* first time it appears), compared as distinct() does.
|
|
262
278
|
* @param {Iterable<T>} other - The other sequence.
|
|
279
|
+
* @param {EqualityComparer<T>} [equalityComparer] - Optional equality comparer; shallowEqual when not given.
|
|
263
280
|
* @returns {From<T>} A new From instance.
|
|
264
281
|
*/
|
|
265
|
-
union(other: Iterable<T>): From<T>;
|
|
282
|
+
union(other: Iterable<T>, equalityComparer?: EqualityComparer<T>): From<T>;
|
|
266
283
|
/**
|
|
267
|
-
* Correlates the elements of two sequences based on matching keys
|
|
284
|
+
* Correlates the elements of two sequences based on matching keys: one result per matching pair, so an element
|
|
285
|
+
* that matches several elements of the other sequence gives one result for each.
|
|
268
286
|
* @template T2, R, R2
|
|
269
287
|
* @param {Iterable<T2>} other - The other sequence.
|
|
270
288
|
* @param {UnaryFunction<T, R>} thisKeySelector - Key selector for this sequence.
|
|
@@ -274,7 +292,8 @@ export declare class From<T> implements Iterable<T> {
|
|
|
274
292
|
*/
|
|
275
293
|
innerJoin<T2, R, R2>(other: Iterable<T2>, thisKeySelector: UnaryFunction<T, R>, otherKeySelector: UnaryFunction<T2, R>, resultSelector: (thisItem: T, otherItem: T2) => R2): From<R2>;
|
|
276
294
|
/**
|
|
277
|
-
* Performs a left join on two sequences
|
|
295
|
+
* Performs a left join on two sequences: one result per matching pair, and one with `undefined` for each element of
|
|
296
|
+
* this sequence that matches none.
|
|
278
297
|
* @template U, K, R
|
|
279
298
|
* @param {Iterable<U>} other - The other sequence.
|
|
280
299
|
* @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.
|
|
@@ -304,7 +323,8 @@ export declare class From<T> implements Iterable<T> {
|
|
|
304
323
|
*/
|
|
305
324
|
rightGroupJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItems: Array<T>, otherItem: U) => R): From<R>;
|
|
306
325
|
/**
|
|
307
|
-
* Performs a right join on two sequences
|
|
326
|
+
* Performs a right join on two sequences: one result per matching pair, and one with `undefined` for each element of
|
|
327
|
+
* the other sequence that matches none.
|
|
308
328
|
* @template U, K, R
|
|
309
329
|
* @param {Iterable<U>} other - The other sequence.
|
|
310
330
|
* @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../src/collections/from.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAEhG,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,MAAM,aAAa,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../src/collections/from.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAEhG,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,MAAM,aAAa,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CA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AAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;CAoBpM;AAiBD;;;GAGG;AACH,qBAAa,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAE,SAAQ,IAAI,CAAC,CAAC,CAAC;IAE1C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAE5B;;OAEG;IACH,IAAW,GAAG,IAAI,IAAI,CAErB;IAED;;;OAGG;gBACgB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;CAIjD"}
|
package/dist/collections/from.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { shallowEqual, toPairs } from "../utilities.js";
|
|
2
2
|
import Order from "../order.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a new From instance from an Iterable or a Supplier of an Iterable.
|
|
5
|
-
* @template T - The type of elements in the source.
|
|
6
|
-
* @param {Iterable<T> | Supplier<Iterable<T>>} source - The source data.
|
|
7
|
-
* @returns {From<T> | From<KeyValuePair<any, any>>} A new From instance.
|
|
8
|
-
* @throws {Error} If source is null or invalid.
|
|
9
|
-
*/
|
|
10
3
|
export default function from(source) {
|
|
11
4
|
if (source == null)
|
|
12
5
|
throw new Error("Source is null.");
|
|
13
6
|
if (typeof source === 'function')
|
|
14
7
|
return From.fn(source);
|
|
15
|
-
if (typeof source[Symbol.iterator] === 'function') {
|
|
8
|
+
if (Symbol.iterator in source && typeof source[Symbol.iterator] === 'function') {
|
|
16
9
|
return From.iterable(source);
|
|
17
10
|
}
|
|
18
11
|
else if (typeof source === 'object') {
|
|
@@ -27,8 +20,9 @@ export default function from(source) {
|
|
|
27
20
|
export class From {
|
|
28
21
|
/**
|
|
29
22
|
* Creates a From instance from an object's entries.
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
23
|
+
* @template TValue - The type of the property values.
|
|
24
|
+
* @param {Record<string, TValue>} obj - The object to convert to pairs.
|
|
25
|
+
* @returns {From<KeyValuePair<string, TValue>>} A From instance of key-value pairs.
|
|
32
26
|
*/
|
|
33
27
|
static object(obj) {
|
|
34
28
|
return new From(function () {
|
|
@@ -427,7 +421,7 @@ export class From {
|
|
|
427
421
|
array.sort((a, b) => {
|
|
428
422
|
const aValue = mapper(a);
|
|
429
423
|
const bValue = mapper(b);
|
|
430
|
-
return aValue > bValue ? 1 :
|
|
424
|
+
return aValue > bValue ? -1 : aValue < bValue ? 1 : 0;
|
|
431
425
|
});
|
|
432
426
|
}
|
|
433
427
|
else {
|
|
@@ -629,11 +623,11 @@ export class From {
|
|
|
629
623
|
});
|
|
630
624
|
}
|
|
631
625
|
/**
|
|
632
|
-
*
|
|
626
|
+
* The elements of this sequence followed by those of the other, duplicates included, as LINQ's Concat.
|
|
633
627
|
* @param {Iterable<T>} other - The other sequence.
|
|
634
628
|
* @returns {From<T>} A new From instance.
|
|
635
629
|
*/
|
|
636
|
-
|
|
630
|
+
concat(other) {
|
|
637
631
|
const self = this;
|
|
638
632
|
return From.fn(function* () {
|
|
639
633
|
yield* self;
|
|
@@ -641,7 +635,18 @@ export class From {
|
|
|
641
635
|
});
|
|
642
636
|
}
|
|
643
637
|
/**
|
|
644
|
-
*
|
|
638
|
+
* The set union, as LINQ's Union: the elements of this sequence and then those of the other, each one once (the
|
|
639
|
+
* first time it appears), compared as distinct() does.
|
|
640
|
+
* @param {Iterable<T>} other - The other sequence.
|
|
641
|
+
* @param {EqualityComparer<T>} [equalityComparer] - Optional equality comparer; shallowEqual when not given.
|
|
642
|
+
* @returns {From<T>} A new From instance.
|
|
643
|
+
*/
|
|
644
|
+
union(other, equalityComparer) {
|
|
645
|
+
return this.concat(other).distinct(equalityComparer);
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Correlates the elements of two sequences based on matching keys: one result per matching pair, so an element
|
|
649
|
+
* that matches several elements of the other sequence gives one result for each.
|
|
645
650
|
* @template T2, R, R2
|
|
646
651
|
* @param {Iterable<T2>} other - The other sequence.
|
|
647
652
|
* @param {UnaryFunction<T, R>} thisKeySelector - Key selector for this sequence.
|
|
@@ -652,17 +657,19 @@ export class From {
|
|
|
652
657
|
innerJoin(other, thisKeySelector, otherKeySelector, resultSelector) {
|
|
653
658
|
const self = this;
|
|
654
659
|
return From.fn(() => {
|
|
655
|
-
const otherByKey =
|
|
656
|
-
|
|
657
|
-
|
|
660
|
+
const otherByKey = groupItemsByKey(other, otherKeySelector);
|
|
661
|
+
const results = [];
|
|
662
|
+
for (const item of self) {
|
|
663
|
+
for (const otherItem of otherByKey.get(thisKeySelector(item)) ?? []) {
|
|
664
|
+
results.push(resultSelector(item, otherItem));
|
|
665
|
+
}
|
|
658
666
|
}
|
|
659
|
-
return
|
|
660
|
-
.filter(item => otherByKey.has(thisKeySelector(item)))
|
|
661
|
-
.map(item => resultSelector(item, otherByKey.get(thisKeySelector(item))));
|
|
667
|
+
return results;
|
|
662
668
|
});
|
|
663
669
|
}
|
|
664
670
|
/**
|
|
665
|
-
* Performs a left join on two sequences
|
|
671
|
+
* Performs a left join on two sequences: one result per matching pair, and one with `undefined` for each element of
|
|
672
|
+
* this sequence that matches none.
|
|
666
673
|
* @template U, K, R
|
|
667
674
|
* @param {Iterable<U>} other - The other sequence.
|
|
668
675
|
* @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.
|
|
@@ -673,11 +680,19 @@ export class From {
|
|
|
673
680
|
leftJoin(other, thisKeySelector, otherKeySelector, resultSelector) {
|
|
674
681
|
const self = this;
|
|
675
682
|
return From.fn(() => {
|
|
676
|
-
const otherByKey =
|
|
677
|
-
|
|
678
|
-
|
|
683
|
+
const otherByKey = groupItemsByKey(other, otherKeySelector);
|
|
684
|
+
const results = [];
|
|
685
|
+
for (const item of self) {
|
|
686
|
+
const matches = otherByKey.get(thisKeySelector(item));
|
|
687
|
+
if (matches === undefined) {
|
|
688
|
+
results.push(resultSelector(item, undefined));
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
for (const otherItem of matches) {
|
|
692
|
+
results.push(resultSelector(item, otherItem));
|
|
693
|
+
}
|
|
679
694
|
}
|
|
680
|
-
return
|
|
695
|
+
return results;
|
|
681
696
|
});
|
|
682
697
|
}
|
|
683
698
|
/**
|
|
@@ -692,15 +707,8 @@ export class From {
|
|
|
692
707
|
leftGroupJoin(other, thisKeySelector, otherKeySelector, resultSelector) {
|
|
693
708
|
const self = this;
|
|
694
709
|
return From.fn(() => {
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
const key = otherKeySelector(item);
|
|
698
|
-
if (!otherByKeys.has(key)) {
|
|
699
|
-
otherByKeys.set(key, []);
|
|
700
|
-
}
|
|
701
|
-
otherByKeys.get(key).push(item);
|
|
702
|
-
}
|
|
703
|
-
return Array.from(self).map(item => resultSelector(item, otherByKeys.get(thisKeySelector(item)) || []));
|
|
710
|
+
const otherByKey = groupItemsByKey(other, otherKeySelector);
|
|
711
|
+
return Array.from(self).map(item => resultSelector(item, otherByKey.get(thisKeySelector(item)) ?? []));
|
|
704
712
|
});
|
|
705
713
|
}
|
|
706
714
|
/**
|
|
@@ -715,19 +723,13 @@ export class From {
|
|
|
715
723
|
rightGroupJoin(other, thisKeySelector, otherKeySelector, resultSelector) {
|
|
716
724
|
const self = this;
|
|
717
725
|
return From.fn(() => {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
const key = thisKeySelector(item);
|
|
721
|
-
if (!thisByKeys.has(key)) {
|
|
722
|
-
thisByKeys.set(key, []);
|
|
723
|
-
}
|
|
724
|
-
thisByKeys.get(key).push(item);
|
|
725
|
-
}
|
|
726
|
-
return Array.from(other).map(item => resultSelector(thisByKeys.get(otherKeySelector(item)) || [], item));
|
|
726
|
+
const thisByKey = groupItemsByKey(self, thisKeySelector);
|
|
727
|
+
return Array.from(other).map(item => resultSelector(thisByKey.get(otherKeySelector(item)) ?? [], item));
|
|
727
728
|
});
|
|
728
729
|
}
|
|
729
730
|
/**
|
|
730
|
-
* Performs a right join on two sequences
|
|
731
|
+
* Performs a right join on two sequences: one result per matching pair, and one with `undefined` for each element of
|
|
732
|
+
* the other sequence that matches none.
|
|
731
733
|
* @template U, K, R
|
|
732
734
|
* @param {Iterable<U>} other - The other sequence.
|
|
733
735
|
* @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.
|
|
@@ -738,14 +740,37 @@ export class From {
|
|
|
738
740
|
rightJoin(other, thisKeySelector, otherKeySelector, resultSelector) {
|
|
739
741
|
const self = this;
|
|
740
742
|
return From.fn(() => {
|
|
741
|
-
const thisByKey =
|
|
742
|
-
|
|
743
|
-
|
|
743
|
+
const thisByKey = groupItemsByKey(self, thisKeySelector);
|
|
744
|
+
const results = [];
|
|
745
|
+
for (const otherItem of other) {
|
|
746
|
+
const matches = thisByKey.get(otherKeySelector(otherItem));
|
|
747
|
+
if (matches === undefined) {
|
|
748
|
+
results.push(resultSelector(undefined, otherItem));
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
for (const item of matches) {
|
|
752
|
+
results.push(resultSelector(item, otherItem));
|
|
753
|
+
}
|
|
744
754
|
}
|
|
745
|
-
return
|
|
755
|
+
return results;
|
|
746
756
|
});
|
|
747
757
|
}
|
|
748
758
|
}
|
|
759
|
+
/** The items of a sequence in lists by their key, in their order, for the joins. */
|
|
760
|
+
function groupItemsByKey(items, keySelector) {
|
|
761
|
+
const itemsByKey = new Map();
|
|
762
|
+
for (const item of items) {
|
|
763
|
+
const key = keySelector(item);
|
|
764
|
+
const group = itemsByKey.get(key);
|
|
765
|
+
if (group === undefined) {
|
|
766
|
+
itemsByKey.set(key, [item]);
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
group.push(item);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
return itemsByKey;
|
|
773
|
+
}
|
|
749
774
|
/**
|
|
750
775
|
* Represents a group of elements that have a common key.
|
|
751
776
|
* @template TKey, T
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from.js","sourceRoot":"","sources":["../../src/collections/from.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,MAAM,aAAa,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAI,MAA2C;IACvE,IAAI,MAAM,IAAI,IAAI;QACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,IAAI,OAAO,MAAM,KAAK,UAAU;QAC5B,OAAO,IAAI,CAAC,EAAE,CAAI,MAAM,CAAC,CAAC;IAC9B,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,QAAQ,CAAI,MAAM,CAAC,CAAC;IACpC,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,IAAI;IAEb;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,GAAQ;QACzB,OAAO,IAAI,IAAI,CAAyB;YACpC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC;IAKD,YAAsB,EAAyB;QAC3C,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,EAAE,CAAI,QAA+B;QAC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G,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QAC7G,CAAC,CAAC,CAAC;IACP,CAAC;IAGD;;;;;;;;OAQG;IACI,SAAS,CAAU,KAAkB,EAAE,eAAoC,EAAE,gBAAqC,EAAE,cAA4D;QAEnL,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,OAAO,IAAI,CAAC,EAAE,CAAI,GAAG,EAAE;YACnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAQ,CAAC;YAClC,KAAK,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;gBACpB,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QACtG,CAAC,CAAC,CAAC;IACP,CAAC;CAEJ;AAED;;;GAGG;AACH,MAAM,OAAO,QAAkB,SAAQ,IAAO;IAI1C;;OAEG;IACH,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,YAAmB,GAAS,EAAE,MAAgB;QAC1C,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {Consumer, EqualityComparer, UnaryFunction, Predicate, Supplier} from \"../types.js\";\nimport {shallowEqual, toPairs} from \"../utilities.js\";\nimport KeyValuePair from \"../key-value-pair.js\";\nimport Order from \"../order.js\";\n\n\n/**\n * Creates a new From instance from an Iterable or a Supplier of an Iterable.\n * @template T - The type of elements in the source.\n * @param {Iterable<T> | Supplier<Iterable<T>>} source - The source data.\n * @returns {From<T> | From<KeyValuePair<any, any>>} A new From instance.\n * @throws {Error} If source is null or invalid.\n */\nexport default function from<T>(source: Iterable<T> | Supplier<Iterable<T>>): From<T> | From<KeyValuePair<any, any>> {\n if (source == null)\n throw new Error(\"Source is null.\");\n if (typeof source === 'function')\n return From.fn<T>(source);\n if (typeof source[Symbol.iterator] === 'function') {\n return From.iterable<T>(source);\n } else if (typeof source === 'object') {\n return From.object(source);\n }\n\n throw new Error(\"Invalid source.\");\n}\n\n/**\n * A LINQ-like wrapper for iterables that provides various transformation and query methods.\n * @template T - The type of elements in the sequence.\n */\nexport class From<T> implements Iterable<T> {\n\n /**\n * Creates a From instance from an object's entries.\n * @param {any} obj - The object to convert to pairs.\n * @returns {From<KeyValuePair<any, any>>} A From instance of key-value pairs.\n */\n public static object(obj: any): From<KeyValuePair<any, any>> {\n return new From<KeyValuePair<any, any>>(function () {\n return toPairs(obj);\n });\n }\n\n\n private readonly _fn: Supplier<Iterable<T>>\n\n protected constructor(fn: Supplier<Iterable<T>>) {\n this._fn = fn;\n }\n\n /**\n * Creates a From instance from a supplier function.\n * @template T\n * @param {Supplier<Iterable<T>>} callable - A function that returns an Iterable.\n * @returns {From<T>} A new From instance.\n */\n public static fn<T>(callable: Supplier<Iterable<T>>): From<T> {\n return new From<T>(callable);\n }\n\n /**\n * Collects all elements into an array and returns a new From instance from it.\n * Useful for freezing the sequence and preventing multiple iterations over a generator.\n * @returns {From<T>} A new From instance with cached data.\n */\n public collect(): From<T> {\n const cache = Array.from(this);\n return From.iterable(cache);\n }\n\n /**\n * Creates a From instance from an Iterable.\n * @template T\n * @param {Iterable<T>} iterable - The source iterable.\n * @returns {From<T>} A new From instance.\n */\n public static iterable<T>(iterable: Iterable<T>): From<T> {\n return From.fn<T>(function* () {\n for (const item of iterable) {\n yield item;\n }\n });\n }\n\n /**\n * Maps each element of the sequence into a new form.\n * @template R\n * @param {UnaryFunction<T, R>} mapper - A transformation function.\n * @returns {From<R>} A new From instance with the mapped elements.\n */\n public map<R>(mapper: UnaryFunction<T, R>): From<R> {\n const self = this;\n return From.fn<R>(function* () {\n for (let item of self) {\n yield mapper(item);\n }\n });\n }\n\n * [Symbol.iterator](): Iterator<T> {\n yield* this._fn();\n }\n\n\n /**\n * Checks if all elements in the sequence satisfy the given predicate.\n * @param {Predicate<T>} predicate - A function to test each element.\n * @returns {boolean} True if all elements satisfy the predicate.\n */\n public all(predicate: Predicate<T>): boolean {\n for (let item of this._fn()) {\n if (!predicate(item)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Checks if any element in the sequence satisfies the given predicate.\n * If no predicate is provided, checks if the sequence is not empty.\n * @param {Predicate<T>} [predicate] - A function to test each element.\n * @returns {boolean} True if any element satisfies the predicate.\n */\n public any(predicate?: Predicate<T>): boolean {\n for (let item of this) {\n if (predicate == null || predicate(item)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Gets the number of elements in the sequence.\n * @returns {number} The count of elements.\n */\n public get length(): number {\n return this.count();\n }\n\n /**\n * Counts the number of elements that satisfy the given predicate.\n * If no predicate is provided, counts all elements.\n * @param {Predicate<T>} [predicate] - A function to test each element.\n * @returns {number} The count of elements.\n */\n public count(predicate?: Predicate<T>): number {\n\n let output = 0;\n\n for (let item of this) {\n if (predicate == null || predicate(item)) {\n output++;\n }\n }\n\n return output;\n }\n\n /**\n * Filters the sequence based on a predicate.\n * @param {Predicate<T>} predicate - A function to test each element.\n * @returns {From<T>} A new From instance with the filtered elements.\n */\n public filter(predicate: Predicate<T>): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n for (let item of self) {\n if (predicate(item)) {\n yield item;\n }\n }\n });\n }\n\n /**\n * Checks if the sequence contains a specific value.\n * @param {T} value - The value to search for.\n * @returns {boolean} True if the value is found.\n */\n public contains(value: T): boolean {\n for (let item of this) {\n if (item === value) {\n return true;\n }\n }\n return false;\n }\n\n\n /**\n * Returns the first element of the sequence that satisfies a condition.\n * @param {Predicate<T>} [predicate] - Optional condition.\n * @returns {T | undefined} The first element or undefined.\n */\n public first(predicate?: Predicate<T>): T | undefined {\n\n if (predicate) {\n for (let item of this) {\n if (predicate(item)) {\n return item;\n }\n }\n } else {\n // noinspection LoopStatementThatDoesntLoopJS\n for (let item of this) {\n return item;\n }\n }\n\n return undefined;\n }\n\n /**\n * Returns the only element of the sequence that satisfies a condition, or throws if more than one exists.\n * @param {Predicate<T>} [predicate] - Optional condition.\n * @returns {T | null} The single element or null if not found.\n * @throws {Error} If more than one element is found.\n */\n public single(predicate?: Predicate<T>): T | null {\n\n let found = false;\n let output: T | null = null;\n\n if (predicate) {\n for (let item of this) {\n if (predicate(item)) {\n if (found) {\n throw new Error(\"Sequence contains more than one element.\");\n }\n found = true;\n output = item;\n }\n }\n } else {\n // noinspection LoopStatementThatDoesntLoopJS\n for (let item of this) {\n if (found) {\n throw new Error(\"Sequence contains more than one element.\");\n }\n found = true;\n output = item;\n }\n }\n\n return output;\n }\n\n /**\n * Appends an item to the end of the sequence.\n * @param {T} item - The item to append.\n * @returns {From<T>} A new From instance.\n */\n public append(item: T): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n for (let element of self) {\n yield element;\n }\n yield item;\n });\n }\n\n /**\n * Prepends an item to the beginning of the sequence.\n * @param {T} item - The item to prepend.\n * @returns {From<T>} A new From instance.\n */\n public prepend(item: T): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n yield item;\n for (let element of self) {\n yield element;\n }\n });\n }\n\n /**\n * Gets the element at a specific index.\n * @param {number} index - The zero-based index.\n * @returns {T | undefined} The element at the index or undefined.\n */\n public at(index: number): T | undefined {\n let idx = 0;\n for (let item of this) {\n if (idx++ === index) {\n return item;\n }\n }\n return undefined;\n }\n\n /**\n * Returns the last element of the sequence that satisfies a condition.\n * @param {Predicate<T>} [predicate] - Optional condition.\n * @returns {T | undefined} The last element or undefined.\n */\n public last(predicate?: Predicate<T>): T | undefined {\n\n\n let last: T | undefined = undefined;\n\n if (predicate)\n for (let item of this) {\n if (!predicate || predicate(item)) {\n last = item;\n }\n }\n else {\n for (let item of this) {\n last = item;\n }\n }\n return last;\n }\n\n /**\n * Projects each element of a sequence to an Iterable and flattens the resulting sequences into one sequence.\n * @template R\n * @param {UnaryFunction<T, Iterable<R>>} mapper - A transformation function.\n * @returns {From<R>} A new From instance.\n */\n public mapMany<R>(mapper: UnaryFunction<T, Iterable<R>>): From<R> {\n const self = this;\n return From.fn(function* () {\n for (const item of self) {\n const subitems = mapper(item)\n for (const subitem of subitems) {\n yield subitem;\n }\n }\n })\n }\n\n /**\n * Flattens a sequence of iterables.\n * @returns {From<any>} A new From instance.\n */\n public flatten(): From<any> {\n const self = this;\n return From.fn<T>(function* () {\n for (let item of self) {\n let temp = <Iterable<any>>item;\n for (let subitem of temp) {\n yield subitem\n }\n }\n });\n }\n\n /**\n * Calculates the sum of the elements in the sequence.\n * @param {UnaryFunction<T, number>} [mapper] - Optional projection function.\n * @returns {number} The sum.\n */\n public sum(mapper?: UnaryFunction<T, number>): number {\n let total = 0;\n\n if (mapper)\n for (let item of this) {\n total += mapper(item);\n }\n else\n for (let item of this) {\n total += item as number;\n }\n return total;\n }\n\n /**\n * Calculates the average of the elements in the sequence.\n * @param {UnaryFunction<T, number>} [mapper] - Optional projection function.\n * @returns {number} The average.\n */\n public avg(mapper?: UnaryFunction<T, number>): number {\n let total = 0;\n let count = 0;\n\n if (mapper)\n for (let item of this) {\n total += mapper(item);\n count++;\n }\n else\n for (let item of this) {\n total += item as number;\n count++;\n }\n return count > 0 ? total / count : 0;\n }\n\n /**\n * Returns the maximum value in the sequence.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {number} The maximum value.\n */\n public max(mapper: UnaryFunction<T, number>): number {\n let max = -Infinity;\n for (let item of this) {\n let value = mapper(item);\n max = value > max ? value : max;\n }\n return max;\n }\n\n /**\n * Returns the minimum value in the sequence.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {number} The minimum value.\n */\n public min(mapper: UnaryFunction<T, number>): number {\n let min = Infinity;\n for (let item of this) {\n let value = mapper(item);\n min = value < min ? value : min;\n }\n return min;\n }\n\n /**\n * Returns the element with the maximum value.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {T | undefined} The element with the maximum value.\n */\n public maxBy(mapper: UnaryFunction<T, number>): T | undefined {\n let max = -Infinity;\n let maxItem: T | undefined;\n for (let item of this) {\n let value = mapper(item);\n if (value > max) {\n max = value;\n maxItem = item;\n }\n }\n return maxItem;\n }\n\n /**\n * Returns the element with the minimum value.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {T | undefined} The element with the minimum value.\n */\n public minBy(mapper: UnaryFunction<T, number>): T | undefined {\n let min = Infinity;\n let minItem: T | undefined;\n for (let item of this) {\n let value = mapper(item);\n if (value < min) {\n min = value;\n minItem = item;\n }\n }\n return minItem;\n }\n\n /**\n * Sorts the elements of the sequence.\n * @template R\n * @param {UnaryFunction<T, R>} mapper - Projection function for the key to sort by.\n * @param {Order} [order] - Ascending or Descending.\n * @returns {From<T>} A new From instance.\n */\n public orderBy<R>(mapper: UnaryFunction<T, R>, order: Order = Order.Ascending): From<T> {\n const array = Array.from(this._fn());\n if (order == Order.Ascending) {\n array.sort((a, b) => {\n const aValue = mapper(a);\n const bValue = mapper(b);\n return aValue > bValue ? 1 : bValue > aValue ? -1 : 0;\n });\n } else if (order == Order.Descending) {\n array.sort((a, b) => {\n const aValue = mapper(a);\n const bValue = mapper(b);\n return aValue > bValue ? 1 : bValue < aValue ? -1 : 0;\n });\n } else {\n throw new Error(\"invalid order argument\");\n }\n\n return From.iterable(array);\n }\n\n /**\n * Groups the elements of the sequence.\n * @template TKey\n * @param {UnaryFunction<T, TKey>} keySelector - Function to extract the key for each element.\n * @param {EqualityComparer<TKey>} [equalityComparer] - Optional comparer for keys.\n * @returns {From<Grouping<TKey, T>>} A new From instance.\n */\n public groupBy<TKey>(keySelector: UnaryFunction<T, TKey>, equalityComparer?: EqualityComparer<TKey>): From<Grouping<TKey, T>> {\n\n equalityComparer = (equalityComparer == null ? shallowEqual : equalityComparer);\n const self = this;\n\n return From.fn<Grouping<TKey, T>>(function* () {\n const groups: Array<[TKey, T[]]> = [];\n for (let item of self) {\n const key = keySelector(item);\n let found = false;\n for (let [entryKey, group] of groups) {\n if (equalityComparer(key, entryKey)) {\n group.push(item);\n found = true;\n break;\n }\n }\n if (!found) {\n groups.push([key, [item]]);\n }\n }\n yield* groups.map(([key, values]) => new Grouping<TKey, T>(key, values));\n });\n }\n\n /**\n * Returns a specified number of contiguous elements from the start of the sequence.\n * @param {number} n - The number of elements to return.\n * @returns {From<T>} A new From instance.\n */\n public head(n: number): From<T> {\n\n const self = this;\n return From.fn<T>(function* () {\n let count = 0;\n for (let item of self) {\n if (count++ < n) {\n yield item;\n } else {\n return;\n }\n }\n });\n }\n\n /**\n * Returns a specified number of contiguous elements from the end of the sequence.\n * @param {number} n - The number of elements to return.\n * @returns {From<T>} A new From instance.\n */\n public tail(n: number): From<T> {\n\n const self = this;\n return From.fn<T>(function* () {\n let buffer = [];\n for (let item of self) {\n buffer.push(item);\n if (buffer.length > n) {\n buffer.shift();\n }\n }\n yield* buffer;\n });\n }\n\n /**\n * Performs the specified action on each element of the sequence.\n * @param {Consumer<T>} action - The action to perform.\n */\n public forEach(action: Consumer<T>): void {\n for (let item of this) {\n action(item);\n }\n }\n\n /**\n * Converts the sequence to an array.\n * @returns {T[]} The array.\n */\n public toArray(): T[] {\n return Array.from(this);\n }\n\n /**\n * Converts the sequence to a record.\n * @template R\n * @param {UnaryFunction<T, string | symbol | number>} keySelector - Key selector.\n * @param {UnaryFunction<T, R>} valueSelector - Value selector.\n * @returns {Record<string | symbol | number, R>} The record.\n */\n public toRecord<R>(keySelector: UnaryFunction<T, string | symbol | number>, valueSelector: UnaryFunction<T, R>): Record<string | symbol | number, R> {\n const output: Record<string | symbol | number, R> = {};\n\n for (let item of this) {\n output[keySelector(item)] = valueSelector(item);\n }\n return output;\n }\n\n /**\n * Converts the sequence to a Map.\n * @template RKey, RValue\n * @param {UnaryFunction<T, RKey>} keySelector - Key selector.\n * @param {UnaryFunction<T, RValue>} valueSelector - Value selector.\n * @returns {Map<RKey, RValue>} The map.\n */\n public toMap<RKey, RValue>(keySelector: UnaryFunction<T, RKey>, valueSelector: UnaryFunction<T, RValue>): Map<RKey, RValue> {\n const map = new Map<any, any>();\n\n for (let item of this) {\n const key = keySelector(item);\n const value = valueSelector(item);\n map.set(key, value);\n }\n\n return map;\n }\n\n\n /**\n * Returns elements that are instances of a specific primitive type.\n * @param {string} type - The type string (e.g., 'string', 'number').\n * @returns {From<T>} A new From instance.\n */\n public instancesOf(type: string): From<T> {\n return this.filter(item => typeof item === type);\n }\n\n /**\n * Checks if all elements are instances of a specific class.\n * @param {new (...args: any[]) => any} type - The class constructor.\n * @returns {boolean} True if all elements are instances of the type.\n */\n public allInstanceOf(type: new (...args: any[]) => any): boolean {\n for (let item of this) {\n if (!(item instanceof type)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Returns distinct elements from the sequence.\n * @param {EqualityComparer<T>} [eq_comparer] - Optional equality comparer.\n * @returns {From<T>} A new From instance.\n */\n public distinct(eq_comparer?: EqualityComparer<T>): From<T> {\n\n if (eq_comparer == null)\n eq_comparer = shallowEqual;\n\n const self = this;\n return From.fn<T>(function* () {\n\n const included = [];\n\n for (let item of self) {\n if (!From.iterable(included).any(x => eq_comparer(x, item))) {\n included.push(item);\n yield item;\n }\n }\n });\n }\n\n /**\n * Inserts an item at a specific index.\n * @param {T} item - The item to insert.\n * @param {number} index - The zero-based index.\n * @returns {From<T>} A new From instance.\n */\n public insert(item: T, index: number): From<T> {\n\n const self = this;\n return From.fn<T>(function* () {\n let i = 0;\n let inserted = false;\n for (let existingItem of self) {\n if (i === index) {\n yield item;\n inserted = true;\n }\n yield existingItem;\n i++;\n }\n if (!inserted) {\n yield item;\n }\n });\n }\n\n /**\n * Bypasses a specified number of elements in a sequence and then returns the remaining elements.\n * @param {number} n - The number of elements to skip.\n * @returns {From<T>} A new From instance.\n */\n public skip(n: number): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n let i = 0;\n for (let item of self) {\n if (i >= n) {\n yield item;\n }\n i++;\n }\n });\n }\n\n\n /**\n * Concatenates two sequences.\n * @param {Iterable<T>} other - The other sequence.\n * @returns {From<T>} A new From instance.\n */\n public union(other: Iterable<T>): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n yield* self;\n yield* other;\n });\n }\n\n /**\n * Correlates the elements of two sequences based on matching keys.\n * @template T2, R, R2\n * @param {Iterable<T2>} other - The other sequence.\n * @param {UnaryFunction<T, R>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<T2, R>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T, otherItem: T2) => R2} resultSelector - Function to create a result element from two matching elements.\n * @returns {From<R2>} A new From instance.\n */\n public innerJoin<T2, R, R2>(other: Iterable<T2>, thisKeySelector: UnaryFunction<T, R>, otherKeySelector: UnaryFunction<T2, R>, resultSelector: (thisItem: T, otherItem: T2) => R2): From<R2> {\n\n const self = this;\n return From.fn<R2>(() => {\n const otherByKey = new Map<R, T2>();\n for (let item of other) {\n otherByKey.set(otherKeySelector(item), item);\n }\n return Array.from(self)\n .filter(item => otherByKey.has(thisKeySelector(item)))\n .map(item => resultSelector(item, otherByKey.get(thisKeySelector(item))!));\n });\n }\n\n /**\n * Performs a left join on two sequences.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T, otherItem: U | undefined) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public leftJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItem: T, otherItem: U | undefined) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const otherByKey = new Map<K, U>();\n for (let item of other) {\n otherByKey.set(otherKeySelector(item), item);\n }\n return Array.from(self).map(item => resultSelector(item, otherByKey.get(thisKeySelector(item))));\n });\n }\n\n\n /**\n * Performs a left group join on two sequences.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T, otherItems: Array<U>) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public leftGroupJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItem: T, otherItems: Array<U>) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const otherByKeys = new Map<K, Array<U>>();\n for (let item of other) {\n const key = otherKeySelector(item);\n if (!otherByKeys.has(key)) {\n otherByKeys.set(key, []);\n }\n otherByKeys.get(key)!.push(item);\n }\n return Array.from(self).map(item => resultSelector(item, otherByKeys.get(thisKeySelector(item)) || []));\n });\n }\n\n /**\n * Performs a right group join on two sequences.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItems: Array<T>, otherItem: U) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public rightGroupJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItems: Array<T>, otherItem: U) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const thisByKeys = new Map<K, Array<T>>();\n for (let item of self) {\n const key = thisKeySelector(item);\n if (!thisByKeys.has(key)) {\n thisByKeys.set(key, []);\n }\n thisByKeys.get(key)!.push(item);\n }\n return Array.from(other).map(item => resultSelector(thisByKeys.get(otherKeySelector(item)) || [], item));\n });\n }\n\n\n /**\n * Performs a right join on two sequences.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T | undefined, otherItem: U) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public rightJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItem: T | undefined, otherItem: U) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const thisByKey = new Map<K, T>();\n for (let item of self) {\n thisByKey.set(thisKeySelector(item), item);\n }\n return Array.from(other).map(item => resultSelector(thisByKey.get(otherKeySelector(item)), item));\n });\n }\n\n}\n\n/**\n * Represents a group of elements that have a common key.\n * @template TKey, T\n */\nexport class Grouping<TKey, T> extends From<T> {\n\n private readonly _key: TKey;\n\n /**\n * Gets the key of the group.\n */\n public get key(): TKey {\n return this._key;\n }\n\n /**\n * @param {TKey} key - The group key.\n * @param {Array<T>} values - The values in the group.\n */\n public constructor(key: TKey, values: Array<T>) {\n super(() => values);\n this._key = key;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"from.js","sourceRoot":"","sources":["../../src/collections/from.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,MAAM,aAAa,CAAC;AAmBhC,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAiF;IAC1G,IAAI,MAAM,IAAI,IAAI;QACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,IAAI,OAAO,MAAM,KAAK,UAAU;QAC5B,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,MAAM,CAAC,QAAQ,IAAI,M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G,MAAM,UAAU,GAAG,IAAI,GAAG,EAAiB,CAAC;IAC5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACJ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,QAAkB,SAAQ,IAAO;IAI1C;;OAEG;IACH,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,YAAmB,GAAS,EAAE,MAAgB;QAC1C,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {Consumer, EqualityComparer, UnaryFunction, Predicate, Supplier} from \"../types.js\";\nimport {shallowEqual, toPairs} from \"../utilities.js\";\nimport KeyValuePair from \"../key-value-pair.js\";\nimport Order from \"../order.js\";\n\n\n/**\n * Creates a new From instance from an Iterable, a Supplier of an Iterable, or the entries of a plain object.\n * @template T - The type of elements in the source.\n * @param {Iterable<T> | Supplier<Iterable<T>>} source - The source data.\n * @returns {From<T>} A new From instance.\n * @throws {Error} If source is null or invalid.\n */\nexport default function from<T>(source: Iterable<T> | Supplier<Iterable<T>>): From<T>;\n/**\n * Creates a new From instance from the enumerable own and inherited properties of a plain object.\n * @template TValue - The type of the property values.\n * @param {Record<string, TValue>} source - The source object.\n * @returns {From<KeyValuePair<string, TValue>>} A From instance of key-value pairs.\n * @throws {Error} If source is null or invalid.\n */\nexport default function from<TValue>(source: Record<string, TValue>): From<KeyValuePair<string, TValue>>;\nexport default function from(source: Iterable<unknown> | Supplier<Iterable<unknown>> | Record<string, unknown>): From<unknown> {\n if (source == null)\n throw new Error(\"Source is null.\");\n if (typeof source === 'function')\n return From.fn(source);\n if (Symbol.iterator in source && typeof source[Symbol.iterator] === 'function') {\n return From.iterable(source as Iterable<unknown>);\n } else if (typeof source === 'object') {\n return From.object(source as Record<string, unknown>);\n }\n\n throw new Error(\"Invalid source.\");\n}\n\n/**\n * A LINQ-like wrapper for iterables that provides various transformation and query methods.\n * @template T - The type of elements in the sequence.\n */\nexport class From<T> implements Iterable<T> {\n\n /**\n * Creates a From instance from an object's entries.\n * @template TValue - The type of the property values.\n * @param {Record<string, TValue>} obj - The object to convert to pairs.\n * @returns {From<KeyValuePair<string, TValue>>} A From instance of key-value pairs.\n */\n public static object<TValue>(obj: Record<string, TValue>): From<KeyValuePair<string, TValue>> {\n return new From<KeyValuePair<string, TValue>>(function () {\n return toPairs(obj);\n });\n }\n\n\n private readonly _fn: Supplier<Iterable<T>>\n\n protected constructor(fn: Supplier<Iterable<T>>) {\n this._fn = fn;\n }\n\n /**\n * Creates a From instance from a supplier function.\n * @template T\n * @param {Supplier<Iterable<T>>} callable - A function that returns an Iterable.\n * @returns {From<T>} A new From instance.\n */\n public static fn<T>(callable: Supplier<Iterable<T>>): From<T> {\n return new From<T>(callable);\n }\n\n /**\n * Collects all elements into an array and returns a new From instance from it.\n * Useful for freezing the sequence and preventing multiple iterations over a generator.\n * @returns {From<T>} A new From instance with cached data.\n */\n public collect(): From<T> {\n const cache = Array.from(this);\n return From.iterable(cache);\n }\n\n /**\n * Creates a From instance from an Iterable.\n * @template T\n * @param {Iterable<T>} iterable - The source iterable.\n * @returns {From<T>} A new From instance.\n */\n public static iterable<T>(iterable: Iterable<T>): From<T> {\n return From.fn<T>(function* () {\n for (const item of iterable) {\n yield item;\n }\n });\n }\n\n /**\n * Maps each element of the sequence into a new form.\n * @template R\n * @param {UnaryFunction<T, R>} mapper - A transformation function.\n * @returns {From<R>} A new From instance with the mapped elements.\n */\n public map<R>(mapper: UnaryFunction<T, R>): From<R> {\n const self = this;\n return From.fn<R>(function* () {\n for (let item of self) {\n yield mapper(item);\n }\n });\n }\n\n * [Symbol.iterator](): Iterator<T> {\n yield* this._fn();\n }\n\n\n /**\n * Checks if all elements in the sequence satisfy the given predicate.\n * @param {Predicate<T>} predicate - A function to test each element.\n * @returns {boolean} True if all elements satisfy the predicate.\n */\n public all(predicate: Predicate<T>): boolean {\n for (let item of this._fn()) {\n if (!predicate(item)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Checks if any element in the sequence satisfies the given predicate.\n * If no predicate is provided, checks if the sequence is not empty.\n * @param {Predicate<T>} [predicate] - A function to test each element.\n * @returns {boolean} True if any element satisfies the predicate.\n */\n public any(predicate?: Predicate<T>): boolean {\n for (let item of this) {\n if (predicate == null || predicate(item)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Gets the number of elements in the sequence.\n * @returns {number} The count of elements.\n */\n public get length(): number {\n return this.count();\n }\n\n /**\n * Counts the number of elements that satisfy the given predicate.\n * If no predicate is provided, counts all elements.\n * @param {Predicate<T>} [predicate] - A function to test each element.\n * @returns {number} The count of elements.\n */\n public count(predicate?: Predicate<T>): number {\n\n let output = 0;\n\n for (let item of this) {\n if (predicate == null || predicate(item)) {\n output++;\n }\n }\n\n return output;\n }\n\n /**\n * Filters the sequence based on a predicate.\n * @param {Predicate<T>} predicate - A function to test each element.\n * @returns {From<T>} A new From instance with the filtered elements.\n */\n public filter(predicate: Predicate<T>): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n for (let item of self) {\n if (predicate(item)) {\n yield item;\n }\n }\n });\n }\n\n /**\n * Checks if the sequence contains a specific value.\n * @param {T} value - The value to search for.\n * @returns {boolean} True if the value is found.\n */\n public contains(value: T): boolean {\n for (let item of this) {\n if (item === value) {\n return true;\n }\n }\n return false;\n }\n\n\n /**\n * Returns the first element of the sequence that satisfies a condition.\n * @param {Predicate<T>} [predicate] - Optional condition.\n * @returns {T | undefined} The first element or undefined.\n */\n public first(predicate?: Predicate<T>): T | undefined {\n\n if (predicate) {\n for (let item of this) {\n if (predicate(item)) {\n return item;\n }\n }\n } else {\n // noinspection LoopStatementThatDoesntLoopJS\n for (let item of this) {\n return item;\n }\n }\n\n return undefined;\n }\n\n /**\n * Returns the only element of the sequence that satisfies a condition, or throws if more than one exists.\n * @param {Predicate<T>} [predicate] - Optional condition.\n * @returns {T | null} The single element or null if not found.\n * @throws {Error} If more than one element is found.\n */\n public single(predicate?: Predicate<T>): T | null {\n\n let found = false;\n let output: T | null = null;\n\n if (predicate) {\n for (let item of this) {\n if (predicate(item)) {\n if (found) {\n throw new Error(\"Sequence contains more than one element.\");\n }\n found = true;\n output = item;\n }\n }\n } else {\n // noinspection LoopStatementThatDoesntLoopJS\n for (let item of this) {\n if (found) {\n throw new Error(\"Sequence contains more than one element.\");\n }\n found = true;\n output = item;\n }\n }\n\n return output;\n }\n\n /**\n * Appends an item to the end of the sequence.\n * @param {T} item - The item to append.\n * @returns {From<T>} A new From instance.\n */\n public append(item: T): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n for (let element of self) {\n yield element;\n }\n yield item;\n });\n }\n\n /**\n * Prepends an item to the beginning of the sequence.\n * @param {T} item - The item to prepend.\n * @returns {From<T>} A new From instance.\n */\n public prepend(item: T): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n yield item;\n for (let element of self) {\n yield element;\n }\n });\n }\n\n /**\n * Gets the element at a specific index.\n * @param {number} index - The zero-based index.\n * @returns {T | undefined} The element at the index or undefined.\n */\n public at(index: number): T | undefined {\n let idx = 0;\n for (let item of this) {\n if (idx++ === index) {\n return item;\n }\n }\n return undefined;\n }\n\n /**\n * Returns the last element of the sequence that satisfies a condition.\n * @param {Predicate<T>} [predicate] - Optional condition.\n * @returns {T | undefined} The last element or undefined.\n */\n public last(predicate?: Predicate<T>): T | undefined {\n\n\n let last: T | undefined = undefined;\n\n if (predicate)\n for (let item of this) {\n if (!predicate || predicate(item)) {\n last = item;\n }\n }\n else {\n for (let item of this) {\n last = item;\n }\n }\n return last;\n }\n\n /**\n * Projects each element of a sequence to an Iterable and flattens the resulting sequences into one sequence.\n * @template R\n * @param {UnaryFunction<T, Iterable<R>>} mapper - A transformation function.\n * @returns {From<R>} A new From instance.\n */\n public mapMany<R>(mapper: UnaryFunction<T, Iterable<R>>): From<R> {\n const self = this;\n return From.fn(function* () {\n for (const item of self) {\n const subitems = mapper(item)\n for (const subitem of subitems) {\n yield subitem;\n }\n }\n })\n }\n\n /**\n * Flattens a sequence of iterables.\n * @returns {From<any>} A new From instance.\n */\n public flatten(): From<any> {\n const self = this;\n return From.fn<T>(function* () {\n for (let item of self) {\n let temp = <Iterable<any>>item;\n for (let subitem of temp) {\n yield subitem\n }\n }\n });\n }\n\n /**\n * Calculates the sum of the elements in the sequence.\n * @param {UnaryFunction<T, number>} [mapper] - Optional projection function.\n * @returns {number} The sum.\n */\n public sum(mapper?: UnaryFunction<T, number>): number {\n let total = 0;\n\n if (mapper)\n for (let item of this) {\n total += mapper(item);\n }\n else\n for (let item of this) {\n total += item as number;\n }\n return total;\n }\n\n /**\n * Calculates the average of the elements in the sequence.\n * @param {UnaryFunction<T, number>} [mapper] - Optional projection function.\n * @returns {number} The average.\n */\n public avg(mapper?: UnaryFunction<T, number>): number {\n let total = 0;\n let count = 0;\n\n if (mapper)\n for (let item of this) {\n total += mapper(item);\n count++;\n }\n else\n for (let item of this) {\n total += item as number;\n count++;\n }\n return count > 0 ? total / count : 0;\n }\n\n /**\n * Returns the maximum value in the sequence.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {number} The maximum value.\n */\n public max(mapper: UnaryFunction<T, number>): number {\n let max = -Infinity;\n for (let item of this) {\n let value = mapper(item);\n max = value > max ? value : max;\n }\n return max;\n }\n\n /**\n * Returns the minimum value in the sequence.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {number} The minimum value.\n */\n public min(mapper: UnaryFunction<T, number>): number {\n let min = Infinity;\n for (let item of this) {\n let value = mapper(item);\n min = value < min ? value : min;\n }\n return min;\n }\n\n /**\n * Returns the element with the maximum value.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {T | undefined} The element with the maximum value.\n */\n public maxBy(mapper: UnaryFunction<T, number>): T | undefined {\n let max = -Infinity;\n let maxItem: T | undefined;\n for (let item of this) {\n let value = mapper(item);\n if (value > max) {\n max = value;\n maxItem = item;\n }\n }\n return maxItem;\n }\n\n /**\n * Returns the element with the minimum value.\n * @param {UnaryFunction<T, number>} mapper - Projection function.\n * @returns {T | undefined} The element with the minimum value.\n */\n public minBy(mapper: UnaryFunction<T, number>): T | undefined {\n let min = Infinity;\n let minItem: T | undefined;\n for (let item of this) {\n let value = mapper(item);\n if (value < min) {\n min = value;\n minItem = item;\n }\n }\n return minItem;\n }\n\n /**\n * Sorts the elements of the sequence.\n * @template R\n * @param {UnaryFunction<T, R>} mapper - Projection function for the key to sort by.\n * @param {Order} [order] - Ascending or Descending.\n * @returns {From<T>} A new From instance.\n */\n public orderBy<R>(mapper: UnaryFunction<T, R>, order: Order = Order.Ascending): From<T> {\n const array = Array.from(this._fn());\n if (order == Order.Ascending) {\n array.sort((a, b) => {\n const aValue = mapper(a);\n const bValue = mapper(b);\n return aValue > bValue ? 1 : bValue > aValue ? -1 : 0;\n });\n } else if (order == Order.Descending) {\n array.sort((a, b) => {\n const aValue = mapper(a);\n const bValue = mapper(b);\n return aValue > bValue ? -1 : aValue < bValue ? 1 : 0;\n });\n } else {\n throw new Error(\"invalid order argument\");\n }\n\n return From.iterable(array);\n }\n\n /**\n * Groups the elements of the sequence.\n * @template TKey\n * @param {UnaryFunction<T, TKey>} keySelector - Function to extract the key for each element.\n * @param {EqualityComparer<TKey>} [equalityComparer] - Optional comparer for keys.\n * @returns {From<Grouping<TKey, T>>} A new From instance.\n */\n public groupBy<TKey>(keySelector: UnaryFunction<T, TKey>, equalityComparer?: EqualityComparer<TKey>): From<Grouping<TKey, T>> {\n\n equalityComparer = (equalityComparer == null ? shallowEqual : equalityComparer);\n const self = this;\n\n return From.fn<Grouping<TKey, T>>(function* () {\n const groups: Array<[TKey, T[]]> = [];\n for (let item of self) {\n const key = keySelector(item);\n let found = false;\n for (let [entryKey, group] of groups) {\n if (equalityComparer(key, entryKey)) {\n group.push(item);\n found = true;\n break;\n }\n }\n if (!found) {\n groups.push([key, [item]]);\n }\n }\n yield* groups.map(([key, values]) => new Grouping<TKey, T>(key, values));\n });\n }\n\n /**\n * Returns a specified number of contiguous elements from the start of the sequence.\n * @param {number} n - The number of elements to return.\n * @returns {From<T>} A new From instance.\n */\n public head(n: number): From<T> {\n\n const self = this;\n return From.fn<T>(function* () {\n let count = 0;\n for (let item of self) {\n if (count++ < n) {\n yield item;\n } else {\n return;\n }\n }\n });\n }\n\n /**\n * Returns a specified number of contiguous elements from the end of the sequence.\n * @param {number} n - The number of elements to return.\n * @returns {From<T>} A new From instance.\n */\n public tail(n: number): From<T> {\n\n const self = this;\n return From.fn<T>(function* () {\n let buffer = [];\n for (let item of self) {\n buffer.push(item);\n if (buffer.length > n) {\n buffer.shift();\n }\n }\n yield* buffer;\n });\n }\n\n /**\n * Performs the specified action on each element of the sequence.\n * @param {Consumer<T>} action - The action to perform.\n */\n public forEach(action: Consumer<T>): void {\n for (let item of this) {\n action(item);\n }\n }\n\n /**\n * Converts the sequence to an array.\n * @returns {T[]} The array.\n */\n public toArray(): T[] {\n return Array.from(this);\n }\n\n /**\n * Converts the sequence to a record.\n * @template R\n * @param {UnaryFunction<T, string | symbol | number>} keySelector - Key selector.\n * @param {UnaryFunction<T, R>} valueSelector - Value selector.\n * @returns {Record<string | symbol | number, R>} The record.\n */\n public toRecord<R>(keySelector: UnaryFunction<T, string | symbol | number>, valueSelector: UnaryFunction<T, R>): Record<string | symbol | number, R> {\n const output: Record<string | symbol | number, R> = {};\n\n for (let item of this) {\n output[keySelector(item)] = valueSelector(item);\n }\n return output;\n }\n\n /**\n * Converts the sequence to a Map.\n * @template RKey, RValue\n * @param {UnaryFunction<T, RKey>} keySelector - Key selector.\n * @param {UnaryFunction<T, RValue>} valueSelector - Value selector.\n * @returns {Map<RKey, RValue>} The map.\n */\n public toMap<RKey, RValue>(keySelector: UnaryFunction<T, RKey>, valueSelector: UnaryFunction<T, RValue>): Map<RKey, RValue> {\n const map = new Map<any, any>();\n\n for (let item of this) {\n const key = keySelector(item);\n const value = valueSelector(item);\n map.set(key, value);\n }\n\n return map;\n }\n\n\n /**\n * Returns elements that are instances of a specific primitive type.\n * @param {string} type - The type string (e.g., 'string', 'number').\n * @returns {From<T>} A new From instance.\n */\n public instancesOf(type: string): From<T> {\n return this.filter(item => typeof item === type);\n }\n\n /**\n * Checks if all elements are instances of a specific class.\n * @param {new (...args: any[]) => any} type - The class constructor.\n * @returns {boolean} True if all elements are instances of the type.\n */\n public allInstanceOf(type: new (...args: any[]) => any): boolean {\n for (let item of this) {\n if (!(item instanceof type)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Returns distinct elements from the sequence.\n * @param {EqualityComparer<T>} [eq_comparer] - Optional equality comparer.\n * @returns {From<T>} A new From instance.\n */\n public distinct(eq_comparer?: EqualityComparer<T>): From<T> {\n\n if (eq_comparer == null)\n eq_comparer = shallowEqual;\n\n const self = this;\n return From.fn<T>(function* () {\n\n const included = [];\n\n for (let item of self) {\n if (!From.iterable(included).any(x => eq_comparer(x, item))) {\n included.push(item);\n yield item;\n }\n }\n });\n }\n\n /**\n * Inserts an item at a specific index.\n * @param {T} item - The item to insert.\n * @param {number} index - The zero-based index.\n * @returns {From<T>} A new From instance.\n */\n public insert(item: T, index: number): From<T> {\n\n const self = this;\n return From.fn<T>(function* () {\n let i = 0;\n let inserted = false;\n for (let existingItem of self) {\n if (i === index) {\n yield item;\n inserted = true;\n }\n yield existingItem;\n i++;\n }\n if (!inserted) {\n yield item;\n }\n });\n }\n\n /**\n * Bypasses a specified number of elements in a sequence and then returns the remaining elements.\n * @param {number} n - The number of elements to skip.\n * @returns {From<T>} A new From instance.\n */\n public skip(n: number): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n let i = 0;\n for (let item of self) {\n if (i >= n) {\n yield item;\n }\n i++;\n }\n });\n }\n\n\n /**\n * The elements of this sequence followed by those of the other, duplicates included, as LINQ's Concat.\n * @param {Iterable<T>} other - The other sequence.\n * @returns {From<T>} A new From instance.\n */\n public concat(other: Iterable<T>): From<T> {\n const self = this;\n return From.fn<T>(function* () {\n yield* self;\n yield* other;\n });\n }\n\n /**\n * The set union, as LINQ's Union: the elements of this sequence and then those of the other, each one once (the\n * first time it appears), compared as distinct() does.\n * @param {Iterable<T>} other - The other sequence.\n * @param {EqualityComparer<T>} [equalityComparer] - Optional equality comparer; shallowEqual when not given.\n * @returns {From<T>} A new From instance.\n */\n public union(other: Iterable<T>, equalityComparer?: EqualityComparer<T>): From<T> {\n return this.concat(other).distinct(equalityComparer);\n }\n\n /**\n * Correlates the elements of two sequences based on matching keys: one result per matching pair, so an element\n * that matches several elements of the other sequence gives one result for each.\n * @template T2, R, R2\n * @param {Iterable<T2>} other - The other sequence.\n * @param {UnaryFunction<T, R>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<T2, R>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T, otherItem: T2) => R2} resultSelector - Function to create a result element from two matching elements.\n * @returns {From<R2>} A new From instance.\n */\n public innerJoin<T2, R, R2>(other: Iterable<T2>, thisKeySelector: UnaryFunction<T, R>, otherKeySelector: UnaryFunction<T2, R>, resultSelector: (thisItem: T, otherItem: T2) => R2): From<R2> {\n\n const self = this;\n return From.fn<R2>(() => {\n const otherByKey = groupItemsByKey(other, otherKeySelector);\n const results: R2[] = [];\n for (const item of self) {\n for (const otherItem of otherByKey.get(thisKeySelector(item)) ?? []) {\n results.push(resultSelector(item, otherItem));\n }\n }\n return results;\n });\n }\n\n /**\n * Performs a left join on two sequences: one result per matching pair, and one with `undefined` for each element of\n * this sequence that matches none.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T, otherItem: U | undefined) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public leftJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItem: T, otherItem: U | undefined) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const otherByKey = groupItemsByKey(other, otherKeySelector);\n const results: R[] = [];\n for (const item of self) {\n const matches = otherByKey.get(thisKeySelector(item));\n if (matches === undefined) {\n results.push(resultSelector(item, undefined));\n continue;\n }\n for (const otherItem of matches) {\n results.push(resultSelector(item, otherItem));\n }\n }\n return results;\n });\n }\n\n\n /**\n * Performs a left group join on two sequences.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T, otherItems: Array<U>) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public leftGroupJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItem: T, otherItems: Array<U>) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const otherByKey = groupItemsByKey(other, otherKeySelector);\n return Array.from(self).map(item => resultSelector(item, otherByKey.get(thisKeySelector(item)) ?? []));\n });\n }\n\n /**\n * Performs a right group join on two sequences.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItems: Array<T>, otherItem: U) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public rightGroupJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItems: Array<T>, otherItem: U) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const thisByKey = groupItemsByKey(self, thisKeySelector);\n return Array.from(other).map(item => resultSelector(thisByKey.get(otherKeySelector(item)) ?? [], item));\n });\n }\n\n\n /**\n * Performs a right join on two sequences: one result per matching pair, and one with `undefined` for each element of\n * the other sequence that matches none.\n * @template U, K, R\n * @param {Iterable<U>} other - The other sequence.\n * @param {UnaryFunction<T, K>} thisKeySelector - Key selector for this sequence.\n * @param {UnaryFunction<U, K>} otherKeySelector - Key selector for the other sequence.\n * @param {(thisItem: T | undefined, otherItem: U) => R} resultSelector - Function to create a result element.\n * @returns {From<R>} A new From instance.\n */\n public rightJoin<U, K, R>(other: Iterable<U>, thisKeySelector: UnaryFunction<T, K>, otherKeySelector: UnaryFunction<U, K>, resultSelector: (thisItem: T | undefined, otherItem: U) => R): From<R> {\n\n const self = this;\n return From.fn<R>(() => {\n const thisByKey = groupItemsByKey(self, thisKeySelector);\n const results: R[] = [];\n for (const otherItem of other) {\n const matches = thisByKey.get(otherKeySelector(otherItem));\n if (matches === undefined) {\n results.push(resultSelector(undefined, otherItem));\n continue;\n }\n for (const item of matches) {\n results.push(resultSelector(item, otherItem));\n }\n }\n return results;\n });\n }\n\n}\n\n/** The items of a sequence in lists by their key, in their order, for the joins. */\nfunction groupItemsByKey<TItem, TKey>(items: Iterable<TItem>, keySelector: UnaryFunction<TItem, TKey>): Map<TKey, TItem[]> {\n const itemsByKey = new Map<TKey, TItem[]>();\n for (const item of items) {\n const key = keySelector(item);\n const group = itemsByKey.get(key);\n if (group === undefined) {\n itemsByKey.set(key, [item]);\n } else {\n group.push(item);\n }\n }\n return itemsByKey;\n}\n\n/**\n * Represents a group of elements that have a common key.\n * @template TKey, T\n */\nexport class Grouping<TKey, T> extends From<T> {\n\n private readonly _key: TKey;\n\n /**\n * Gets the key of the group.\n */\n public get key(): TKey {\n return this._key;\n }\n\n /**\n * @param {TKey} key - The group key.\n * @param {Array<T>} values - The values in the group.\n */\n public constructor(key: TKey, values: Array<T>) {\n super(() => values);\n this._key = key;\n }\n}"]}
|
package/dist/draft.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ type DraftMethods<T> = {
|
|
|
36
36
|
*
|
|
37
37
|
* @returns Array of modified property keys (does not recurse into children).
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
getModifiedProps(): (keyof T)[];
|
|
40
40
|
/**
|
|
41
41
|
* Manually mark (or unmark) a property as modified.
|
|
42
42
|
* Primarily used by child drafts to notify their parent, but also
|
|
@@ -67,7 +67,7 @@ type ParentLink = {
|
|
|
67
67
|
/**
|
|
68
68
|
* Create a draft proxy over `original`. The proxy exposes the same properties
|
|
69
69
|
* as the original (with nested objects wrapped as child drafts) plus the
|
|
70
|
-
* control methods `commit`, `rollback`, `isModified`, `
|
|
70
|
+
* control methods `commit`, `rollback`, `isModified`, `getModifiedProps` and
|
|
71
71
|
* `setModified`.
|
|
72
72
|
*
|
|
73
73
|
* Mutations on the draft do not affect the original until `commit()` is called.
|
package/dist/draft.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI;IACnB;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;IAEtC;;;;;;;;OAQG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;IAExC;;;;;OAKG;IACH,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,7 +74,7 @@ function deepDraft(value, parentLink) {
|
|
|
74
74
|
/**
|
|
75
75
|
* Create a draft proxy over `original`. The proxy exposes the same properties
|
|
76
76
|
* as the original (with nested objects wrapped as child drafts) plus the
|
|
77
|
-
* control methods `commit`, `rollback`, `isModified`, `
|
|
77
|
+
* control methods `commit`, `rollback`, `isModified`, `getModifiedProps` and
|
|
78
78
|
* `setModified`.
|
|
79
79
|
*
|
|
80
80
|
* Mutations on the draft do not affect the original until `commit()` is called.
|
|
@@ -166,7 +166,7 @@ export default function draft(original, parentLink) {
|
|
|
166
166
|
isModified(key) {
|
|
167
167
|
return key === undefined ? touched.size > 0 : touched.has(key);
|
|
168
168
|
},
|
|
169
|
-
|
|
169
|
+
getModifiedProps() {
|
|
170
170
|
return [...touched];
|
|
171
171
|
},
|
|
172
172
|
setModified(key, modified = true) {
|