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,58 @@
1
+ declare const enum StringComparison {
2
+ CurrentCulture = 0,
3
+ CurrentCultureIgnoreCase = 1,
4
+ InvariantCulture = 2,
5
+ InvariantCultureIgnoreCase = 3,
6
+ Ordinal = 4,
7
+ OrdinalIgnoreCase = 5
8
+ }
9
+ export declare function compare(...args: any[]): number;
10
+ export declare function compareOrdinal(x: string, y: string): number;
11
+ export declare function compareTo(x: string, y: string): number;
12
+ export declare function startsWith(str: string, pattern: string, ic: boolean | StringComparison): boolean;
13
+ export declare function endsWith(str: string, pattern: string, ic: boolean | StringComparison): boolean;
14
+ export declare function indexOfAny(str: string, anyOf: string[], ...args: number[]): number;
15
+ export type IPrintfFormatContinuation = (f: (x: string) => any) => any;
16
+ export interface IPrintfFormat {
17
+ input: string;
18
+ cont: IPrintfFormatContinuation;
19
+ }
20
+ export declare function printf(input: string): IPrintfFormat;
21
+ export declare function interpolate(str: string, values: any[]): string;
22
+ export declare function toConsole(arg: IPrintfFormat | string): any;
23
+ export declare function toConsoleError(arg: IPrintfFormat | string): any;
24
+ export declare function toText(arg: IPrintfFormat | string): any;
25
+ export declare function toFail(arg: IPrintfFormat | string): any;
26
+ export declare function fsFormat(str: string): (cont: (...args: any[]) => any) => any;
27
+ export declare function format(str: string | object, ...args: any[]): string;
28
+ export declare function initialize(n: number, f: (i: number) => string): string;
29
+ export declare function insert(str: string, startIndex: number, value: string): string;
30
+ export declare function isNullOrEmpty(str: string | any): boolean;
31
+ export declare function isNullOrWhiteSpace(str: string | any): boolean;
32
+ export declare function concat(...xs: any[]): string;
33
+ export declare function join<T>(delimiter: string, xs: Iterable<T>): string;
34
+ export declare function joinWithIndices(delimiter: string, xs: string[], startIndex: number, count: number): string;
35
+ export declare function toBase64String(inArray: ArrayLike<number>): string;
36
+ export declare function fromBase64String(b64Encoded: string): number[];
37
+ export declare function padLeft(str: string, len: number, ch?: string): string;
38
+ export declare function padRight(str: string, len: number, ch?: string): string;
39
+ export declare function remove(str: string, startIndex: number, count?: number): string;
40
+ export declare function replace(str: string, search: string, replace: string): string;
41
+ export declare function replicate(n: number, x: string): string;
42
+ export declare function getCharAtIndex(input: string, index: number): string;
43
+ export declare function split(str: string, splitters: string[], count?: number, options?: number): string[];
44
+ export declare function trim(str: string, ...chars: string[]): string;
45
+ export declare function trimStart(str: string, ...chars: string[]): any;
46
+ export declare function trimEnd(str: string, ...chars: string[]): any;
47
+ export declare function filter(pred: (char: string) => boolean, x: string): string;
48
+ export declare function substring(str: string, startIndex: number, length?: number): string;
49
+ export declare function toCharArray2(str: string, startIndex: number, length: number): string[];
50
+ interface FormattableString {
51
+ strs: TemplateStringsArray;
52
+ args: any[];
53
+ fmts?: string[];
54
+ }
55
+ export declare function fmt(strs: TemplateStringsArray, ...args: any[]): FormattableString;
56
+ export declare function fmtWith(fmts: string[]): (strs: TemplateStringsArray, ...args: any[]) => FormattableString;
57
+ export declare function getFormat(s: FormattableString): string;
58
+ export {};
@@ -0,0 +1,554 @@
1
+ import { toString as dateToString } from "./Date.js";
2
+ import { compare as numericCompare, isNumeric, multiply, toExponential, toFixed, toHex, toPrecision } from "./Numeric.js";
3
+ import { escape } from "./RegExp.js";
4
+ import { toString } from "./Types.js";
5
+ const fsFormatRegExp = /(^|[^%])%([0+\- ]*)(\*|\d+)?(?:\.(\d+))?(\w)/g;
6
+ const interpolateRegExp = /(?:(^|[^%])%([0+\- ]*)(\d+)?(?:\.(\d+))?(\w))?%P\(\)/g;
7
+ const formatRegExp = /\{(\d+)(,-?\d+)?(?:\:([a-zA-Z])(\d{0,2})|\:(.+?))?\}/g;
8
+ function isLessThan(x, y) {
9
+ return numericCompare(x, y) < 0;
10
+ }
11
+ function cmp(x, y, ic) {
12
+ function isIgnoreCase(i) {
13
+ return i === true ||
14
+ i === 1 /* StringComparison.CurrentCultureIgnoreCase */ ||
15
+ i === 3 /* StringComparison.InvariantCultureIgnoreCase */ ||
16
+ i === 5 /* StringComparison.OrdinalIgnoreCase */;
17
+ }
18
+ function isOrdinal(i) {
19
+ return i === 4 /* StringComparison.Ordinal */ ||
20
+ i === 5 /* StringComparison.OrdinalIgnoreCase */;
21
+ }
22
+ if (x == null) {
23
+ return y == null ? 0 : -1;
24
+ }
25
+ if (y == null) {
26
+ return 1;
27
+ } // everything is bigger than null
28
+ if (isOrdinal(ic)) {
29
+ if (isIgnoreCase(ic)) {
30
+ x = x.toLowerCase();
31
+ y = y.toLowerCase();
32
+ }
33
+ return (x === y) ? 0 : (x < y ? -1 : 1);
34
+ }
35
+ else {
36
+ if (isIgnoreCase(ic)) {
37
+ x = x.toLocaleLowerCase();
38
+ y = y.toLocaleLowerCase();
39
+ }
40
+ return x.localeCompare(y);
41
+ }
42
+ }
43
+ export function compare(...args) {
44
+ switch (args.length) {
45
+ case 2: return cmp(args[0], args[1], false);
46
+ case 3: return cmp(args[0], args[1], args[2]);
47
+ case 4: return cmp(args[0], args[1], args[2] === true);
48
+ case 5: return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), false);
49
+ case 6: return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), args[5]);
50
+ case 7: return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), args[5] === true);
51
+ default: throw new Error("String.compare: Unsupported number of parameters");
52
+ }
53
+ }
54
+ export function compareOrdinal(x, y) {
55
+ return cmp(x, y, 4 /* StringComparison.Ordinal */);
56
+ }
57
+ export function compareTo(x, y) {
58
+ return cmp(x, y, 0 /* StringComparison.CurrentCulture */);
59
+ }
60
+ export function startsWith(str, pattern, ic) {
61
+ if (ic === 4 /* StringComparison.Ordinal */) { // to avoid substring allocation
62
+ return str.startsWith(pattern);
63
+ }
64
+ if (str.length >= pattern.length) {
65
+ return cmp(str.substr(0, pattern.length), pattern, ic) === 0;
66
+ }
67
+ return false;
68
+ }
69
+ export function endsWith(str, pattern, ic) {
70
+ if (ic === 4 /* StringComparison.Ordinal */) { // to avoid substring allocation
71
+ return str.endsWith(pattern);
72
+ }
73
+ if (str.length >= pattern.length) {
74
+ return cmp(str.substr(str.length - pattern.length, pattern.length), pattern, ic) === 0;
75
+ }
76
+ return false;
77
+ }
78
+ export function indexOfAny(str, anyOf, ...args) {
79
+ if (str == null || str === "") {
80
+ return -1;
81
+ }
82
+ const startIndex = (args.length > 0) ? args[0] : 0;
83
+ if (startIndex < 0) {
84
+ throw new Error("Start index cannot be negative");
85
+ }
86
+ const length = (args.length > 1) ? args[1] : str.length - startIndex;
87
+ if (length < 0) {
88
+ throw new Error("Length cannot be negative");
89
+ }
90
+ if (startIndex + length > str.length) {
91
+ throw new Error("Invalid startIndex and length");
92
+ }
93
+ const endIndex = startIndex + length;
94
+ const anyOfAsStr = "".concat.apply("", anyOf);
95
+ for (let i = startIndex; i < endIndex; i++) {
96
+ if (anyOfAsStr.indexOf(str[i]) > -1) {
97
+ return i;
98
+ }
99
+ }
100
+ return -1;
101
+ }
102
+ export function printf(input) {
103
+ return {
104
+ input,
105
+ cont: fsFormat(input),
106
+ };
107
+ }
108
+ export function interpolate(str, values) {
109
+ let valIdx = 0;
110
+ let strIdx = 0;
111
+ let result = "";
112
+ interpolateRegExp.lastIndex = 0;
113
+ let match = interpolateRegExp.exec(str);
114
+ while (match) {
115
+ // The first group corresponds to the no-escape char (^|[^%]), the actual pattern starts in the next char
116
+ // Note: we don't use negative lookbehind because some browsers don't support it yet
117
+ const matchIndex = match.index + (match[1] || "").length;
118
+ result += str.substring(strIdx, matchIndex).replace(/%%/g, "%");
119
+ const [, , flags, padLength, precision, format] = match;
120
+ // Save interpolateRegExp.lastIndex before running formatReplacement because the values
121
+ // may also involve interpolation and make use of interpolateRegExp (see #3078)
122
+ strIdx = interpolateRegExp.lastIndex;
123
+ result += formatReplacement(values[valIdx++], flags, padLength, precision, format);
124
+ // Move interpolateRegExp.lastIndex one char behind to make sure we match the no-escape char next time
125
+ interpolateRegExp.lastIndex = strIdx - 1;
126
+ match = interpolateRegExp.exec(str);
127
+ }
128
+ result += str.substring(strIdx).replace(/%%/g, "%");
129
+ return result;
130
+ }
131
+ function continuePrint(cont, arg) {
132
+ return typeof arg === "string" ? cont(arg) : arg.cont(cont);
133
+ }
134
+ export function toConsole(arg) {
135
+ // Don't remove the lambda here, see #1357
136
+ return continuePrint((x) => console.log(x), arg);
137
+ }
138
+ export function toConsoleError(arg) {
139
+ return continuePrint((x) => console.error(x), arg);
140
+ }
141
+ export function toText(arg) {
142
+ return continuePrint((x) => x, arg);
143
+ }
144
+ export function toFail(arg) {
145
+ return continuePrint((x) => {
146
+ throw new Error(x);
147
+ }, arg);
148
+ }
149
+ function formatReplacement(rep, flags, padLength, precision, format) {
150
+ let sign = "";
151
+ flags = flags || "";
152
+ format = format || "";
153
+ if (isNumeric(rep)) {
154
+ if (format.toLowerCase() !== "x") {
155
+ if (isLessThan(rep, 0)) {
156
+ rep = multiply(rep, -1);
157
+ sign = "-";
158
+ }
159
+ else {
160
+ if (flags.indexOf(" ") >= 0) {
161
+ sign = " ";
162
+ }
163
+ else if (flags.indexOf("+") >= 0) {
164
+ sign = "+";
165
+ }
166
+ }
167
+ }
168
+ precision = precision == null ? null : parseInt(precision, 10);
169
+ switch (format) {
170
+ case "f":
171
+ case "F":
172
+ precision = precision != null ? precision : 6;
173
+ rep = toFixed(rep, precision);
174
+ break;
175
+ case "g":
176
+ case "G":
177
+ rep = precision != null ? toPrecision(rep, precision) : toPrecision(rep);
178
+ break;
179
+ case "e":
180
+ case "E":
181
+ rep = precision != null ? toExponential(rep, precision) : toExponential(rep);
182
+ break;
183
+ case "x":
184
+ rep = toHex(rep);
185
+ break;
186
+ case "X":
187
+ rep = toHex(rep).toUpperCase();
188
+ break;
189
+ default: // AOid
190
+ rep = String(rep);
191
+ break;
192
+ }
193
+ }
194
+ else if (rep instanceof Date) {
195
+ rep = dateToString(rep);
196
+ }
197
+ else {
198
+ rep = toString(rep);
199
+ }
200
+ padLength = typeof padLength === "number" ? padLength : parseInt(padLength, 10);
201
+ if (!isNaN(padLength)) {
202
+ const zeroFlag = flags.indexOf("0") >= 0; // Use '0' for left padding
203
+ const minusFlag = flags.indexOf("-") >= 0; // Right padding
204
+ const ch = minusFlag || !zeroFlag ? " " : "0";
205
+ if (ch === "0") {
206
+ rep = pad(rep, padLength - sign.length, ch, minusFlag);
207
+ rep = sign + rep;
208
+ }
209
+ else {
210
+ rep = pad(sign + rep, padLength, ch, minusFlag);
211
+ }
212
+ }
213
+ else {
214
+ rep = sign + rep;
215
+ }
216
+ return rep;
217
+ }
218
+ function createPrinter(cont, _strParts, _matches, _result = "", padArg = -1) {
219
+ return (...args) => {
220
+ // Make copies of the values passed by reference because the function can be used multiple times
221
+ let result = _result;
222
+ const strParts = _strParts.slice();
223
+ const matches = _matches.slice();
224
+ for (const arg of args) {
225
+ const [, , flags, _padLength, precision, format] = matches[0];
226
+ let padLength = _padLength;
227
+ if (padArg >= 0) {
228
+ padLength = padArg;
229
+ padArg = -1;
230
+ }
231
+ else if (padLength === "*") {
232
+ if (arg < 0) {
233
+ throw new Error("Non-negative number required");
234
+ }
235
+ padArg = arg;
236
+ continue;
237
+ }
238
+ result += strParts[0];
239
+ result += formatReplacement(arg, flags, padLength, precision, format);
240
+ strParts.splice(0, 1);
241
+ matches.splice(0, 1);
242
+ }
243
+ if (matches.length === 0) {
244
+ result += strParts[0];
245
+ return cont(result);
246
+ }
247
+ else {
248
+ return createPrinter(cont, strParts, matches, result, padArg);
249
+ }
250
+ };
251
+ }
252
+ export function fsFormat(str) {
253
+ return (cont) => {
254
+ fsFormatRegExp.lastIndex = 0;
255
+ const strParts = [];
256
+ const matches = [];
257
+ let strIdx = 0;
258
+ let match = fsFormatRegExp.exec(str);
259
+ while (match) {
260
+ // The first group corresponds to the no-escape char (^|[^%]), the actual pattern starts in the next char
261
+ // Note: we don't use negative lookbehind because some browsers don't support it yet
262
+ const matchIndex = match.index + (match[1] || "").length;
263
+ strParts.push(str.substring(strIdx, matchIndex).replace(/%%/g, "%"));
264
+ matches.push(match);
265
+ strIdx = fsFormatRegExp.lastIndex;
266
+ // Likewise we need to move fsFormatRegExp.lastIndex one char behind to make sure we match the no-escape char next time
267
+ fsFormatRegExp.lastIndex -= 1;
268
+ match = fsFormatRegExp.exec(str);
269
+ }
270
+ if (strParts.length === 0) {
271
+ return cont(str.replace(/%%/g, "%"));
272
+ }
273
+ else {
274
+ strParts.push(str.substring(strIdx).replace(/%%/g, "%"));
275
+ return createPrinter(cont, strParts, matches);
276
+ }
277
+ };
278
+ }
279
+ export function format(str, ...args) {
280
+ let str2;
281
+ if (typeof str === "object") {
282
+ // Called with culture info
283
+ str2 = String(args[0]);
284
+ args.shift();
285
+ }
286
+ else {
287
+ str2 = str;
288
+ }
289
+ return str2.replace(formatRegExp, (_, idx, padLength, format, precision, pattern) => {
290
+ if (idx < 0 || idx >= args.length) {
291
+ throw new Error("Index must be greater or equal to zero and less than the arguments' length.");
292
+ }
293
+ let rep = args[idx];
294
+ if (isNumeric(rep)) {
295
+ precision = precision == null ? null : parseInt(precision, 10);
296
+ switch (format) {
297
+ case "f":
298
+ case "F":
299
+ precision = precision != null ? precision : 2;
300
+ rep = toFixed(rep, precision);
301
+ break;
302
+ case "g":
303
+ case "G":
304
+ rep = precision != null ? toPrecision(rep, precision) : toPrecision(rep);
305
+ break;
306
+ case "e":
307
+ case "E":
308
+ rep = precision != null ? toExponential(rep, precision) : toExponential(rep);
309
+ break;
310
+ case "p":
311
+ case "P":
312
+ precision = precision != null ? precision : 2;
313
+ rep = toFixed(multiply(rep, 100), precision) + " %";
314
+ break;
315
+ case "d":
316
+ case "D":
317
+ rep = precision != null ? padLeft(String(rep), precision, "0") : String(rep);
318
+ break;
319
+ case "x":
320
+ case "X":
321
+ rep = precision != null ? padLeft(toHex(rep), precision, "0") : toHex(rep);
322
+ if (format === "X") {
323
+ rep = rep.toUpperCase();
324
+ }
325
+ break;
326
+ default:
327
+ if (pattern) {
328
+ let sign = "";
329
+ rep = pattern.replace(/([0#,]+)(\.[0#]+)?/, (_, intPart, decimalPart) => {
330
+ if (isLessThan(rep, 0)) {
331
+ rep = multiply(rep, -1);
332
+ sign = "-";
333
+ }
334
+ decimalPart = decimalPart == null ? "" : decimalPart.substring(1);
335
+ rep = toFixed(rep, Math.max(decimalPart.length, 0));
336
+ let [repInt, repDecimal] = rep.split(".");
337
+ repDecimal || (repDecimal = "");
338
+ const leftZeroes = intPart.replace(/,/g, "").replace(/^#+/, "").length;
339
+ repInt = padLeft(repInt, leftZeroes, "0");
340
+ const rightZeros = decimalPart.replace(/#+$/, "").length;
341
+ if (rightZeros > repDecimal.length) {
342
+ repDecimal = padRight(repDecimal, rightZeros, "0");
343
+ }
344
+ else if (rightZeros < repDecimal.length) {
345
+ repDecimal = repDecimal.substring(0, rightZeros) + repDecimal.substring(rightZeros).replace(/0+$/, "");
346
+ }
347
+ // Thousands separator
348
+ if (intPart.indexOf(",") > 0) {
349
+ const i = repInt.length % 3;
350
+ const thousandGroups = Math.floor(repInt.length / 3);
351
+ let thousands = i > 0 ? repInt.substr(0, i) + (thousandGroups > 0 ? "," : "") : "";
352
+ for (let j = 0; j < thousandGroups; j++) {
353
+ thousands += repInt.substr(i + j * 3, 3) + (j < thousandGroups - 1 ? "," : "");
354
+ }
355
+ repInt = thousands;
356
+ }
357
+ return repDecimal.length > 0 ? repInt + "." + repDecimal : repInt;
358
+ });
359
+ rep = sign + rep;
360
+ }
361
+ }
362
+ }
363
+ else if (rep instanceof Date) {
364
+ rep = dateToString(rep, pattern || format);
365
+ }
366
+ else {
367
+ rep = toString(rep);
368
+ }
369
+ padLength = parseInt((padLength || " ").substring(1), 10);
370
+ if (!isNaN(padLength)) {
371
+ rep = pad(String(rep), Math.abs(padLength), " ", padLength < 0);
372
+ }
373
+ return rep;
374
+ });
375
+ }
376
+ export function initialize(n, f) {
377
+ if (n < 0) {
378
+ throw new Error("String length must be non-negative");
379
+ }
380
+ const xs = new Array(n);
381
+ for (let i = 0; i < n; i++) {
382
+ xs[i] = f(i);
383
+ }
384
+ return xs.join("");
385
+ }
386
+ export function insert(str, startIndex, value) {
387
+ if (startIndex < 0 || startIndex > str.length) {
388
+ throw new Error("startIndex is negative or greater than the length of this instance.");
389
+ }
390
+ return str.substring(0, startIndex) + value + str.substring(startIndex);
391
+ }
392
+ export function isNullOrEmpty(str) {
393
+ return typeof str !== "string" || str.length === 0;
394
+ }
395
+ export function isNullOrWhiteSpace(str) {
396
+ return typeof str !== "string" || /^\s*$/.test(str);
397
+ }
398
+ export function concat(...xs) {
399
+ return xs.map((x) => String(x)).join("");
400
+ }
401
+ export function join(delimiter, xs) {
402
+ if (Array.isArray(xs)) {
403
+ return xs.join(delimiter);
404
+ }
405
+ else {
406
+ return Array.from(xs).join(delimiter);
407
+ }
408
+ }
409
+ export function joinWithIndices(delimiter, xs, startIndex, count) {
410
+ const endIndexPlusOne = startIndex + count;
411
+ if (endIndexPlusOne > xs.length) {
412
+ throw new Error("Index and count must refer to a location within the buffer.");
413
+ }
414
+ return xs.slice(startIndex, endIndexPlusOne).join(delimiter);
415
+ }
416
+ function notSupported(name) {
417
+ throw new Error("The environment doesn't support '" + name + "', please use a polyfill.");
418
+ }
419
+ export function toBase64String(inArray) {
420
+ let str = "";
421
+ for (let i = 0; i < inArray.length; i++) {
422
+ str += String.fromCharCode(inArray[i]);
423
+ }
424
+ return typeof btoa === "function" ? btoa(str) : notSupported("btoa");
425
+ }
426
+ export function fromBase64String(b64Encoded) {
427
+ const binary = typeof atob === "function" ? atob(b64Encoded) : notSupported("atob");
428
+ const bytes = new Uint8Array(binary.length);
429
+ for (let i = 0; i < binary.length; i++) {
430
+ bytes[i] = binary.charCodeAt(i);
431
+ }
432
+ return bytes;
433
+ }
434
+ function pad(str, len, ch, isRight) {
435
+ ch = ch || " ";
436
+ len = len - str.length;
437
+ for (let i = 0; i < len; i++) {
438
+ str = isRight ? str + ch : ch + str;
439
+ }
440
+ return str;
441
+ }
442
+ export function padLeft(str, len, ch) {
443
+ return pad(str, len, ch);
444
+ }
445
+ export function padRight(str, len, ch) {
446
+ return pad(str, len, ch, true);
447
+ }
448
+ export function remove(str, startIndex, count) {
449
+ if (startIndex >= str.length) {
450
+ throw new Error("startIndex must be less than length of string");
451
+ }
452
+ if (typeof count === "number" && (startIndex + count) > str.length) {
453
+ throw new Error("Index and count must refer to a location within the string.");
454
+ }
455
+ return str.slice(0, startIndex) + (typeof count === "number" ? str.substr(startIndex + count) : "");
456
+ }
457
+ export function replace(str, search, replace) {
458
+ return str.replace(new RegExp(escape(search), "g"), replace);
459
+ }
460
+ export function replicate(n, x) {
461
+ return initialize(n, () => x);
462
+ }
463
+ export function getCharAtIndex(input, index) {
464
+ if (index < 0 || index >= input.length) {
465
+ throw new Error("Index was outside the bounds of the array.");
466
+ }
467
+ return input[index];
468
+ }
469
+ export function split(str, splitters, count, options) {
470
+ count = typeof count === "number" ? count : undefined;
471
+ options = typeof options === "number" ? options : 0;
472
+ if (count && count < 0) {
473
+ throw new Error("Count cannot be less than zero");
474
+ }
475
+ if (count === 0) {
476
+ return [];
477
+ }
478
+ const removeEmpty = (options & 1) === 1;
479
+ const trim = (options & 2) === 2;
480
+ splitters = splitters || [];
481
+ splitters = splitters.filter(x => x).map(escape);
482
+ splitters = splitters.length > 0 ? splitters : ["\\s"];
483
+ const splits = [];
484
+ const reg = new RegExp(splitters.join("|"), "g");
485
+ let findSplits = true;
486
+ let i = 0;
487
+ do {
488
+ const match = reg.exec(str);
489
+ if (match === null) {
490
+ const candidate = trim ? str.substring(i).trim() : str.substring(i);
491
+ if (!removeEmpty || candidate.length > 0) {
492
+ splits.push(candidate);
493
+ }
494
+ findSplits = false;
495
+ }
496
+ else {
497
+ const candidate = trim ? str.substring(i, match.index).trim() : str.substring(i, match.index);
498
+ if (!removeEmpty || candidate.length > 0) {
499
+ if (count != null && splits.length + 1 === count) {
500
+ splits.push(trim ? str.substring(i).trim() : str.substring(i));
501
+ findSplits = false;
502
+ }
503
+ else {
504
+ splits.push(candidate);
505
+ }
506
+ }
507
+ i = reg.lastIndex;
508
+ }
509
+ } while (findSplits);
510
+ return splits;
511
+ }
512
+ export function trim(str, ...chars) {
513
+ if (chars.length === 0) {
514
+ return str.trim();
515
+ }
516
+ const pattern = "[" + escape(chars.join("")) + "]+";
517
+ return str.replace(new RegExp("^" + pattern), "").replace(new RegExp(pattern + "$"), "");
518
+ }
519
+ export function trimStart(str, ...chars) {
520
+ return chars.length === 0
521
+ ? str.trimStart()
522
+ : str.replace(new RegExp("^[" + escape(chars.join("")) + "]+"), "");
523
+ }
524
+ export function trimEnd(str, ...chars) {
525
+ return chars.length === 0
526
+ ? str.trimEnd()
527
+ : str.replace(new RegExp("[" + escape(chars.join("")) + "]+$"), "");
528
+ }
529
+ export function filter(pred, x) {
530
+ return x.split("").filter((c) => pred(c)).join("");
531
+ }
532
+ export function substring(str, startIndex, length) {
533
+ if ((startIndex + (length || 0) > str.length)) {
534
+ throw new Error("Invalid startIndex and/or length");
535
+ }
536
+ return length != null ? str.substr(startIndex, length) : str.substr(startIndex);
537
+ }
538
+ export function toCharArray2(str, startIndex, length) {
539
+ return substring(str, startIndex, length).split("");
540
+ }
541
+ export function fmt(strs, ...args) {
542
+ return ({ strs, args });
543
+ }
544
+ export function fmtWith(fmts) {
545
+ return (strs, ...args) => ({ strs, args, fmts });
546
+ }
547
+ export function getFormat(s) {
548
+ const strs = s.strs.map((value) => value.replace(/{/g, '{{').replace(/}/g, '}}'));
549
+ return s.fmts
550
+ ? strs
551
+ .reduce((acc, newPart, index) => acc + `{${String(index - 1) + s.fmts[index - 1]}}` + newPart)
552
+ : strs
553
+ .reduce((acc, newPart, index) => acc + `{${index - 1}}` + newPart);
554
+ }
@@ -0,0 +1,79 @@
1
+ import { int32 } from "./Int32.js";
2
+ import { IEnumerator, IEqualityComparer, IComparer } from "./Util.js";
3
+ import { TypeInfo } from "./Reflection.js";
4
+ import { FSharpRef } from "./Types.js";
5
+ export declare class Comparer$1<T> implements IComparer<T> {
6
+ readonly comparison: ((arg0: T, arg1: T) => int32);
7
+ constructor(comparison: ((arg0: T, arg1: T) => int32));
8
+ Compare(x: T, y: T): int32;
9
+ }
10
+ export declare function Comparer$1_$reflection(gen0: TypeInfo): TypeInfo;
11
+ export declare function Comparer$1_$ctor_47C913C<T>(comparison: ((arg0: T, arg1: T) => int32)): Comparer$1<T>;
12
+ export declare function Comparer$1_get_Default<T>(): Comparer$1<T>;
13
+ export declare function Comparer$1_Create_47C913C<T>(comparison: ((arg0: T, arg1: T) => int32)): Comparer$1<T>;
14
+ export declare function Comparer$1__Compare_5BDDA0<T>(_: Comparer$1<T>, x: T, y: T): int32;
15
+ export declare class EqualityComparer$1<T> implements IEqualityComparer<T> {
16
+ readonly getHashCode: ((arg0: T) => int32);
17
+ readonly equals: ((arg0: T, arg1: T) => boolean);
18
+ constructor(equals: ((arg0: T, arg1: T) => boolean), getHashCode: ((arg0: T) => int32));
19
+ Equals(x: T, y: T): boolean;
20
+ GetHashCode(x: T): int32;
21
+ }
22
+ export declare function EqualityComparer$1_$reflection(gen0: TypeInfo): TypeInfo;
23
+ export declare function EqualityComparer$1_$ctor_Z6EE254AB<T>(equals: ((arg0: T, arg1: T) => boolean), getHashCode: ((arg0: T) => int32)): EqualityComparer$1<T>;
24
+ export declare function EqualityComparer$1_get_Default<T>(): EqualityComparer$1<T>;
25
+ export declare function EqualityComparer$1_Create_Z6EE254AB<T>(equals: ((arg0: T, arg1: T) => boolean), getHashCode: ((arg0: T) => int32)): EqualityComparer$1<T>;
26
+ export declare function EqualityComparer$1__Equals_5BDDA0<T>(_: EqualityComparer$1<T>, x: T, y: T): boolean;
27
+ export declare function EqualityComparer$1__GetHashCode_2B595<T>(_: EqualityComparer$1<T>, x: T): int32;
28
+ export declare class Stack$1<T> implements Iterable<T> {
29
+ contents: T[];
30
+ count: int32;
31
+ constructor(initialContents: T[], initialCount: int32);
32
+ GetEnumerator(): IEnumerator<T>;
33
+ [Symbol.iterator](): Iterator<T>;
34
+ "System.Collections.IEnumerable.GetEnumerator"(): IEnumerator<any>;
35
+ }
36
+ export declare function Stack$1_$reflection(gen0: TypeInfo): TypeInfo;
37
+ export declare function Stack$1_$ctor_Z524259A4<T>(initialCapacity: int32): Stack$1<T>;
38
+ export declare function Stack$1_$ctor<T>(): Stack$1<T>;
39
+ export declare function Stack$1_$ctor_BB573A<T>(xs: Iterable<T>): Stack$1<T>;
40
+ export declare function Stack$1__Ensure_Z524259A4<T>(_: Stack$1<T>, newSize: int32): void;
41
+ export declare function Stack$1__get_Count<T>(_: Stack$1<T>): int32;
42
+ export declare function Stack$1__Pop<T>(_: Stack$1<T>): T;
43
+ export declare function Stack$1__Peek<T>(_: Stack$1<T>): T;
44
+ export declare function Stack$1__Contains_2B595<T>(_: Stack$1<T>, x: T): boolean;
45
+ export declare function Stack$1__TryPeek_1F3DB691<T>(this$: Stack$1<T>, result: FSharpRef<T>): boolean;
46
+ export declare function Stack$1__TryPop_1F3DB691<T>(this$: Stack$1<T>, result: FSharpRef<T>): boolean;
47
+ export declare function Stack$1__Push_2B595<T>(this$: Stack$1<T>, x: T): void;
48
+ export declare function Stack$1__Clear<T>(_: Stack$1<T>): void;
49
+ export declare function Stack$1__TrimExcess<T>(this$: Stack$1<T>): void;
50
+ export declare function Stack$1__ToArray<T>(_: Stack$1<T>): T[];
51
+ export declare class Queue$1<T> implements Iterable<T> {
52
+ contents: T[];
53
+ count: int32;
54
+ head: int32;
55
+ tail: int32;
56
+ constructor(initialContents: T[], initialCount: int32);
57
+ GetEnumerator(): IEnumerator<T>;
58
+ [Symbol.iterator](): Iterator<T>;
59
+ "System.Collections.IEnumerable.GetEnumerator"(): IEnumerator<any>;
60
+ }
61
+ export declare function Queue$1_$reflection(gen0: TypeInfo): TypeInfo;
62
+ export declare function Queue$1_$ctor_Z524259A4<T>(initialCapacity: int32): Queue$1<T>;
63
+ export declare function Queue$1_$ctor<T>(): Queue$1<T>;
64
+ export declare function Queue$1_$ctor_BB573A<T>(xs: Iterable<T>): Queue$1<T>;
65
+ export declare function Queue$1__get_Count<T>(_: Queue$1<T>): int32;
66
+ export declare function Queue$1__Enqueue_2B595<T>(_: Queue$1<T>, value: T): void;
67
+ export declare function Queue$1__Dequeue<T>(_: Queue$1<T>): T;
68
+ export declare function Queue$1__Peek<T>(_: Queue$1<T>): T;
69
+ export declare function Queue$1__TryDequeue_1F3DB691<T>(this$: Queue$1<T>, result: FSharpRef<T>): boolean;
70
+ export declare function Queue$1__TryPeek_1F3DB691<T>(this$: Queue$1<T>, result: FSharpRef<T>): boolean;
71
+ export declare function Queue$1__Contains_2B595<T>(_: Queue$1<T>, x: T): boolean;
72
+ export declare function Queue$1__Clear<T>(_: Queue$1<T>): void;
73
+ export declare function Queue$1__TrimExcess<T>(_: Queue$1<T>): void;
74
+ export declare function Queue$1__ToArray<T>(_: Queue$1<T>): T[];
75
+ export declare function Queue$1__CopyTo_Z3B4C077E<T>(_: Queue$1<T>, target: T[], start: int32): void;
76
+ export declare function Queue$1__size<T>(this$: Queue$1<T>): int32;
77
+ export declare function Queue$1__toIndex_Z524259A4<T>(this$: Queue$1<T>, i: int32): int32;
78
+ export declare function Queue$1__ensure_Z524259A4<T>(this$: Queue$1<T>, requiredSize: int32): void;
79
+ export declare function Queue$1__toSeq<T>(this$: Queue$1<T>): Iterable<T>;