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.
Files changed (47) hide show
  1. package/dist/asynchronous/collector.d.ts +231 -0
  2. package/dist/asynchronous/collector.js +800 -0
  3. package/dist/asynchronous/semantic.d.ts +257 -0
  4. package/dist/asynchronous/semantic.js +1853 -0
  5. package/dist/factory.d.ts +110 -32
  6. package/dist/factory.js +582 -189
  7. package/dist/guard.d.ts +24 -27
  8. package/dist/guard.js +37 -43
  9. package/dist/hook.d.ts +11 -7
  10. package/dist/hook.js +74 -21
  11. package/dist/index.d.ts +2 -3
  12. package/dist/index.js +2 -3
  13. package/dist/optional.d.ts +5 -5
  14. package/dist/optional.js +14 -10
  15. package/dist/symbol.d.ts +19 -23
  16. package/dist/symbol.js +19 -23
  17. package/dist/synchronous/collector.d.ts +232 -0
  18. package/dist/{collector.js → synchronous/collector.js} +160 -170
  19. package/dist/{collectable.d.ts → synchronous/semantic.d.ts} +114 -71
  20. package/dist/{collectable.js → synchronous/semantic.js} +761 -294
  21. package/dist/utility.d.ts +8 -2
  22. package/dist/utility.js +1 -0
  23. package/package.json +1 -1
  24. package/readme.cn.md +158 -697
  25. package/readme.de.md +163 -432
  26. package/readme.es.md +163 -433
  27. package/readme.fr.md +162 -444
  28. package/readme.jp.md +162 -442
  29. package/readme.kr.md +161 -430
  30. package/readme.md +157 -799
  31. package/readme.ru.md +161 -426
  32. package/readme.tw.md +161 -436
  33. package/dist/collector.d.ts +0 -245
  34. package/dist/map.d.ts +0 -76
  35. package/dist/map.js +0 -253
  36. package/dist/node.d.ts +0 -182
  37. package/dist/node.js +0 -918
  38. package/dist/semantic.d.ts +0 -52
  39. package/dist/semantic.js +0 -504
  40. package/dist/set.d.ts +0 -19
  41. package/dist/set.js +0 -65
  42. package/dist/statistics.d.ts +0 -97
  43. package/dist/statistics.js +0 -483
  44. package/dist/tree.d.ts +0 -82
  45. package/dist/tree.js +0 -257
  46. package/dist/window.d.ts +0 -12
  47. package/dist/window.js +0 -72
