compostjs 0.0.11 → 0.0.12

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 (141) hide show
  1. package/dist/fable_modules/fable-library-js.4.28.0/Array.d.ts +123 -0
  2. package/dist/fable_modules/fable-library-js.4.28.0/Array.js +1242 -0
  3. package/dist/fable_modules/fable-library-js.4.28.0/Async.d.ts +26 -0
  4. package/dist/fable_modules/fable-library-js.4.28.0/Async.js +145 -0
  5. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.d.ts +59 -0
  6. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.js +183 -0
  7. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.d.ts +115 -0
  8. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.js +283 -0
  9. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.d.ts +27 -0
  10. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.js +138 -0
  11. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.d.ts +3 -0
  12. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.js +21 -0
  13. package/dist/fable_modules/fable-library-js.4.28.0/CHANGELOG.md +100 -0
  14. package/dist/fable_modules/fable-library-js.4.28.0/Char.d.ts +65 -0
  15. package/dist/fable_modules/fable-library-js.4.28.0/Char.js +169 -0
  16. package/dist/fable_modules/fable-library-js.4.28.0/Choice.d.ts +121 -0
  17. package/dist/fable_modules/fable-library-js.4.28.0/Choice.js +184 -0
  18. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.d.ts +7 -0
  19. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.js +182 -0
  20. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.d.ts +9 -0
  21. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.js +21 -0
  22. package/dist/fable_modules/fable-library-js.4.28.0/Date.d.ts +70 -0
  23. package/dist/fable_modules/fable-library-js.4.28.0/Date.js +748 -0
  24. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.d.ts +63 -0
  25. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.js +268 -0
  26. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.d.ts +18 -0
  27. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.js +124 -0
  28. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.d.ts +45 -0
  29. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.js +212 -0
  30. package/dist/fable_modules/fable-library-js.4.28.0/Double.d.ts +11 -0
  31. package/dist/fable_modules/fable-library-js.4.28.0/Double.js +46 -0
  32. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.d.ts +12 -0
  33. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.js +173 -0
  34. package/dist/fable_modules/fable-library-js.4.28.0/Event.d.ts +31 -0
  35. package/dist/fable_modules/fable-library-js.4.28.0/Event.js +93 -0
  36. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.d.ts +7 -0
  37. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.js +27 -0
  38. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.d.ts +12 -0
  39. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.js +27 -0
  40. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.d.ts +17 -0
  41. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.js +69 -0
  42. package/dist/fable_modules/fable-library-js.4.28.0/Global.d.ts +24 -0
  43. package/dist/fable_modules/fable-library-js.4.28.0/Global.js +8 -0
  44. package/dist/fable_modules/fable-library-js.4.28.0/Guid.d.ts +10 -0
  45. package/dist/fable_modules/fable-library-js.4.28.0/Guid.js +142 -0
  46. package/dist/fable_modules/fable-library-js.4.28.0/Int32.d.ts +28 -0
  47. package/dist/fable_modules/fable-library-js.4.28.0/Int32.js +135 -0
  48. package/dist/fable_modules/fable-library-js.4.28.0/List.d.ts +143 -0
  49. package/dist/fable_modules/fable-library-js.4.28.0/List.js +1273 -0
  50. package/dist/fable_modules/fable-library-js.4.28.0/Long.d.ts +3 -0
  51. package/dist/fable_modules/fable-library-js.4.28.0/Long.js +46 -0
  52. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.d.ts +25 -0
  53. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.js +93 -0
  54. package/dist/fable_modules/fable-library-js.4.28.0/Map.d.ts +178 -0
  55. package/dist/fable_modules/fable-library-js.4.28.0/Map.js +1396 -0
  56. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.d.ts +12 -0
  57. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.js +127 -0
  58. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.d.ts +52 -0
  59. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.js +327 -0
  60. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.d.ts +39 -0
  61. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.js +233 -0
  62. package/dist/fable_modules/fable-library-js.4.28.0/Native.d.ts +2 -0
  63. package/dist/fable_modules/fable-library-js.4.28.0/Native.js +8 -0
  64. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.d.ts +19 -0
  65. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.js +71 -0
  66. package/dist/fable_modules/fable-library-js.4.28.0/Observable.d.ts +32 -0
  67. package/dist/fable_modules/fable-library-js.4.28.0/Observable.js +113 -0
  68. package/dist/fable_modules/fable-library-js.4.28.0/Option.d.ts +28 -0
  69. package/dist/fable_modules/fable-library-js.4.28.0/Option.js +96 -0
  70. package/dist/fable_modules/fable-library-js.4.28.0/README.md +3 -0
  71. package/dist/fable_modules/fable-library-js.4.28.0/Random.d.ts +37 -0
  72. package/dist/fable_modules/fable-library-js.4.28.0/Random.js +170 -0
  73. package/dist/fable_modules/fable-library-js.4.28.0/Range.d.ts +12 -0
  74. package/dist/fable_modules/fable-library-js.4.28.0/Range.js +45 -0
  75. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.d.ts +119 -0
  76. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.js +461 -0
  77. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.d.ts +10 -0
  78. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.js +131 -0
  79. package/dist/fable_modules/fable-library-js.4.28.0/Result.d.ts +37 -0
  80. package/dist/fable_modules/fable-library-js.4.28.0/Result.js +165 -0
  81. package/dist/fable_modules/fable-library-js.4.28.0/Seq.d.ts +165 -0
  82. package/dist/fable_modules/fable-library-js.4.28.0/Seq.js +1378 -0
  83. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.d.ts +18 -0
  84. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.js +111 -0
  85. package/dist/fable_modules/fable-library-js.4.28.0/Set.d.ts +190 -0
  86. package/dist/fable_modules/fable-library-js.4.28.0/Set.js +1789 -0
  87. package/dist/fable_modules/fable-library-js.4.28.0/String.d.ts +58 -0
  88. package/dist/fable_modules/fable-library-js.4.28.0/String.js +554 -0
  89. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.d.ts +79 -0
  90. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.js +317 -0
  91. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.d.ts +38 -0
  92. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.js +162 -0
  93. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.d.ts +5 -0
  94. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.js +5 -0
  95. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.d.ts +15 -0
  96. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.js +122 -0
  97. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.d.ts +34 -0
  98. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.js +177 -0
  99. package/dist/fable_modules/fable-library-js.4.28.0/Timer.d.ts +19 -0
  100. package/dist/fable_modules/fable-library-js.4.28.0/Timer.js +67 -0
  101. package/dist/fable_modules/fable-library-js.4.28.0/Types.d.ts +58 -0
  102. package/dist/fable_modules/fable-library-js.4.28.0/Types.js +208 -0
  103. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.d.ts +2 -0
  104. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.js +4 -0
  105. package/dist/fable_modules/fable-library-js.4.28.0/Uri.d.ts +31 -0
  106. package/dist/fable_modules/fable-library-js.4.28.0/Uri.js +159 -0
  107. package/dist/fable_modules/fable-library-js.4.28.0/Util.d.ts +210 -0
  108. package/dist/fable_modules/fable-library-js.4.28.0/Util.js +769 -0
  109. package/dist/fable_modules/fable-library-js.4.28.0/big.d.ts +338 -0
  110. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.d.ts +5 -0
  111. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.js +825 -0
  112. package/dist/fable_modules/fable-library-js.4.28.0/package.json +24 -0
  113. package/dist/fable_modules/project_cracked.json +1 -0
  114. package/package.json +4 -3
  115. package/.claude/settings.local.json +0 -11
  116. package/copy-latest.sh +0 -1
  117. package/dist/fable-library.2.10.1/Array.js +0 -1336
  118. package/dist/fable-library.2.10.1/Async.js +0 -121
  119. package/dist/fable-library.2.10.1/AsyncBuilder.js +0 -200
  120. package/dist/fable-library.2.10.1/Date.js +0 -501
  121. package/dist/fable-library.2.10.1/Decimal.js +0 -208
  122. package/dist/fable-library.2.10.1/Event.js +0 -193
  123. package/dist/fable-library.2.10.1/Int32.js +0 -157
  124. package/dist/fable-library.2.10.1/List.js +0 -1234
  125. package/dist/fable-library.2.10.1/Long.js +0 -155
  126. package/dist/fable-library.2.10.1/Map.js +0 -1292
  127. package/dist/fable-library.2.10.1/MutableMap.js +0 -360
  128. package/dist/fable-library.2.10.1/MutableSet.js +0 -279
  129. package/dist/fable-library.2.10.1/Observable.js +0 -131
  130. package/dist/fable-library.2.10.1/Option.js +0 -118
  131. package/dist/fable-library.2.10.1/Reflection.js +0 -345
  132. package/dist/fable-library.2.10.1/RegExp.js +0 -118
  133. package/dist/fable-library.2.10.1/Seq.js +0 -917
  134. package/dist/fable-library.2.10.1/Set.js +0 -1692
  135. package/dist/fable-library.2.10.1/String.js +0 -679
  136. package/dist/fable-library.2.10.1/Types.js +0 -308
  137. package/dist/fable-library.2.10.1/Util.js +0 -761
  138. package/dist/helpers.js +0 -31
  139. package/dist/lib/big.js +0 -905
  140. package/dist/lib/long.js +0 -1375
  141. package/index.html +0 -49
