@glutinum/cli 0.4.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 (173) hide show
  1. package/README.md +74 -7
  2. package/dist/Glutinum.Converter/FsharpAST.js +152 -20
  3. package/dist/Glutinum.Converter/FsharpAST.js.map +1 -1
  4. package/dist/Glutinum.Converter/Generate.js +17 -5
  5. package/dist/Glutinum.Converter/Generate.js.map +1 -1
  6. package/dist/Glutinum.Converter/GlueAST.js +110 -17
  7. package/dist/Glutinum.Converter/GlueAST.js.map +1 -1
  8. package/dist/Glutinum.Converter/Log.js +9 -5
  9. package/dist/Glutinum.Converter/Log.js.map +1 -1
  10. package/dist/Glutinum.Converter/Printer.js +486 -132
  11. package/dist/Glutinum.Converter/Printer.js.map +1 -1
  12. package/dist/Glutinum.Converter/Read.js +8 -5
  13. package/dist/Glutinum.Converter/Read.js.map +1 -1
  14. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +14 -6
  15. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +1 -1
  16. package/dist/Glutinum.Converter/Reader/Declaration.js +50 -0
  17. package/dist/Glutinum.Converter/Reader/Declaration.js.map +1 -0
  18. package/dist/Glutinum.Converter/Reader/Documentation.js +119 -0
  19. package/dist/Glutinum.Converter/Reader/Documentation.js.map +1 -0
  20. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +9 -8
  21. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js.map +1 -1
  22. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +42 -0
  23. package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +1 -0
  24. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +13 -4
  25. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js.map +1 -1
  26. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +4 -2
  27. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js.map +1 -1
  28. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
  29. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +1 -1
  30. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
  31. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js.map +1 -1
  32. package/dist/Glutinum.Converter/Reader/NamedTupleMember.js +7 -0
  33. package/dist/Glutinum.Converter/Reader/NamedTupleMember.js.map +1 -0
  34. package/dist/Glutinum.Converter/Reader/Node.js +23 -11
  35. package/dist/Glutinum.Converter/Reader/Node.js.map +1 -1
  36. package/dist/Glutinum.Converter/Reader/Parameters.js +3 -3
  37. package/dist/Glutinum.Converter/Reader/Parameters.js.map +1 -1
  38. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
  39. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +1 -1
  40. package/dist/Glutinum.Converter/Reader/TypeNode.js +160 -18
  41. package/dist/Glutinum.Converter/Reader/TypeNode.js.map +1 -1
  42. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -21
  43. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +1 -1
  44. package/dist/Glutinum.Converter/Reader/TypeParameters.js +2 -2
  45. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +107 -77
  46. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +1 -1
  47. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -8
  48. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +1 -1
  49. package/dist/Glutinum.Converter/Reader/Utils.js +73 -7
  50. package/dist/Glutinum.Converter/Reader/Utils.js.map +1 -1
  51. package/dist/Glutinum.Converter/Reader/VariableStatement.js +13 -7
  52. package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +1 -1
  53. package/dist/Glutinum.Converter/Transform.js +599 -203
  54. package/dist/Glutinum.Converter/Transform.js.map +1 -1
  55. package/dist/Glutinum.Converter/TypeScript.js +1 -1
  56. package/dist/Glutinum.Converter/Utils/Keywords.js +3 -3
  57. package/dist/Glutinum.Converter/Utils/List.js +62 -0
  58. package/dist/Glutinum.Converter/Utils/List.js.map +1 -0
  59. package/dist/Glutinum.Converter/Utils/Naming.js +96 -17
  60. package/dist/Glutinum.Converter/Utils/Naming.js.map +1 -1
  61. package/dist/Glutinum.Converter/Utils/String.js +6 -1
  62. package/dist/Glutinum.Converter/Utils/String.js.map +1 -1
  63. package/dist/Program.js +9 -10
  64. package/dist/Program.js.map +1 -1
  65. package/package.json +22 -3
  66. package/dist/Glutinum.Converter/Reader/NamedDeclaration.js +0 -36
  67. package/dist/Glutinum.Converter/Reader/NamedDeclaration.js.map +0 -1
  68. package/dist/Glutinum.Converter/Reader/Types.js +0 -16
  69. package/dist/Glutinum.Converter/Reader/Types.js.map +0 -1
  70. package/dist/fable_modules/fable-library.4.5.0/Array.d.ts +0 -120
  71. package/dist/fable_modules/fable-library.4.5.0/Array.js +0 -1204
  72. package/dist/fable_modules/fable-library.4.5.0/Async.d.ts +0 -32
  73. package/dist/fable_modules/fable-library.4.5.0/Async.js +0 -158
  74. package/dist/fable_modules/fable-library.4.5.0/AsyncBuilder.d.ts +0 -59
  75. package/dist/fable_modules/fable-library.4.5.0/AsyncBuilder.js +0 -183
  76. package/dist/fable_modules/fable-library.4.5.0/BigInt.d.ts +0 -115
  77. package/dist/fable_modules/fable-library.4.5.0/BigInt.js +0 -282
  78. package/dist/fable_modules/fable-library.4.5.0/BitConverter.d.ts +0 -27
  79. package/dist/fable_modules/fable-library.4.5.0/BitConverter.js +0 -138
  80. package/dist/fable_modules/fable-library.4.5.0/Boolean.d.ts +0 -3
  81. package/dist/fable_modules/fable-library.4.5.0/Boolean.js +0 -21
  82. package/dist/fable_modules/fable-library.4.5.0/CHANGELOG.md +0 -11
  83. package/dist/fable_modules/fable-library.4.5.0/Char.d.ts +0 -65
  84. package/dist/fable_modules/fable-library.4.5.0/Char.js +0 -169
  85. package/dist/fable_modules/fable-library.4.5.0/Choice.d.ts +0 -138
  86. package/dist/fable_modules/fable-library.4.5.0/Choice.js +0 -227
  87. package/dist/fable_modules/fable-library.4.5.0/Date.d.ts +0 -70
  88. package/dist/fable_modules/fable-library.4.5.0/Date.js +0 -451
  89. package/dist/fable_modules/fable-library.4.5.0/DateOffset.d.ts +0 -63
  90. package/dist/fable_modules/fable-library.4.5.0/DateOffset.js +0 -268
  91. package/dist/fable_modules/fable-library.4.5.0/DateOnly.d.ts +0 -18
  92. package/dist/fable_modules/fable-library.4.5.0/DateOnly.js +0 -124
  93. package/dist/fable_modules/fable-library.4.5.0/Decimal.d.ts +0 -45
  94. package/dist/fable_modules/fable-library.4.5.0/Decimal.js +0 -212
  95. package/dist/fable_modules/fable-library.4.5.0/Double.d.ts +0 -11
  96. package/dist/fable_modules/fable-library.4.5.0/Double.js +0 -46
  97. package/dist/fable_modules/fable-library.4.5.0/Encoding.d.ts +0 -12
  98. package/dist/fable_modules/fable-library.4.5.0/Encoding.js +0 -173
  99. package/dist/fable_modules/fable-library.4.5.0/Event.d.ts +0 -31
  100. package/dist/fable_modules/fable-library.4.5.0/Event.js +0 -93
  101. package/dist/fable_modules/fable-library.4.5.0/FSharp.Collections.d.ts +0 -7
  102. package/dist/fable_modules/fable-library.4.5.0/FSharp.Collections.js +0 -27
  103. package/dist/fable_modules/fable-library.4.5.0/FSharp.Core.d.ts +0 -17
  104. package/dist/fable_modules/fable-library.4.5.0/FSharp.Core.js +0 -69
  105. package/dist/fable_modules/fable-library.4.5.0/Global.d.ts +0 -24
  106. package/dist/fable_modules/fable-library.4.5.0/Global.js +0 -8
  107. package/dist/fable_modules/fable-library.4.5.0/Guid.d.ts +0 -10
  108. package/dist/fable_modules/fable-library.4.5.0/Guid.js +0 -142
  109. package/dist/fable_modules/fable-library.4.5.0/Int32.d.ts +0 -28
  110. package/dist/fable_modules/fable-library.4.5.0/Int32.js +0 -135
  111. package/dist/fable_modules/fable-library.4.5.0/List.d.ts +0 -143
  112. package/dist/fable_modules/fable-library.4.5.0/List.js +0 -1273
  113. package/dist/fable_modules/fable-library.4.5.0/Long.d.ts +0 -3
  114. package/dist/fable_modules/fable-library.4.5.0/Long.js +0 -46
  115. package/dist/fable_modules/fable-library.4.5.0/MailboxProcessor.d.ts +0 -25
  116. package/dist/fable_modules/fable-library.4.5.0/MailboxProcessor.js +0 -93
  117. package/dist/fable_modules/fable-library.4.5.0/Map.d.ts +0 -178
  118. package/dist/fable_modules/fable-library.4.5.0/Map.js +0 -1396
  119. package/dist/fable_modules/fable-library.4.5.0/MapUtil.d.ts +0 -10
  120. package/dist/fable_modules/fable-library.4.5.0/MapUtil.js +0 -112
  121. package/dist/fable_modules/fable-library.4.5.0/MutableMap.d.ts +0 -52
  122. package/dist/fable_modules/fable-library.4.5.0/MutableMap.js +0 -326
  123. package/dist/fable_modules/fable-library.4.5.0/MutableSet.d.ts +0 -39
  124. package/dist/fable_modules/fable-library.4.5.0/MutableSet.js +0 -232
  125. package/dist/fable_modules/fable-library.4.5.0/Native.d.ts +0 -2
  126. package/dist/fable_modules/fable-library.4.5.0/Native.js +0 -8
  127. package/dist/fable_modules/fable-library.4.5.0/Numeric.d.ts +0 -19
  128. package/dist/fable_modules/fable-library.4.5.0/Numeric.js +0 -71
  129. package/dist/fable_modules/fable-library.4.5.0/Observable.d.ts +0 -32
  130. package/dist/fable_modules/fable-library.4.5.0/Observable.js +0 -113
  131. package/dist/fable_modules/fable-library.4.5.0/Option.d.ts +0 -28
  132. package/dist/fable_modules/fable-library.4.5.0/Option.js +0 -96
  133. package/dist/fable_modules/fable-library.4.5.0/README.md +0 -3
  134. package/dist/fable_modules/fable-library.4.5.0/Random.d.ts +0 -37
  135. package/dist/fable_modules/fable-library.4.5.0/Random.js +0 -170
  136. package/dist/fable_modules/fable-library.4.5.0/Range.d.ts +0 -12
  137. package/dist/fable_modules/fable-library.4.5.0/Range.js +0 -45
  138. package/dist/fable_modules/fable-library.4.5.0/Reflection.d.ts +0 -119
  139. package/dist/fable_modules/fable-library.4.5.0/Reflection.js +0 -461
  140. package/dist/fable_modules/fable-library.4.5.0/RegExp.d.ts +0 -10
  141. package/dist/fable_modules/fable-library.4.5.0/RegExp.js +0 -132
  142. package/dist/fable_modules/fable-library.4.5.0/Seq.d.ts +0 -165
  143. package/dist/fable_modules/fable-library.4.5.0/Seq.js +0 -1379
  144. package/dist/fable_modules/fable-library.4.5.0/Seq2.d.ts +0 -18
  145. package/dist/fable_modules/fable-library.4.5.0/Seq2.js +0 -111
  146. package/dist/fable_modules/fable-library.4.5.0/Set.d.ts +0 -190
  147. package/dist/fable_modules/fable-library.4.5.0/Set.js +0 -1789
  148. package/dist/fable_modules/fable-library.4.5.0/String.d.ts +0 -49
  149. package/dist/fable_modules/fable-library.4.5.0/String.js +0 -540
  150. package/dist/fable_modules/fable-library.4.5.0/System.Collections.Generic.d.ts +0 -71
  151. package/dist/fable_modules/fable-library.4.5.0/System.Collections.Generic.js +0 -307
  152. package/dist/fable_modules/fable-library.4.5.0/System.Text.d.ts +0 -30
  153. package/dist/fable_modules/fable-library.4.5.0/System.Text.js +0 -110
  154. package/dist/fable_modules/fable-library.4.5.0/SystemException.d.ts +0 -5
  155. package/dist/fable_modules/fable-library.4.5.0/SystemException.js +0 -5
  156. package/dist/fable_modules/fable-library.4.5.0/TimeOnly.d.ts +0 -15
  157. package/dist/fable_modules/fable-library.4.5.0/TimeOnly.js +0 -122
  158. package/dist/fable_modules/fable-library.4.5.0/TimeSpan.d.ts +0 -34
  159. package/dist/fable_modules/fable-library.4.5.0/TimeSpan.js +0 -177
  160. package/dist/fable_modules/fable-library.4.5.0/Timer.d.ts +0 -19
  161. package/dist/fable_modules/fable-library.4.5.0/Timer.js +0 -67
  162. package/dist/fable_modules/fable-library.4.5.0/Types.d.ts +0 -58
  163. package/dist/fable_modules/fable-library.4.5.0/Types.js +0 -208
  164. package/dist/fable_modules/fable-library.4.5.0/Unicode.13.0.0.d.ts +0 -2
  165. package/dist/fable_modules/fable-library.4.5.0/Unicode.13.0.0.js +0 -4
  166. package/dist/fable_modules/fable-library.4.5.0/Uri.d.ts +0 -29
  167. package/dist/fable_modules/fable-library.4.5.0/Uri.js +0 -142
  168. package/dist/fable_modules/fable-library.4.5.0/Util.d.ts +0 -207
  169. package/dist/fable_modules/fable-library.4.5.0/Util.js +0 -781
  170. package/dist/fable_modules/fable-library.4.5.0/lib/big.d.ts +0 -5
  171. package/dist/fable_modules/fable-library.4.5.0/lib/big.js +0 -826
  172. package/dist/fable_modules/fable-library.4.5.0/package.json +0 -23
  173. package/dist/fable_modules/project_cracked.json +0 -1