package/dist/guard.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- import type { Collectable, OrderedCollectable, Statistics, UnorderedCollectable, WindowCollectable } from "./collectable";
2
- import type { Collector } from "./collector";
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 { Semantic } from "./semantic";
7
- import type { HashSet } from "./set";
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 Iterable<unknown>;
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 isSemantic: (target: unknown) => target is Semantic<unknown>;
20
- export declare let isCollector: (target: unknown) => target is Collector<unknown, unknown, unknown>;
21
- export declare let isCollectable: (target: unknown) => target is Collectable<unknown>;
22
- export declare let isOrderedCollectable: (target: unknown) => target is OrderedCollectable<unknown>;
23
- export declare let isWindowCollectable: (target: unknown) => target is WindowCollectable<unknown>;
24
- export declare let isUnorderedCollectable: (target: unknown) => target is UnorderedCollectable<unknown>;
25
- export declare let isStatistics: (target: unknown) => target is Statistics<unknown, number | bigint>;
26
- export declare let isNumericStatistics: (target: unknown) => target is Statistics<unknown, number | bigint>;
27
- export declare let isBigIntStatistics: (target: unknown) => target is Statistics<unknown, number | bigint>;
28
- export declare let isSemanticMap: (target: unknown) => target is SemanticMap<unknown, unknown>;
29
- export declare let isHashMap: (target: unknown) => target is HashMap<unknown, unknown>;
30
- export declare let isHashSet: (target: unknown) => target is HashSet<unknown>;
31
- export declare let isNode: (target: unknown) => target is Node<unknown, any>;
32
- export declare let isLinearNode: (target: unknown) => target is LinearNode<unknown>;
33
- export declare let isBinaryNode: (target: unknown) => target is BinaryNode<unknown, any>;
34
- export declare let isRedBlackNode: (target: unknown) => target is BinaryNode<unknown, any>;
35
- export declare let isTree: (target: unknown) => target is Node<unknown, any>;
36
- export declare let isBinaryTree: (target: unknown) => target is Node<unknown, any>;
37
- export declare let isRedBlackTree: (target: unknown) => target is Node<unknown, any>;
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 { BigIntStatisticsSymbol, BinaryNodeSymbol, CollectableSymbol, CollectorsSymbol, LinearNodeSymbol, NodeSymbol, NumericStatisticsSymbol, OptionalSymbol, OrderedCollectableSymbol, RedBlackNodeSymbol, SemanticMapSymbol, SemanticSymbol, StatisticsSymbol, UnorderedCollectableSymbol, WindowCollectableSymbol } from "./symbol";
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 isSemantic = (target) => {
38
+ export let isAsynchronousSemantic = (target) => {
39
39
  if (isObject(target)) {
40
- return Reflect.get(target, "Semantic") === SemanticSymbol;
40
+ return Reflect.get(target, "AsynchronousSemantic") === AsynchronousSemanticSymbol;
41
41
  }
42
42
  return false;
43
43
  };
44
- export let isCollector = (target) => {
44
+ export let isSynchronousSemantic = (target) => {
45
45
  if (isObject(target)) {
46
- return Reflect.get(target, "Collector") === CollectorsSymbol;
46
+ return Reflect.get(target, "SynchronousSemantic") === SynchronousSemanticSymbol;
47
47
  }
48
48
  return false;
49
49
  };
50
- export let isCollectable = (target) => {
50
+ export let isAsynchronousCollectable = (target) => {
51
51
  if (isObject(target)) {
52
- return Reflect.get(target, "Collectable") === CollectableSymbol;
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 isOrderedCollectable = (target) => {
56
+ export let isSynchronousCollectable = (target) => {
57
57
  if (isObject(target)) {
58
- return Reflect.get(target, "OrderedCollectable") === OrderedCollectableSymbol;
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 isWindowCollectable = (target) => {
62
+ export let isAsynchronousOrderedCollectable = (target) => {
63
63
  if (isObject(target)) {
64
- return Reflect.get(target, "WindowCollectable") === WindowCollectableSymbol;
64
+ return Reflect.get(target, "AsynchronousOrderedCollectable") === AsynchronousOrderedCollectableSymbol;
65
65
  }
66
66
  return false;
67
67
  };
68
- export let isUnorderedCollectable = (target) => {
68
+ export let isSynchronousOrderedCollectable = (target) => {
69
69
  if (isObject(target)) {
70
- return Reflect.get(target, "UnorderedCollectable") === UnorderedCollectableSymbol;
70
+ return Reflect.get(target, "SynchronousOrderedCollectable") === SynchronousOrderedCollectableSymbol;
71
71
  }
72
72
  return false;
73
73
  };
74
- export let isStatistics = (target) => {
74
+ export let isAsynchronousUnorderedCollectable = (target) => {
75
75
  if (isObject(target)) {
76
- return Reflect.get(target, "Statistics") === StatisticsSymbol;
76
+ return Reflect.get(target, "AsynchronousUnorderedCollectable") === AsynchronousUnorderedCollectableSymbol;
77
77
  }
78
78
  return false;
79
79
  };
80
- export let isNumericStatistics = (target) => {
80
+ export let isSynchronousUnorderedCollectable = (target) => {
81
81
  if (isObject(target)) {
82
- return Reflect.get(target, "NumericStatistics") === NumericStatisticsSymbol;
82
+ return Reflect.get(target, "SynchronousUnorderedCollectable") === SynchronousUnorderedCollectableSymbol;
83
83
  }
84
84
  return false;
85
85
  };
86
- export let isBigIntStatistics = (target) => {
86
+ export let isAsynchronousStatistics = (target) => {
87
87
  if (isObject(target)) {
88
- return Reflect.get(target, "BigIntStatistics") === BigIntStatisticsSymbol;
88
+ return Reflect.get(target, "AsynchronousStatistics") === AsynchronousStatisticsSymbol;
89
89
  }
90
90
  return false;
91
91
  };
92
- export let isSemanticMap = (target) => {
92
+ export let isSynchronousStatistics = (target) => {
93
93
  if (isObject(target)) {
94
- return Reflect.get(target, "SemanticMap") === SemanticMapSymbol;
94
+ return Reflect.get(target, "SynchronousStatistics") === SynchronousStatisticsSymbol;
95
95
  }
96
96
  return false;
97
97
  };
98
- export let isHashMap = (target) => {
98
+ export let isAsynchronousBigIntStatistics = (target) => {
99
99
  if (isObject(target)) {
100
- return Reflect.get(target, "HashMap") === SemanticMapSymbol;
100
+ return Reflect.get(target, "AsynchronousBigIntStatistics") === AsynchronousBigIntStatisticsSymbol;
101
101
  }
102
102
  return false;
103
103
  };
104
- export let isHashSet = (target) => {
104
+ export let isSynchronousBigIntStatistics = (target) => {
105
105
  if (isObject(target)) {
106
- return false;
106
+ return Reflect.get(target, "SynchronousBigIntStatistics") === SynchronousBigIntStatisticsSymbol;
107
107
  }
108
108
  return false;
109
109
  };
110
- export let isNode = (target) => {
110
+ export let isAsynchronousNumericStatistics = (target) => {
111
111
  if (isObject(target)) {
112
- return Reflect.get(target, "Node") === NodeSymbol;
112
+ return Reflect.get(target, "AsynchronousBigIntStatistics") === AsynchronousNumericStatisticsSymbol;
113
113
  }
114
114
  return false;
115
115
  };
116
- export let isLinearNode = (target) => {
116
+ export let isSynchronousNumericStatistics = (target) => {
117
117
  if (isObject(target)) {
118
- return isNode(target) && Reflect.get(target, "LinearNode") === LinearNodeSymbol;
118
+ return Reflect.get(target, "AsynchronousNumericStatistics") === SynchronousNumericStatisticsSymbol;
119
119
  }
120
120
  return false;
121
121
  };
122
- export let isBinaryNode = (target) => {
122
+ export let isAsynchronousWindowCollectable = (target) => {
123
123
  if (isObject(target)) {
124
- return isNode(target) && Reflect.get(target, "BinaryNode") === BinaryNodeSymbol;
124
+ return Reflect.get(target, "AsynchronousWindowCollectable") === AsynchronousWindowCollectableSymbol;
125
125
  }
126
126
  return false;
127
127
  };
128
- export let isRedBlackNode = (target) => {
128
+ export let isSynchronousWindowCollectable = (target) => {
129
129
  if (isObject(target)) {
130
- return isBinaryNode(target) && Reflect.get(target, "RedBlackNode") === RedBlackNodeSymbol;
130
+ return Reflect.get(target, "SynchronousWindowCollectable") === SynchronousWindowCollectableSymbol;
131
131
  }
132
132
  return false;
133
133
  };
134
- export let isTree = (target) => {
134
+ export let isSynchronousCollector = (target) => {
135
135
  if (isObject(target)) {
136
- return isNode(target) && (isLinearNode(target) || isBinaryNode(target));
136
+ return Reflect.get(target, "SynchronousCollector") === SynchronousCollectorSymbol;
137
137
  }
138
138
  return false;
139
139
  };
140
- export let isBinaryTree = (target) => {
140
+ export let isAsynchronousCollector = (target) => {
141
141
  if (isObject(target)) {
142
- return isNode(target) && isBinaryNode(target);
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, Generator } from "./utility";
2
+ import type { Comparator, SynchronousGenerator } from "./utility";
3
3
  export declare let useCompare: <T>(t1: T, t2: T) => number;
4
- export declare let Useandom: <T = number | bigint>(index: T) => T;
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>) => Generator<E>;
23
+ export declare let useGenerator: <E>(iterable: Iterable<E>) => SynchronousGenerator<E>;
20
24
  interface UseArrange {
21
- <E>(source: Iterable<E>): Generator<E>;
22
- <E>(source: Iterable<E>, comparator: Comparator<E>): Generator<E>;
23
- <E>(source: Generator<E>): Generator<E>;
24
- <E>(source: Generator<E>, comparator: Comparator<E>): Generator<E>;
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 { useToArray } from "./collector";
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
- export let Useandom = (index) => {
48
- if (isNumber(index)) {
49
- let x = Number(index);
50
- let phi = (1 + Math.sqrt(5)) / 2;
51
- let vanDerCorput = (base, n) => {
52
- let result = 0;
53
- let f = 1 / base;
54
- let i = n;
55
- while (i > 0) {
56
- result += (i % base) * f;
57
- i = Math.floor(i / base);
58
- f = f / base;
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 input type");
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 = useToArray();
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 "./collectable";
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 "./collectable";
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";
@@ -1,12 +1,12 @@
1
- import type { Semantic } from "./semantic";
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(): Semantic<T>;
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 { empty, generate } from "./factory";
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
- return mapper(this.value);
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
- return mapper(this.value);
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 generate(() => {
86
- return this.value;
87
- }, () => {
88
- return this.isEmpty();
89
- });
93
+ return useOf(this.value);
90
94
  }
91
- return empty();
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 SemanticSymbol: symbol;
3
- export declare let CollectorsSymbol: symbol;
4
- export declare let CollectableSymbol: symbol;
5
- export declare let OrderedCollectableSymbol: symbol;
6
- export declare let WindowCollectableSymbol: symbol;
7
- export declare let StatisticsSymbol: symbol;
8
- export declare let NumericStatisticsSymbol: symbol;
9
- export declare let BigIntStatisticsSymbol: symbol;
10
- export declare let UnorderedCollectableSymbol: symbol;
11
- export declare let SemanticMapSymbol: symbol;
12
- export declare let HashMapSymbol: symbol;
13
- export declare let HashSetSymbol: symbol;
14
- export declare let TreeMapSymbol: symbol;
15
- export declare let TreeSetSymbol: symbol;
16
- export declare let NodeSymbol: symbol;
17
- export declare let LinearNodeSymbol: symbol;
18
- export declare let BinaryNodeSymbol: symbol;
19
- export declare let RedBlackNodeSymbol: symbol;
20
- export declare let AverageLevelNodeSymbol: symbol;
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 SemanticSymbol = Symbol.for("Semantic");
3
- export let CollectorsSymbol = Symbol.for("Collector");
4
- export let CollectableSymbol = Symbol.for("Collectable");
5
- export let OrderedCollectableSymbol = Symbol.for("OrderedCollectable");
6
- export let WindowCollectableSymbol = Symbol.for("WindowCollectable");
7
- export let StatisticsSymbol = Symbol.for("Statistics");
8
- export let NumericStatisticsSymbol = Symbol.for("NumericStatistics");
9
- export let BigIntStatisticsSymbol = Symbol.for("BigIntStatistics");
10
- export let UnorderedCollectableSymbol = Symbol.for("UnorderedCollectable");
11
- export let SemanticMapSymbol = Symbol.for("SemanticMap");
12
- export let HashMapSymbol = Symbol.for("HashMap");
13
- export let HashSetSymbol = Symbol.for("HashSet");
14
- export let TreeMapSymbol = Symbol.for("TreeMap");
15
- export let TreeSetSymbol = Symbol.for("TreeSet");
16
- export let NodeSymbol = Symbol.for("Node");
17
- export let LinearNodeSymbol = Symbol.for("LinearNode");
18
- export let BinaryNodeSymbol = Symbol.for("BinaryNode");
19
- export let RedBlackNodeSymbol = Symbol.for("RedBlackNode");
20
- export let AverageLevelNodeSymbol = Symbol.for("AverageLevelNode");
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");