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