@fable-org/fable-library-ts 1.8.0 → 1.10.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.
package/Array.ts CHANGED
@@ -5,6 +5,7 @@ import { value as value_2, map as map_1, defaultArg, Option, some } from "./Opti
5
5
  import { min as min_1, max as max_1 } from "./Double.js";
6
6
  import { IComparer, equals as equals_1, IDisposable, disposeSafe, IEnumerator, getEnumerator, copyToArray, IEqualityComparer, defaultOf } from "./Util.js";
7
7
  import { SR_indexOutOfBounds } from "./Global.js";
8
+ import { Operators_IsNull } from "./FSharp.Core.js";
8
9
  import { FSharpRef } from "./Types.js";
9
10
 
10
11
  function indexNotFound<$a>(): $a {
@@ -865,15 +866,15 @@ export function splitAt<T>(index: int32, array: T[]): [T[], T[]] {
865
866
  }
866
867
 
867
868
  export function compareWith<T>(comparer: ((arg0: T, arg1: T) => int32), source1: T[], source2: T[]): int32 {
868
- if (source1 == null) {
869
- if (source2 == null) {
869
+ if (Operators_IsNull<T[]>(source1)) {
870
+ if (Operators_IsNull<T[]>(source2)) {
870
871
  return 0;
871
872
  }
872
873
  else {
873
874
  return -1;
874
875
  }
875
876
  }
876
- else if (source2 == null) {
877
+ else if (Operators_IsNull<T[]>(source2)) {
877
878
  return 1;
878
879
  }
879
880
  else {
@@ -902,15 +903,15 @@ export function compareWith<T>(comparer: ((arg0: T, arg1: T) => int32), source1:
902
903
  }
903
904
 
904
905
  export function compareTo<T>(comparer: ((arg0: T, arg1: T) => int32), source1: T[], source2: T[]): int32 {
905
- if (source1 == null) {
906
- if (source2 == null) {
906
+ if (Operators_IsNull<T[]>(source1)) {
907
+ if (Operators_IsNull<T[]>(source2)) {
907
908
  return 0;
908
909
  }
909
910
  else {
910
911
  return -1;
911
912
  }
912
913
  }
913
- else if (source2 == null) {
914
+ else if (Operators_IsNull<T[]>(source2)) {
914
915
  return 1;
915
916
  }
916
917
  else {
@@ -935,15 +936,15 @@ export function compareTo<T>(comparer: ((arg0: T, arg1: T) => int32), source1: T
935
936
  }
936
937
 
937
938
  export function equalsWith<T>(equals: ((arg0: T, arg1: T) => boolean), array1: T[], array2: T[]): boolean {
938
- if (array1 == null) {
939
- if (array2 == null) {
939
+ if (Operators_IsNull<T[]>(array1)) {
940
+ if (Operators_IsNull<T[]>(array2)) {
940
941
  return true;
941
942
  }
942
943
  else {
943
944
  return false;
944
945
  }
945
946
  }
946
- else if (array2 == null) {
947
+ else if (Operators_IsNull<T[]>(array2)) {
947
948
  return false;
948
949
  }
949
950
  else {
@@ -1357,7 +1358,7 @@ export function resize<T>(xs: FSharpRef<T[]>, newSize: int32, zero?: Option<T>,
1357
1358
  throw new Error("The input must be non-negative.\\nParameter name: newSize");
1358
1359
  }
1359
1360
  const zero_1: T = defaultArg<T>(zero, defaultOf());
1360
- if (xs.contents == null) {
1361
+ if (Operators_IsNull<T[]>(xs.contents)) {
1361
1362
  xs.contents = ((array = Helpers_allocateArrayFromCons<T>(cons, newSize), array.fill(zero_1, 0, (0 + newSize))));
1362
1363
  }
1363
1364
  else {
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 1.10.0 - 2025-01-23
11
+
12
+ ### Added
13
+
14
+ * [JS/TS] Add `StringBuiler.Append(c: char, repeatCount: int)` overload (by @roboz0r)
15
+
16
+ ## 1.9.0 - 2025-01-09
17
+
18
+ ### Added
19
+
20
+ * [JS/TS] Add new `TimSpane` overload support coming from .NET 9 (by @MangelMaxime)
21
+
22
+ ### Fixed
23
+
24
+ * [JS/TS] Fix `DateTimeOffset.ToLocalTime` (by @MangelMaxime)
25
+
10
26
  ## 1.8.0 - 2024-11-19
11
27
 
12
28
  * [JS/TS] Fix `h` in `DateTime.ToString` (@MangelMaxime)
package/DateOffset.ts CHANGED
@@ -166,6 +166,10 @@ export function toUniversalTime(date: IDateTimeOffset): Date {
166
166
  }
167
167
 
168
168
  export function toLocalTime(date: IDateTimeOffset): Date {
169
+ return DateTime(date.getTime() + offset(now()), DateKind.Local);
170
+ }
171
+
172
+ export function localDateTime(date: IDateTimeOffset) : Date {
169
173
  return DateTime(date.getTime(), DateKind.Local);
170
174
  }
171
175
 
package/FSharp.Core.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { IDisposable, disposeSafe, defaultOf, IEqualityComparer, IComparer, structuralHash, equals } from "./Util.js";
2
2
  import { int32 } from "./Int32.js";
3
3
  import { HashIdentity_Structural, ComparisonIdentity_Structural } from "./FSharp.Collections.js";
4
- import { Option } from "./Option.js";
4
+ import { value as value_1, Nullable, Option } from "./Option.js";
5
+ import { FSharpChoice$2_$union, FSharpChoice$2_Choice2Of2, FSharpChoice$2_Choice1Of2 } from "./Choice.js";
5
6
  import { StringBuilder, StringBuilder__Append_Z721C83C5 } from "./System.Text.js";
6
7
 
7
8
  export const LanguagePrimitives_GenericEqualityComparer: any = {
@@ -68,6 +69,103 @@ export function Operators_Lock<$a, $b>(_lockObj: $a, action: (() => $b)): $b {
68
69
  return action();
69
70
  }
70
71
 
72
+ export function Operators_IsNull<T>(value: T): boolean {
73
+ if (equals(value, defaultOf())) {
74
+ return true;
75
+ }
76
+ else {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ export function Operators_IsNotNull<T>(value: T): boolean {
82
+ if (equals(value, defaultOf())) {
83
+ return false;
84
+ }
85
+ else {
86
+ return true;
87
+ }
88
+ }
89
+
90
+ export function Operators_IsNullV<T extends any>(value: Nullable<T>): boolean {
91
+ return !(value != null);
92
+ }
93
+
94
+ export function Operators_NonNull<T>(value: T): T {
95
+ if (equals(value, defaultOf())) {
96
+ throw new Error();
97
+ }
98
+ else {
99
+ return value;
100
+ }
101
+ }
102
+
103
+ export function Operators_NonNullV<T extends any>(value: Nullable<T>): T {
104
+ if (value != null) {
105
+ return value_1(value);
106
+ }
107
+ else {
108
+ throw new Error();
109
+ }
110
+ }
111
+
112
+ export function Operators_NullMatchPattern<T>(value: T): FSharpChoice$2_$union<void, T> {
113
+ if (equals(value, defaultOf())) {
114
+ return FSharpChoice$2_Choice1Of2<void, T>(undefined);
115
+ }
116
+ else {
117
+ return FSharpChoice$2_Choice2Of2<void, T>(value);
118
+ }
119
+ }
120
+
121
+ export function Operators_NullValueMatchPattern<T extends any>(value: Nullable<T>): FSharpChoice$2_$union<void, T> {
122
+ if (value != null) {
123
+ return FSharpChoice$2_Choice2Of2<void, T>(value_1(value));
124
+ }
125
+ else {
126
+ return FSharpChoice$2_Choice1Of2<void, T>(undefined);
127
+ }
128
+ }
129
+
130
+ export function Operators_NonNullQuickPattern<T>(value: T): T {
131
+ if (equals(value, defaultOf())) {
132
+ throw new Error();
133
+ }
134
+ else {
135
+ return value;
136
+ }
137
+ }
138
+
139
+ export function Operators_NonNullQuickValuePattern<T extends any>(value: Nullable<T>): T {
140
+ if (value != null) {
141
+ return value_1(value);
142
+ }
143
+ else {
144
+ throw new Error();
145
+ }
146
+ }
147
+
148
+ export function Operators_WithNull<T>(value: T): T {
149
+ return value;
150
+ }
151
+
152
+ export function Operators_WithNullV<T extends any>(value: T): T {
153
+ return value;
154
+ }
155
+
156
+ export function Operators_NullV<T extends any>(): Nullable<T> {
157
+ return defaultOf();
158
+ }
159
+
160
+ export function Operators_NullArgCheck<T>(argumentName: string, value: T): T {
161
+ if (equals(value, defaultOf())) {
162
+ throw new Error(argumentName);
163
+ }
164
+ else {
165
+ return value;
166
+ }
167
+ }
168
+
71
169
  export function ExtraTopLevelOperators_LazyPattern<$a>(input: any): $a {
72
170
  return input.Value;
73
171
  }
package/Random.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { uint8, int32, float64 } from "./Int32.js";
2
2
  import { class_type, TypeInfo } from "./Reflection.js";
3
3
  import { fromFloat64, op_Addition, toInt32, toFloat64, compare, int64, fromInt32, toInt64 } from "./BigInt.js";
4
+ import { Operators_IsNull } from "./FSharp.Core.js";
4
5
  import { item, fill, setItem } from "./Array.js";
5
6
 
6
7
  function Native_random(): float64 {
@@ -129,7 +130,7 @@ export class Seeded implements IRandom {
129
130
  }
130
131
  NextBytes(buffer: uint8[]): void {
131
132
  const this$: Seeded = this;
132
- if (buffer == null) {
133
+ if (Operators_IsNull<uint8[]>(buffer)) {
133
134
  throw new Error("buffer");
134
135
  }
135
136
  for (let i = 0; i <= (buffer.length - 1); i++) {
package/Seq.ts CHANGED
@@ -2,7 +2,7 @@ import { IComparer, clear, defaultOf, equals, isDisposable, IEqualityComparer, i
2
2
  import { toString } from "./Types.js";
3
3
  import { class_type, TypeInfo } from "./Reflection.js";
4
4
  import { some, value as value_1, Option } from "./Option.js";
5
- import { Operators_Lock, Operators_NullArg } from "./FSharp.Core.js";
5
+ import { Operators_Lock, Operators_NullArg, Operators_IsNull } from "./FSharp.Core.js";
6
6
  import { chunkBySize as chunkBySize_1, permute as permute_1, transpose as transpose_1, map as map_1, windowed as windowed_1, splitInto as splitInto_1, pairwise as pairwise_1, scanBack as scanBack_1, reverse as reverse_1, mapFoldBack as mapFoldBack_1, mapFold as mapFold_1, tryItem as tryItem_1, tryHead as tryHead_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, singleton as singleton_1 } from "./Array.js";
7
7
  import { length as length_1, tryItem as tryItem_2, isEmpty as isEmpty_1, tryHead as tryHead_2, ofSeq as ofSeq_1, ofArray as ofArray_1, toArray as toArray_1, FSharpList } from "./List.js";
8
8
  import { int32 } from "./Int32.js";
@@ -325,7 +325,7 @@ export function indexNotFound<$a>(): $a {
325
325
  }
326
326
 
327
327
  export function checkNonNull<$a>(argName: string, arg: $a): void {
328
- if (arg == null) {
328
+ if (Operators_IsNull<$a>(arg)) {
329
329
  Operators_NullArg<void>(argName);
330
330
  }
331
331
  }
package/System.Text.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { replace, format, substring, isNullOrEmpty, join } from "./String.js";
1
+ import { replace, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
2
2
  import { float64, int32 } from "./Int32.js";
3
3
  import { class_type, TypeInfo } from "./Reflection.js";
4
4
  import { clear, int32ToString } from "./Util.js";
@@ -53,6 +53,12 @@ export function StringBuilder__Append_244C7CD6(x: StringBuilder, c: string): Str
53
53
  return x;
54
54
  }
55
55
 
56
+ export function StringBuilder__Append_61B1CA(x: StringBuilder, c: string, repeatCount: int32): StringBuilder {
57
+ const s: string = replicate(repeatCount, c);
58
+ void (x.buf.push(s));
59
+ return x;
60
+ }
61
+
56
62
  export function StringBuilder__Append_Z524259A4(x: StringBuilder, o: int32): StringBuilder {
57
63
  void (x.buf.push(int32ToString(o)));
58
64
  return x;
package/TimeSpan.ts CHANGED
@@ -35,20 +35,24 @@ export function fromTicks(ticks: number | bigint) {
35
35
  return Number(BigInt(ticks) / 10000n);
36
36
  }
37
37
 
38
- export function fromDays(d: number) {
39
- return create(d, 0, 0, 0);
38
+ export function fromDays(d: number, h: number = 0, m: bigint = 0n, s: bigint = 0n, ms: bigint = 0n) {
39
+ return create(d, h, Number(m), Number(s), Number(ms));
40
40
  }
41
41
 
42
- export function fromHours(h: number) {
43
- return create(h, 0, 0);
42
+ export function fromHours(h: number, m: bigint = 0n, s: bigint = 0n, ms: bigint = 0n) {
43
+ return create(0, h, Number(m), Number(s), Number(ms));
44
44
  }
45
45
 
46
- export function fromMinutes(m: number) {
47
- return create(0, m, 0);
46
+ export function fromMinutes(m: number | bigint, s: bigint = 0n, ms: bigint = 0n) {
47
+ return create(0, 0, Number(m), Number(s), Number(ms));
48
48
  }
49
49
 
50
- export function fromSeconds(s: number) {
51
- return create(0, 0, s);
50
+ export function fromSeconds(s: number | bigint, ms: bigint = 0n) {
51
+ return create(0, 0, 0, Number(s), Number(ms));
52
+ }
53
+
54
+ export function fromMilliseconds(ms: number | bigint) {
55
+ return Number(ms);
52
56
  }
53
57
 
54
58
  export function days(ts: TimeSpan) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "name": "@fable-org/fable-library-ts",
6
- "version": "1.8.0",
6
+ "version": "1.10.0",
7
7
  "description": "Core library used by F# projects compiled with fable.io",
8
8
  "author": "Fable Contributors",
9
9
  "license": "MIT",