@fable-org/fable-library-ts 2.0.0-beta.3 → 2.0.0-beta.5

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 (55) hide show
  1. package/Array.ts +1385 -1378
  2. package/Async.ts +13 -12
  3. package/AsyncBuilder.ts +10 -11
  4. package/BigInt.ts +6 -6
  5. package/BitConverter.ts +3 -3
  6. package/Boolean.ts +3 -2
  7. package/CHANGELOG.md +12 -0
  8. package/Char.ts +38 -35
  9. package/Choice.ts +326 -301
  10. package/CollectionUtil.ts +4 -4
  11. package/Date.ts +67 -62
  12. package/DateOffset.ts +48 -57
  13. package/DateOnly.ts +8 -8
  14. package/Decimal.ts +9 -9
  15. package/Double.ts +3 -2
  16. package/Encoding.ts +1 -1
  17. package/Event.ts +3 -3
  18. package/FSharp.Collections.ts +53 -34
  19. package/FSharp.Core.CompilerServices.ts +38 -37
  20. package/FSharp.Core.ts +186 -185
  21. package/Global.ts +80 -37
  22. package/Guid.ts +7 -6
  23. package/Int32.ts +20 -17
  24. package/List.ts +1429 -1417
  25. package/Long.ts +6 -5
  26. package/MailboxProcessor.ts +8 -7
  27. package/Map.ts +1550 -1552
  28. package/MapUtil.ts +5 -5
  29. package/MutableMap.ts +358 -345
  30. package/MutableSet.ts +250 -249
  31. package/Native.ts +19 -11
  32. package/Numeric.ts +1 -1
  33. package/Observable.ts +3 -3
  34. package/Option.ts +10 -4
  35. package/Random.ts +196 -194
  36. package/Range.ts +57 -56
  37. package/Reflection.ts +73 -40
  38. package/RegExp.ts +5 -3
  39. package/Result.ts +201 -196
  40. package/Seq.ts +1517 -1525
  41. package/Seq2.ts +130 -129
  42. package/Set.ts +1955 -1955
  43. package/String.ts +41 -38
  44. package/System.Collections.Generic.ts +401 -380
  45. package/System.Text.ts +204 -203
  46. package/System.ts +366 -0
  47. package/TimeOnly.ts +10 -10
  48. package/TimeSpan.ts +11 -11
  49. package/Timer.ts +2 -2
  50. package/Types.ts +1 -19
  51. package/Uri.ts +13 -10
  52. package/Util.ts +77 -21
  53. package/package.json +22 -22
  54. package/tsconfig.json +18 -5
  55. package/SystemException.ts +0 -7
