@magnusopera/fscript 0.75.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 (79) hide show
  1. package/README.md +5 -0
  2. package/dist/FScript.Language/Ast.js +234 -0
  3. package/dist/FScript.Language/BuiltinFunctions.js +2039 -0
  4. package/dist/FScript.Language/BuiltinSignatures.js +24 -0
  5. package/dist/FScript.Language/BuiltinTypes.js +13 -0
  6. package/dist/FScript.Language/Error.js +74 -0
  7. package/dist/FScript.Language/Eval.js +2404 -0
  8. package/dist/FScript.Language/IncludeResolver.js +806 -0
  9. package/dist/FScript.Language/Lexer.js +1067 -0
  10. package/dist/FScript.Language/Library.js +28 -0
  11. package/dist/FScript.Language/Parser.js +2368 -0
  12. package/dist/FScript.Language/Pretty.js +115 -0
  13. package/dist/FScript.Language/Span.js +33 -0
  14. package/dist/FScript.Language/Token.js +32 -0
  15. package/dist/FScript.Language/TypeInfer.js +2561 -0
  16. package/dist/FScript.Language/Types.js +205 -0
  17. package/dist/FScript.Language/Value.js +91 -0
  18. package/dist/Library.js +732 -0
  19. package/dist/fable_modules/fable-library-js.5.2.0/Array.js +1347 -0
  20. package/dist/fable_modules/fable-library-js.5.2.0/Async.js +134 -0
  21. package/dist/fable_modules/fable-library-js.5.2.0/AsyncBuilder.js +183 -0
  22. package/dist/fable_modules/fable-library-js.5.2.0/BigInt.js +306 -0
  23. package/dist/fable_modules/fable-library-js.5.2.0/BitConverter.js +138 -0
  24. package/dist/fable_modules/fable-library-js.5.2.0/Boolean.js +22 -0
  25. package/dist/fable_modules/fable-library-js.5.2.0/CHANGELOG.md +234 -0
  26. package/dist/fable_modules/fable-library-js.5.2.0/Char.js +202 -0
  27. package/dist/fable_modules/fable-library-js.5.2.0/Choice.js +184 -0
  28. package/dist/fable_modules/fable-library-js.5.2.0/CollectionUtil.js +182 -0
  29. package/dist/fable_modules/fable-library-js.5.2.0/ConditionalWeakTable.js +21 -0
  30. package/dist/fable_modules/fable-library-js.5.2.0/Date.js +841 -0
  31. package/dist/fable_modules/fable-library-js.5.2.0/DateOffset.js +261 -0
  32. package/dist/fable_modules/fable-library-js.5.2.0/DateOnly.js +124 -0
  33. package/dist/fable_modules/fable-library-js.5.2.0/Decimal.js +238 -0
  34. package/dist/fable_modules/fable-library-js.5.2.0/Double.js +47 -0
  35. package/dist/fable_modules/fable-library-js.5.2.0/Encoding.js +185 -0
  36. package/dist/fable_modules/fable-library-js.5.2.0/Event.js +93 -0
  37. package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Collections.js +45 -0
  38. package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.CompilerServices.js +27 -0
  39. package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.js +156 -0
  40. package/dist/fable_modules/fable-library-js.5.2.0/Global.js +29 -0
  41. package/dist/fable_modules/fable-library-js.5.2.0/Guid.js +161 -0
  42. package/dist/fable_modules/fable-library-js.5.2.0/Int32.js +135 -0
  43. package/dist/fable_modules/fable-library-js.5.2.0/List.js +1323 -0
  44. package/dist/fable_modules/fable-library-js.5.2.0/Long.js +47 -0
  45. package/dist/fable_modules/fable-library-js.5.2.0/MailboxProcessor.js +94 -0
  46. package/dist/fable_modules/fable-library-js.5.2.0/Map.js +1396 -0
  47. package/dist/fable_modules/fable-library-js.5.2.0/MapUtil.js +130 -0
  48. package/dist/fable_modules/fable-library-js.5.2.0/MutableMap.js +339 -0
  49. package/dist/fable_modules/fable-library-js.5.2.0/MutableSet.js +233 -0
  50. package/dist/fable_modules/fable-library-js.5.2.0/Native.js +14 -0
  51. package/dist/fable_modules/fable-library-js.5.2.0/Numeric.js +75 -0
  52. package/dist/fable_modules/fable-library-js.5.2.0/Observable.js +113 -0
  53. package/dist/fable_modules/fable-library-js.5.2.0/Option.js +104 -0
  54. package/dist/fable_modules/fable-library-js.5.2.0/README.md +3 -0
  55. package/dist/fable_modules/fable-library-js.5.2.0/Random.js +172 -0
  56. package/dist/fable_modules/fable-library-js.5.2.0/Range.js +45 -0
  57. package/dist/fable_modules/fable-library-js.5.2.0/Reflection.js +479 -0
  58. package/dist/fable_modules/fable-library-js.5.2.0/RegExp.js +141 -0
  59. package/dist/fable_modules/fable-library-js.5.2.0/Result.js +165 -0
  60. package/dist/fable_modules/fable-library-js.5.2.0/Seq.js +1417 -0
  61. package/dist/fable_modules/fable-library-js.5.2.0/Seq2.js +111 -0
  62. package/dist/fable_modules/fable-library-js.5.2.0/Set.js +1816 -0
  63. package/dist/fable_modules/fable-library-js.5.2.0/String.js +674 -0
  64. package/dist/fable_modules/fable-library-js.5.2.0/System.Collections.Generic.js +333 -0
  65. package/dist/fable_modules/fable-library-js.5.2.0/System.Text.js +200 -0
  66. package/dist/fable_modules/fable-library-js.5.2.0/System.js +283 -0
  67. package/dist/fable_modules/fable-library-js.5.2.0/TimeOnly.js +122 -0
  68. package/dist/fable_modules/fable-library-js.5.2.0/TimeSpan.js +180 -0
  69. package/dist/fable_modules/fable-library-js.5.2.0/Timer.js +67 -0
  70. package/dist/fable_modules/fable-library-js.5.2.0/Types.js +198 -0
  71. package/dist/fable_modules/fable-library-js.5.2.0/Unicode.13.0.0.js +4 -0
  72. package/dist/fable_modules/fable-library-js.5.2.0/Uri.js +165 -0
  73. package/dist/fable_modules/fable-library-js.5.2.0/Util.js +795 -0
  74. package/dist/fable_modules/fable-library-js.5.2.0/big.d.ts +338 -0
  75. package/dist/fable_modules/fable-library-js.5.2.0/lib/big.js +825 -0
  76. package/dist/fable_modules/fable-library-js.5.2.0/package.json +24 -0
  77. package/dist/fable_modules/fable-library-js.5.2.0/quotation.js +618 -0
  78. package/dist/fable_modules/project_cracked.json +1 -0
  79. package/package.json +36 -0
