@fable-org/fable-library-ts 1.10.0 → 2.0.0-beta.2

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.
package/Async.ts CHANGED
@@ -159,12 +159,14 @@ export function sleep(millisecondsDueTime: number) {
159
159
  });
160
160
  }
161
161
 
162
- export function runSynchronously(): never {
163
- throw new Error("Asynchronous code cannot be run synchronously in JS");
164
- }
165
-
166
162
  export function start<T>(computation: Async<T>, cancellationToken?: CancellationToken) {
167
- return startWithContinuations(computation, cancellationToken);
163
+ return startWithContinuations(
164
+ computation,
165
+ emptyContinuation,
166
+ function (err) { throw err },
167
+ emptyContinuation,
168
+ cancellationToken
169
+ );
168
170
  }
169
171
 
170
172
  export function startImmediate<T>(computation: Async<T>, cancellationToken?: CancellationToken) {
@@ -173,19 +175,16 @@ export function startImmediate<T>(computation: Async<T>, cancellationToken?: Can
173
175
 
174
176
  export function startWithContinuations<T>(
175
177
  computation: Async<T>,
176
- continuation?: Continuation<T> | CancellationToken,
177
- exceptionContinuation?: Continuation<any>,
178
- cancellationContinuation?: Continuation<any>,
178
+ continuation: Continuation<T>,
179
+ exceptionContinuation: Continuation<any>,
180
+ cancellationContinuation: Continuation<any>,
179
181
  cancelToken?: CancellationToken) {
180
- if (typeof continuation !== "function") {
181
- cancelToken = continuation as CancellationToken;
182
- continuation = undefined;
183
- }
182
+
184
183
  const trampoline = new Trampoline();
185
184
  computation({
186
185
  onSuccess: continuation ? continuation as Continuation<T> : emptyContinuation,
187
- onError: exceptionContinuation ? exceptionContinuation : emptyContinuation,
188
- onCancel: cancellationContinuation ? cancellationContinuation : emptyContinuation,
186
+ onError: exceptionContinuation,
187
+ onCancel: cancellationContinuation,
189
188
  cancelToken: cancelToken ? cancelToken : defaultCancellationToken,
190
189
  trampoline,
191
190
  });
package/BigInt.ts CHANGED
@@ -130,20 +130,46 @@ export function toByteArray(value: bigint): number[] {
130
130
  return toSignedBytes(value, isBigEndian) as any as number[];
131
131
  }
132
132
 
133
- export function toInt8(x: bigint): int8 { return Number(BigInt.asIntN(8, x)); }
134
- export function toUInt8(x: bigint): uint8 { return Number(BigInt.asUintN(8, x)); }
135
- export function toInt16(x: bigint): int16 { return Number(BigInt.asIntN(16, x)); }
136
- export function toUInt16(x: bigint): uint16 { return Number(BigInt.asUintN(16, x)); }
137
- export function toInt32(x: bigint): int32 { return Number(BigInt.asIntN(32, x)); }
138
- export function toUInt32(x: bigint): uint32 { return Number(BigInt.asUintN(32, x)); }
139
- export function toInt64(x: bigint): int64 { return BigInt.asIntN(64, x); }
140
- export function toUInt64(x: bigint): uint64 { return BigInt.asUintN(64, x); }
141
- export function toInt128(x: bigint): int128 { return BigInt.asIntN(128, x); }
142
- export function toUInt128(x: bigint): uint128 { return BigInt.asUintN(128, x); }
143
- export function toNativeInt(x: bigint): nativeint { return BigInt.asIntN(64, x); }
144
- export function toUNativeInt(x: bigint): unativeint { return BigInt.asUintN(64, x); }
145
-
146
- export function toFloat16(x: bigint): float32 { return Number(x); }
133
+ export function toIntN_unchecked(bits: number, x: bigint, signed: boolean): bigint {
134
+ return signed ? BigInt.asIntN(bits, x) : BigInt.asUintN(bits, x);
135
+ }
136
+
137
+ export function toIntN(bits: number, x: bigint, signed: boolean): bigint {
138
+ let higher_bits = abs(x) >> BigInt(bits);
139
+ if (higher_bits !== 0n) {
140
+ const s = signed ? "a signed" : "an unsigned";
141
+ throw new Error(`Value was either too large or too small for ${s} ${bits}-bit integer.`);
142
+ }
143
+ return signed ? BigInt.asIntN(bits, x) : BigInt.asUintN(bits, x);
144
+ }
145
+
146
+ export function toInt8(x: bigint): int8 { return Number(toIntN(8, x, true)); }
147
+ export function toUInt8(x: bigint): uint8 { return Number(toIntN(8, x, false)); }
148
+ export function toInt16(x: bigint): int16 { return Number(toIntN(16, x, true)); }
149
+ export function toUInt16(x: bigint): uint16 { return Number(toIntN(16, x, false)); }
150
+ export function toInt32(x: bigint): int32 { return Number(toIntN(32, x, true)); }
151
+ export function toUInt32(x: bigint): uint32 { return Number(toIntN(32, x, false)); }
152
+ export function toInt64(x: bigint): int64 { return toIntN(64, x, true); }
153
+ export function toUInt64(x: bigint): uint64 { return toIntN(64, x, false); }
154
+ export function toInt128(x: bigint): int128 { return toIntN(128, x, true); }
155
+ export function toUInt128(x: bigint): uint128 { return toIntN(128, x, false); }
156
+ export function toNativeInt(x: bigint): nativeint { return toIntN(64, x, true); }
157
+ export function toUNativeInt(x: bigint): unativeint { return toIntN(64, x, false); }
158
+
159
+ export function toInt8_unchecked(x: bigint): int8 { return Number(toIntN_unchecked(8, x, true)); }
160
+ export function toUInt8_unchecked(x: bigint): uint8 { return Number(toIntN_unchecked(8, x, false)); }
161
+ export function toInt16_unchecked(x: bigint): int16 { return Number(toIntN_unchecked(16, x, true)); }
162
+ export function toUInt16_unchecked(x: bigint): uint16 { return Number(toIntN_unchecked(16, x, false)); }
163
+ export function toInt32_unchecked(x: bigint): int32 { return Number(toIntN_unchecked(32, x, true)); }
164
+ export function toUInt32_unchecked(x: bigint): uint32 { return Number(toIntN_unchecked(32, x, false)); }
165
+ export function toInt64_unchecked(x: bigint): int64 { return toIntN_unchecked(64, x, true); }
166
+ export function toUInt64_unchecked(x: bigint): uint64 { return toIntN_unchecked(64, x, false); }
167
+ export function toInt128_unchecked(x: bigint): int128 { return toIntN_unchecked(128, x, true); }
168
+ export function toUInt128_unchecked(x: bigint): uint128 { return toIntN_unchecked(128, x, false); }
169
+ export function toNativeInt_unchecked(x: bigint): nativeint { return toIntN_unchecked(64, x, true); }
170
+ export function toUNativeInt_unchecked(x: bigint): unativeint { return toIntN_unchecked(64, x, false); }
171
+
172
+ export function toFloat16(x: bigint): float16 { return Number(x); }
147
173
  export function toFloat32(x: bigint): float32 { return Number(x); }
148
174
  export function toFloat64(x: bigint): float64 { return Number(x); }
149
175
 
@@ -191,14 +217,14 @@ export function modPow(x: bigint, e: bigint, m: bigint): bigint {
191
217
  export function divRem(x: bigint, y: bigint): [bigint, bigint];
192
218
  export function divRem(x: bigint, y: bigint, out: FSharpRef<bigint>): bigint;
193
219
  export function divRem(x: bigint, y: bigint, out?: FSharpRef<bigint>): bigint | [bigint, bigint] {
194
- const div = x / y;
195
- const rem = x % y;
196
- if (out === void 0) {
197
- return [div, rem];
198
- } else {
199
- out.contents = rem;
200
- return div;
201
- }
220
+ const div = x / y;
221
+ const rem = x % y;
222
+ if (out === void 0) {
223
+ return [div, rem];
224
+ } else {
225
+ out.contents = rem;
226
+ return div;
227
+ }
202
228
  }
203
229
 
204
230
  export function greatestCommonDivisor(x: bigint, y: bigint): bigint {
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 2.0.0-beta.2 - 2025-03-03
11
+
12
+ * [JS/TS] Fix #4049: decimal/bigint to integer conversion checks (by @ncave)
13
+ * [JS/TS] Fix `decimal` to `char` conversion checks (by @ManngelMaxime)
14
+ * [JS/TS] Propagate non-captured exception when running `Async.Start` or `Async.StartImmediate` (by @MangelMaxime)
15
+ * [JS/TS] Remove `Async.RunSynchronously` (by @MangelMaxime)
16
+ * [JS/TS] Change signature of `startWithContinuations` to always require all its arguments (by @MangelMaxime)
17
+ * [JS/TS] Fix short `DateTime` and `DateTimeOffset` short format strings (by @MangelMaxime)
18
+ * [JS/TS] Add `C` and `c` format for numeric types (by @MangelMaxime)
19
+ * [JS/TS] Add `B` and `b` format for numeric types (by @MangelMaxime)
20
+ * [JS/TS] Add `n` format for numeric types (by @MangelMaxime)
21
+ * [JS/TS] Fix numeric formats (by @MangelMaxime)
22
+
23
+ ## 2.0.0-beta.1 - 2025-02-16
24
+
25
+ * Compiled with Fable 5.0.0-alpha.10
26
+
10
27
  ## 1.10.0 - 2025-01-23
11
28
 
12
29
  ### Added
@@ -55,7 +72,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55
72
 
56
73
  * [JS/TS] Fix escaping of `{` and `}` in FormattableString (#3890) (by @roboz0r)
57
74
  * [JS/TS] Fix `uri.Host` to return the host name without the port (by @MangelMaxime)
58
- * [JS/TS] Fix TypeScript compilation by resolving type of `jsOptions` (#3894) (by @ManngelMaxime)
75
+ * [JS/TS] Fix TypeScript compilation by resolving type of `jsOptions` (#3894) (by @MangelMaxime)
59
76
 
60
77
  ## 1.4.3 - 2024-09-04
61
78