metano-runtime 2.1.0 → 2.3.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/README.md +139 -0
- package/dist/system/equality.d.ts +8 -0
- package/dist/system/equality.js +13 -5
- package/dist/system/json/index.d.ts +1 -0
- package/dist/system/json/index.js +1 -0
- package/dist/system/json/union-guard-registry.d.ts +30 -0
- package/dist/system/json/union-guard-registry.js +34 -0
- package/dist/system/linq/compare-keys.d.ts +3 -2
- package/dist/system/linq/compare-keys.js +9 -7
- package/dist/system/linq/expr-tree-visitor.d.ts +173 -0
- package/dist/system/linq/expr-tree-visitor.js +417 -0
- package/dist/system/linq/expr-tree.d.ts +156 -0
- package/dist/system/linq/expr-tree.js +18 -0
- package/dist/system/linq/index.d.ts +29 -23
- package/dist/system/linq/index.js +25 -70
- package/dist/system/linq/linq.d.ts +107 -0
- package/dist/system/linq/linq.js +46 -0
- package/dist/system/linq/operators.d.ts +34 -0
- package/dist/system/linq/operators.js +352 -0
- package/dist/system/linq/terminals.d.ts +22 -0
- package/dist/system/linq/terminals.js +314 -0
- package/dist/system/linq/types.d.ts +249 -0
- package/dist/system/linq/types.js +0 -0
- package/package.json +2 -1
- package/dist/system/linq/append-enumerable.d.ts +0 -8
- package/dist/system/linq/append-enumerable.js +0 -15
- package/dist/system/linq/concat-enumerable.d.ts +0 -8
- package/dist/system/linq/concat-enumerable.js +0 -15
- package/dist/system/linq/distinct-by-enumerable.d.ts +0 -8
- package/dist/system/linq/distinct-by-enumerable.js +0 -21
- package/dist/system/linq/distinct-enumerable.d.ts +0 -7
- package/dist/system/linq/distinct-enumerable.js +0 -19
- package/dist/system/linq/enumerable-base.d.ts +0 -98
- package/dist/system/linq/enumerable-base.js +0 -306
- package/dist/system/linq/enumerable.d.ts +0 -16
- package/dist/system/linq/enumerable.js +0 -33
- package/dist/system/linq/except-enumerable.d.ts +0 -8
- package/dist/system/linq/except-enumerable.js +0 -22
- package/dist/system/linq/group-by-enumerable.d.ts +0 -8
- package/dist/system/linq/group-by-enumerable.js +0 -31
- package/dist/system/linq/intersect-enumerable.d.ts +0 -8
- package/dist/system/linq/intersect-enumerable.js +0 -22
- package/dist/system/linq/order-by-enumerable.d.ts +0 -9
- package/dist/system/linq/order-by-enumerable.js +0 -22
- package/dist/system/linq/prepend-enumerable.d.ts +0 -8
- package/dist/system/linq/prepend-enumerable.js +0 -15
- package/dist/system/linq/reverse-enumerable.d.ts +0 -7
- package/dist/system/linq/reverse-enumerable.js +0 -15
- package/dist/system/linq/select-enumerable.d.ts +0 -8
- package/dist/system/linq/select-enumerable.js +0 -17
- package/dist/system/linq/select-many-enumerable.d.ts +0 -8
- package/dist/system/linq/select-many-enumerable.js +0 -17
- package/dist/system/linq/skip-enumerable.d.ts +0 -8
- package/dist/system/linq/skip-enumerable.js +0 -21
- package/dist/system/linq/skip-while-enumerable.d.ts +0 -8
- package/dist/system/linq/skip-while-enumerable.js +0 -21
- package/dist/system/linq/source-enumerable.d.ts +0 -7
- package/dist/system/linq/source-enumerable.js +0 -12
- package/dist/system/linq/take-enumerable.d.ts +0 -8
- package/dist/system/linq/take-enumerable.js +0 -20
- package/dist/system/linq/take-while-enumerable.d.ts +0 -8
- package/dist/system/linq/take-while-enumerable.js +0 -19
- package/dist/system/linq/then-by-enumerable.d.ts +0 -9
- package/dist/system/linq/then-by-enumerable.js +0 -61
- package/dist/system/linq/union-enumerable.d.ts +0 -8
- package/dist/system/linq/union-enumerable.js +0 -27
- package/dist/system/linq/where-enumerable.d.ts +0 -8
- package/dist/system/linq/where-enumerable.js +0 -18
- package/dist/system/linq/zip-enumerable.d.ts +0 -9
- package/dist/system/linq/zip-enumerable.js +0 -24
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.js";
|
|
2
|
-
/** Wraps an existing Iterable as the source of a LINQ chain. */
|
|
3
|
-
export class SourceEnumerable extends EnumerableBase {
|
|
4
|
-
source;
|
|
5
|
-
constructor(source) {
|
|
6
|
-
super();
|
|
7
|
-
this.source = source;
|
|
8
|
-
}
|
|
9
|
-
*[Symbol.iterator]() {
|
|
10
|
-
yield* this.source;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.ts";
|
|
2
|
-
/** Returns a specified number of elements from the start. */
|
|
3
|
-
export declare class TakeEnumerable<T> extends EnumerableBase<T> {
|
|
4
|
-
readonly source: EnumerableBase<T>;
|
|
5
|
-
readonly takeCount: number;
|
|
6
|
-
constructor(source: EnumerableBase<T>, takeCount: number);
|
|
7
|
-
[Symbol.iterator](): Iterator<T>;
|
|
8
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.js";
|
|
2
|
-
/** Returns a specified number of elements from the start. */
|
|
3
|
-
export class TakeEnumerable extends EnumerableBase {
|
|
4
|
-
source;
|
|
5
|
-
takeCount;
|
|
6
|
-
constructor(source, takeCount) {
|
|
7
|
-
super();
|
|
8
|
-
this.source = source;
|
|
9
|
-
this.takeCount = takeCount;
|
|
10
|
-
}
|
|
11
|
-
*[Symbol.iterator]() {
|
|
12
|
-
let taken = 0;
|
|
13
|
-
for (const item of this.source) {
|
|
14
|
-
if (taken >= this.takeCount)
|
|
15
|
-
break;
|
|
16
|
-
yield item;
|
|
17
|
-
taken++;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.ts";
|
|
2
|
-
/** Yields elements while a predicate is true. Equivalent to C# .TakeWhile() */
|
|
3
|
-
export declare class TakeWhileEnumerable<T> extends EnumerableBase<T> {
|
|
4
|
-
readonly source: EnumerableBase<T>;
|
|
5
|
-
readonly predicate: (item: T, index: number) => boolean;
|
|
6
|
-
constructor(source: EnumerableBase<T>, predicate: (item: T, index: number) => boolean);
|
|
7
|
-
[Symbol.iterator](): Iterator<T>;
|
|
8
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.js";
|
|
2
|
-
/** Yields elements while a predicate is true. Equivalent to C# .TakeWhile() */
|
|
3
|
-
export class TakeWhileEnumerable extends EnumerableBase {
|
|
4
|
-
source;
|
|
5
|
-
predicate;
|
|
6
|
-
constructor(source, predicate) {
|
|
7
|
-
super();
|
|
8
|
-
this.source = source;
|
|
9
|
-
this.predicate = predicate;
|
|
10
|
-
}
|
|
11
|
-
*[Symbol.iterator]() {
|
|
12
|
-
let i = 0;
|
|
13
|
-
for (const item of this.source) {
|
|
14
|
-
if (!this.predicate(item, i++))
|
|
15
|
-
break;
|
|
16
|
-
yield item;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.ts";
|
|
2
|
-
/** Secondary sort: sorts elements by a key, preserving the order of the previous sort for equal keys. */
|
|
3
|
-
export declare class ThenByEnumerable<T, K> extends EnumerableBase<T> {
|
|
4
|
-
readonly source: EnumerableBase<T>;
|
|
5
|
-
readonly keySelector: (item: T) => K;
|
|
6
|
-
readonly descending: boolean;
|
|
7
|
-
constructor(source: EnumerableBase<T>, keySelector: (item: T) => K, descending: boolean);
|
|
8
|
-
[Symbol.iterator](): Iterator<T>;
|
|
9
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.js";
|
|
2
|
-
import { compareKeys } from "./compare-keys.js";
|
|
3
|
-
/** Secondary sort: sorts elements by a key, preserving the order of the previous sort for equal keys. */
|
|
4
|
-
export class ThenByEnumerable extends EnumerableBase {
|
|
5
|
-
source;
|
|
6
|
-
keySelector;
|
|
7
|
-
descending;
|
|
8
|
-
constructor(source, keySelector, descending) {
|
|
9
|
-
super();
|
|
10
|
-
this.source = source;
|
|
11
|
-
this.keySelector = keySelector;
|
|
12
|
-
this.descending = descending;
|
|
13
|
-
}
|
|
14
|
-
*[Symbol.iterator]() {
|
|
15
|
-
// Materialize and collect all comparators from the chain
|
|
16
|
-
const comparators = collectComparators(this);
|
|
17
|
-
const items = materializeSource(this);
|
|
18
|
-
items.sort((a, b) => {
|
|
19
|
-
for (const cmp of comparators) {
|
|
20
|
-
const result = cmp(a, b);
|
|
21
|
-
if (result !== 0)
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
return 0;
|
|
25
|
-
});
|
|
26
|
-
yield* items;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/** Walks the chain of OrderBy/ThenBy to collect all comparators in order. */
|
|
30
|
-
function collectComparators(node) {
|
|
31
|
-
const comparators = [];
|
|
32
|
-
let current = node;
|
|
33
|
-
while (current instanceof ThenByEnumerable) {
|
|
34
|
-
const thenBy = current;
|
|
35
|
-
comparators.unshift(makeComparator(thenBy.keySelector, thenBy.descending));
|
|
36
|
-
current = thenBy.source;
|
|
37
|
-
}
|
|
38
|
-
// The root should be an OrderByEnumerable-like (has keySelector + descending)
|
|
39
|
-
if ("keySelector" in current && "descending" in current) {
|
|
40
|
-
const orderBy = current;
|
|
41
|
-
comparators.unshift(makeComparator(orderBy.keySelector, orderBy.descending));
|
|
42
|
-
}
|
|
43
|
-
return comparators;
|
|
44
|
-
}
|
|
45
|
-
/** Walks to the root source (past all OrderBy/ThenBy) and materializes it. */
|
|
46
|
-
function materializeSource(node) {
|
|
47
|
-
let current = node;
|
|
48
|
-
while (current instanceof ThenByEnumerable) {
|
|
49
|
-
current = current.source;
|
|
50
|
-
}
|
|
51
|
-
if ("source" in current) {
|
|
52
|
-
return [...current.source];
|
|
53
|
-
}
|
|
54
|
-
return [...current];
|
|
55
|
-
}
|
|
56
|
-
function makeComparator(keySelector, descending) {
|
|
57
|
-
return (a, b) => {
|
|
58
|
-
const cmp = compareKeys(keySelector(a), keySelector(b));
|
|
59
|
-
return descending ? -cmp : cmp;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.ts";
|
|
2
|
-
/** Produces the set union of two sequences. Equivalent to C# .Union() */
|
|
3
|
-
export declare class UnionEnumerable<T> extends EnumerableBase<T> {
|
|
4
|
-
readonly source: EnumerableBase<T>;
|
|
5
|
-
readonly second: Iterable<T>;
|
|
6
|
-
constructor(source: EnumerableBase<T>, second: Iterable<T>);
|
|
7
|
-
[Symbol.iterator](): Iterator<T>;
|
|
8
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.js";
|
|
2
|
-
import { HashSet } from "../collections/hash-set.js";
|
|
3
|
-
/** Produces the set union of two sequences. Equivalent to C# .Union() */
|
|
4
|
-
export class UnionEnumerable extends EnumerableBase {
|
|
5
|
-
source;
|
|
6
|
-
second;
|
|
7
|
-
constructor(source, second) {
|
|
8
|
-
super();
|
|
9
|
-
this.source = source;
|
|
10
|
-
this.second = second;
|
|
11
|
-
}
|
|
12
|
-
*[Symbol.iterator]() {
|
|
13
|
-
const seen = new HashSet();
|
|
14
|
-
for (const item of this.source) {
|
|
15
|
-
if (!seen.has(item)) {
|
|
16
|
-
seen.add(item);
|
|
17
|
-
yield item;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
for (const item of this.second) {
|
|
21
|
-
if (!seen.has(item)) {
|
|
22
|
-
seen.add(item);
|
|
23
|
-
yield item;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.ts";
|
|
2
|
-
/** Filters elements based on a predicate. Equivalent to C# .Where() */
|
|
3
|
-
export declare class WhereEnumerable<T> extends EnumerableBase<T> {
|
|
4
|
-
readonly source: EnumerableBase<T>;
|
|
5
|
-
readonly predicate: (item: T, index: number) => boolean;
|
|
6
|
-
constructor(source: EnumerableBase<T>, predicate: (item: T, index: number) => boolean);
|
|
7
|
-
[Symbol.iterator](): Iterator<T>;
|
|
8
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.js";
|
|
2
|
-
/** Filters elements based on a predicate. Equivalent to C# .Where() */
|
|
3
|
-
export class WhereEnumerable extends EnumerableBase {
|
|
4
|
-
source;
|
|
5
|
-
predicate;
|
|
6
|
-
constructor(source, predicate) {
|
|
7
|
-
super();
|
|
8
|
-
this.source = source;
|
|
9
|
-
this.predicate = predicate;
|
|
10
|
-
}
|
|
11
|
-
*[Symbol.iterator]() {
|
|
12
|
-
let i = 0;
|
|
13
|
-
for (const item of this.source) {
|
|
14
|
-
if (this.predicate(item, i++))
|
|
15
|
-
yield item;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.ts";
|
|
2
|
-
/** Combines two sequences element-by-element using a result selector. Equivalent to C# .Zip() */
|
|
3
|
-
export declare class ZipEnumerable<T, U, R> extends EnumerableBase<R> {
|
|
4
|
-
readonly source: EnumerableBase<T>;
|
|
5
|
-
readonly second: Iterable<U>;
|
|
6
|
-
readonly resultSelector: (first: T, second: U) => R;
|
|
7
|
-
constructor(source: EnumerableBase<T>, second: Iterable<U>, resultSelector: (first: T, second: U) => R);
|
|
8
|
-
[Symbol.iterator](): Iterator<R>;
|
|
9
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { EnumerableBase } from "./enumerable-base.js";
|
|
2
|
-
/** Combines two sequences element-by-element using a result selector. Equivalent to C# .Zip() */
|
|
3
|
-
export class ZipEnumerable extends EnumerableBase {
|
|
4
|
-
source;
|
|
5
|
-
second;
|
|
6
|
-
resultSelector;
|
|
7
|
-
constructor(source, second, resultSelector) {
|
|
8
|
-
super();
|
|
9
|
-
this.source = source;
|
|
10
|
-
this.second = second;
|
|
11
|
-
this.resultSelector = resultSelector;
|
|
12
|
-
}
|
|
13
|
-
*[Symbol.iterator]() {
|
|
14
|
-
const iter1 = this.source[Symbol.iterator]();
|
|
15
|
-
const iter2 = this.second[Symbol.iterator]();
|
|
16
|
-
while (true) {
|
|
17
|
-
const a = iter1.next();
|
|
18
|
-
const b = iter2.next();
|
|
19
|
-
if (a.done || b.done)
|
|
20
|
-
break;
|
|
21
|
-
yield this.resultSelector(a.value, b.value);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|