@@ -1,501 +0,0 @@
1
- /**
2
- * DateTimeOffset functions.
3
- *
4
- * Note: Date instances are always DateObjects in local
5
- * timezone (because JS dates are all kinds of messed up).
6
- * A local date returns UTC epoc when `.getTime()` is called.
7
- *
8
- * Basically; invariant: date.getTime() always return UTC time.
9
- */
10
- import { fromValue, ticksToUnixEpochMilliseconds, unixEpochMillisecondsToTicks } from "./Long";
11
- import { compareDates, dateOffset, padWithZeros } from "./Util";
12
- export const offsetRegex = /(?:Z|[+-](\d+):?([0-5]?\d)?)\s*$/;
13
- export function dateOffsetToString(offset) {
14
- const isMinus = offset < 0;
15
- offset = Math.abs(offset);
16
- const hours = ~~(offset / 3600000);
17
- const minutes = offset % 3600000 / 60000;
18
- return (isMinus ? "-" : "+") + padWithZeros(hours, 2) + ":" + padWithZeros(minutes, 2);
19
- }
20
- export function dateToHalfUTCString(date, half) {
21
- const str = date.toISOString();
22
- return half === "first" ? str.substring(0, str.indexOf("T")) : str.substring(str.indexOf("T") + 1, str.length - 1);
23
- }
24
-
25
- function dateToISOString(d, utc) {
26
- if (utc) {
27
- return d.toISOString();
28
- } else {
29
- // JS Date is always local
30
- const printOffset = d.kind == null ? true : d.kind === 2
31
- /* Local */
32
- ;
33
- return padWithZeros(d.getFullYear(), 4) + "-" + padWithZeros(d.getMonth() + 1, 2) + "-" + padWithZeros(d.getDate(), 2) + "T" + padWithZeros(d.getHours(), 2) + ":" + padWithZeros(d.getMinutes(), 2) + ":" + padWithZeros(d.getSeconds(), 2) + "." + padWithZeros(d.getMilliseconds(), 3) + (printOffset ? dateOffsetToString(d.getTimezoneOffset() * -60000) : "");
34
- }
35
- }
36
-
37
- function dateToISOStringWithOffset(dateWithOffset, offset) {
38
- const str = dateWithOffset.toISOString();
39
- return str.substring(0, str.length - 1) + dateOffsetToString(offset);
40
- }
41
-
42
- function dateToStringWithCustomFormat(date, format, utc) {
43
- return format.replace(/(\w)\1*/g, match => {
44
- let rep = Number.NaN;
45
-
46
- switch (match.substring(0, 1)) {
47
- case "y":
48
- const y = utc ? date.getUTCFullYear() : date.getFullYear();
49
- rep = match.length < 4 ? y % 100 : y;
50
- break;
51
-
52
- case "M":
53
- rep = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
54
- break;
55
-
56
- case "d":
57
- rep = utc ? date.getUTCDate() : date.getDate();
58
- break;
59
-
60
- case "H":
61
- rep = utc ? date.getUTCHours() : date.getHours();
62
- break;
63
-
64
- case "h":
65
- const h = utc ? date.getUTCHours() : date.getHours();
66
- rep = h > 12 ? h % 12 : h;
67
- break;
68
-
69
- case "m":
70
- rep = utc ? date.getUTCMinutes() : date.getMinutes();
71
- break;
72
-
73
- case "s":
74
- rep = utc ? date.getUTCSeconds() : date.getSeconds();
75
- break;
76
-
77
- case "f":
78
- rep = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
79
- break;
80
- }
81
-
82
- if (Number.isNaN(rep)) {
83
- return match;
84
- } else {
85
- return rep < 10 && match.length > 1 ? "0" + rep : "" + rep;
86
- }
87
- });
88
- }
89
-
90
- function dateToStringWithOffset(date, format) {
91
- var _a, _b, _c;
92
-
93
- const d = new Date(date.getTime() + ((_a = date.offset) !== null && _a !== void 0 ? _a : 0));
94
-
95
- if (typeof format !== "string") {
96
- return d.toISOString().replace(/\.\d+/, "").replace(/[A-Z]|\.\d+/g, " ") + dateOffsetToString((_b = date.offset) !== null && _b !== void 0 ? _b : 0);
97
- } else if (format.length === 1) {
98
- switch (format) {
99
- case "D":
100
- case "d":
101
- return dateToHalfUTCString(d, "first");
102
-
103
- case "T":
104
- case "t":
105
- return dateToHalfUTCString(d, "second");
106
-
107
- case "O":
108
- case "o":
109
- return dateToISOStringWithOffset(d, (_c = date.offset) !== null && _c !== void 0 ? _c : 0);
110
-
111
- default:
112
- throw new Error("Unrecognized Date print format");
113
- }
114
- } else {
115
- return dateToStringWithCustomFormat(d, format, true);
116
- }
117
- }
118
-
119
- function dateToStringWithKind(date, format) {
120
- const utc = date.kind === 1
121
- /* UTC */
122
- ;
123
-
124
- if (typeof format !== "string") {
125
- return utc ? date.toUTCString() : date.toLocaleString();
126
- } else if (format.length === 1) {
127
- switch (format) {
128
- case "D":
129
- case "d":
130
- return utc ? dateToHalfUTCString(date, "first") : date.toLocaleDateString();
131
-
132
- case "T":
133
- case "t":
134
- return utc ? dateToHalfUTCString(date, "second") : date.toLocaleTimeString();
135
-
136
- case "O":
137
- case "o":
138
- return dateToISOString(date, utc);
139
-
140
- default:
141
- throw new Error("Unrecognized Date print format");
142
- }
143
- } else {
144
- return dateToStringWithCustomFormat(date, format, utc);
145
- }
146
- }
147
-
148
- export function toString(date, format, _provider) {
149
- return date.offset != null ? dateToStringWithOffset(date, format) : dateToStringWithKind(date, format);
150
- }
151
- export default function DateTime(value, kind) {
152
- const d = new Date(value);
153
- d.kind = (kind == null ? 0
154
- /* Unspecified */
155
- : kind) | 0;
156
- return d;
157
- }
158
- export function fromTicks(ticks, kind) {
159
- ticks = fromValue(ticks);
160
- kind = kind != null ? kind : 0
161
- /* Unspecified */
162
- ;
163
- let date = DateTime(ticksToUnixEpochMilliseconds(ticks), kind); // Ticks are local to offset (in this case, either UTC or Local/Unknown).
164
- // If kind is anything but UTC, that means that the tick number was not
165
- // in utc, thus getTime() cannot return UTC, and needs to be shifted.
166
-
167
- if (kind !== 1
168
- /* UTC */
169
- ) {
170
- date = DateTime(date.getTime() - dateOffset(date), kind);
171
- }
172
-
173
- return date;
174
- }
175
- export function fromDateTimeOffset(date, kind) {
176
- var _a;
177
-
178
- switch (kind) {
179
- case 1
180
- /* UTC */
181
- :
182
- return DateTime(date.getTime(), 1
183
- /* UTC */
184
- );
185
-
186
- case 2
187
- /* Local */
188
- :
189
- return DateTime(date.getTime(), 2
190
- /* Local */
191
- );
192
-
193
- default:
194
- const d = DateTime(date.getTime() + ((_a = date.offset) !== null && _a !== void 0 ? _a : 0), kind);
195
- return DateTime(d.getTime() - dateOffset(d), kind);
196
- }
197
- }
198
- export function getTicks(date) {
199
- return unixEpochMillisecondsToTicks(date.getTime(), dateOffset(date));
200
- }
201
- export function minValue() {
202
- // This is "0001-01-01T00:00:00.000Z", actual JS min value is -8640000000000000
203
- return DateTime(-62135596800000, 0
204
- /* Unspecified */
205
- );
206
- }
207
- export function maxValue() {
208
- // This is "9999-12-31T23:59:59.999Z", actual JS max value is 8640000000000000
209
- return DateTime(253402300799999, 0
210
- /* Unspecified */
211
- );
212
- }
213
- export function parseRaw(str) {
214
- let date = new Date(str);
215
-
216
- if (isNaN(date.getTime())) {
217
- // Try to check strings JS Date cannot parse (see #1045, #1422)
218
- // tslint:disable-next-line:max-line-length
219
- const m = /^\s*(\d+[^\w\s:]\d+[^\w\s:]\d+)?\s*(\d+:\d+(?::\d+(?:\.\d+)?)?)?\s*([AaPp][Mm])?\s*([+-]\d+(?::\d+)?)?\s*$/.exec(str);
220
-
221
- if (m != null) {
222
- let baseDate;
223
- let timeInSeconds = 0;
224
-
225
- if (m[2] != null) {
226
- const timeParts = m[2].split(":");
227
- timeInSeconds = parseInt(timeParts[0], 10) * 3600 + parseInt(timeParts[1] || "0", 10) * 60 + parseFloat(timeParts[2] || "0");
228
-
229
- if (m[3] != null && m[3].toUpperCase() === "PM") {
230
- timeInSeconds += 720;
231
- }
232
- }
233
-
234
- if (m[4] != null) {
235
- // There's an offset, parse as UTC
236
- if (m[1] != null) {
237
- baseDate = new Date(m[1] + " UTC");
238
- } else {
239
- const d = new Date();
240
- baseDate = new Date(d.getUTCFullYear() + "/" + (d.getUTCMonth() + 1) + "/" + d.getUTCDate());
241
- }
242
-
243
- const offsetParts = m[4].substr(1).split(":");
244
- let offsetInMinutes = parseInt(offsetParts[0], 10) * 60 + parseInt(offsetParts[1] || "0", 10);
245
-
246
- if (m[4][0] === "+") {
247
- offsetInMinutes *= -1;
248
- }
249
-
250
- timeInSeconds += offsetInMinutes * 60;
251
- } else {
252
- if (m[1] != null) {
253
- baseDate = new Date(m[1]);
254
- } else {
255
- const d = new Date();
256
- baseDate = new Date(d.getFullYear() + "/" + (d.getMonth() + 1) + "/" + d.getDate());
257
- }
258
- }
259
-
260
- date = new Date(baseDate.getTime() + timeInSeconds * 1000); // correct for daylight savings time
261
-
262
- date = new Date(date.getTime() + (date.getTimezoneOffset() - baseDate.getTimezoneOffset()) * 60000);
263
- } else {
264
- throw new Error("The string is not a valid Date.");
265
- }
266
- }
267
-
268
- return date;
269
- }
270
- export function parse(str, detectUTC = false) {
271
- const date = parseRaw(str);
272
- const offset = offsetRegex.exec(str); // .NET always parses DateTime as Local if there's offset info (even "Z")
273
- // Newtonsoft.Json uses UTC if the offset is "Z"
274
-
275
- const kind = offset != null ? detectUTC && offset[0] === "Z" ? 1
276
- /* UTC */
277
- : 2
278
- /* Local */
279
- : 0
280
- /* Unspecified */
281
- ;
282
- return DateTime(date.getTime(), kind);
283
- }
284
- export function tryParse(v, _refValue) {
285
- try {
286
- // if value is null or whitespace, parsing fails
287
- if (v == null || v.trim() === "") {
288
- return [false, minValue()];
289
- }
290
-
291
- return [true, parse(v)];
292
- } catch (_err) {
293
- return [false, minValue()];
294
- }
295
- }
296
- export function create(year, month, day, h = 0, m = 0, s = 0, ms = 0, kind) {
297
- const dateValue = kind === 1
298
- /* UTC */
299
- ? Date.UTC(year, month - 1, day, h, m, s, ms) : new Date(year, month - 1, day, h, m, s, ms).getTime();
300
-
301
- if (isNaN(dateValue)) {
302
- throw new Error("The parameters describe an unrepresentable Date.");
303
- }
304
-
305
- const date = DateTime(dateValue, kind);
306
-
307
- if (year <= 99) {
308
- date.setFullYear(year, month - 1, day);
309
- }
310
-
311
- return date;
312
- }
313
- export function now() {
314
- return DateTime(Date.now(), 2
315
- /* Local */
316
- );
317
- }
318
- export function utcNow() {
319
- return DateTime(Date.now(), 1
320
- /* UTC */
321
- );
322
- }
323
- export function today() {
324
- return date(now());
325
- }
326
- export function isLeapYear(year) {
327
- return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
328
- }
329
- export function daysInMonth(year, month) {
330
- return month === 2 ? isLeapYear(year) ? 29 : 28 : month >= 8 ? month % 2 === 0 ? 31 : 30 : month % 2 === 0 ? 30 : 31;
331
- }
332
- export function toUniversalTime(date) {
333
- return date.kind === 1
334
- /* UTC */
335
- ? date : DateTime(date.getTime(), 1
336
- /* UTC */
337
- );
338
- }
339
- export function toLocalTime(date) {
340
- return date.kind === 2
341
- /* Local */
342
- ? date : DateTime(date.getTime(), 2
343
- /* Local */
344
- );
345
- }
346
- export function specifyKind(d, kind) {
347
- return create(year(d), month(d), day(d), hour(d), minute(d), second(d), millisecond(d), kind);
348
- }
349
- export function timeOfDay(d) {
350
- return hour(d) * 3600000 + minute(d) * 60000 + second(d) * 1000 + millisecond(d);
351
- }
352
- export function date(d) {
353
- return create(year(d), month(d), day(d), 0, 0, 0, 0, d.kind);
354
- }
355
- export function day(d) {
356
- return d.kind === 1
357
- /* UTC */
358
- ? d.getUTCDate() : d.getDate();
359
- }
360
- export function hour(d) {
361
- return d.kind === 1
362
- /* UTC */
363
- ? d.getUTCHours() : d.getHours();
364
- }
365
- export function millisecond(d) {
366
- return d.kind === 1
367
- /* UTC */
368
- ? d.getUTCMilliseconds() : d.getMilliseconds();
369
- }
370
- export function minute(d) {
371
- return d.kind === 1
372
- /* UTC */
373
- ? d.getUTCMinutes() : d.getMinutes();
374
- }
375
- export function month(d) {
376
- return (d.kind === 1
377
- /* UTC */
378
- ? d.getUTCMonth() : d.getMonth()) + 1;
379
- }
380
- export function second(d) {
381
- return d.kind === 1
382
- /* UTC */
383
- ? d.getUTCSeconds() : d.getSeconds();
384
- }
385
- export function year(d) {
386
- return d.kind === 1
387
- /* UTC */
388
- ? d.getUTCFullYear() : d.getFullYear();
389
- }
390
- export function dayOfWeek(d) {
391
- return d.kind === 1
392
- /* UTC */
393
- ? d.getUTCDay() : d.getDay();
394
- }
395
- export function dayOfYear(d) {
396
- const _year = year(d);
397
-
398
- const _month = month(d);
399
-
400
- let _day = day(d);
401
-
402
- for (let i = 1; i < _month; i++) {
403
- _day += daysInMonth(_year, i);
404
- }
405
-
406
- return _day;
407
- }
408
- export function add(d, ts) {
409
- const newDate = DateTime(d.getTime() + ts, d.kind);
410
-
411
- if (d.kind === 2
412
- /* Local */
413
- ) {
414
- const oldTzOffset = d.getTimezoneOffset();
415
- const newTzOffset = newDate.getTimezoneOffset();
416
- return oldTzOffset !== newTzOffset ? DateTime(newDate.getTime() + (newTzOffset - oldTzOffset) * 60000, d.kind) : newDate;
417
- } else {
418
- return newDate;
419
- }
420
- }
421
- export function addDays(d, v) {
422
- return add(d, v * 86400000);
423
- }
424
- export function addHours(d, v) {
425
- return add(d, v * 3600000);
426
- }
427
- export function addMinutes(d, v) {
428
- return add(d, v * 60000);
429
- }
430
- export function addSeconds(d, v) {
431
- return add(d, v * 1000);
432
- }
433
- export function addMilliseconds(d, v) {
434
- return add(d, v);
435
- }
436
- export function addYears(d, v) {
437
- const newMonth = month(d);
438
- const newYear = year(d) + v;
439
-
440
- const _daysInMonth = daysInMonth(newYear, newMonth);
441
-
442
- const newDay = Math.min(_daysInMonth, day(d));
443
- return create(newYear, newMonth, newDay, hour(d), minute(d), second(d), millisecond(d), d.kind);
444
- }
445
- export function addMonths(d, v) {
446
- let newMonth = month(d) + v;
447
- let newMonth_ = 0;
448
- let yearOffset = 0;
449
-
450
- if (newMonth > 12) {
451
- newMonth_ = newMonth % 12;
452
- yearOffset = Math.floor(newMonth / 12);
453
- newMonth = newMonth_;
454
- } else if (newMonth < 1) {
455
- newMonth_ = 12 + newMonth % 12;
456
- yearOffset = Math.floor(newMonth / 12) + (newMonth_ === 12 ? -1 : 0);
457
- newMonth = newMonth_;
458
- }
459
-
460
- const newYear = year(d) + yearOffset;
461
-
462
- const _daysInMonth = daysInMonth(newYear, newMonth);
463
-
464
- const newDay = Math.min(_daysInMonth, day(d));
465
- return create(newYear, newMonth, newDay, hour(d), minute(d), second(d), millisecond(d), d.kind);
466
- }
467
- export function subtract(d, that) {
468
- return typeof that === "number" ? add(d, -that) : d.getTime() - that.getTime();
469
- }
470
- export function toLongDateString(d) {
471
- return d.toDateString();
472
- }
473
- export function toShortDateString(d) {
474
- return d.toLocaleDateString();
475
- }
476
- export function toLongTimeString(d) {
477
- return d.toLocaleTimeString();
478
- }
479
- export function toShortTimeString(d) {
480
- return d.toLocaleTimeString().replace(/:\d\d(?!:)/, "");
481
- }
482
- export function equals(d1, d2) {
483
- return d1.getTime() === d2.getTime();
484
- }
485
- export const compare = compareDates;
486
- export const compareTo = compareDates;
487
- export function op_Addition(x, y) {
488
- return add(x, y);
489
- }
490
- export function op_Subtraction(x, y) {
491
- return subtract(x, y);
492
- }
493
- export function isDaylightSavingTime(x) {
494
- const jan = new Date(x.getFullYear(), 0, 1);
495
- const jul = new Date(x.getFullYear(), 6, 1);
496
- return isDST(jan.getTimezoneOffset(), jul.getTimezoneOffset(), x.getTimezoneOffset());
497
- }
498
-
499
- function isDST(janOffset, julOffset, tOffset) {
500
- return Math.min(janOffset, julOffset) === tOffset;
501
- }
@@ -1,208 +0,0 @@
1
- import Decimal from "../lib/big";
2
- export default Decimal;
3
- export const get_Zero = new Decimal(0);
4
- export const get_One = new Decimal(1);
5
- export const get_MinusOne = new Decimal(-1);
6
- export const get_MaxValue = new Decimal("79228162514264337593543950335");
7
- export const get_MinValue = new Decimal("-79228162514264337593543950335");
8
- export function compare(x, y) {
9
- return x.cmp(y);
10
- }
11
- export function equals(x, y) {
12
- return !x.cmp(y);
13
- }
14
- export function abs(x) {
15
- return x.abs();
16
- }
17
- export function round(x, digits = 0) {
18
- return x.round(digits, 2
19
- /* ROUND_HALF_EVEN */
20
- );
21
- }
22
- export function truncate(x) {
23
- return x.round(0, 0
24
- /* ROUND_DOWN */
25
- );
26
- }
27
- export function ceiling(x) {
28
- return x.round(0, x.cmp(0) >= 0 ? 3
29
- /* ROUND_UP */
30
- : 0
31
- /* ROUND_DOWN */
32
- );
33
- }
34
- export function floor(x) {
35
- return x.round(0, x.cmp(0) >= 0 ? 0
36
- /* ROUND_DOWN */
37
- : 3
38
- /* ROUND_UP */
39
- );
40
- }
41
- export function pow(x, n) {
42
- return x.pow(n);
43
- }
44
- export function sqrt(x) {
45
- return x.sqrt();
46
- }
47
- export function op_Addition(x, y) {
48
- return x.add(y);
49
- }
50
- export function op_Subtraction(x, y) {
51
- return x.sub(y);
52
- }
53
- export function op_Multiply(x, y) {
54
- return x.mul(y);
55
- }
56
- export function op_Division(x, y) {
57
- return x.div(y);
58
- }
59
- export function op_Modulus(x, y) {
60
- return x.mod(y);
61
- }
62
- export function op_UnaryNegation(x) {
63
- const x2 = new Decimal(x);
64
- x2.s = -x2.s || 0;
65
- return x2;
66
- }
67
- export const add = op_Addition;
68
- export const subtract = op_Subtraction;
69
- export const multiply = op_Multiply;
70
- export const divide = op_Division;
71
- export const remainder = op_Modulus;
72
- export const negate = op_UnaryNegation;
73
- export function toString(x) {
74
- return x.toString();
75
- }
76
- export function tryParse(str) {
77
- try {
78
- return [true, new Decimal(str.trim())];
79
- } catch (_a) {
80
- return [false, get_Zero];
81
- }
82
- }
83
- export function parse(str) {
84
- const [ok, value] = tryParse(str);
85
-
86
- if (ok) {
87
- return value;
88
- } else {
89
- throw new Error("Input string was not in a correct format.");
90
- }
91
- }
92
- export function toNumber(x) {
93
- return +x;
94
- }
95
-
96
- function decimalToHex(dec, bitSize) {
97
- const hex = new Uint8Array(bitSize / 4 | 0);
98
- let hexCount = 1;
99
-
100
- for (let d = 0; d < dec.length; d++) {
101
- let value = dec[d];
102
-
103
- for (let i = 0; i < hexCount; i++) {
104
- const digit = hex[i] * 10 + value | 0;
105
- hex[i] = digit & 0xF;
106
- value = digit >> 4;
107
- }
108
-
109
- if (value !== 0) {
110
- hex[hexCount++] = value;
111
- }
112
- }
113
-
114
- return hex.slice(0, hexCount); // digits in reverse order
115
- }
116
-
117
- function hexToDecimal(hex, bitSize) {
118
- const dec = new Uint8Array(bitSize * 301 / 1000 + 1 | 0);
119
- let decCount = 1;
120
-
121
- for (let d = hex.length - 1; d >= 0; d--) {
122
- let carry = hex[d];
123
-
124
- for (let i = 0; i < decCount; i++) {
125
- const val = dec[i] * 16 + carry | 0;
126
- dec[i] = val % 10 | 0;
127
- carry = val / 10 | 0;
128
- }
129
-
130
- while (carry > 0) {
131
- dec[decCount++] = carry % 10 | 0;
132
- carry = carry / 10 | 0;
133
- }
134
- }
135
-
136
- return dec.slice(0, decCount); // digits in reverse order
137
- }
138
-
139
- function setInt32Bits(hexDigits, bits, offset) {
140
- for (let i = 0; i < 8; i++) {
141
- hexDigits[offset + i] = bits >> i * 4 & 0xF;
142
- }
143
- }
144
-
145
- function getInt32Bits(hexDigits, offset) {
146
- let bits = 0;
147
-
148
- for (let i = 0; i < 8; i++) {
149
- bits = bits | hexDigits[offset + i] << i * 4;
150
- }
151
-
152
- return bits;
153
- }
154
-
155
- export function fromIntArray(bits) {
156
- return fromInts(bits[0], bits[1], bits[2], bits[3]);
157
- }
158
- export function fromInts(low, mid, high, signExp) {
159
- const isNegative = signExp < 0;
160
- const scale = signExp >> 16 & 0x7F;
161
- return fromParts(low, mid, high, isNegative, scale);
162
- }
163
- export function fromParts(low, mid, high, isNegative, scale) {
164
- const bitSize = 96;
165
- const hexDigits = new Uint8Array(bitSize / 4);
166
- setInt32Bits(hexDigits, low, 0);
167
- setInt32Bits(hexDigits, mid, 8);
168
- setInt32Bits(hexDigits, high, 16);
169
- const decDigits = hexToDecimal(hexDigits, bitSize);
170
- scale = scale & 0x7F;
171
- const big = new Decimal(0);
172
- big.c = Array.from(decDigits.reverse());
173
- big.e = decDigits.length - scale - 1;
174
- big.s = isNegative ? -1 : 1;
175
- const d = new Decimal(big);
176
- return d;
177
- }
178
- export function getBits(d) {
179
- const bitSize = 96;
180
- const decDigits = Uint8Array.from(d.c);
181
- const hexDigits = decimalToHex(decDigits, bitSize);
182
- const low = getInt32Bits(hexDigits, 0);
183
- const mid = getInt32Bits(hexDigits, 8);
184
- const high = getInt32Bits(hexDigits, 16);
185
- const decStr = d.toString();
186
- const dotPos = decStr.indexOf(".");
187
- const scale = dotPos < 0 ? 0 : decStr.length - dotPos - 1;
188
- const signExp = (scale & 0x7F) << 16 | (d.s < 0 ? 0x80000000 : 0);
189
- return [low, mid, high, signExp];
190
- }
191
- export function makeRangeStepFunction(step, last) {
192
- const stepComparedWithZero = step.cmp(get_Zero);
193
-
194
- if (stepComparedWithZero === 0) {
195
- throw new Error("The step of a range cannot be zero");
196
- }
197
-
198
- const stepGreaterThanZero = stepComparedWithZero > 0;
199
- return x => {
200
- const comparedWithLast = x.cmp(last);
201
-
202
- if (stepGreaterThanZero && comparedWithLast <= 0 || !stepGreaterThanZero && comparedWithLast >= 0) {
203
- return [x, op_Addition(x, step)];
204
- } else {
205
- return undefined;
206
- }
207
- };
208
- }