@@ -1,10 +0,0 @@
1
- import { IMap, ISet } from "./Util.js";
2
- import { FSharpRef } from "./Types.js";
3
- export declare function keyValueList(fields: Iterable<any>, caseRule?: number): {
4
- [k: string]: any;
5
- };
6
- export declare function containsValue<K, V>(v: V, map: IMap<K, V>): boolean;
7
- export declare function tryGetValue<K, V>(map: IMap<K, V>, key: K, defaultValue: FSharpRef<V>): boolean;
8
- export declare function addToSet<T>(v: T, set: ISet<T>): boolean;
9
- export declare function addToDict<K, V>(dict: IMap<K, V>, k: K, v: V): void;
10
- export declare function getItemFromDict<K, V>(map: IMap<K, V>, key: K): V;
@@ -1,112 +0,0 @@
1
- import { equals } from "./Util.js";
2
- import { Union } from "./Types.js";
3
- const CaseRules = {
4
- None: 0,
5
- LowerFirst: 1,
6
- SnakeCase: 2,
7
- SnakeCaseAllCaps: 3,
8
- KebabCase: 4,
9
- };
10
- function dashify(str, separator) {
11
- return str.replace(/[a-z]?[A-Z]/g, (m) => m.length === 1
12
- ? m.toLowerCase()
13
- : m.charAt(0) + separator + m.charAt(1).toLowerCase());
14
- }
15
- function changeCase(str, caseRule) {
16
- switch (caseRule) {
17
- case CaseRules.LowerFirst:
18
- return str.charAt(0).toLowerCase() + str.slice(1);
19
- case CaseRules.SnakeCase:
20
- return dashify(str, "_");
21
- case CaseRules.SnakeCaseAllCaps:
22
- return dashify(str, "_").toUpperCase();
23
- case CaseRules.KebabCase:
24
- return dashify(str, "-");
25
- case CaseRules.None:
26
- default:
27
- return str;
28
- }
29
- }
30
- export function keyValueList(fields, caseRule = CaseRules.None) {
31
- const obj = {};
32
- const definedCaseRule = caseRule;
33
- function fail(kvPair) {
34
- throw new Error("Cannot infer key and value of " + String(kvPair));
35
- }
36
- function assign(key, caseRule, value) {
37
- key = changeCase(key, caseRule);
38
- obj[key] = value;
39
- }
40
- for (let kvPair of fields) {
41
- let caseRule = CaseRules.None;
42
- if (kvPair == null) {
43
- fail(kvPair);
44
- }
45
- // Deflate unions and use the defined case rule
46
- if (kvPair instanceof Union) {
47
- const name = kvPair.cases()[kvPair.tag];
48
- kvPair = kvPair.fields.length === 0 ? name : [name].concat(kvPair.fields);
49
- caseRule = definedCaseRule;
50
- }
51
- if (Array.isArray(kvPair)) {
52
- switch (kvPair.length) {
53
- case 0:
54
- fail(kvPair);
55
- break;
56
- case 1:
57
- assign(kvPair[0], caseRule, true);
58
- break;
59
- case 2:
60
- const value = kvPair[1];
61
- assign(kvPair[0], caseRule, value);
62
- break;
63
- default:
64
- assign(kvPair[0], caseRule, kvPair.slice(1));
65
- }
66
- }
67
- else if (typeof kvPair === "string") {
68
- assign(kvPair, caseRule, true);
69
- }
70
- else {
71
- fail(kvPair);
72
- }
73
- }
74
- return obj;
75
- }
76
- // TODO: Move these methods to Map and Set modules
77
- export function containsValue(v, map) {
78
- for (const kv of map) {
79
- if (equals(v, kv[1])) {
80
- return true;
81
- }
82
- }
83
- return false;
84
- }
85
- export function tryGetValue(map, key, defaultValue) {
86
- if (map.has(key)) {
87
- defaultValue.contents = map.get(key);
88
- return true;
89
- }
90
- return false;
91
- }
92
- export function addToSet(v, set) {
93
- if (set.has(v)) {
94
- return false;
95
- }
96
- set.add(v);
97
- return true;
98
- }
99
- export function addToDict(dict, k, v) {
100
- if (dict.has(k)) {
101
- throw new Error("An item with the same key has already been added. Key: " + k);
102
- }
103
- dict.set(k, v);
104
- }
105
- export function getItemFromDict(map, key) {
106
- if (map.has(key)) {
107
- return map.get(key);
108
- }
109
- else {
110
- throw new Error(`The given key '${key}' was not present in the dictionary.`);
111
- }
112
- }
@@ -1,52 +0,0 @@
1
- import { IEqualityComparer, IMap, IEnumerator } from "./Util.js";
2
- import { Option } from "./Option.js";
3
- import { int32 } from "./Int32.js";
4
- import { FSharpRef } from "./Types.js";
5
- import { TypeInfo } from "./Reflection.js";
6
- export declare class Dictionary<Key, Value> implements IMap<Key, Value>, Iterable<[Key, Value]>, Iterable<[Key, Value]> {
7
- readonly comparer: IEqualityComparer<Key>;
8
- readonly hashMap: IMap<int32, [Key, Value][]>;
9
- "init@9": int32;
10
- constructor(pairs: Iterable<[Key, Value]>, comparer: IEqualityComparer<Key>);
11
- get [Symbol.toStringTag](): string;
12
- toJSON(): any;
13
- "System.Collections.IEnumerable.GetEnumerator"(): IEnumerator<any>;
14
- GetEnumerator(): IEnumerator<[Key, Value]>;
15
- [Symbol.iterator](): Iterator<[Key, Value]>;
16
- "System.Collections.Generic.ICollection`1.Add2B595"(item: [Key, Value]): void;
17
- "System.Collections.Generic.ICollection`1.Clear"(): void;
18
- "System.Collections.Generic.ICollection`1.Contains2B595"(item: [Key, Value]): boolean;
19
- "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: [Key, Value][], arrayIndex: int32): void;
20
- "System.Collections.Generic.ICollection`1.get_Count"(): int32;
21
- "System.Collections.Generic.ICollection`1.get_IsReadOnly"(): boolean;
22
- "System.Collections.Generic.ICollection`1.Remove2B595"(item: [Key, Value]): boolean;
23
- "System.Collections.Generic.IDictionary`2.Add5BDDA1"(key: Key, value: Value): void;
24
- "System.Collections.Generic.IDictionary`2.ContainsKey2B595"(key: Key): boolean;
25
- "System.Collections.Generic.IDictionary`2.get_Item2B595"(key: Key): Value;
26
- "System.Collections.Generic.IDictionary`2.set_Item5BDDA1"(key: Key, v: Value): void;
27
- "System.Collections.Generic.IDictionary`2.get_Keys"(): Iterable<Key>;
28
- "System.Collections.Generic.IDictionary`2.Remove2B595"(key: Key): boolean;
29
- "System.Collections.Generic.IDictionary`2.TryGetValue6DC89625"(key: Key, value: FSharpRef<Value>): boolean;
30
- "System.Collections.Generic.IDictionary`2.get_Values"(): Iterable<Value>;
31
- get size(): int32;
32
- clear(): void;
33
- delete(k: Key): boolean;
34
- entries(): Iterable<[Key, Value]>;
35
- get(k: Key): Value;
36
- has(k: Key): boolean;
37
- keys(): Iterable<Key>;
38
- set(k: Key, v: Value): IMap<Key, Value>;
39
- values(): Iterable<Value>;
40
- forEach(f: ((arg0: Value, arg1: Key, arg2: IMap<Key, Value>) => void), thisArg?: Option<any>): void;
41
- }
42
- export declare function Dictionary_$reflection(gen0: TypeInfo, gen1: TypeInfo): TypeInfo;
43
- export declare function Dictionary_$ctor_6623D9B3<Key, Value>(pairs: Iterable<[Key, Value]>, comparer: IEqualityComparer<Key>): Dictionary<Key, Value>;
44
- export declare function Dictionary__TryFind_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): Option<[Key, Value]>;
45
- export declare function Dictionary__get_Comparer<Key, Value>(this$: Dictionary<Key, Value>): IEqualityComparer<Key>;
46
- export declare function Dictionary__Clear<Key, Value>(this$: Dictionary<Key, Value>): void;
47
- export declare function Dictionary__get_Count<Key, Value>(this$: Dictionary<Key, Value>): int32;
48
- export declare function Dictionary__get_Item_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): Value;
49
- export declare function Dictionary__set_Item_5BDDA1<Key, Value>(this$: Dictionary<Key, Value>, k: Key, v: Value): void;
50
- export declare function Dictionary__Add_5BDDA1<Key, Value>(this$: Dictionary<Key, Value>, k: Key, v: Value): void;
51
- export declare function Dictionary__ContainsKey_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): boolean;
52
- export declare function Dictionary__Remove_2B595<Key, Value>(this$: Dictionary<Key, Value>, k: Key): boolean;
@@ -1,326 +0,0 @@
1
- import { disposeSafe, defaultOf, equals, toIterator, getEnumerator } from "./Util.js";
2
- import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.js";
3
- import { value as value_1 } from "./Option.js";
4
- import { FSharpRef } from "./Types.js";
5
- import { class_type } from "./Reflection.js";
6
- import { getItemFromDict, tryGetValue } from "./MapUtil.js";
7
- import { format } from "./String.js";
8
- export class Dictionary {
9
- constructor(pairs, comparer) {
10
- const this$ = new FSharpRef(defaultOf());
11
- this.comparer = comparer;
12
- this$.contents = this;
13
- this.hashMap = (new Map([]));
14
- this["init@9"] = 1;
15
- const enumerator = getEnumerator(pairs);
16
- try {
17
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
18
- const pair = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
19
- Dictionary__Add_5BDDA1(this$.contents, pair[0], pair[1]);
20
- }
21
- }
22
- finally {
23
- disposeSafe(enumerator);
24
- }
25
- }
26
- get [Symbol.toStringTag]() {
27
- return "Dictionary";
28
- }
29
- toJSON() {
30
- const this$ = this;
31
- return Array.from(this$);
32
- }
33
- "System.Collections.IEnumerable.GetEnumerator"() {
34
- const this$ = this;
35
- return getEnumerator(this$);
36
- }
37
- GetEnumerator() {
38
- const this$ = this;
39
- return getEnumerator(concat(this$.hashMap.values()));
40
- }
41
- [Symbol.iterator]() {
42
- return toIterator(getEnumerator(this));
43
- }
44
- "System.Collections.Generic.ICollection`1.Add2B595"(item) {
45
- const this$ = this;
46
- Dictionary__Add_5BDDA1(this$, item[0], item[1]);
47
- }
48
- "System.Collections.Generic.ICollection`1.Clear"() {
49
- const this$ = this;
50
- Dictionary__Clear(this$);
51
- }
52
- "System.Collections.Generic.ICollection`1.Contains2B595"(item) {
53
- const this$ = this;
54
- const matchValue = Dictionary__TryFind_2B595(this$, item[0]);
55
- let matchResult, p_1;
56
- if (matchValue != null) {
57
- if (equals(value_1(matchValue)[1], item[1])) {
58
- matchResult = 0;
59
- p_1 = value_1(matchValue);
60
- }
61
- else {
62
- matchResult = 1;
63
- }
64
- }
65
- else {
66
- matchResult = 1;
67
- }
68
- switch (matchResult) {
69
- case 0:
70
- return true;
71
- default:
72
- return false;
73
- }
74
- }
75
- "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
76
- const this$ = this;
77
- iterateIndexed((i, e) => {
78
- array[arrayIndex + i] = e;
79
- }, this$);
80
- }
81
- "System.Collections.Generic.ICollection`1.get_Count"() {
82
- const this$ = this;
83
- return Dictionary__get_Count(this$) | 0;
84
- }
85
- "System.Collections.Generic.ICollection`1.get_IsReadOnly"() {
86
- return false;
87
- }
88
- "System.Collections.Generic.ICollection`1.Remove2B595"(item) {
89
- const this$ = this;
90
- const matchValue = Dictionary__TryFind_2B595(this$, item[0]);
91
- if (matchValue != null) {
92
- if (equals(value_1(matchValue)[1], item[1])) {
93
- Dictionary__Remove_2B595(this$, item[0]);
94
- }
95
- return true;
96
- }
97
- else {
98
- return false;
99
- }
100
- }
101
- "System.Collections.Generic.IDictionary`2.Add5BDDA1"(key, value) {
102
- const this$ = this;
103
- Dictionary__Add_5BDDA1(this$, key, value);
104
- }
105
- "System.Collections.Generic.IDictionary`2.ContainsKey2B595"(key) {
106
- const this$ = this;
107
- return Dictionary__ContainsKey_2B595(this$, key);
108
- }
109
- "System.Collections.Generic.IDictionary`2.get_Item2B595"(key) {
110
- const this$ = this;
111
- return Dictionary__get_Item_2B595(this$, key);
112
- }
113
- "System.Collections.Generic.IDictionary`2.set_Item5BDDA1"(key, v) {
114
- const this$ = this;
115
- Dictionary__set_Item_5BDDA1(this$, key, v);
116
- }
117
- "System.Collections.Generic.IDictionary`2.get_Keys"() {
118
- const this$ = this;
119
- return toArray(delay(() => map((pair) => pair[0], this$)));
120
- }
121
- "System.Collections.Generic.IDictionary`2.Remove2B595"(key) {
122
- const this$ = this;
123
- return Dictionary__Remove_2B595(this$, key);
124
- }
125
- "System.Collections.Generic.IDictionary`2.TryGetValue6DC89625"(key, value) {
126
- const this$ = this;
127
- const matchValue = Dictionary__TryFind_2B595(this$, key);
128
- if (matchValue != null) {
129
- const pair = value_1(matchValue);
130
- value.contents = pair[1];
131
- return true;
132
- }
133
- else {
134
- return false;
135
- }
136
- }
137
- "System.Collections.Generic.IDictionary`2.get_Values"() {
138
- const this$ = this;
139
- return toArray(delay(() => map((pair) => pair[1], this$)));
140
- }
141
- get size() {
142
- const this$ = this;
143
- return Dictionary__get_Count(this$) | 0;
144
- }
145
- clear() {
146
- const this$ = this;
147
- Dictionary__Clear(this$);
148
- }
149
- delete(k) {
150
- const this$ = this;
151
- return Dictionary__Remove_2B595(this$, k);
152
- }
153
- entries() {
154
- const this$ = this;
155
- return map((p) => [p[0], p[1]], this$);
156
- }
157
- get(k) {
158
- const this$ = this;
159
- return Dictionary__get_Item_2B595(this$, k);
160
- }
161
- has(k) {
162
- const this$ = this;
163
- return Dictionary__ContainsKey_2B595(this$, k);
164
- }
165
- keys() {
166
- const this$ = this;
167
- return map((p) => p[0], this$);
168
- }
169
- set(k, v) {
170
- const this$ = this;
171
- Dictionary__set_Item_5BDDA1(this$, k, v);
172
- return this$;
173
- }
174
- values() {
175
- const this$ = this;
176
- return map((p) => p[1], this$);
177
- }
178
- forEach(f, thisArg) {
179
- const this$ = this;
180
- iterate((p) => {
181
- f(p[1], p[0], this$);
182
- }, this$);
183
- }
184
- }
185
- export function Dictionary_$reflection(gen0, gen1) {
186
- return class_type("Fable.Collections.Dictionary", [gen0, gen1], Dictionary);
187
- }
188
- export function Dictionary_$ctor_6623D9B3(pairs, comparer) {
189
- return new Dictionary(pairs, comparer);
190
- }
191
- function Dictionary__TryFindIndex_2B595(this$, k) {
192
- const h = this$.comparer.GetHashCode(k) | 0;
193
- let matchValue;
194
- let outArg = defaultOf();
195
- matchValue = [tryGetValue(this$.hashMap, h, new FSharpRef(() => outArg, (v) => {
196
- outArg = v;
197
- })), outArg];
198
- if (matchValue[0]) {
199
- return [true, h, matchValue[1].findIndex((pair) => this$.comparer.Equals(k, pair[0]))];
200
- }
201
- else {
202
- return [false, h, -1];
203
- }
204
- }
205
- export function Dictionary__TryFind_2B595(this$, k) {
206
- const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
207
- let matchResult;
208
- if (matchValue[0]) {
209
- if (matchValue[2] > -1) {
210
- matchResult = 0;
211
- }
212
- else {
213
- matchResult = 1;
214
- }
215
- }
216
- else {
217
- matchResult = 1;
218
- }
219
- switch (matchResult) {
220
- case 0:
221
- return getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]];
222
- default:
223
- return void 0;
224
- }
225
- }
226
- export function Dictionary__get_Comparer(this$) {
227
- return this$.comparer;
228
- }
229
- export function Dictionary__Clear(this$) {
230
- this$.hashMap.clear();
231
- }
232
- export function Dictionary__get_Count(this$) {
233
- let count = 0;
234
- let enumerator = getEnumerator(this$.hashMap.values());
235
- try {
236
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
237
- const pairs = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
238
- count = ((count + pairs.length) | 0);
239
- }
240
- }
241
- finally {
242
- disposeSafe(enumerator);
243
- }
244
- return count | 0;
245
- }
246
- export function Dictionary__get_Item_2B595(this$, k) {
247
- const matchValue = Dictionary__TryFind_2B595(this$, k);
248
- if (matchValue != null) {
249
- return value_1(matchValue)[1];
250
- }
251
- else {
252
- throw new Error("The item was not found in collection");
253
- }
254
- }
255
- export function Dictionary__set_Item_5BDDA1(this$, k, v) {
256
- const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
257
- if (matchValue[0]) {
258
- if (matchValue[2] > -1) {
259
- getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]] = [k, v];
260
- }
261
- else {
262
- const value = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v]));
263
- }
264
- }
265
- else {
266
- this$.hashMap.set(matchValue[1], [[k, v]]);
267
- }
268
- }
269
- export function Dictionary__Add_5BDDA1(this$, k, v) {
270
- const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
271
- if (matchValue[0]) {
272
- if (matchValue[2] > -1) {
273
- throw new Error(format("An item with the same key has already been added. Key: {0}", k));
274
- }
275
- else {
276
- const value = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v]));
277
- }
278
- }
279
- else {
280
- this$.hashMap.set(matchValue[1], [[k, v]]);
281
- }
282
- }
283
- export function Dictionary__ContainsKey_2B595(this$, k) {
284
- const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
285
- let matchResult;
286
- if (matchValue[0]) {
287
- if (matchValue[2] > -1) {
288
- matchResult = 0;
289
- }
290
- else {
291
- matchResult = 1;
292
- }
293
- }
294
- else {
295
- matchResult = 1;
296
- }
297
- switch (matchResult) {
298
- case 0:
299
- return true;
300
- default:
301
- return false;
302
- }
303
- }
304
- export function Dictionary__Remove_2B595(this$, k) {
305
- const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
306
- let matchResult;
307
- if (matchValue[0]) {
308
- if (matchValue[2] > -1) {
309
- matchResult = 0;
310
- }
311
- else {
312
- matchResult = 1;
313
- }
314
- }
315
- else {
316
- matchResult = 1;
317
- }
318
- switch (matchResult) {
319
- case 0: {
320
- getItemFromDict(this$.hashMap, matchValue[1]).splice(matchValue[2], 1);
321
- return true;
322
- }
323
- default:
324
- return false;
325
- }
326
- }
@@ -1,39 +0,0 @@
1
- import { IMap, IEqualityComparer, ISet, IEnumerator } from "./Util.js";
2
- import { int32 } from "./Int32.js";
3
- import { Option } from "./Option.js";
4
- import { TypeInfo } from "./Reflection.js";
5
- export declare class HashSet<T> implements ISet<T>, Iterable<T>, Iterable<T> {
6
- readonly comparer: IEqualityComparer<T>;
7
- readonly hashMap: IMap<int32, T[]>;
8
- "init@9": int32;
9
- constructor(items: Iterable<T>, comparer: IEqualityComparer<T>);
10
- get [Symbol.toStringTag](): string;
11
- toJSON(): any;
12
- "System.Collections.IEnumerable.GetEnumerator"(): IEnumerator<any>;
13
- GetEnumerator(): IEnumerator<T>;
14
- [Symbol.iterator](): Iterator<T>;
15
- "System.Collections.Generic.ICollection`1.Add2B595"(item: T): void;
16
- "System.Collections.Generic.ICollection`1.Clear"(): void;
17
- "System.Collections.Generic.ICollection`1.Contains2B595"(item: T): boolean;
18
- "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: T[], arrayIndex: int32): void;
19
- "System.Collections.Generic.ICollection`1.get_Count"(): int32;
20
- "System.Collections.Generic.ICollection`1.get_IsReadOnly"(): boolean;
21
- "System.Collections.Generic.ICollection`1.Remove2B595"(item: T): boolean;
22
- get size(): int32;
23
- add(k: T): ISet<T>;
24
- clear(): void;
25
- delete(k: T): boolean;
26
- has(k: T): boolean;
27
- keys(): Iterable<T>;
28
- values(): Iterable<T>;
29
- entries(): Iterable<[T, T]>;
30
- forEach(f: ((arg0: T, arg1: T, arg2: ISet<T>) => void), thisArg?: Option<any>): void;
31
- }
32
- export declare function HashSet_$reflection(gen0: TypeInfo): TypeInfo;
33
- export declare function HashSet_$ctor_Z6150332D<T>(items: Iterable<T>, comparer: IEqualityComparer<T>): HashSet<T>;
34
- export declare function HashSet__get_Comparer<T>(this$: HashSet<T>): IEqualityComparer<T>;
35
- export declare function HashSet__Clear<T>(this$: HashSet<T>): void;
36
- export declare function HashSet__get_Count<T>(this$: HashSet<T>): int32;
37
- export declare function HashSet__Add_2B595<T>(this$: HashSet<T>, k: T): boolean;
38
- export declare function HashSet__Contains_2B595<T>(this$: HashSet<T>, k: T): boolean;
39
- export declare function HashSet__Remove_2B595<T>(this$: HashSet<T>, k: T): boolean;