semantic-typescript 0.5.0 → 0.6.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/asynchronous/collector.d.ts +231 -0
- package/dist/asynchronous/collector.js +800 -0
- package/dist/asynchronous/semantic.d.ts +257 -0
- package/dist/asynchronous/semantic.js +1853 -0
- package/dist/factory.d.ts +110 -32
- package/dist/factory.js +582 -189
- package/dist/guard.d.ts +24 -27
- package/dist/guard.js +37 -43
- package/dist/hook.d.ts +11 -7
- package/dist/hook.js +74 -21
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/optional.d.ts +5 -5
- package/dist/optional.js +14 -10
- package/dist/symbol.d.ts +19 -23
- package/dist/symbol.js +19 -23
- package/dist/synchronous/collector.d.ts +232 -0
- package/dist/{collector.js → synchronous/collector.js} +160 -170
- package/dist/{collectable.d.ts → synchronous/semantic.d.ts} +114 -71
- package/dist/{collectable.js → synchronous/semantic.js} +761 -294
- package/dist/utility.d.ts +8 -2
- package/dist/utility.js +1 -0
- package/package.json +1 -1
- package/readme.cn.md +158 -697
- package/readme.de.md +163 -432
- package/readme.es.md +163 -433
- package/readme.fr.md +162 -444
- package/readme.jp.md +162 -442
- package/readme.kr.md +161 -430
- package/readme.md +157 -799
- package/readme.ru.md +161 -426
- package/readme.tw.md +161 -436
- package/dist/collector.d.ts +0 -245
- package/dist/map.d.ts +0 -76
- package/dist/map.js +0 -253
- package/dist/node.d.ts +0 -182
- package/dist/node.js +0 -918
- package/dist/semantic.d.ts +0 -52
- package/dist/semantic.js +0 -504
- package/dist/set.d.ts +0 -19
- package/dist/set.js +0 -65
- package/dist/statistics.d.ts +0 -97
- package/dist/statistics.js +0 -483
- package/dist/tree.d.ts +0 -82
- package/dist/tree.js +0 -257
- package/dist/window.d.ts +0 -12
- package/dist/window.js +0 -72
package/dist/guard.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { HashMap, SemanticMap } from "./map";
|
|
4
|
-
import type { BinaryNode, LinearNode, Node } from "./node";
|
|
1
|
+
import type { AsynchronousCollector } from "./asynchronous/collector";
|
|
2
|
+
import type { AsynchronousBigIntStatistics, AsynchronousNumericStatistics, AsynchronousOrderedCollectable, AsynchronousSemantic, AsynchronousStatistics, AsynchronousUnorderedCollectable, AsynchronousWindowCollectable } from "./asynchronous/semantic";
|
|
5
3
|
import type { Optional } from "./optional";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
4
|
+
import type { SynchronousCollector } from "./synchronous/collector";
|
|
5
|
+
import type { SynchronousBigIntStatistics, SynchronousNumericStatistics, SynchronousOrderedCollectable, SynchronousSemantic, SynchronousStatistics, SynchronousUnorderedCollectable, SynchronousWindowCollectable } from "./synchronous/semantic";
|
|
8
6
|
import type { AsyncFunction, MaybePrimitive, Primitive } from "./utility";
|
|
9
7
|
export declare let isBoolean: (target: unknown) => target is boolean;
|
|
10
8
|
export declare let isString: (target: unknown) => target is string;
|
|
@@ -14,28 +12,27 @@ export declare let isObject: (target: unknown) => target is object;
|
|
|
14
12
|
export declare let isSymbol: (target: unknown) => target is symbol;
|
|
15
13
|
export declare let isBigInt: (target: unknown) => target is bigint;
|
|
16
14
|
export declare let isPrimitive: (target: MaybePrimitive<unknown>) => target is Primitive;
|
|
17
|
-
export declare let isAsyncIterable: (target: unknown) => target is
|
|
15
|
+
export declare let isAsyncIterable: (target: unknown) => target is AsyncIterable<unknown>;
|
|
18
16
|
export declare let isIterable: (target: unknown) => target is Iterable<unknown>;
|
|
19
|
-
export declare let
|
|
20
|
-
export declare let
|
|
21
|
-
export declare let
|
|
22
|
-
export declare let
|
|
23
|
-
export declare let
|
|
24
|
-
export declare let
|
|
25
|
-
export declare let
|
|
26
|
-
export declare let
|
|
27
|
-
export declare let
|
|
28
|
-
export declare let
|
|
29
|
-
export declare let
|
|
30
|
-
export declare let
|
|
31
|
-
export declare let
|
|
32
|
-
export declare let
|
|
33
|
-
export declare let
|
|
34
|
-
export declare let
|
|
35
|
-
export declare let
|
|
36
|
-
export declare let
|
|
37
|
-
export declare let
|
|
38
|
-
export declare let isOptional: <T>(target: unknown) => target is Optional<T>;
|
|
17
|
+
export declare let isAsynchronousSemantic: (target: unknown) => target is AsynchronousSemantic<unknown>;
|
|
18
|
+
export declare let isSynchronousSemantic: (target: unknown) => target is SynchronousSemantic<unknown>;
|
|
19
|
+
export declare let isAsynchronousCollectable: (target: unknown) => target is AsynchronousSemantic<unknown>;
|
|
20
|
+
export declare let isSynchronousCollectable: (target: unknown) => target is SynchronousSemantic<unknown>;
|
|
21
|
+
export declare let isAsynchronousOrderedCollectable: (target: unknown) => target is AsynchronousOrderedCollectable<unknown>;
|
|
22
|
+
export declare let isSynchronousOrderedCollectable: (target: unknown) => target is SynchronousOrderedCollectable<unknown>;
|
|
23
|
+
export declare let isAsynchronousUnorderedCollectable: (target: unknown) => target is AsynchronousUnorderedCollectable<unknown>;
|
|
24
|
+
export declare let isSynchronousUnorderedCollectable: (target: unknown) => target is SynchronousUnorderedCollectable<unknown>;
|
|
25
|
+
export declare let isAsynchronousStatistics: (target: unknown) => target is AsynchronousStatistics<unknown, number | bigint>;
|
|
26
|
+
export declare let isSynchronousStatistics: (target: unknown) => target is SynchronousStatistics<unknown, number | bigint>;
|
|
27
|
+
export declare let isAsynchronousBigIntStatistics: (target: unknown) => target is AsynchronousBigIntStatistics<unknown>;
|
|
28
|
+
export declare let isSynchronousBigIntStatistics: (target: unknown) => target is SynchronousBigIntStatistics<unknown>;
|
|
29
|
+
export declare let isAsynchronousNumericStatistics: (target: unknown) => target is AsynchronousNumericStatistics<unknown>;
|
|
30
|
+
export declare let isSynchronousNumericStatistics: (target: unknown) => target is SynchronousNumericStatistics<unknown>;
|
|
31
|
+
export declare let isAsynchronousWindowCollectable: (target: unknown) => target is AsynchronousWindowCollectable<unknown>;
|
|
32
|
+
export declare let isSynchronousWindowCollectable: (target: unknown) => target is SynchronousWindowCollectable<unknown>;
|
|
33
|
+
export declare let isSynchronousCollector: (target: unknown) => target is SynchronousCollector<unknown, unknown, unknown>;
|
|
34
|
+
export declare let isAsynchronousCollector: (target: unknown) => target is AsynchronousCollector<unknown, unknown, unknown>;
|
|
35
|
+
export declare let isOptional: (target: unknown) => target is Optional<unknown>;
|
|
39
36
|
export declare let isPromise: (target: unknown) => target is Promise<unknown>;
|
|
40
37
|
export declare let isAsyncFunction: (target: unknown) => target is AsyncFunction;
|
|
41
38
|
export declare let isGeneratorFunction: (target: unknown) => target is Generator<unknown, unknown, unknown>;
|
package/dist/guard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AsynchronousBigIntStatisticsSymbol, AsynchronousCollectorSymbol, AsynchronousNumericStatisticsSymbol, AsynchronousOrderedCollectableSymbol, AsynchronousSemanticSymbol, AsynchronousStatisticsSymbol, AsynchronousUnorderedCollectableSymbol, AsynchronousWindowCollectableSymbol, OptionalSymbol, SynchronousBigIntStatisticsSymbol, SynchronousCollectorSymbol, SynchronousNumericStatisticsSymbol, SynchronousOrderedCollectableSymbol, SynchronousSemanticSymbol, SynchronousStatisticsSymbol, SynchronousUnorderedCollectableSymbol, SynchronousWindowCollectableSymbol } from "./symbol";
|
|
2
2
|
export let isBoolean = (target) => {
|
|
3
3
|
return typeof target === "boolean";
|
|
4
4
|
};
|
|
@@ -35,117 +35,111 @@ export let isIterable = (target) => {
|
|
|
35
35
|
}
|
|
36
36
|
return false;
|
|
37
37
|
};
|
|
38
|
-
export let
|
|
38
|
+
export let isAsynchronousSemantic = (target) => {
|
|
39
39
|
if (isObject(target)) {
|
|
40
|
-
return Reflect.get(target, "
|
|
40
|
+
return Reflect.get(target, "AsynchronousSemantic") === AsynchronousSemanticSymbol;
|
|
41
41
|
}
|
|
42
42
|
return false;
|
|
43
43
|
};
|
|
44
|
-
export let
|
|
44
|
+
export let isSynchronousSemantic = (target) => {
|
|
45
45
|
if (isObject(target)) {
|
|
46
|
-
return Reflect.get(target, "
|
|
46
|
+
return Reflect.get(target, "SynchronousSemantic") === SynchronousSemanticSymbol;
|
|
47
47
|
}
|
|
48
48
|
return false;
|
|
49
49
|
};
|
|
50
|
-
export let
|
|
50
|
+
export let isAsynchronousCollectable = (target) => {
|
|
51
51
|
if (isObject(target)) {
|
|
52
|
-
return Reflect.get(target, "
|
|
52
|
+
return Reflect.get(target, "AsynchronousCollectable") === AsynchronousSemanticSymbol || isAsynchronousSemantic(target) || isAsynchronousOrderedCollectable(target) || isAsynchronousUnorderedCollectable(target) || isAsynchronousStatistics(target) || isAsynchronousNumericStatistics(target) || isAsynchronousBigIntStatistics(target) || isAsynchronousWindowCollectable(target);
|
|
53
53
|
}
|
|
54
54
|
return false;
|
|
55
55
|
};
|
|
56
|
-
export let
|
|
56
|
+
export let isSynchronousCollectable = (target) => {
|
|
57
57
|
if (isObject(target)) {
|
|
58
|
-
return Reflect.get(target, "
|
|
58
|
+
return Reflect.get(target, "SynchronousCollectable") === SynchronousSemanticSymbol || isSynchronousSemantic(target) || isSynchronousOrderedCollectable(target) || isSynchronousUnorderedCollectable(target) || isSynchronousStatistics(target) || isSynchronousNumericStatistics(target) || isSynchronousBigIntStatistics(target) || isSynchronousWindowCollectable(target);
|
|
59
59
|
}
|
|
60
60
|
return false;
|
|
61
61
|
};
|
|
62
|
-
export let
|
|
62
|
+
export let isAsynchronousOrderedCollectable = (target) => {
|
|
63
63
|
if (isObject(target)) {
|
|
64
|
-
return Reflect.get(target, "
|
|
64
|
+
return Reflect.get(target, "AsynchronousOrderedCollectable") === AsynchronousOrderedCollectableSymbol;
|
|
65
65
|
}
|
|
66
66
|
return false;
|
|
67
67
|
};
|
|
68
|
-
export let
|
|
68
|
+
export let isSynchronousOrderedCollectable = (target) => {
|
|
69
69
|
if (isObject(target)) {
|
|
70
|
-
return Reflect.get(target, "
|
|
70
|
+
return Reflect.get(target, "SynchronousOrderedCollectable") === SynchronousOrderedCollectableSymbol;
|
|
71
71
|
}
|
|
72
72
|
return false;
|
|
73
73
|
};
|
|
74
|
-
export let
|
|
74
|
+
export let isAsynchronousUnorderedCollectable = (target) => {
|
|
75
75
|
if (isObject(target)) {
|
|
76
|
-
return Reflect.get(target, "
|
|
76
|
+
return Reflect.get(target, "AsynchronousUnorderedCollectable") === AsynchronousUnorderedCollectableSymbol;
|
|
77
77
|
}
|
|
78
78
|
return false;
|
|
79
79
|
};
|
|
80
|
-
export let
|
|
80
|
+
export let isSynchronousUnorderedCollectable = (target) => {
|
|
81
81
|
if (isObject(target)) {
|
|
82
|
-
return Reflect.get(target, "
|
|
82
|
+
return Reflect.get(target, "SynchronousUnorderedCollectable") === SynchronousUnorderedCollectableSymbol;
|
|
83
83
|
}
|
|
84
84
|
return false;
|
|
85
85
|
};
|
|
86
|
-
export let
|
|
86
|
+
export let isAsynchronousStatistics = (target) => {
|
|
87
87
|
if (isObject(target)) {
|
|
88
|
-
return Reflect.get(target, "
|
|
88
|
+
return Reflect.get(target, "AsynchronousStatistics") === AsynchronousStatisticsSymbol;
|
|
89
89
|
}
|
|
90
90
|
return false;
|
|
91
91
|
};
|
|
92
|
-
export let
|
|
92
|
+
export let isSynchronousStatistics = (target) => {
|
|
93
93
|
if (isObject(target)) {
|
|
94
|
-
return Reflect.get(target, "
|
|
94
|
+
return Reflect.get(target, "SynchronousStatistics") === SynchronousStatisticsSymbol;
|
|
95
95
|
}
|
|
96
96
|
return false;
|
|
97
97
|
};
|
|
98
|
-
export let
|
|
98
|
+
export let isAsynchronousBigIntStatistics = (target) => {
|
|
99
99
|
if (isObject(target)) {
|
|
100
|
-
return Reflect.get(target, "
|
|
100
|
+
return Reflect.get(target, "AsynchronousBigIntStatistics") === AsynchronousBigIntStatisticsSymbol;
|
|
101
101
|
}
|
|
102
102
|
return false;
|
|
103
103
|
};
|
|
104
|
-
export let
|
|
104
|
+
export let isSynchronousBigIntStatistics = (target) => {
|
|
105
105
|
if (isObject(target)) {
|
|
106
|
-
return
|
|
106
|
+
return Reflect.get(target, "SynchronousBigIntStatistics") === SynchronousBigIntStatisticsSymbol;
|
|
107
107
|
}
|
|
108
108
|
return false;
|
|
109
109
|
};
|
|
110
|
-
export let
|
|
110
|
+
export let isAsynchronousNumericStatistics = (target) => {
|
|
111
111
|
if (isObject(target)) {
|
|
112
|
-
return Reflect.get(target, "
|
|
112
|
+
return Reflect.get(target, "AsynchronousBigIntStatistics") === AsynchronousNumericStatisticsSymbol;
|
|
113
113
|
}
|
|
114
114
|
return false;
|
|
115
115
|
};
|
|
116
|
-
export let
|
|
116
|
+
export let isSynchronousNumericStatistics = (target) => {
|
|
117
117
|
if (isObject(target)) {
|
|
118
|
-
return
|
|
118
|
+
return Reflect.get(target, "AsynchronousNumericStatistics") === SynchronousNumericStatisticsSymbol;
|
|
119
119
|
}
|
|
120
120
|
return false;
|
|
121
121
|
};
|
|
122
|
-
export let
|
|
122
|
+
export let isAsynchronousWindowCollectable = (target) => {
|
|
123
123
|
if (isObject(target)) {
|
|
124
|
-
return
|
|
124
|
+
return Reflect.get(target, "AsynchronousWindowCollectable") === AsynchronousWindowCollectableSymbol;
|
|
125
125
|
}
|
|
126
126
|
return false;
|
|
127
127
|
};
|
|
128
|
-
export let
|
|
128
|
+
export let isSynchronousWindowCollectable = (target) => {
|
|
129
129
|
if (isObject(target)) {
|
|
130
|
-
return
|
|
130
|
+
return Reflect.get(target, "SynchronousWindowCollectable") === SynchronousWindowCollectableSymbol;
|
|
131
131
|
}
|
|
132
132
|
return false;
|
|
133
133
|
};
|
|
134
|
-
export let
|
|
134
|
+
export let isSynchronousCollector = (target) => {
|
|
135
135
|
if (isObject(target)) {
|
|
136
|
-
return
|
|
136
|
+
return Reflect.get(target, "SynchronousCollector") === SynchronousCollectorSymbol;
|
|
137
137
|
}
|
|
138
138
|
return false;
|
|
139
139
|
};
|
|
140
|
-
export let
|
|
140
|
+
export let isAsynchronousCollector = (target) => {
|
|
141
141
|
if (isObject(target)) {
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
return false;
|
|
145
|
-
};
|
|
146
|
-
export let isRedBlackTree = (target) => {
|
|
147
|
-
if (isObject(target)) {
|
|
148
|
-
return isNode(target) && isRedBlackNode(target);
|
|
142
|
+
return Reflect.get(target, "AsynchronousCollector") === AsynchronousCollectorSymbol;
|
|
149
143
|
}
|
|
150
144
|
return false;
|
|
151
145
|
};
|
package/dist/hook.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type DeepPropertyKey, type DeepPropertyValue } from "./utility";
|
|
2
|
-
import type { Comparator,
|
|
2
|
+
import type { Comparator, SynchronousGenerator } from "./utility";
|
|
3
3
|
export declare let useCompare: <T>(t1: T, t2: T) => number;
|
|
4
|
-
|
|
4
|
+
interface UseRandom {
|
|
5
|
+
<N extends number | bigint>(start: N): N extends number ? number : (N extends bigint ? bigint : never);
|
|
6
|
+
<N extends number | bigint>(start: N, end: N): N;
|
|
7
|
+
}
|
|
8
|
+
export declare let useRandom: UseRandom;
|
|
5
9
|
export type UseTraverseKey<T extends object> = DeepPropertyKey<T> & (symbol | string | number);
|
|
6
10
|
export type UseTraverseValue<T extends object> = DeepPropertyValue<T>;
|
|
7
11
|
export type UseTraversePath<T extends object> = Array<UseTraverseKey<T> & (symbol | string | number)>;
|
|
@@ -16,12 +20,12 @@ interface UseTraverse {
|
|
|
16
20
|
<T extends object>(t: T, callback: UseTraversePathCallback<T>): void;
|
|
17
21
|
}
|
|
18
22
|
export declare let useTraverse: UseTraverse;
|
|
19
|
-
export declare let useGenerator: <E>(iterable: Iterable<E>) =>
|
|
23
|
+
export declare let useGenerator: <E>(iterable: Iterable<E>) => SynchronousGenerator<E>;
|
|
20
24
|
interface UseArrange {
|
|
21
|
-
<E>(source: Iterable<E>):
|
|
22
|
-
<E>(source: Iterable<E>, comparator: Comparator<E>):
|
|
23
|
-
<E>(source:
|
|
24
|
-
<E>(source:
|
|
25
|
+
<E>(source: Iterable<E>): SynchronousGenerator<E>;
|
|
26
|
+
<E>(source: Iterable<E>, comparator: Comparator<E>): SynchronousGenerator<E>;
|
|
27
|
+
<E>(source: SynchronousGenerator<E>): SynchronousGenerator<E>;
|
|
28
|
+
<E>(source: SynchronousGenerator<E>, comparator: Comparator<E>): SynchronousGenerator<E>;
|
|
25
29
|
}
|
|
26
30
|
export declare let useArrange: UseArrange;
|
|
27
31
|
export declare let useToNumber: <T = unknown>(target: T) => number;
|
package/dist/hook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSynchronousToArray } from "./synchronous/collector";
|
|
2
2
|
import { isBigInt, isFunction, isIterable, isNumber, isObject, isPrimitive } from "./guard";
|
|
3
3
|
import { invalidate, validate } from "./utility";
|
|
4
4
|
export let useCompare = (t1, t2) => {
|
|
@@ -44,28 +44,81 @@ export let useCompare = (t1, t2) => {
|
|
|
44
44
|
}
|
|
45
45
|
throw new TypeError("Cannot compare values of different types.");
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
let
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
;
|
|
48
|
+
export let useRandom = (start, end) => {
|
|
49
|
+
let getRandomBits = () => {
|
|
50
|
+
let random = Math.random();
|
|
51
|
+
let full = random * 0x10000000000000;
|
|
52
|
+
let high = Math.floor(full / 0x100000000);
|
|
53
|
+
let low = Math.floor(full) & 0xFFFFFFFF;
|
|
54
|
+
return [high, low];
|
|
55
|
+
};
|
|
56
|
+
let getRandomBigInt = () => {
|
|
57
|
+
let [h1, l1] = getRandomBits();
|
|
58
|
+
let [h2, l2] = getRandomBits();
|
|
59
|
+
let [h3, l3] = getRandomBits();
|
|
60
|
+
return ((BigInt(h1) << 84n) | (BigInt(l1) << 52n) | (BigInt(h2) << 32n) | (BigInt(l2) << 3n) | (BigInt(h3) << 116n)) | (BigInt(l3) << 80n);
|
|
61
|
+
};
|
|
62
|
+
if (isNumber(start)) {
|
|
63
|
+
let seed = Math.random();
|
|
64
|
+
if (isNumber(end)) {
|
|
65
|
+
let minimum = Math.min(start, end);
|
|
66
|
+
let maximum = Math.max(start, end);
|
|
67
|
+
let range = maximum - minimum;
|
|
68
|
+
return (minimum + seed * range);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return Math.exp(-seed);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (isBigInt(start)) {
|
|
75
|
+
let randomBigInt = getRandomBigInt();
|
|
76
|
+
if (isBigInt(end)) {
|
|
77
|
+
let minimum = start < end ? start : end;
|
|
78
|
+
let maximum = start < end ? end : start;
|
|
79
|
+
let range = maximum - minimum;
|
|
80
|
+
if (range === 0n) {
|
|
81
|
+
return minimum;
|
|
82
|
+
}
|
|
83
|
+
let mask = range;
|
|
84
|
+
mask |= mask >> 1n;
|
|
85
|
+
mask |= mask >> 2n;
|
|
86
|
+
mask |= mask >> 4n;
|
|
87
|
+
mask |= mask >> 8n;
|
|
88
|
+
mask |= mask >> 16n;
|
|
89
|
+
mask |= mask >> 32n;
|
|
90
|
+
mask |= mask >> 64n;
|
|
91
|
+
let result;
|
|
92
|
+
do {
|
|
93
|
+
let raw = randomBigInt & mask;
|
|
94
|
+
result = raw;
|
|
95
|
+
result ^= result >> 17n;
|
|
96
|
+
result *= 0xed5ad4bbn;
|
|
97
|
+
result ^= result >> 11n;
|
|
98
|
+
result *= 0xac4c1b51n;
|
|
99
|
+
result ^= result >> 15n;
|
|
100
|
+
result *= 0x31848babn;
|
|
101
|
+
result ^= result >> 14n;
|
|
102
|
+
} while (result >= range);
|
|
103
|
+
return (minimum + result);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
let seed = Math.random();
|
|
107
|
+
let expValue = Math.exp(-seed);
|
|
108
|
+
let normalized = expValue / Math.E;
|
|
109
|
+
let [high, low] = getRandomBits();
|
|
110
|
+
let adjusted = BigInt(Math.floor(normalized * 0xFFFFFFFF)) << 32n;
|
|
111
|
+
let result = (adjusted | BigInt(low)) ^ BigInt(high);
|
|
112
|
+
if (start <= 0n) {
|
|
113
|
+
return 0n;
|
|
114
|
+
}
|
|
115
|
+
if (result >= start) {
|
|
116
|
+
result = result % start;
|
|
59
117
|
}
|
|
60
118
|
return result;
|
|
61
|
-
}
|
|
62
|
-
let h = vanDerCorput(2, x) + vanDerCorput(3, x);
|
|
63
|
-
let golden = (x * phi) % 1;
|
|
64
|
-
let lcg = (1103515245 * x + 12345) % 2147483648;
|
|
65
|
-
let mixed = (h * 0.5 + golden * 0.3 + lcg / 2147483648 * 0.2);
|
|
66
|
-
return (mixed * 1000000);
|
|
119
|
+
}
|
|
67
120
|
}
|
|
68
|
-
throw new TypeError("Invalid
|
|
121
|
+
throw new TypeError("Invalid arguments.");
|
|
69
122
|
};
|
|
70
123
|
;
|
|
71
124
|
;
|
|
@@ -157,7 +210,7 @@ export let useArrange = (source, comparator) => {
|
|
|
157
210
|
}
|
|
158
211
|
}
|
|
159
212
|
else if (isFunction(source)) {
|
|
160
|
-
let collector =
|
|
213
|
+
let collector = useSynchronousToArray();
|
|
161
214
|
let buffer = collector.collect(source);
|
|
162
215
|
if (validate(comparator) && isFunction(comparator)) {
|
|
163
216
|
return useGenerator(buffer.sort(comparator));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./collector";
|
|
1
|
+
export * from "./asynchronous/collector";
|
|
2
|
+
export * from "./synchronous/collector";
|
|
3
3
|
export * from "./factory";
|
|
4
4
|
export * from "./guard";
|
|
5
5
|
export * from "./hook";
|
|
6
6
|
export * from "./optional";
|
|
7
|
-
export * from "./semantic";
|
|
8
7
|
export * from "./symbol";
|
|
9
8
|
export * from "./utility";
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./collector";
|
|
1
|
+
export * from "./asynchronous/collector";
|
|
2
|
+
export * from "./synchronous/collector";
|
|
3
3
|
export * from "./factory";
|
|
4
4
|
export * from "./guard";
|
|
5
5
|
export * from "./hook";
|
|
6
6
|
export * from "./optional";
|
|
7
|
-
export * from "./semantic";
|
|
8
7
|
export * from "./symbol";
|
|
9
8
|
export * from "./utility";
|
package/dist/optional.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type Consumer, type Functional, type MaybeInvalid, type Predicate, type Runnable } from "./utility";
|
|
1
|
+
import type { SynchronousSemantic } from "./synchronous/semantic";
|
|
2
|
+
import { type Consumer, type Functional, type MaybeInvalid, type Predicate, type Runnable, type Valid } from "./utility";
|
|
3
3
|
export declare class Optional<T> {
|
|
4
4
|
protected value: MaybeInvalid<T>;
|
|
5
5
|
protected readonly Optional: Symbol;
|
|
6
6
|
protected constructor(value: MaybeInvalid<T>);
|
|
7
7
|
filter(predicate: Predicate<T>): Optional<T>;
|
|
8
|
-
get(): T
|
|
9
|
-
get(defaultValue: T): T
|
|
8
|
+
get(): Valid<T>;
|
|
9
|
+
get(defaultValue: T): Valid<T>;
|
|
10
10
|
ifPresent(action: Consumer<T>): void;
|
|
11
11
|
ifPresent(action: Consumer<T>, elseAction: Runnable): void;
|
|
12
12
|
isEmpty(): boolean;
|
|
@@ -15,7 +15,7 @@ export declare class Optional<T> {
|
|
|
15
15
|
flat(mapper: Functional<T, Optional<T>>): Optional<T>;
|
|
16
16
|
flatMap<R>(mapper: Functional<T, Optional<R>>): Optional<R>;
|
|
17
17
|
orElse(other: MaybeInvalid<T>): MaybeInvalid<T>;
|
|
18
|
-
semantic():
|
|
18
|
+
semantic(): SynchronousSemantic<T>;
|
|
19
19
|
static empty<T>(): Optional<T>;
|
|
20
20
|
static of<T>(value: MaybeInvalid<T>): Optional<T>;
|
|
21
21
|
static ofNullable<T>(value?: MaybeInvalid<T>): Optional<T>;
|
package/dist/optional.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isFunction } from "./guard";
|
|
1
|
+
import { useEmpty, useOf } from "./factory";
|
|
2
|
+
import { isFunction, isOptional } from "./guard";
|
|
3
3
|
import { OptionalSymbol } from "./symbol";
|
|
4
4
|
import { invalidate, validate } from "./utility";
|
|
5
5
|
export class Optional {
|
|
@@ -64,13 +64,21 @@ export class Optional {
|
|
|
64
64
|
}
|
|
65
65
|
flat(mapper) {
|
|
66
66
|
if (this.isPresent() && isFunction(mapper)) {
|
|
67
|
-
|
|
67
|
+
let result = mapper(this.value);
|
|
68
|
+
if (isOptional(result)) {
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
throw new TypeError("Must return an Optional.");
|
|
68
72
|
}
|
|
69
73
|
return new Optional(null);
|
|
70
74
|
}
|
|
71
75
|
flatMap(mapper) {
|
|
72
76
|
if (this.isPresent() && isFunction(mapper)) {
|
|
73
|
-
|
|
77
|
+
let result = mapper(this.value);
|
|
78
|
+
if (isOptional(result)) {
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
throw new TypeError("Must return an Optional.");
|
|
74
82
|
}
|
|
75
83
|
return new Optional(null);
|
|
76
84
|
}
|
|
@@ -82,13 +90,9 @@ export class Optional {
|
|
|
82
90
|
}
|
|
83
91
|
semantic() {
|
|
84
92
|
if (this.isPresent()) {
|
|
85
|
-
return
|
|
86
|
-
return this.value;
|
|
87
|
-
}, () => {
|
|
88
|
-
return this.isEmpty();
|
|
89
|
-
});
|
|
93
|
+
return useOf(this.value);
|
|
90
94
|
}
|
|
91
|
-
return
|
|
95
|
+
return useEmpty();
|
|
92
96
|
}
|
|
93
97
|
static empty() {
|
|
94
98
|
return new Optional(null);
|
package/dist/symbol.d.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
export declare let OptionalSymbol: symbol;
|
|
2
|
-
export declare let
|
|
3
|
-
export declare let
|
|
4
|
-
export declare let
|
|
5
|
-
export declare let
|
|
6
|
-
export declare let
|
|
7
|
-
export declare let
|
|
8
|
-
export declare let
|
|
9
|
-
export declare let
|
|
10
|
-
export declare let
|
|
11
|
-
export declare let
|
|
12
|
-
export declare let
|
|
13
|
-
export declare let
|
|
14
|
-
export declare let
|
|
15
|
-
export declare let
|
|
16
|
-
export declare let
|
|
17
|
-
export declare let
|
|
18
|
-
export declare let
|
|
19
|
-
export declare let
|
|
20
|
-
export declare let
|
|
21
|
-
export declare let TreeSymbol: symbol;
|
|
22
|
-
export declare let BinaryTreeSymbol: symbol;
|
|
23
|
-
export declare let RedBlackTreeSymbol: symbol;
|
|
24
|
-
export declare let AVLTreeSymbol: symbol;
|
|
2
|
+
export declare let AsynchronousSemanticSymbol: symbol;
|
|
3
|
+
export declare let SynchronousSemanticSymbol: symbol;
|
|
4
|
+
export declare let AsynchronousCollectorSymbol: symbol;
|
|
5
|
+
export declare let SynchronousCollectorSymbol: symbol;
|
|
6
|
+
export declare let DispatchCollectableSymbol: symbol;
|
|
7
|
+
export declare let AsynchronousCollectableSymbol: symbol;
|
|
8
|
+
export declare let SynchronousCollectableSymbol: symbol;
|
|
9
|
+
export declare let AsynchronousOrderedCollectableSymbol: symbol;
|
|
10
|
+
export declare let SynchronousOrderedCollectableSymbol: symbol;
|
|
11
|
+
export declare let AsynchronousUnorderedCollectableSymbol: symbol;
|
|
12
|
+
export declare let SynchronousUnorderedCollectableSymbol: symbol;
|
|
13
|
+
export declare let AsynchronousWindowCollectableSymbol: symbol;
|
|
14
|
+
export declare let SynchronousWindowCollectableSymbol: symbol;
|
|
15
|
+
export declare let AsynchronousStatisticsSymbol: symbol;
|
|
16
|
+
export declare let SynchronousStatisticsSymbol: symbol;
|
|
17
|
+
export declare let AsynchronousNumericStatisticsSymbol: symbol;
|
|
18
|
+
export declare let SynchronousNumericStatisticsSymbol: symbol;
|
|
19
|
+
export declare let AsynchronousBigIntStatisticsSymbol: symbol;
|
|
20
|
+
export declare let SynchronousBigIntStatisticsSymbol: symbol;
|
package/dist/symbol.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
export let OptionalSymbol = Symbol.for("Optional");
|
|
2
|
-
export let
|
|
3
|
-
export let
|
|
4
|
-
export let
|
|
5
|
-
export let
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
export let
|
|
17
|
-
export let
|
|
18
|
-
export let
|
|
19
|
-
export let
|
|
20
|
-
export let
|
|
21
|
-
export let TreeSymbol = Symbol.for("Tree");
|
|
22
|
-
export let BinaryTreeSymbol = Symbol.for("BinaryTree");
|
|
23
|
-
export let RedBlackTreeSymbol = Symbol.for("RedBlackTree");
|
|
24
|
-
export let AVLTreeSymbol = Symbol.for("AVLTree");
|
|
2
|
+
export let AsynchronousSemanticSymbol = Symbol.for("AsynchronousSemantic");
|
|
3
|
+
export let SynchronousSemanticSymbol = Symbol.for("SynchronousSemantic");
|
|
4
|
+
export let AsynchronousCollectorSymbol = Symbol.for("AsynchronousCollector");
|
|
5
|
+
export let SynchronousCollectorSymbol = Symbol.for("SynchronousCollector");
|
|
6
|
+
export let DispatchCollectableSymbol = Symbol.for("DispatchCollectable");
|
|
7
|
+
export let AsynchronousCollectableSymbol = Symbol.for("AsynchronousCollectable");
|
|
8
|
+
export let SynchronousCollectableSymbol = Symbol.for("SynchronousCollectable");
|
|
9
|
+
export let AsynchronousOrderedCollectableSymbol = Symbol.for("OrderedAsynchronousCollectable");
|
|
10
|
+
export let SynchronousOrderedCollectableSymbol = Symbol.for("OrderedSynchronousCollectable");
|
|
11
|
+
export let AsynchronousUnorderedCollectableSymbol = Symbol.for("AsynchronousUnorderedCollectable");
|
|
12
|
+
export let SynchronousUnorderedCollectableSymbol = Symbol.for("SynchronousUnorderedCollectable");
|
|
13
|
+
export let AsynchronousWindowCollectableSymbol = Symbol.for("AsynchronousWindowCollectable");
|
|
14
|
+
export let SynchronousWindowCollectableSymbol = Symbol.for("SynchronousWindowCollectable");
|
|
15
|
+
export let AsynchronousStatisticsSymbol = Symbol.for("AsynchronousStatistics");
|
|
16
|
+
export let SynchronousStatisticsSymbol = Symbol.for("AsynchronousStatistics");
|
|
17
|
+
export let AsynchronousNumericStatisticsSymbol = Symbol.for("AsynchronousNumericStatistics");
|
|
18
|
+
export let SynchronousNumericStatisticsSymbol = Symbol.for("SynchronousNumericStatisticsSymbol");
|
|
19
|
+
export let AsynchronousBigIntStatisticsSymbol = Symbol.for("AsynchronousBigIntStatistics");
|
|
20
|
+
export let SynchronousBigIntStatisticsSymbol = Symbol.for("SynchronousBigIntStatisticsSymbol");
|