compostjs 0.0.11 → 0.1.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 (143) hide show
  1. package/dist/compost.js +34 -28
  2. package/dist/core.js +94 -73
  3. package/dist/fable_modules/fable-library-js.4.28.0/Array.d.ts +123 -0
  4. package/dist/fable_modules/fable-library-js.4.28.0/Array.js +1242 -0
  5. package/dist/fable_modules/fable-library-js.4.28.0/Async.d.ts +26 -0
  6. package/dist/fable_modules/fable-library-js.4.28.0/Async.js +145 -0
  7. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.d.ts +59 -0
  8. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.js +183 -0
  9. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.d.ts +115 -0
  10. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.js +283 -0
  11. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.d.ts +27 -0
  12. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.js +138 -0
  13. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.d.ts +3 -0
  14. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.js +21 -0
  15. package/dist/fable_modules/fable-library-js.4.28.0/CHANGELOG.md +100 -0
  16. package/dist/fable_modules/fable-library-js.4.28.0/Char.d.ts +65 -0
  17. package/dist/fable_modules/fable-library-js.4.28.0/Char.js +169 -0
  18. package/dist/fable_modules/fable-library-js.4.28.0/Choice.d.ts +121 -0
  19. package/dist/fable_modules/fable-library-js.4.28.0/Choice.js +184 -0
  20. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.d.ts +7 -0
  21. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.js +182 -0
  22. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.d.ts +9 -0
  23. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.js +21 -0
  24. package/dist/fable_modules/fable-library-js.4.28.0/Date.d.ts +70 -0
  25. package/dist/fable_modules/fable-library-js.4.28.0/Date.js +748 -0
  26. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.d.ts +63 -0
  27. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.js +268 -0
  28. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.d.ts +18 -0
  29. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.js +124 -0
  30. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.d.ts +45 -0
  31. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.js +212 -0
  32. package/dist/fable_modules/fable-library-js.4.28.0/Double.d.ts +11 -0
  33. package/dist/fable_modules/fable-library-js.4.28.0/Double.js +46 -0
  34. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.d.ts +12 -0
  35. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.js +173 -0
  36. package/dist/fable_modules/fable-library-js.4.28.0/Event.d.ts +31 -0
  37. package/dist/fable_modules/fable-library-js.4.28.0/Event.js +93 -0
  38. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.d.ts +7 -0
  39. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.js +27 -0
  40. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.d.ts +12 -0
  41. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.js +27 -0
  42. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.d.ts +17 -0
  43. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.js +69 -0
  44. package/dist/fable_modules/fable-library-js.4.28.0/Global.d.ts +24 -0
  45. package/dist/fable_modules/fable-library-js.4.28.0/Global.js +8 -0
  46. package/dist/fable_modules/fable-library-js.4.28.0/Guid.d.ts +10 -0
  47. package/dist/fable_modules/fable-library-js.4.28.0/Guid.js +142 -0
  48. package/dist/fable_modules/fable-library-js.4.28.0/Int32.d.ts +28 -0
  49. package/dist/fable_modules/fable-library-js.4.28.0/Int32.js +135 -0
  50. package/dist/fable_modules/fable-library-js.4.28.0/List.d.ts +143 -0
  51. package/dist/fable_modules/fable-library-js.4.28.0/List.js +1273 -0
  52. package/dist/fable_modules/fable-library-js.4.28.0/Long.d.ts +3 -0
  53. package/dist/fable_modules/fable-library-js.4.28.0/Long.js +46 -0
  54. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.d.ts +25 -0
  55. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.js +93 -0
  56. package/dist/fable_modules/fable-library-js.4.28.0/Map.d.ts +178 -0
  57. package/dist/fable_modules/fable-library-js.4.28.0/Map.js +1396 -0
  58. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.d.ts +12 -0
  59. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.js +127 -0
  60. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.d.ts +52 -0
  61. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.js +327 -0
  62. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.d.ts +39 -0
  63. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.js +233 -0
  64. package/dist/fable_modules/fable-library-js.4.28.0/Native.d.ts +2 -0
  65. package/dist/fable_modules/fable-library-js.4.28.0/Native.js +8 -0
  66. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.d.ts +19 -0
  67. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.js +71 -0
  68. package/dist/fable_modules/fable-library-js.4.28.0/Observable.d.ts +32 -0
  69. package/dist/fable_modules/fable-library-js.4.28.0/Observable.js +113 -0
  70. package/dist/fable_modules/fable-library-js.4.28.0/Option.d.ts +28 -0
  71. package/dist/fable_modules/fable-library-js.4.28.0/Option.js +96 -0
  72. package/dist/fable_modules/fable-library-js.4.28.0/README.md +3 -0
  73. package/dist/fable_modules/fable-library-js.4.28.0/Random.d.ts +37 -0
  74. package/dist/fable_modules/fable-library-js.4.28.0/Random.js +170 -0
  75. package/dist/fable_modules/fable-library-js.4.28.0/Range.d.ts +12 -0
  76. package/dist/fable_modules/fable-library-js.4.28.0/Range.js +45 -0
  77. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.d.ts +119 -0
  78. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.js +461 -0
  79. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.d.ts +10 -0
  80. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.js +131 -0
  81. package/dist/fable_modules/fable-library-js.4.28.0/Result.d.ts +37 -0
  82. package/dist/fable_modules/fable-library-js.4.28.0/Result.js +165 -0
  83. package/dist/fable_modules/fable-library-js.4.28.0/Seq.d.ts +165 -0
  84. package/dist/fable_modules/fable-library-js.4.28.0/Seq.js +1378 -0
  85. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.d.ts +18 -0
  86. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.js +111 -0
  87. package/dist/fable_modules/fable-library-js.4.28.0/Set.d.ts +190 -0
  88. package/dist/fable_modules/fable-library-js.4.28.0/Set.js +1789 -0
  89. package/dist/fable_modules/fable-library-js.4.28.0/String.d.ts +58 -0
  90. package/dist/fable_modules/fable-library-js.4.28.0/String.js +554 -0
  91. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.d.ts +79 -0
  92. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.js +317 -0
  93. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.d.ts +38 -0
  94. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.js +162 -0
  95. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.d.ts +5 -0
  96. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.js +5 -0
  97. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.d.ts +15 -0
  98. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.js +122 -0
  99. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.d.ts +34 -0
  100. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.js +177 -0
  101. package/dist/fable_modules/fable-library-js.4.28.0/Timer.d.ts +19 -0
  102. package/dist/fable_modules/fable-library-js.4.28.0/Timer.js +67 -0
  103. package/dist/fable_modules/fable-library-js.4.28.0/Types.d.ts +58 -0
  104. package/dist/fable_modules/fable-library-js.4.28.0/Types.js +208 -0
  105. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.d.ts +2 -0
  106. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.js +4 -0
  107. package/dist/fable_modules/fable-library-js.4.28.0/Uri.d.ts +31 -0
  108. package/dist/fable_modules/fable-library-js.4.28.0/Uri.js +159 -0
  109. package/dist/fable_modules/fable-library-js.4.28.0/Util.d.ts +210 -0
  110. package/dist/fable_modules/fable-library-js.4.28.0/Util.js +769 -0
  111. package/dist/fable_modules/fable-library-js.4.28.0/big.d.ts +338 -0
  112. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.d.ts +5 -0
  113. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.js +825 -0
  114. package/dist/fable_modules/fable-library-js.4.28.0/package.json +24 -0
  115. package/dist/fable_modules/project_cracked.json +1 -0
  116. package/package.json +5 -4
  117. package/.claude/settings.local.json +0 -11
  118. package/copy-latest.sh +0 -1
  119. package/dist/fable-library.2.10.1/Array.js +0 -1336
  120. package/dist/fable-library.2.10.1/Async.js +0 -121
  121. package/dist/fable-library.2.10.1/AsyncBuilder.js +0 -200
  122. package/dist/fable-library.2.10.1/Date.js +0 -501
  123. package/dist/fable-library.2.10.1/Decimal.js +0 -208
  124. package/dist/fable-library.2.10.1/Event.js +0 -193
  125. package/dist/fable-library.2.10.1/Int32.js +0 -157
  126. package/dist/fable-library.2.10.1/List.js +0 -1234
  127. package/dist/fable-library.2.10.1/Long.js +0 -155
  128. package/dist/fable-library.2.10.1/Map.js +0 -1292
  129. package/dist/fable-library.2.10.1/MutableMap.js +0 -360
  130. package/dist/fable-library.2.10.1/MutableSet.js +0 -279
  131. package/dist/fable-library.2.10.1/Observable.js +0 -131
  132. package/dist/fable-library.2.10.1/Option.js +0 -118
  133. package/dist/fable-library.2.10.1/Reflection.js +0 -345
  134. package/dist/fable-library.2.10.1/RegExp.js +0 -118
  135. package/dist/fable-library.2.10.1/Seq.js +0 -917
  136. package/dist/fable-library.2.10.1/Set.js +0 -1692
  137. package/dist/fable-library.2.10.1/String.js +0 -679
  138. package/dist/fable-library.2.10.1/Types.js +0 -308
  139. package/dist/fable-library.2.10.1/Util.js +0 -761
  140. package/dist/helpers.js +0 -31
  141. package/dist/lib/big.js +0 -905
  142. package/dist/lib/long.js +0 -1375
  143. package/index.html +0 -49