@@ -0,0 +1,138 @@
1
+ const littleEndian = true;
2
+ export function isLittleEndian() {
3
+ return littleEndian;
4
+ }
5
+ export function getBytesBoolean(value) {
6
+ const bytes = new Uint8Array(1);
7
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
8
+ view.setUint8(0, value ? 1 : 0);
9
+ return bytes;
10
+ }
11
+ export function getBytesChar(value) {
12
+ const bytes = new Uint8Array(2);
13
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
14
+ view.setUint16(0, value.charCodeAt(0), littleEndian);
15
+ return bytes;
16
+ }
17
+ export function getBytesInt16(value) {
18
+ const bytes = new Uint8Array(2);
19
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
20
+ view.setInt16(0, value, littleEndian);
21
+ return bytes;
22
+ }
23
+ export function getBytesInt32(value) {
24
+ const bytes = new Uint8Array(4);
25
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
26
+ view.setInt32(0, value, littleEndian);
27
+ return bytes;
28
+ }
29
+ export function getBytesInt64(value) {
30
+ const bytes = new Uint8Array(8);
31
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
32
+ view.setBigInt64(0, value, littleEndian);
33
+ return bytes;
34
+ }
35
+ export function getBytesUInt16(value) {
36
+ const bytes = new Uint8Array(2);
37
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
38
+ view.setUint16(0, value, littleEndian);
39
+ return bytes;
40
+ }
41
+ export function getBytesUInt32(value) {
42
+ const bytes = new Uint8Array(4);
43
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
44
+ view.setUint32(0, value, littleEndian);
45
+ return bytes;
46
+ }
47
+ export function getBytesUInt64(value) {
48
+ const bytes = new Uint8Array(8);
49
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
50
+ view.setBigUint64(0, value, littleEndian);
51
+ return bytes;
52
+ }
53
+ export function getBytesSingle(value) {
54
+ const bytes = new Uint8Array(4);
55
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
56
+ view.setFloat32(0, value, littleEndian);
57
+ return bytes;
58
+ }
59
+ export function getBytesDouble(value) {
60
+ const bytes = new Uint8Array(8);
61
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
62
+ view.setFloat64(0, value, littleEndian);
63
+ return bytes;
64
+ }
65
+ export function int64BitsToDouble(value) {
66
+ const buffer = new ArrayBuffer(8);
67
+ const view = new DataView(buffer);
68
+ view.setBigInt64(0, value, littleEndian);
69
+ return view.getFloat64(0, littleEndian);
70
+ }
71
+ export function doubleToInt64Bits(value) {
72
+ const buffer = new ArrayBuffer(8);
73
+ const view = new DataView(buffer);
74
+ view.setFloat64(0, value, littleEndian);
75
+ return view.getBigInt64(0, littleEndian);
76
+ }
77
+ export function toBoolean(bytes, offset) {
78
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
79
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
80
+ return view.getUint8(offset) === 1 ? true : false;
81
+ }
82
+ export function toChar(bytes, offset) {
83
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
84
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
85
+ const code = view.getUint16(offset, littleEndian);
86
+ return String.fromCharCode(code);
87
+ }
88
+ export function toInt16(bytes, offset) {
89
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
90
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
91
+ return view.getInt16(offset, littleEndian);
92
+ }
93
+ export function toInt32(bytes, offset) {
94
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
95
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
96
+ return view.getInt32(offset, littleEndian);
97
+ }
98
+ export function toInt64(bytes, offset) {
99
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
100
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
101
+ return view.getBigInt64(offset, littleEndian);
102
+ }
103
+ export function toUInt16(bytes, offset) {
104
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
105
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
106
+ return view.getUint16(offset, littleEndian);
107
+ }
108
+ export function toUInt32(bytes, offset) {
109
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
110
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
111
+ return view.getUint32(offset, littleEndian);
112
+ }
113
+ export function toUInt64(bytes, offset) {
114
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
115
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
116
+ return view.getBigUint64(offset, littleEndian);
117
+ }
118
+ export function toSingle(bytes, offset) {
119
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
120
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
121
+ return view.getFloat32(offset, littleEndian);
122
+ }
123
+ export function toDouble(bytes, offset) {
124
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
125
+ const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
126
+ return view.getFloat64(offset, littleEndian);
127
+ }
128
+ export function toString(bytes, offset, count) {
129
+ const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
130
+ let buffer = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
131
+ if (offset != null && count != null) {
132
+ buffer = buffer.subarray(offset, offset + count);
133
+ }
134
+ else if (offset != null) {
135
+ buffer = buffer.subarray(offset);
136
+ }
137
+ return Array.from(buffer).map((b) => ("0" + b.toString(16)).slice(-2)).join("-");
138
+ }
@@ -0,0 +1,22 @@
1
+ import { FSharpRef } from "./Types.js";
2
+ import { Exception } from "./Util.js";
3
+ export function tryParse(str, defValue) {
4
+ if (str != null && str.match(/^\s*true\s*$/i)) {
5
+ defValue.contents = true;
6
+ return true;
7
+ }
8
+ else if (str != null && str.match(/^\s*false\s*$/i)) {
9
+ defValue.contents = false;
10
+ return true;
11
+ }
12
+ return false;
13
+ }
14
+ export function parse(str) {
15
+ const defValue = new FSharpRef(false);
16
+ if (tryParse(str, defValue)) {
17
+ return defValue.contents;
18
+ }
19
+ else {
20
+ throw new Exception(`String '${str}' was not recognized as a valid Boolean.`);
21
+ }
22
+ }
@@ -0,0 +1,234 @@
1
+ ---
2
+ last_commit_released: 15eb83ed36657f75073fb0e1b4cac677e24fc9bb
3
+ updaters:
4
+ - package.json:
5
+ file: package.json
6
+ - regex:
7
+ file: ./../Fable.Transforms/Global/Compiler.fs
8
+ pattern: (?<=let JS_LIBRARY_VERSION = ").*(?=")
9
+ ---
10
+
11
+ # Changelog
12
+
13
+ All notable changes to this project will be documented in this file.
14
+
15
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
16
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
17
+
18
+ ## 2.1.1 - 2026-06-10
19
+
20
+ ### 🐞 Bug Fixes
21
+
22
+ * *(js/ts)* Reject JS-permissive date strings that .NET TryParse rejects (#4588) ([09003de](https://github.com/fable-compiler/Fable/commit/09003de8bc72e4f73281828d905d49aab7db3f55))
23
+ * *(js/ts)* Make Exception.ToString() return the message instead of "Exception" (#4635) ([4c36f76](https://github.com/fable-compiler/Fable/commit/4c36f761bd378da800e30657c58355bd5324a653))
24
+
25
+ <strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/63bcd3d90f37cb3934edcc59b5f54f49ffab3896..15eb83ed36657f75073fb0e1b4cac677e24fc9bb)</small></strong>
26
+
27
+ ## 2.1.0 - 2026-05-28
28
+
29
+ ### 🚀 Features
30
+
31
+ * *(js/ts/python)* Add missing standard DateTime format specifiers for JS/TS and Python (#4547) ([90f5eb7](https://github.com/fable-compiler/Fable/commit/90f5eb7f61710bc679f6fdec30ff5d864984ac08))
32
+ * *(js/ts/python)* Add missing StringBuilder.Append overloads for numeric types (#4568) ([b402c30](https://github.com/fable-compiler/Fable/commit/b402c30d04bfca8644314ba4b21894abfff6a713))
33
+
34
+ ### 🐞 Bug Fixes
35
+
36
+ * [JS/TS] Fix DatetimeOffset.ToString("s") (#4596) ([3ce6f3f](https://github.com/fable-compiler/Fable/commit/3ce6f3fd88cc7f67e34e2bbc311e722c55ffbf45))
37
+ * *(js/ts)* Fix datetime custom format off by one year (#4558) ([83bdbb5](https://github.com/fable-compiler/Fable/commit/83bdbb5b34e70eae203831a3a442d477d15911e1))
38
+ * *(js/ts)* Hex format specifier uses no padding unless precision is specified (#4603) ([ba9857a](https://github.com/fable-compiler/Fable/commit/ba9857a4dcbf7ab1f936241f6619fda43e039040))
39
+ * *(js/ts)* Fix Decimal.GetBits returning incorrect mantissa after round arithmetic result (#4561) ([345bcd4](https://github.com/fable-compiler/Fable/commit/345bcd4b99417b304c71059966126fad74cf3a97))
40
+ * *(js/ts)* Fix G/g format specifier corrupting exponential notation when trimming trailing zeros (#4587) ([773c098](https://github.com/fable-compiler/Fable/commit/773c098a8f7ac7e8db1d4e490dec1294a80321ee))
41
+ * *(js/ts/python)* Fix FSharpOption not recognized as union type in F# reflection (#4529) ([d78a37d](https://github.com/fable-compiler/Fable/commit/d78a37db9f4c25eb51fac8afcd320b4ea36c60a7))
42
+ * *(ts)* Enforce browser-only compatibility in fable-library-ts tsconfig (#4563) ([10c81c1](https://github.com/fable-compiler/Fable/commit/10c81c1361208eb61f5fa78c6704e6fccc068fb1))
43
+
44
+ <strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/b471dc16fc3b5132af77b5974d1669c9b8220cca..63bcd3d90f37cb3934edcc59b5f54f49ffab3896)</small></strong>
45
+
46
+ ## 2.0.0 - 2026-04-21
47
+
48
+ ### Fixed
49
+
50
+ * [JS/TS] Fix `ResizeArray` (`System.Collections.Generic.List`) equality to use reference equality instead of structural equality (fixes #3718)
51
+ * [JS/TS] Fix `String.Contains` ignoring `StringComparison` argument (second argument was silently discarded)
52
+
53
+ ## 2.0.0-rc.6 - 2026-04-07
54
+
55
+ ### Fixed
56
+
57
+ * [JS/TS] Fix `Async.StartChild` with timeout always timing out even when the computation finishes before the deadline (fixes #4481) (by @MangelMaxime)
58
+
59
+ ## 2.0.0-rc.5 - 2026-03-31
60
+
61
+ ### Fixed
62
+
63
+ * [JS/TS] Improve `Regex.Escape` and `Regex.Unescape` handling (by @MangelMaxime)
64
+ * [JS/TS] Fixed quotation for union string cases (by @MangelMaxime)
65
+
66
+ ## 2.0.0-rc.4 - 2026-03-19
67
+
68
+ ### Fixed
69
+
70
+ * [JS/TS] Fix `Unchecked.defaultof<char>` being emitted as `null` instead of `'\0'` (by @MangelMaxime)
71
+
72
+ ## 2.0.0-rc.3 - 2026-03-10
73
+
74
+ ### Fixed
75
+
76
+ * [TS] Expose optional `stack` property on `Exception` (by @MangelMaxime)
77
+
78
+ ## 2.0.0-rc.2 - 2026-03-03
79
+
80
+ ### Fixed
81
+
82
+ * [JS/TS] Allows compiling `fable-library-ts` for Browser environment (by @goswinr)
83
+
84
+ ## 2.0.0-rc.1 - 2026-02-26
85
+
86
+ ## 2.0.0-beta.7 - 2026-02-03
87
+
88
+ * [JS/TS] Fix `StringBuilder.Chars` getter and setter (by @MangelMaxime)
89
+
90
+ ## 2.0.0-beta.6 - 2025-12-26
91
+
92
+ ### Fixed
93
+
94
+ * [JS/TS] Fix #4305 `DateTimeOffset.Now` returns wrong time (by @ncave)
95
+
96
+ ## 2.0.0-beta.5 - 2025-11-19
97
+
98
+ ### Changed
99
+
100
+ * [JS/TS] Replace the deprecated `substr` method with `slice` (by @Thorium)
101
+
102
+ ## 2.0.0-beta.4 - 2025-07-25
103
+
104
+ ### Added
105
+
106
+ * [JS/TS] Initial support for Nullable Reference Types (by @ncave)
107
+
108
+ ## 2.0.0-beta.3 - 2025-03-14
109
+
110
+ ### Fixed
111
+
112
+ * [JS/TS] Make `nullArgCheck` report the same error message as on .NET (by @MangelMaxime)
113
+
114
+ ## 2.0.0-beta.2 - 2025-03-03
115
+
116
+ * [JS/TS] Fix #4049: decimal/bigint to integer conversion checks (by @ncave)
117
+ * [JS/TS] Fix `decimal` to `char` conversion checks (by @ManngelMaxime)
118
+ * [JS/TS] Propagate non-captured exception when running `Async.Start` or `Async.StartImmediate` (by @MangelMaxime)
119
+ * [JS/TS] Remove `Async.RunSynchronously` (by @MangelMaxime)
120
+ * [JS/TS] Change signature of `startWithContinuations` to always require all its arguments (by @MangelMaxime)
121
+ * [JS/TS] Fix short `DateTime` and `DateTimeOffset` short format strings (by @MangelMaxime)
122
+ * [JS/TS] Add `C` and `c` format for numeric types (by @MangelMaxime)
123
+ * [JS/TS] Add `B` and `b` format for numeric types (by @MangelMaxime)
124
+ * [JS/TS] Add `n` format for numeric types (by @MangelMaxime)
125
+ * [JS/TS] Fix numeric formats (by @MangelMaxime)
126
+
127
+ ## 2.0.0-beta.1 - 2025-02-16
128
+
129
+ * Compiled with Fable 5.0.0-alpha.10
130
+
131
+ ## 1.10.0 - 2025-01-23
132
+
133
+ ### Added
134
+
135
+ * [JS/TS] Add `StringBuiler.Append(c: char, repeatCount: int)` overload (by @roboz0r)
136
+
137
+ ## 1.9.0 - 2025-01-09
138
+
139
+ ### Added
140
+
141
+ * [JS/TS] Add new `TimSpane` overload support coming from .NET 9 (by @MangelMaxime)
142
+
143
+ ### Fixed
144
+
145
+ * [JS/TS] Fix `DateTimeOffset.ToLocalTime` (by @MangelMaxime)
146
+
147
+ ## 1.8.0 - 2024-11-19
148
+
149
+ * [JS/TS] Fix `h` in `DateTime.ToString` (@MangelMaxime)
150
+ * [JS/TS] Fix `hh` in `DateTime.ToString` (@MangelMaxime)
151
+
152
+ ## 1.7.0 - 2024-11-19
153
+
154
+ ### Fixed
155
+
156
+ * [JS/TS] Added missing IReadOnlyCollection helpers (#3953)
157
+
158
+ ## 1.6.0 - 2024-10-02
159
+
160
+ ### Removed
161
+
162
+ * Remove `Async` (from `Async.ts`) class (by @MangelMaxime)
163
+
164
+ ### Changed
165
+
166
+ * Renamed `IAsync` to `Async` in `AsyncBuilder.ts` (#3906) (by @ncave)
167
+
168
+ ## 1.5.0 - 2024-09-19
169
+
170
+ ### Added
171
+
172
+ * [JS/TS] Add support for `OrdinalIgnoreCase` overload for `String.EndsWith` (#3892) (by @goswinr)
173
+ * [JS/TS] Add `uri.Port`, `uri.IsDefaultPort` (by @MangelMaxime)
174
+
175
+ ### Fixed
176
+
177
+ * [JS/TS] Fix escaping of `{` and `}` in FormattableString (#3890) (by @roboz0r)
178
+ * [JS/TS] Fix `uri.Host` to return the host name without the port (by @MangelMaxime)
179
+ * [JS/TS] Fix TypeScript compilation by resolving type of `jsOptions` (#3894) (by @MangelMaxime)
180
+
181
+ ## 1.4.3 - 2024-09-04
182
+
183
+ * [JS/TS] Fixed Decimal comparisons (#3884) (by @ncave)
184
+
185
+ ## 1.4.2 - 2024-06-13
186
+
187
+ ### Fixed
188
+
189
+ * [JS/TS] Fixed BigInt.ToDecimal with negative values (#3500) (by @ncave)
190
+
191
+ ## 1.4.1 - 2024-06-13
192
+
193
+ ### Fixed
194
+
195
+ * [JS/TS] Fixed DateTime.MinValue, DateTime.MaxValue (#3836) (by @ncave)
196
+
197
+ ## 1.4.0 - 2024-03-20
198
+
199
+ ### Added
200
+
201
+ * [JS/TS] Add `ConditionalWeakTable` (by @chkn)
202
+
203
+ ## 1.3.0 - 2024-03-18
204
+
205
+ * [JS/TS] `Boolean.tryParse` should not crash on `null` string (@goswinr)
206
+
207
+ ## 1.2.0 - 2024-03-01
208
+
209
+ ### Fixed
210
+
211
+ * [GH-3772](https://github.com/fable-compiler/Fable/pull/3772) [JS/TS] Re-implement `DateTime.ToString` custom format handling (by @MangelMaxime)
212
+
213
+ It now supports all custom format specifiers, and behave as if `CultureInfo.InvariantCulture` was used (Fable does not support Globalization).
214
+
215
+ ## 1.1.0 - 2024-02-20
216
+
217
+ ### Added
218
+
219
+ #### JavaScript
220
+
221
+ * [GH-3759](https://github.com/fable-compiler/Fable/issues/3759) Add `StringBuilder.Chars` (by @MangelMaxime)
222
+ * Add `StringBuilder.AppendFormat` (by @ncave)
223
+ * [GH-3748](https://github.com/fable-compiler/Fable/pull/3748) Add `Array.getItem` and `Array.setItem` (by @MangelMaxime)
224
+
225
+ ## 1.0.0 - 2024-02-13
226
+
227
+ * Release stable version
228
+
229
+ ## 1.0.0-beta-001 - 2024-02-12
230
+
231
+ ### Changed
232
+
233
+ * Separate `Result` from `Choice`
234
+ * Released as part of Fable 4.12.0
@@ -0,0 +1,202 @@
1
+ import * as Unicode from "./Unicode.13.0.0.js";
2
+ import { Exception } from "./Util.js";
3
+ function getCategoryFunc() {
4
+ // unpack Unicode codepoint ranges (delta encoded) and general categories
5
+ const offset = 35; // offsets unprintable characters
6
+ const a1 = [...Unicode.rangeDeltas].map((ch) => (ch.codePointAt(0) ?? 0) - offset);
7
+ const a2 = [...Unicode.categories].map((ch) => (ch.codePointAt(0) ?? 0) - offset);
8
+ const codepoints = new Uint32Array(a1);
9
+ const categories = new Uint8Array(a2);
10
+ for (let i = 1; i < codepoints.length; ++i) {
11
+ codepoints[i] += codepoints[i - 1];
12
+ }
13
+ // binary search in unicode ranges
14
+ return (cp) => {
15
+ let hi = codepoints.length;
16
+ let lo = 0;
17
+ while (hi - lo > 1) {
18
+ const mid = Math.floor((hi + lo) / 2);
19
+ const test = codepoints[mid];
20
+ if (cp < test) {
21
+ hi = mid;
22
+ }
23
+ else if (cp === test) {
24
+ hi = lo = mid;
25
+ break;
26
+ }
27
+ else if (test < cp) {
28
+ lo = mid;
29
+ }
30
+ }
31
+ return categories[lo];
32
+ };
33
+ }
34
+ export const UnicodeCategory = {
35
+ UppercaseLetter: 0,
36
+ LowercaseLetter: 1,
37
+ TitlecaseLetter: 2,
38
+ ModifierLetter: 3,
39
+ OtherLetter: 4,
40
+ NonSpacingMark: 5,
41
+ SpacingCombiningMark: 6,
42
+ EnclosingMark: 7,
43
+ DecimalDigitNumber: 8,
44
+ LetterNumber: 9,
45
+ OtherNumber: 10,
46
+ SpaceSeparator: 11,
47
+ LineSeparator: 12,
48
+ ParagraphSeparator: 13,
49
+ Control: 14,
50
+ Format: 15,
51
+ Surrogate: 16,
52
+ PrivateUse: 17,
53
+ ConnectorPunctuation: 18,
54
+ DashPunctuation: 19,
55
+ OpenPunctuation: 20,
56
+ ClosePunctuation: 21,
57
+ InitialQuotePunctuation: 22,
58
+ FinalQuotePunctuation: 23,
59
+ OtherPunctuation: 24,
60
+ MathSymbol: 25,
61
+ CurrencySymbol: 26,
62
+ ModifierSymbol: 27,
63
+ OtherSymbol: 28,
64
+ OtherNotAssigned: 29,
65
+ };
66
+ const isControlMask = 1 << UnicodeCategory.Control;
67
+ const isDigitMask = 1 << UnicodeCategory.DecimalDigitNumber;
68
+ const isLetterMask = 0
69
+ | 1 << UnicodeCategory.UppercaseLetter
70
+ | 1 << UnicodeCategory.LowercaseLetter
71
+ | 1 << UnicodeCategory.TitlecaseLetter
72
+ | 1 << UnicodeCategory.ModifierLetter
73
+ | 1 << UnicodeCategory.OtherLetter;
74
+ const isLetterOrDigitMask = isLetterMask | isDigitMask;
75
+ const isUpperMask = 1 << UnicodeCategory.UppercaseLetter;
76
+ const isLowerMask = 1 << UnicodeCategory.LowercaseLetter;
77
+ const isNumberMask = 0
78
+ | 1 << UnicodeCategory.DecimalDigitNumber
79
+ | 1 << UnicodeCategory.LetterNumber
80
+ | 1 << UnicodeCategory.OtherNumber;
81
+ const isPunctuationMask = 0
82
+ | 1 << UnicodeCategory.ConnectorPunctuation
83
+ | 1 << UnicodeCategory.DashPunctuation
84
+ | 1 << UnicodeCategory.OpenPunctuation
85
+ | 1 << UnicodeCategory.ClosePunctuation
86
+ | 1 << UnicodeCategory.InitialQuotePunctuation
87
+ | 1 << UnicodeCategory.FinalQuotePunctuation
88
+ | 1 << UnicodeCategory.OtherPunctuation;
89
+ const isSeparatorMask = 0
90
+ | 1 << UnicodeCategory.SpaceSeparator
91
+ | 1 << UnicodeCategory.LineSeparator
92
+ | 1 << UnicodeCategory.ParagraphSeparator;
93
+ const isSymbolMask = 0
94
+ | 1 << UnicodeCategory.MathSymbol
95
+ | 1 << UnicodeCategory.CurrencySymbol
96
+ | 1 << UnicodeCategory.ModifierSymbol
97
+ | 1 << UnicodeCategory.OtherSymbol;
98
+ const isWhiteSpaceMask = 0
99
+ | 1 << UnicodeCategory.SpaceSeparator
100
+ | 1 << UnicodeCategory.LineSeparator
101
+ | 1 << UnicodeCategory.ParagraphSeparator;
102
+ const unicodeCategoryFunc = getCategoryFunc();
103
+ function charCodeAt(s, index) {
104
+ if (index >= 0 && index < s.length) {
105
+ return s.charCodeAt(index);
106
+ }
107
+ else {
108
+ throw new Exception("Index out of range.");
109
+ }
110
+ }
111
+ export const getUnicodeCategory = (s) => getUnicodeCategory2(s, 0);
112
+ export const isControl = (s) => isControl2(s, 0);
113
+ export const isDigit = (s) => isDigit2(s, 0);
114
+ export const isLetter = (s) => isLetter2(s, 0);
115
+ export const isLetterOrDigit = (s) => isLetterOrDigit2(s, 0);
116
+ export const isUpper = (s) => isUpper2(s, 0);
117
+ export const isLower = (s) => isLower2(s, 0);
118
+ export const isNumber = (s) => isNumber2(s, 0);
119
+ export const isPunctuation = (s) => isPunctuation2(s, 0);
120
+ export const isSeparator = (s) => isSeparator2(s, 0);
121
+ export const isSymbol = (s) => isSymbol2(s, 0);
122
+ export const isWhiteSpace = (s) => isWhiteSpace2(s, 0);
123
+ export const isHighSurrogate = (s) => isHighSurrogate2(s, 0);
124
+ export const isLowSurrogate = (s) => isLowSurrogate2(s, 0);
125
+ export const isSurrogate = (s) => isSurrogate2(s, 0);
126
+ export function getUnicodeCategory2(s, index) {
127
+ const cp = charCodeAt(s, index);
128
+ return unicodeCategoryFunc(cp);
129
+ }
130
+ export function isControl2(s, index) {
131
+ const test = 1 << getUnicodeCategory2(s, index);
132
+ return (test & isControlMask) !== 0;
133
+ }
134
+ export function isDigit2(s, index) {
135
+ const test = 1 << getUnicodeCategory2(s, index);
136
+ return (test & isDigitMask) !== 0;
137
+ }
138
+ export function isLetter2(s, index) {
139
+ const test = 1 << getUnicodeCategory2(s, index);
140
+ return (test & isLetterMask) !== 0;
141
+ }
142
+ export function isLetterOrDigit2(s, index) {
143
+ const test = 1 << getUnicodeCategory2(s, index);
144
+ return (test & isLetterOrDigitMask) !== 0;
145
+ }
146
+ export function isUpper2(s, index) {
147
+ const test = 1 << getUnicodeCategory2(s, index);
148
+ return (test & isUpperMask) !== 0;
149
+ }
150
+ export function isLower2(s, index) {
151
+ const test = 1 << getUnicodeCategory2(s, index);
152
+ return (test & isLowerMask) !== 0;
153
+ }
154
+ export function isNumber2(s, index) {
155
+ const test = 1 << getUnicodeCategory2(s, index);
156
+ return (test & isNumberMask) !== 0;
157
+ }
158
+ export function isPunctuation2(s, index) {
159
+ const test = 1 << getUnicodeCategory2(s, index);
160
+ return (test & isPunctuationMask) !== 0;
161
+ }
162
+ export function isSeparator2(s, index) {
163
+ const test = 1 << getUnicodeCategory2(s, index);
164
+ return (test & isSeparatorMask) !== 0;
165
+ }
166
+ export function isSymbol2(s, index) {
167
+ const test = 1 << getUnicodeCategory2(s, index);
168
+ return (test & isSymbolMask) !== 0;
169
+ }
170
+ export function isWhiteSpace2(s, index) {
171
+ const test = 1 << getUnicodeCategory2(s, index);
172
+ if ((test & isWhiteSpaceMask) !== 0) {
173
+ return true;
174
+ }
175
+ const cp = charCodeAt(s, index);
176
+ return (0x09 <= cp && cp <= 0x0D) || cp === 0x85 || cp === 0xA0;
177
+ }
178
+ export function isHighSurrogate2(s, index) {
179
+ const cp = charCodeAt(s, index);
180
+ return (0xD800 <= cp && cp <= 0xDBFF);
181
+ }
182
+ export function isLowSurrogate2(s, index) {
183
+ const cp = charCodeAt(s, index);
184
+ return (0xDC00 <= cp && cp <= 0xDFFF);
185
+ }
186
+ export function isSurrogate2(s, index) {
187
+ const cp = charCodeAt(s, index);
188
+ return (0xD800 <= cp && cp <= 0xDFFF);
189
+ }
190
+ export function isSurrogatePair(s, index) {
191
+ return typeof index === "number"
192
+ ? isHighSurrogate2(s, index) && isLowSurrogate2(s, index + 1)
193
+ : isHighSurrogate(s) && isLowSurrogate(index);
194
+ }
195
+ export function parse(input) {
196
+ if (input.length === 1) {
197
+ return input[0];
198
+ }
199
+ else {
200
+ throw new Exception("String must be exactly one character long.");
201
+ }
202
+ }