package/Random.ts CHANGED
@@ -1,197 +1,199 @@
1
- import { uint8, int32, float64 } from "./Int32.js";
2
- import { class_type, TypeInfo } from "./Reflection.js";
3
- import { fromFloat64, op_Addition, toInt32_unchecked, toFloat64, compare, int64, fromInt32, toInt64_unchecked } from "./BigInt.js";
4
- import { Operators_IsNull } from "./FSharp.Core.js";
5
- import { item, fill, setItem } from "./Array.js";
6
-
7
- function Native_random(): float64 {
8
- return Math.random();
9
- }
10
-
11
- function Native_randomNext(min: int32, max: int32): int32 {
12
- if (max < min) {
13
- throw new Error("minValue must be less than maxValue");
1
+
2
+ import { uint8, int32, float64 } from "./Int32.ts";
3
+ import { ArgumentNullException_$ctor_Z721C83C5, ArgumentOutOfRangeException_$ctor_Z721C83C5 } from "./System.ts";
4
+ import { Operators_IsNull, Operators_NonNull } from "./FSharp.Core.ts";
5
+ import { MutableArray } from "./Util.ts";
6
+ import { class_type, TypeInfo } from "./Reflection.ts";
7
+ import { fromFloat64, op_Addition, toInt32_unchecked, toFloat64, compare, int64, fromInt32, toInt64_unchecked } from "./BigInt.ts";
8
+ import { item, setItem } from "./Array.ts";
9
+
10
+ function Native_random(): float64 {
11
+ return Math.random();
12
+ }
13
+
14
+ function Native_randomNext(minValue: int32, maxValue: int32): int32 {
15
+ if (maxValue < minValue) {
16
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("minValue must be less than maxValue");
17
+ }
18
+ return Math.floor(Math.random() * (maxValue - minValue)) + minValue;
19
+ }
20
+
21
+ function Native_randomBytes(buffer: MutableArray<uint8>): void {
22
+ if (Operators_IsNull<any>(buffer)) {
23
+ throw ArgumentNullException_$ctor_Z721C83C5("buffer");
24
+ }
25
+ for (let i = 0; i < buffer.length; i += 6) {
26
+ // Pick random 48-bit number. Fill buffer in 2 24-bit chunks to avoid bitwise truncation.
27
+ let r = Math.floor(Math.random() * 281474976710656); // Low 24 bits = chunk 1.
28
+ const rhi = Math.floor(r / 16777216); // High 24 bits shifted via division = chunk 2.
29
+ for (let j = 0; j < 6 && i + j < buffer.length; j++) {
30
+ if (j === 3) { r = rhi; }
31
+ buffer[i + j] = r & 255;
32
+ r >>>= 8;
14
33
  }
15
- return Math.floor(Math.random() * (max - min)) + min
16
- ;
17
- }
18
-
19
- function Native_randomBytes(buffer: uint8[]): void {
20
- if (buffer == null) {
21
- throw new Error("Buffer cannot be null");
34
+ };
35
+ }
36
+
37
+ export interface IRandom {
38
+ Next0(): int32,
39
+ Next1(maxValue: int32): int32,
40
+ Next2(minValue: int32, maxValue: int32): int32,
41
+ NextBytes(buffer: MutableArray<uint8>): void,
42
+ NextDouble(): float64
43
+ }
44
+
45
+ export class NonSeeded implements IRandom {
46
+ constructor() {
47
+ }
48
+ Next0(): int32 {
49
+ return Native_randomNext(0, 2147483647) | 0;
50
+ }
51
+ Next1(maxValue: int32): int32 {
52
+ return Native_randomNext(0, maxValue) | 0;
53
+ }
54
+ Next2(minValue: int32, maxValue: int32): int32 {
55
+ return Native_randomNext(minValue, maxValue) | 0;
56
+ }
57
+ NextDouble(): float64 {
58
+ return Native_random();
59
+ }
60
+ NextBytes(buffer: MutableArray<uint8>): void {
61
+ Native_randomBytes(buffer);
62
+ }
63
+ }
64
+
65
+ export function NonSeeded_$reflection(): TypeInfo {
66
+ return class_type("Random.NonSeeded", undefined, NonSeeded);
67
+ }
68
+
69
+ export function NonSeeded_$ctor(): NonSeeded {
70
+ return new NonSeeded();
71
+ }
72
+
73
+ export class Seeded implements IRandom {
74
+ readonly MBIG: int32;
75
+ inext: int32;
76
+ inextp: int32;
77
+ seedArray: MutableArray<int32>;
78
+ constructor(seed: int32) {
79
+ this.MBIG = 2147483647;
80
+ this.inext = 0;
81
+ this.inextp = 0;
82
+ this.seedArray = (new Int32Array(56));
83
+ let ii = 0;
84
+ let mj = 0;
85
+ let mk = 0;
86
+ const subtraction: int32 = ((seed === -2147483648) ? 2147483647 : Math.abs(seed)) | 0;
87
+ mj = ((161803398 - subtraction) | 0);
88
+ this.seedArray[55] = (mj | 0);
89
+ mk = 1;
90
+ for (let i = 1; i <= 54; i++) {
91
+ ii = (((21 * i) % 55) | 0);
92
+ this.seedArray[ii] = (mk | 0);
93
+ mk = ((mj - mk) | 0);
94
+ if (mk < 0) {
95
+ mk = ((mk + this.MBIG) | 0);
96
+ }
97
+ mj = (item(ii, this.seedArray) | 0);
22
98
  }
23
- for (let i = 0; i < buffer.length; i += 6) {
24
- // Pick random 48-bit number. Fill buffer in 2 24-bit chunks to avoid bitwise truncation.
25
- let r = Math.floor(Math.random() * 281474976710656); // Low 24 bits = chunk 1.
26
- const rhi = Math.floor(r / 16777216); // High 24 bits shifted via division = chunk 2.
27
- for (let j = 0; j < 6 && i + j < buffer.length; j++) {
28
- if (j === 3) { r = rhi; }
29
- buffer[i + j] = r & 255;
30
- r >>>= 8;
99
+ for (let k = 1; k <= 4; k++) {
100
+ for (let i_1 = 1; i_1 <= 55; i_1++) {
101
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) - item(1 + ((i_1 + 30) % 55), this.seedArray)) | 0);
102
+ if (item(i_1, this.seedArray) < 0) {
103
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) + this.MBIG) | 0);
104
+ }
31
105
  }
32
- };
33
- }
34
-
35
- export interface IRandom {
36
- Next0(): int32,
37
- Next1(maxValue: int32): int32,
38
- Next2(minValue: int32, maxValue: int32): int32,
39
- NextBytes(buffer: uint8[]): void,
40
- NextDouble(): float64
41
- }
42
-
43
- export class NonSeeded implements IRandom {
44
- constructor() {
45
- }
46
- Next0(): int32 {
47
- return Native_randomNext(0, 2147483647) | 0;
48
- }
49
- Next1(maxValue: int32): int32 {
50
- return Native_randomNext(0, maxValue) | 0;
51
- }
52
- Next2(minValue: int32, maxValue: int32): int32 {
53
- return Native_randomNext(minValue, maxValue) | 0;
54
- }
55
- NextDouble(): float64 {
56
- return Native_random();
57
- }
58
- NextBytes(buffer: uint8[]): void {
59
- Native_randomBytes(buffer);
60
- }
61
- }
62
-
63
- export function NonSeeded_$reflection(): TypeInfo {
64
- return class_type("Random.NonSeeded", undefined, NonSeeded);
65
- }
66
-
67
- export function NonSeeded_$ctor(): NonSeeded {
68
- return new NonSeeded();
69
- }
70
-
71
- export class Seeded implements IRandom {
72
- readonly MBIG: int32;
73
- inext: int32;
74
- inextp: int32;
75
- seedArray: int32[];
76
- constructor(seed: int32) {
77
- this.MBIG = 2147483647;
78
- this.inext = 0;
79
- this.inextp = 0;
80
- this.seedArray = fill(new Array(56), 0, 56, 0);
81
- let ii = 0;
82
- let mj = 0;
83
- let mk = 0;
84
- const subtraction: int32 = ((seed === -2147483648) ? 2147483647 : Math.abs(seed)) | 0;
85
- mj = ((161803398 - subtraction) | 0);
86
- this.seedArray[55] = (mj | 0);
87
- mk = 1;
88
- for (let i = 1; i <= 54; i++) {
89
- ii = (((21 * i) % 55) | 0);
90
- this.seedArray[ii] = (mk | 0);
91
- mk = ((mj - mk) | 0);
92
- if (mk < 0) {
93
- mk = ((mk + this.MBIG) | 0);
94
- }
95
- mj = (item(ii, this.seedArray) | 0);
96
- }
97
- for (let k = 1; k <= 4; k++) {
98
- for (let i_1 = 1; i_1 <= 55; i_1++) {
99
- this.seedArray[i_1] = ((item(i_1, this.seedArray) - item(1 + ((i_1 + 30) % 55), this.seedArray)) | 0);
100
- if (item(i_1, this.seedArray) < 0) {
101
- this.seedArray[i_1] = ((item(i_1, this.seedArray) + this.MBIG) | 0);
102
- }
103
- }
104
- }
105
- this.inext = 0;
106
- this.inextp = 21;
107
- }
108
- Next0(): int32 {
109
- const this$: Seeded = this;
110
- return Seeded__InternalSample(this$) | 0;
111
- }
112
- Next1(maxValue: int32): int32 {
113
- const this$: Seeded = this;
114
- if (maxValue < 0) {
115
- throw new Error("maxValue must be positive");
116
- }
117
- return ~~(Seeded__Sample(this$) * maxValue) | 0;
118
- }
119
- Next2(minValue: int32, maxValue: int32): int32 {
120
- const this$: Seeded = this;
121
- if (minValue > maxValue) {
122
- throw new Error("minValue must be less than maxValue");
123
- }
124
- const range: int64 = toInt64_unchecked(fromInt32(maxValue - minValue));
125
- return ((compare(range, toInt64_unchecked(fromInt32(2147483647))) <= 0) ? (~~(Seeded__Sample(this$) * toFloat64(range)) + minValue) : ~~toInt32_unchecked(toInt64_unchecked(op_Addition(toInt64_unchecked(fromFloat64(Seeded__GetSampleForLargeRange(this$) * toFloat64(range))), toInt64_unchecked(fromInt32(minValue)))))) | 0;
126
- }
127
- NextDouble(): float64 {
128
- const this$: Seeded = this;
129
- return Seeded__Sample(this$);
130
- }
131
- NextBytes(buffer: uint8[]): void {
132
- const this$: Seeded = this;
133
- if (Operators_IsNull<uint8[]>(buffer)) {
134
- throw new Error("buffer");
135
- }
136
- for (let i = 0; i <= (buffer.length - 1); i++) {
137
- setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
138
- }
139
- }
140
- }
141
-
142
- export function Seeded_$reflection(): TypeInfo {
143
- return class_type("Random.Seeded", undefined, Seeded);
144
- }
145
-
146
- export function Seeded_$ctor_Z524259A4(seed: int32): Seeded {
147
- return new Seeded(seed);
148
- }
149
-
150
- function Seeded__InternalSample(_: Seeded): int32 {
151
- let retVal = 0;
152
- let locINext: int32 = _.inext;
153
- let locINextp: int32 = _.inextp;
154
- locINext = ((locINext + 1) | 0);
155
- if (locINext >= 56) {
156
- locINext = 1;
157
- }
158
- locINextp = ((locINextp + 1) | 0);
159
- if (locINextp >= 56) {
160
- locINextp = 1;
161
- }
162
- retVal = ((item(locINext, _.seedArray) - item(locINextp, _.seedArray)) | 0);
163
- if (retVal === _.MBIG) {
164
- retVal = ((retVal - 1) | 0);
165
- }
166
- if (retVal < 0) {
167
- retVal = ((retVal + _.MBIG) | 0);
168
- }
169
- _.seedArray[locINext] = (retVal | 0);
170
- _.inext = (locINext | 0);
171
- _.inextp = (locINextp | 0);
172
- return retVal | 0;
173
- }
174
-
175
- export function Seeded__Sample(this$: Seeded): float64 {
176
- return Seeded__InternalSample(this$) * (1 / this$.MBIG);
177
- }
178
-
179
- export function Seeded__GetSampleForLargeRange(this$: Seeded): float64 {
180
- let result: float64 = Seeded__InternalSample(this$);
181
- if ((Seeded__InternalSample(this$) % 2) === 0) {
182
- result = -result;
183
- }
184
- let d: float64 = result;
185
- d = (d + (2147483647 - 1));
186
- d = (d / (2 * ((2147483647 - 1) >>> 0)));
187
- return d;
188
- }
189
-
190
- export function nonSeeded(): NonSeeded {
191
- return NonSeeded_$ctor();
192
- }
193
-
194
- export function seeded(seed: int32): Seeded {
195
- return Seeded_$ctor_Z524259A4(seed);
196
- }
197
-
106
+ }
107
+ this.inext = 0;
108
+ this.inextp = 21;
109
+ }
110
+ Next0(): int32 {
111
+ const this$: Seeded = this;
112
+ return Seeded__InternalSample(this$) | 0;
113
+ }
114
+ Next1(maxValue: int32): int32 {
115
+ const this$: Seeded = this;
116
+ if (maxValue < 0) {
117
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("maxValue must be positive");
118
+ }
119
+ return ~~(Seeded__Sample(this$) * maxValue) | 0;
120
+ }
121
+ Next2(minValue: int32, maxValue: int32): int32 {
122
+ const this$: Seeded = this;
123
+ if (minValue > maxValue) {
124
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("minValue must be less than maxValue");
125
+ }
126
+ const range: int64 = toInt64_unchecked(fromInt32(maxValue - minValue));
127
+ return ((compare(range, toInt64_unchecked(fromInt32(2147483647))) <= 0) ? (~~(Seeded__Sample(this$) * toFloat64(range)) + minValue) : ~~toInt32_unchecked(toInt64_unchecked(op_Addition(toInt64_unchecked(fromFloat64(Seeded__GetSampleForLargeRange(this$) * toFloat64(range))), toInt64_unchecked(fromInt32(minValue)))))) | 0;
128
+ }
129
+ NextDouble(): float64 {
130
+ const this$: Seeded = this;
131
+ return Seeded__Sample(this$);
132
+ }
133
+ NextBytes(buffer: MutableArray<uint8>): void {
134
+ const this$: Seeded = this;
135
+ if (Operators_IsNull<any>(buffer)) {
136
+ throw ArgumentNullException_$ctor_Z721C83C5("buffer");
137
+ }
138
+ for (let i = 0; i <= (buffer.length - 1); i++) {
139
+ setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
140
+ }
141
+ }
142
+ }
143
+
144
+ export function Seeded_$reflection(): TypeInfo {
145
+ return class_type("Random.Seeded", undefined, Seeded);
146
+ }
147
+
148
+ export function Seeded_$ctor_Z524259A4(seed: int32): Seeded {
149
+ return new Seeded(seed);
150
+ }
151
+
152
+ function Seeded__InternalSample(_: Seeded): int32 {
153
+ let retVal = 0;
154
+ let locINext: int32 = _.inext;
155
+ let locINextp: int32 = _.inextp;
156
+ locINext = ((locINext + 1) | 0);
157
+ if (locINext >= 56) {
158
+ locINext = 1;
159
+ }
160
+ locINextp = ((locINextp + 1) | 0);
161
+ if (locINextp >= 56) {
162
+ locINextp = 1;
163
+ }
164
+ retVal = ((item(locINext, _.seedArray) - item(locINextp, _.seedArray)) | 0);
165
+ if (retVal === _.MBIG) {
166
+ retVal = ((retVal - 1) | 0);
167
+ }
168
+ if (retVal < 0) {
169
+ retVal = ((retVal + _.MBIG) | 0);
170
+ }
171
+ _.seedArray[locINext] = (retVal | 0);
172
+ _.inext = (locINext | 0);
173
+ _.inextp = (locINextp | 0);
174
+ return retVal | 0;
175
+ }
176
+
177
+ export function Seeded__Sample(this$: Seeded): float64 {
178
+ return Seeded__InternalSample(this$) * (1 / this$.MBIG);
179
+ }
180
+
181
+ export function Seeded__GetSampleForLargeRange(this$: Seeded): float64 {
182
+ let result: float64 = Seeded__InternalSample(this$);
183
+ if ((Seeded__InternalSample(this$) % 2) === 0) {
184
+ result = -result;
185
+ }
186
+ let d: float64 = result;
187
+ d = (d + (2147483647 - 1));
188
+ d = (d / (2 * ((2147483647 - 1) >>> 0)));
189
+ return d;
190
+ }
191
+
192
+ export function nonSeeded(): NonSeeded {
193
+ return NonSeeded_$ctor();
194
+ }
195
+
196
+ export function seeded(seed: int32): Seeded {
197
+ return Seeded_$ctor_Z524259A4(seed);
198
+ }
199
+
package/Range.ts CHANGED
@@ -1,56 +1,57 @@
1
- import { compare } from "./Util.js";
2
- import { float64, int32 } from "./Int32.js";
3
- import { Option } from "./Option.js";
4
- import { unfold, delay } from "./Seq.js";
5
- import { uint64, toUInt64_unchecked, int64, toInt64_unchecked, op_Addition, fromZero } from "./BigInt.js";
6
- import { decimal, op_Addition as op_Addition_1, fromParts } from "./Decimal.js";
7
-
8
- export function makeRangeStepFunction<T>(step: T, stop: T, zero: T, add: ((arg0: T, arg1: T) => T)): ((arg0: T) => Option<[T, T]>) {
9
- const stepComparedWithZero: int32 = compare(step, zero) | 0;
10
- if (stepComparedWithZero === 0) {
11
- throw new Error("The step of a range cannot be zero");
12
- }
13
- const stepGreaterThanZero: boolean = stepComparedWithZero > 0;
14
- return (x: T): Option<[T, T]> => {
15
- const comparedWithLast: int32 = compare(x, stop) | 0;
16
- return ((stepGreaterThanZero && (comparedWithLast <= 0)) ? true : (!stepGreaterThanZero && (comparedWithLast >= 0))) ? ([x, add(x, step)] as [T, T]) : undefined;
17
- };
18
- }
19
-
20
- export function integralRangeStep<T>(start: T, step: T, stop: T, zero: T, add: ((arg0: T, arg1: T) => T)): Iterable<T> {
21
- const stepFn: ((arg0: T) => Option<[T, T]>) = makeRangeStepFunction<T>(step, stop, zero, add);
22
- return delay<T>((): Iterable<T> => unfold<T, T>(stepFn, start));
23
- }
24
-
25
- export function rangeBigInt(start: bigint, step: bigint, stop: bigint): Iterable<bigint> {
26
- return integralRangeStep<bigint>(start, step, stop, fromZero(), op_Addition);
27
- }
28
-
29
- export function rangeDecimal(start: decimal, step: decimal, stop: decimal): Iterable<decimal> {
30
- return integralRangeStep<decimal>(start, step, stop, fromParts(0, 0, 0, false, 0), op_Addition_1);
31
- }
32
-
33
- export function rangeDouble(start: float64, step: float64, stop: float64): Iterable<float64> {
34
- return integralRangeStep<float64>(start, step, stop, 0, (x: float64, y: float64): float64 => (x + y));
35
- }
36
-
37
- export function rangeInt64(start: int64, step: int64, stop: int64): Iterable<int64> {
38
- return integralRangeStep<int64>(start, step, stop, 0n, (x: int64, y: int64): int64 => toInt64_unchecked(op_Addition(x, y)));
39
- }
40
-
41
- export function rangeUInt64(start: uint64, step: uint64, stop: uint64): Iterable<uint64> {
42
- return integralRangeStep<uint64>(start, step, stop, 0n, (x: uint64, y: uint64): uint64 => toUInt64_unchecked(op_Addition(x, y)));
43
- }
44
-
45
- export function rangeChar(start: string, stop: string): Iterable<string> {
46
- const intStop: int32 = ~~stop.charCodeAt(0) | 0;
47
- return delay<string>((): Iterable<string> => unfold<int32, string>((i: int32): Option<[string, int32]> => {
48
- if (i <= intStop) {
49
- return [String.fromCharCode(i & 0xFFFF), i + 1] as [string, int32];
50
- }
51
- else {
52
- return undefined;
53
- }
54
- }, ~~start.charCodeAt(0)));
55
- }
56
-
1
+
2
+ import { Exception, compare } from "./Util.ts";
3
+ import { float64, int32 } from "./Int32.ts";
4
+ import { Option } from "./Option.ts";
5
+ import { unfold, delay } from "./Seq.ts";
6
+ import { uint64, toUInt64_unchecked, int64, toInt64_unchecked, op_Addition, fromZero } from "./BigInt.ts";
7
+ import { decimal, op_Addition as op_Addition_1, fromParts } from "./Decimal.ts";
8
+
9
+ export function makeRangeStepFunction<T>(step: T, stop: T, zero: T, add: ((arg0: T, arg1: T) => T)): ((arg0: T) => Option<[T, T]>) {
10
+ const stepComparedWithZero: int32 = compare(step, zero) | 0;
11
+ if (stepComparedWithZero === 0) {
12
+ throw new Exception("The step of a range cannot be zero");
13
+ }
14
+ const stepGreaterThanZero: boolean = stepComparedWithZero > 0;
15
+ return (x: T): Option<[T, T]> => {
16
+ const comparedWithLast: int32 = compare(x, stop) | 0;
17
+ return ((stepGreaterThanZero && (comparedWithLast <= 0)) ? true : (!stepGreaterThanZero && (comparedWithLast >= 0))) ? ([x, add(x, step)] as [T, T]) : undefined;
18
+ };
19
+ }
20
+
21
+ export function integralRangeStep<T>(start: T, step: T, stop: T, zero: T, add: ((arg0: T, arg1: T) => T)): Iterable<T> {
22
+ const stepFn: ((arg0: T) => Option<[T, T]>) = makeRangeStepFunction<T>(step, stop, zero, add);
23
+ return delay<T>((): Iterable<T> => unfold<T, T>(stepFn, start));
24
+ }
25
+
26
+ export function rangeBigInt(start: bigint, step: bigint, stop: bigint): Iterable<bigint> {
27
+ return integralRangeStep<bigint>(start, step, stop, fromZero(), op_Addition);
28
+ }
29
+
30
+ export function rangeDecimal(start: decimal, step: decimal, stop: decimal): Iterable<decimal> {
31
+ return integralRangeStep<decimal>(start, step, stop, fromParts(0, 0, 0, false, 0), op_Addition_1);
32
+ }
33
+
34
+ export function rangeDouble(start: float64, step: float64, stop: float64): Iterable<float64> {
35
+ return integralRangeStep<float64>(start, step, stop, 0, (x: float64, y: float64): float64 => (x + y));
36
+ }
37
+
38
+ export function rangeInt64(start: int64, step: int64, stop: int64): Iterable<int64> {
39
+ return integralRangeStep<int64>(start, step, stop, 0n, (x: int64, y: int64): int64 => toInt64_unchecked(op_Addition(x, y)));
40
+ }
41
+
42
+ export function rangeUInt64(start: uint64, step: uint64, stop: uint64): Iterable<uint64> {
43
+ return integralRangeStep<uint64>(start, step, stop, 0n, (x: uint64, y: uint64): uint64 => toUInt64_unchecked(op_Addition(x, y)));
44
+ }
45
+
46
+ export function rangeChar(start: string, stop: string): Iterable<string> {
47
+ const intStop: int32 = ~~stop.charCodeAt(0) | 0;
48
+ return delay<string>((): Iterable<string> => unfold<int32, string>((i: int32): Option<[string, int32]> => {
49
+ if (i <= intStop) {
50
+ return [String.fromCharCode(i & 0xFFFF), i + 1] as [string, int32];
51
+ }
52
+ else {
53
+ return undefined;
54
+ }
55
+ }, ~~start.charCodeAt(0)));
56
+ }
57
+