@@ -0,0 +1,12 @@
1
+ import { IMap, IMapOrWeakMap, 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: IMapOrWeakMap<K, V>, key: K, defaultValue: FSharpRef<V>): boolean;
8
+ export declare function addToSet<T>(v: T, set: ISet<T>): boolean;
9
+ export declare function tryAddToDict<K, V>(dict: IMapOrWeakMap<K, V>, k: K, v: V): boolean;
10
+ export declare function addToDict<K, V>(dict: IMapOrWeakMap<K, V>, k: K, v: V): void;
11
+ export declare function getItemFromDict<K, V>(map: IMap<K, V>, key: K): V;
12
+ export declare function getItemFromDictOrCreate<K, V>(map: IMapOrWeakMap<K, V>, key: K, createValue: (key: K) => V): V;
@@ -0,0 +1,127 @@
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 tryAddToDict(dict, k, v) {
100
+ if (dict.has(k)) {
101
+ return false;
102
+ }
103
+ dict.set(k, v);
104
+ return true;
105
+ }
106
+ export function addToDict(dict, k, v) {
107
+ if (dict.has(k)) {
108
+ throw new Error("An item with the same key has already been added. Key: " + k);
109
+ }
110
+ dict.set(k, v);
111
+ }
112
+ export function getItemFromDict(map, key) {
113
+ if (map.has(key)) {
114
+ return map.get(key);
115
+ }
116
+ else {
117
+ throw new Error(`The given key '${key}' was not present in the dictionary.`);
118
+ }
119
+ }
120
+ export function getItemFromDictOrCreate(map, key, createValue) {
121
+ if (map.has(key)) {
122
+ return map.get(key);
123
+ }
124
+ const value = createValue(key);
125
+ map.set(key, value);
126
+ return value;
127
+ }
@@ -0,0 +1,52 @@
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;
@@ -0,0 +1,327 @@
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 { setItem } from "./Array.js";
5
+ import { FSharpRef } from "./Types.js";
6
+ import { class_type } from "./Reflection.js";
7
+ import { getItemFromDict, tryGetValue } from "./MapUtil.js";
8
+ import { format } from "./String.js";
9
+ export class Dictionary {
10
+ constructor(pairs, comparer) {
11
+ const this$ = new FSharpRef(defaultOf());
12
+ this.comparer = comparer;
13
+ this$.contents = this;
14
+ this.hashMap = (new Map([]));
15
+ this["init@9"] = 1;
16
+ const enumerator = getEnumerator(pairs);
17
+ try {
18
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
19
+ const pair = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
20
+ Dictionary__Add_5BDDA1(this$.contents, pair[0], pair[1]);
21
+ }
22
+ }
23
+ finally {
24
+ disposeSafe(enumerator);
25
+ }
26
+ }
27
+ get [Symbol.toStringTag]() {
28
+ return "Dictionary";
29
+ }
30
+ toJSON() {
31
+ const this$ = this;
32
+ return Array.from(this$);
33
+ }
34
+ "System.Collections.IEnumerable.GetEnumerator"() {
35
+ const this$ = this;
36
+ return getEnumerator(this$);
37
+ }
38
+ GetEnumerator() {
39
+ const this$ = this;
40
+ return getEnumerator(concat(this$.hashMap.values()));
41
+ }
42
+ [Symbol.iterator]() {
43
+ return toIterator(getEnumerator(this));
44
+ }
45
+ "System.Collections.Generic.ICollection`1.Add2B595"(item) {
46
+ const this$ = this;
47
+ Dictionary__Add_5BDDA1(this$, item[0], item[1]);
48
+ }
49
+ "System.Collections.Generic.ICollection`1.Clear"() {
50
+ const this$ = this;
51
+ Dictionary__Clear(this$);
52
+ }
53
+ "System.Collections.Generic.ICollection`1.Contains2B595"(item) {
54
+ const this$ = this;
55
+ const matchValue = Dictionary__TryFind_2B595(this$, item[0]);
56
+ let matchResult, p_1;
57
+ if (matchValue != null) {
58
+ if (equals(value_1(matchValue)[1], item[1])) {
59
+ matchResult = 0;
60
+ p_1 = value_1(matchValue);
61
+ }
62
+ else {
63
+ matchResult = 1;
64
+ }
65
+ }
66
+ else {
67
+ matchResult = 1;
68
+ }
69
+ switch (matchResult) {
70
+ case 0:
71
+ return true;
72
+ default:
73
+ return false;
74
+ }
75
+ }
76
+ "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
77
+ const this$ = this;
78
+ iterateIndexed((i, e) => {
79
+ setItem(array, arrayIndex + i, e);
80
+ }, this$);
81
+ }
82
+ "System.Collections.Generic.ICollection`1.get_Count"() {
83
+ const this$ = this;
84
+ return Dictionary__get_Count(this$) | 0;
85
+ }
86
+ "System.Collections.Generic.ICollection`1.get_IsReadOnly"() {
87
+ return false;
88
+ }
89
+ "System.Collections.Generic.ICollection`1.Remove2B595"(item) {
90
+ const this$ = this;
91
+ const matchValue = Dictionary__TryFind_2B595(this$, item[0]);
92
+ if (matchValue != null) {
93
+ if (equals(value_1(matchValue)[1], item[1])) {
94
+ Dictionary__Remove_2B595(this$, item[0]);
95
+ }
96
+ return true;
97
+ }
98
+ else {
99
+ return false;
100
+ }
101
+ }
102
+ "System.Collections.Generic.IDictionary`2.Add5BDDA1"(key, value) {
103
+ const this$ = this;
104
+ Dictionary__Add_5BDDA1(this$, key, value);
105
+ }
106
+ "System.Collections.Generic.IDictionary`2.ContainsKey2B595"(key) {
107
+ const this$ = this;
108
+ return Dictionary__ContainsKey_2B595(this$, key);
109
+ }
110
+ "System.Collections.Generic.IDictionary`2.get_Item2B595"(key) {
111
+ const this$ = this;
112
+ return Dictionary__get_Item_2B595(this$, key);
113
+ }
114
+ "System.Collections.Generic.IDictionary`2.set_Item5BDDA1"(key, v) {
115
+ const this$ = this;
116
+ Dictionary__set_Item_5BDDA1(this$, key, v);
117
+ }
118
+ "System.Collections.Generic.IDictionary`2.get_Keys"() {
119
+ const this$ = this;
120
+ return toArray(delay(() => map((pair) => pair[0], this$)));
121
+ }
122
+ "System.Collections.Generic.IDictionary`2.Remove2B595"(key) {
123
+ const this$ = this;
124
+ return Dictionary__Remove_2B595(this$, key);
125
+ }
126
+ "System.Collections.Generic.IDictionary`2.TryGetValue6DC89625"(key, value) {
127
+ const this$ = this;
128
+ const matchValue = Dictionary__TryFind_2B595(this$, key);
129
+ if (matchValue != null) {
130
+ const pair = value_1(matchValue);
131
+ value.contents = pair[1];
132
+ return true;
133
+ }
134
+ else {
135
+ return false;
136
+ }
137
+ }
138
+ "System.Collections.Generic.IDictionary`2.get_Values"() {
139
+ const this$ = this;
140
+ return toArray(delay(() => map((pair) => pair[1], this$)));
141
+ }
142
+ get size() {
143
+ const this$ = this;
144
+ return Dictionary__get_Count(this$) | 0;
145
+ }
146
+ clear() {
147
+ const this$ = this;
148
+ Dictionary__Clear(this$);
149
+ }
150
+ delete(k) {
151
+ const this$ = this;
152
+ return Dictionary__Remove_2B595(this$, k);
153
+ }
154
+ entries() {
155
+ const this$ = this;
156
+ return map((p) => [p[0], p[1]], this$);
157
+ }
158
+ get(k) {
159
+ const this$ = this;
160
+ return Dictionary__get_Item_2B595(this$, k);
161
+ }
162
+ has(k) {
163
+ const this$ = this;
164
+ return Dictionary__ContainsKey_2B595(this$, k);
165
+ }
166
+ keys() {
167
+ const this$ = this;
168
+ return map((p) => p[0], this$);
169
+ }
170
+ set(k, v) {
171
+ const this$ = this;
172
+ Dictionary__set_Item_5BDDA1(this$, k, v);
173
+ return this$;
174
+ }
175
+ values() {
176
+ const this$ = this;
177
+ return map((p) => p[1], this$);
178
+ }
179
+ forEach(f, thisArg) {
180
+ const this$ = this;
181
+ iterate((p) => {
182
+ f(p[1], p[0], this$);
183
+ }, this$);
184
+ }
185
+ }
186
+ export function Dictionary_$reflection(gen0, gen1) {
187
+ return class_type("Fable.Collections.Dictionary", [gen0, gen1], Dictionary);
188
+ }
189
+ export function Dictionary_$ctor_6623D9B3(pairs, comparer) {
190
+ return new Dictionary(pairs, comparer);
191
+ }
192
+ function Dictionary__TryFindIndex_2B595(this$, k) {
193
+ const h = this$.comparer.GetHashCode(k) | 0;
194
+ let matchValue;
195
+ let outArg = defaultOf();
196
+ matchValue = [tryGetValue(this$.hashMap, h, new FSharpRef(() => outArg, (v) => {
197
+ outArg = v;
198
+ })), outArg];
199
+ if (matchValue[0]) {
200
+ return [true, h, matchValue[1].findIndex((pair) => this$.comparer.Equals(k, pair[0]))];
201
+ }
202
+ else {
203
+ return [false, h, -1];
204
+ }
205
+ }
206
+ export function Dictionary__TryFind_2B595(this$, k) {
207
+ const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
208
+ let matchResult;
209
+ if (matchValue[0]) {
210
+ if (matchValue[2] > -1) {
211
+ matchResult = 0;
212
+ }
213
+ else {
214
+ matchResult = 1;
215
+ }
216
+ }
217
+ else {
218
+ matchResult = 1;
219
+ }
220
+ switch (matchResult) {
221
+ case 0:
222
+ return getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]];
223
+ default:
224
+ return undefined;
225
+ }
226
+ }
227
+ export function Dictionary__get_Comparer(this$) {
228
+ return this$.comparer;
229
+ }
230
+ export function Dictionary__Clear(this$) {
231
+ this$.hashMap.clear();
232
+ }
233
+ export function Dictionary__get_Count(this$) {
234
+ let count = 0;
235
+ let enumerator = getEnumerator(this$.hashMap.values());
236
+ try {
237
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
238
+ const pairs = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
239
+ count = ((count + pairs.length) | 0);
240
+ }
241
+ }
242
+ finally {
243
+ disposeSafe(enumerator);
244
+ }
245
+ return count | 0;
246
+ }
247
+ export function Dictionary__get_Item_2B595(this$, k) {
248
+ const matchValue = Dictionary__TryFind_2B595(this$, k);
249
+ if (matchValue != null) {
250
+ return value_1(matchValue)[1];
251
+ }
252
+ else {
253
+ throw new Error("The item was not found in collection");
254
+ }
255
+ }
256
+ export function Dictionary__set_Item_5BDDA1(this$, k, v) {
257
+ const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
258
+ if (matchValue[0]) {
259
+ if (matchValue[2] > -1) {
260
+ getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]] = [k, v];
261
+ }
262
+ else {
263
+ const value = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v]));
264
+ }
265
+ }
266
+ else {
267
+ this$.hashMap.set(matchValue[1], [[k, v]]);
268
+ }
269
+ }
270
+ export function Dictionary__Add_5BDDA1(this$, k, v) {
271
+ const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
272
+ if (matchValue[0]) {
273
+ if (matchValue[2] > -1) {
274
+ throw new Error(format("An item with the same key has already been added. Key: {0}", k));
275
+ }
276
+ else {
277
+ const value = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v]));
278
+ }
279
+ }
280
+ else {
281
+ this$.hashMap.set(matchValue[1], [[k, v]]);
282
+ }
283
+ }
284
+ export function Dictionary__ContainsKey_2B595(this$, k) {
285
+ const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
286
+ let matchResult;
287
+ if (matchValue[0]) {
288
+ if (matchValue[2] > -1) {
289
+ matchResult = 0;
290
+ }
291
+ else {
292
+ matchResult = 1;
293
+ }
294
+ }
295
+ else {
296
+ matchResult = 1;
297
+ }
298
+ switch (matchResult) {
299
+ case 0:
300
+ return true;
301
+ default:
302
+ return false;
303
+ }
304
+ }
305
+ export function Dictionary__Remove_2B595(this$, k) {
306
+ const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
307
+ let matchResult;
308
+ if (matchValue[0]) {
309
+ if (matchValue[2] > -1) {
310
+ matchResult = 0;
311
+ }
312
+ else {
313
+ matchResult = 1;
314
+ }
315
+ }
316
+ else {
317
+ matchResult = 1;
318
+ }
319
+ switch (matchResult) {
320
+ case 0: {
321
+ getItemFromDict(this$.hashMap, matchValue[1]).splice(matchValue[2], 1);
322
+ return true;
323
+ }
324
+ default:
325
+ return false;
326
+ }
327
+ }
@@ -0,0 +1,39 @@
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;