@fable-org/fable-library-ts 1.0.0 → 1.2.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/Date.ts CHANGED
@@ -15,6 +15,360 @@ import { compareDates, DateKind, dateOffset, IDateTime, IDateTimeOffset, padWith
15
15
  export type OffsetInMinutes = number;
16
16
  export type Offset = "Z" | OffsetInMinutes | null;
17
17
 
18
+ const shortDays =
19
+ [
20
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
21
+ ]
22
+
23
+ const longDays =
24
+ [
25
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
26
+ ]
27
+
28
+ const shortMonths =
29
+ [
30
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
31
+ ]
32
+
33
+ const longMonths =
34
+ [
35
+ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
36
+ ]
37
+
38
+
39
+ function parseRepeatToken(format: string, pos: number, patternChar: string) {
40
+ let tokenLength = 0;
41
+ let internalPos = pos;
42
+ while (internalPos < format.length && format[internalPos] === patternChar) {
43
+ internalPos++;
44
+ tokenLength++;
45
+ }
46
+
47
+ return tokenLength;
48
+ }
49
+
50
+ function parseNextChar(format: string, pos: number) {
51
+ if (pos >= format.length - 1) {
52
+ return -1
53
+ }
54
+
55
+ return format.charCodeAt(pos + 1);
56
+ }
57
+
58
+ function parseQuotedString(format: string, pos: number) : [string, number] {
59
+ let beginPos = pos;
60
+ // Get the character used to quote the string
61
+ const quoteChar = format[pos];
62
+
63
+ let result = "";
64
+ let foundQuote = false;
65
+
66
+ while (pos < format.length) {
67
+ pos++;
68
+ const currentChar = format[pos];
69
+ if (currentChar === quoteChar) {
70
+ foundQuote = true;
71
+ break;
72
+ } else if (currentChar === "\\") {
73
+ if (pos < format.length) {
74
+ pos++;
75
+ result += format[pos];
76
+ } else {
77
+ // This means that '\' is the last character in the string.
78
+ throw new Error("Invalid string format");
79
+ }
80
+ } else {
81
+ result += currentChar;
82
+ }
83
+ }
84
+
85
+ if (!foundQuote) {
86
+ // We could not find the matching quote
87
+ throw new Error(`Invalid string format could not find matching quote for ${quoteChar}`);
88
+ }
89
+
90
+ return [result, pos - beginPos + 1];
91
+ }
92
+
93
+ function dateToStringWithCustomFormat(date: Date, format: string, utc: boolean) {
94
+ let cursorPos = 0;
95
+ let tokenLength = 0;
96
+ let result = "";
97
+ const localizedDate = utc ? DateTime(date.getTime(), DateKind.UTC) : date;
98
+
99
+ while (cursorPos < format.length) {
100
+ const token = format[cursorPos];
101
+
102
+ switch (token) {
103
+ case "d":
104
+ tokenLength = parseRepeatToken(format, cursorPos, "d");
105
+ cursorPos += tokenLength;
106
+ switch (tokenLength) {
107
+ case 1:
108
+ result += localizedDate.getDate();
109
+ break;
110
+ case 2:
111
+ result += padWithZeros(localizedDate.getDate(), 2);
112
+ break;
113
+ case 3:
114
+ result += shortDays[dayOfWeek(localizedDate)];
115
+ break;
116
+ case 4:
117
+ result += longDays[dayOfWeek(localizedDate)];
118
+ break;
119
+ default:
120
+ break;
121
+ }
122
+ break;
123
+ case "f":
124
+ tokenLength = parseRepeatToken(format, cursorPos, "f");
125
+ cursorPos += tokenLength;
126
+ if (tokenLength <= 3) {
127
+ const precision = 10 ** (3 - tokenLength);
128
+ result += padWithZeros(Math.floor(millisecond(localizedDate) / precision), tokenLength);
129
+ } else if (tokenLength <= 7) {
130
+ // JavaScript Date only support precision to the millisecond
131
+ // so we fill the rest of the precision with 0 as if the date didn't have
132
+ // milliseconds provided to it.
133
+ // This is to have the same behavior as .NET when doing:
134
+ // DateTime(1, 2, 3, 4, 5, 6, DateTimeKind.Utc).ToString("fffff") => 00000
135
+ result += (""+millisecond(localizedDate)).padEnd(tokenLength, "0");
136
+ }
137
+ break;
138
+ case "F":
139
+ tokenLength = parseRepeatToken(format, cursorPos, "F");
140
+ cursorPos += tokenLength;
141
+ if (tokenLength <= 3) {
142
+ const precision = 10 ** (3 - tokenLength);
143
+ const value = Math.floor(millisecond(localizedDate) / precision)
144
+ if (value != 0) {
145
+ result += padWithZeros(value, tokenLength);
146
+ }
147
+ } else if (tokenLength <= 7) {
148
+ // JavaScript Date only support precision to the millisecond
149
+ // so we can't go beyond that.
150
+ // We also need to pad start with 0 if the value is not 0
151
+ const value = millisecond(localizedDate);
152
+ if (value != 0) {
153
+ result += padWithZeros(value, 3);
154
+ }
155
+ }
156
+ break;
157
+ case "g":
158
+ tokenLength = parseRepeatToken(format, cursorPos, "g");
159
+ cursorPos += tokenLength;
160
+ if (tokenLength <= 2) {
161
+ result += "A.D.";
162
+ }
163
+ break;
164
+ case "h":
165
+ tokenLength = parseRepeatToken(format, cursorPos, "h");
166
+ cursorPos += tokenLength;
167
+ switch (tokenLength) {
168
+ case 1:
169
+ result += hour(localizedDate) % 12
170
+ break;
171
+ case 2:
172
+ result += padWithZeros(hour(localizedDate) % 12, 2);
173
+ break;
174
+ default:
175
+ break;
176
+ }
177
+ break;
178
+ case "H":
179
+ tokenLength = parseRepeatToken(format, cursorPos, "H");
180
+ cursorPos += tokenLength;
181
+ switch (tokenLength) {
182
+ case 1:
183
+ result += hour(localizedDate);
184
+ break;
185
+ case 2:
186
+ result += padWithZeros(hour(localizedDate), 2);
187
+ break;
188
+ default:
189
+ break;
190
+ }
191
+ break;
192
+ case "K":
193
+ tokenLength = parseRepeatToken(format, cursorPos, "K");
194
+ cursorPos += tokenLength;
195
+ switch (tokenLength) {
196
+ case 1:
197
+ switch (kind(localizedDate)) {
198
+ case DateKind.UTC:
199
+ result += "Z";
200
+ break;
201
+ case DateKind.Local:
202
+ result += dateOffsetToString(localizedDate.getTimezoneOffset() * -60000);
203
+ break;
204
+ case DateKind.Unspecified:
205
+ break;
206
+ }
207
+ break;
208
+ default:
209
+ break;
210
+ }
211
+ break;
212
+ case "m":
213
+ tokenLength = parseRepeatToken(format, cursorPos, "m");
214
+ cursorPos += tokenLength;
215
+ switch (tokenLength) {
216
+ case 1:
217
+ result += minute(localizedDate);
218
+ break;
219
+ case 2:
220
+ result += padWithZeros(minute(localizedDate), 2);
221
+ break;
222
+ default:
223
+ break;
224
+ }
225
+ break;
226
+ case "M":
227
+ tokenLength = parseRepeatToken(format, cursorPos, "M");
228
+ cursorPos += tokenLength;
229
+ switch (tokenLength) {
230
+ case 1:
231
+ result += month(localizedDate);
232
+ break;
233
+ case 2:
234
+ result += padWithZeros(month(localizedDate), 2);
235
+ break;
236
+ case 3:
237
+ result += shortMonths[month(localizedDate) - 1];
238
+ break;
239
+ case 4:
240
+ result += longMonths[month(localizedDate) - 1];
241
+ break;
242
+ default:
243
+ break;
244
+ }
245
+ break;
246
+ case "s":
247
+ tokenLength = parseRepeatToken(format, cursorPos, "s");
248
+ cursorPos += tokenLength;
249
+ switch (tokenLength) {
250
+ case 1:
251
+ result += second(localizedDate);
252
+ break;
253
+ case 2:
254
+ result += padWithZeros(second(localizedDate), 2);
255
+ break;
256
+ default:
257
+ break;
258
+ }
259
+ break;
260
+ case "t":
261
+ tokenLength = parseRepeatToken(format, cursorPos, "t");
262
+ cursorPos += tokenLength;
263
+ switch (tokenLength) {
264
+ case 1:
265
+ result += localizedDate.getHours() < 12 ? "A" : "P";
266
+ break;
267
+ case 2:
268
+ result += localizedDate.getHours() < 12 ? "AM" : "PM";
269
+ break;
270
+ default:
271
+ break;
272
+ }
273
+ break;
274
+ case "y":
275
+ tokenLength = parseRepeatToken(format, cursorPos, "y");
276
+ cursorPos += tokenLength;
277
+ switch (tokenLength) {
278
+ case 1:
279
+ result += localizedDate.getFullYear() % 100;
280
+ break;
281
+ case 2:
282
+ result += padWithZeros(localizedDate.getFullYear() % 100, 2);
283
+ break;
284
+ case 3:
285
+ result += padWithZeros(localizedDate.getFullYear(), 3);
286
+ break;
287
+ case 4:
288
+ result += padWithZeros(localizedDate.getFullYear(), 4);
289
+ break;
290
+ case 5:
291
+ result += padWithZeros(localizedDate.getFullYear(), 5);
292
+ break;
293
+ default:
294
+ break;
295
+ }
296
+ break;
297
+ case "z":
298
+ tokenLength = parseRepeatToken(format, cursorPos, "z");
299
+ cursorPos += tokenLength;
300
+ let utcOffsetText = "";
301
+
302
+ switch (kind(localizedDate)) {
303
+ case DateKind.UTC:
304
+ utcOffsetText = "+00:00";
305
+ break;
306
+ case DateKind.Local:
307
+ utcOffsetText = dateOffsetToString(localizedDate.getTimezoneOffset() * -60000);
308
+ break;
309
+ case DateKind.Unspecified:
310
+ utcOffsetText = dateOffsetToString(toLocalTime(localizedDate).getTimezoneOffset() * -60000);
311
+ break;
312
+ }
313
+
314
+ const sign = utcOffsetText[0] === "-" ? "-" : "+";
315
+ const hours = parseInt(utcOffsetText.substring(1, 3), 10);
316
+ const minutes = parseInt(utcOffsetText.substring(4, 6), 10);
317
+
318
+ switch (tokenLength) {
319
+ case 1:
320
+ result += `${sign}${hours}`;
321
+ break;
322
+ case 2:
323
+ result += `${sign}${padWithZeros(hours, 2)}`;
324
+ break;
325
+ default:
326
+ result += `${sign}${padWithZeros(hours, 2)}:${padWithZeros(minutes, 2)}`;
327
+ break;
328
+ }
329
+ break;
330
+ case ":":
331
+ result += ":";
332
+ cursorPos++;
333
+ break;
334
+ case "/":
335
+ result += "/";
336
+ cursorPos++;
337
+ break;
338
+ case "'":
339
+ case '"':
340
+ const [quotedString, quotedStringLenght] = parseQuotedString(format, cursorPos);
341
+ result += quotedString;
342
+ cursorPos += quotedStringLenght;
343
+ break;
344
+ case "%":
345
+ const nextChar = parseNextChar(format, cursorPos);
346
+ if (nextChar >= 0 && nextChar !== "%".charCodeAt(0)) {
347
+ cursorPos += 2;
348
+ result += dateToStringWithCustomFormat(localizedDate, String.fromCharCode(nextChar), utc);
349
+ } else {
350
+ throw new Error("Invalid format string");
351
+ }
352
+ break;
353
+ case "\\":
354
+ const nextChar2 = parseNextChar(format, cursorPos);
355
+ if (nextChar2 >= 0) {
356
+ cursorPos += 2;
357
+ result += String.fromCharCode(nextChar2);
358
+ } else {
359
+ throw new Error("Invalid format string");
360
+ }
361
+ break;
362
+ default:
363
+ cursorPos++;
364
+ result += token;
365
+ break;
366
+ }
367
+ }
368
+
369
+ return result;
370
+ }
371
+
18
372
  export function kind(value: IDateTime): number {
19
373
  return value.kind || 0;
20
374
  }
@@ -66,31 +420,6 @@ function dateToISOStringWithOffset(dateWithOffset: Date, offset: number) {
66
420
  return str.substring(0, str.length - 1) + dateOffsetToString(offset);
67
421
  }
68
422
 
69
- function dateToStringWithCustomFormat(date: Date, format: string, utc: boolean) {
70
- return format.replace(/(\w)\1*/g, (match: string) => {
71
- let rep = Number.NaN;
72
- switch (match.substring(0, 1)) {
73
- case "y":
74
- const y = utc ? date.getUTCFullYear() : date.getFullYear();
75
- rep = match.length < 4 ? y % 100 : y; break;
76
- case "M": rep = (utc ? date.getUTCMonth() : date.getMonth()) + 1; break;
77
- case "d": rep = utc ? date.getUTCDate() : date.getDate(); break;
78
- case "H": rep = utc ? date.getUTCHours() : date.getHours(); break;
79
- case "h":
80
- const h = utc ? date.getUTCHours() : date.getHours();
81
- rep = h > 12 ? h % 12 : h; break;
82
- case "m": rep = utc ? date.getUTCMinutes() : date.getMinutes(); break;
83
- case "s": rep = utc ? date.getUTCSeconds() : date.getSeconds(); break;
84
- case "f": rep = utc ? date.getUTCMilliseconds() : date.getMilliseconds(); break;
85
- }
86
- if (Number.isNaN(rep)) {
87
- return match;
88
- } else {
89
- return padWithZeros(rep, match.length);
90
- }
91
- });
92
- }
93
-
94
423
  function dateToStringWithOffset(date: IDateTimeOffset, format?: string) {
95
424
  const d = new Date(date.getTime() + (date.offset ?? 0));
96
425
  if (typeof format !== "string") {
package/List.ts CHANGED
@@ -5,7 +5,7 @@ import { int32 } from "./Int32.js";
5
5
  import { Record } from "./Types.js";
6
6
  import { class_type, record_type, option_type, TypeInfo } from "./Reflection.js";
7
7
  import { SR_inputSequenceTooLong, SR_inputSequenceEmpty, SR_inputMustBeNonNegative, SR_notEnoughElements, SR_differentLengths, SR_keyNotFoundAlt, SR_indexOutOfBounds, SR_inputWasEmpty } from "./Global.js";
8
- import { transpose as transpose_1, splitInto as splitInto_1, windowed as windowed_1, pairwise as pairwise_1, chunkBySize as chunkBySize_1, map as map_1, permute as permute_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, scanBack as scanBack_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, fill } from "./Array.js";
8
+ import { transpose as transpose_1, splitInto as splitInto_1, windowed as windowed_1, pairwise as pairwise_1, chunkBySize as chunkBySize_1, map as map_1, permute as permute_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, scanBack as scanBack_1, item as item_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, setItem, fill } from "./Array.js";
9
9
 
10
10
  export class FSharpList<T> extends Record implements Iterable<T> {
11
11
  readonly head: T;
@@ -384,7 +384,7 @@ export function toArray<T>(xs: FSharpList<T>): T[] {
384
384
  while (true) {
385
385
  const i: int32 = i_mut, xs_1: FSharpList<T> = xs_1_mut;
386
386
  if (!FSharpList__get_IsEmpty<T>(xs_1)) {
387
- res[i] = FSharpList__get_Head<T>(xs_1);
387
+ setItem(res, i, FSharpList__get_Head<T>(xs_1));
388
388
  i_mut = (i + 1);
389
389
  xs_1_mut = FSharpList__get_Tail<T>(xs_1);
390
390
  continue loop;
@@ -508,7 +508,7 @@ export function toSeq<T>(xs: FSharpList<T>): Iterable<T> {
508
508
  export function ofArrayWithTail<T>(xs: T[], tail_1: FSharpList<T>): FSharpList<T> {
509
509
  let res: FSharpList<T> = tail_1;
510
510
  for (let i: int32 = xs.length - 1; i >= 0; i--) {
511
- res = FSharpList_Cons_305B8EAC<T>(xs[i], res);
511
+ res = FSharpList_Cons_305B8EAC<T>(item_1(i, xs), res);
512
512
  }
513
513
  return res;
514
514
  }
package/Map.ts CHANGED
@@ -3,7 +3,7 @@ import { some, value as value_1, Option } from "./Option.js";
3
3
  import { int32 } from "./Int32.js";
4
4
  import { structuralHash, IMap, compare, toIterator, equals, IDisposable, disposeSafe, getEnumerator, isArrayLike, IEnumerator, IComparer } from "./Util.js";
5
5
  import { singleton, ofArrayWithTail, head, tail, isEmpty as isEmpty_1, fold as fold_1, empty as empty_1, FSharpList, cons } from "./List.js";
6
- import { map as map_2, fill } from "./Array.js";
6
+ import { map as map_2, item, fill, setItem } from "./Array.js";
7
7
  import { FSharpRef, Record } from "./Types.js";
8
8
  import { tryPick as tryPick_1, pick as pick_1, iterate as iterate_1, compareWith, map as map_1, unfold } from "./Seq.js";
9
9
  import { format, join } from "./String.js";
@@ -817,7 +817,7 @@ export function MapTreeModule_toList<Key, Value>(m: Option<MapTreeLeaf$2<Key, Va
817
817
  export function MapTreeModule_copyToArray<$a, $b>(m: Option<MapTreeLeaf$2<$a, $b>>, arr: [$a, $b][], i: int32): void {
818
818
  let j: int32 = i;
819
819
  MapTreeModule_iter<$a, $b>((x: $a, y: $b): void => {
820
- arr[j] = ([x, y] as [$a, $b]);
820
+ setItem(arr, j, [x, y] as [$a, $b]);
821
821
  j = ((j + 1) | 0);
822
822
  }, m);
823
823
  }
@@ -854,7 +854,7 @@ export function MapTreeModule_mkFromEnumerator<$a, $b>(comparer_mut: IComparer<$
854
854
  export function MapTreeModule_ofArray<Key, Value>(comparer: IComparer<Key>, arr: [Key, Value][]): Option<MapTreeLeaf$2<Key, Value>> {
855
855
  let res: Option<MapTreeLeaf$2<Key, Value>> = MapTreeModule_empty<Key, Value>();
856
856
  for (let idx = 0; idx <= (arr.length - 1); idx++) {
857
- const forLoopVar: [Key, Value] = arr[idx];
857
+ const forLoopVar: [Key, Value] = item(idx, arr);
858
858
  res = MapTreeModule_add<Key, Value>(comparer, forLoopVar[0], forLoopVar[1], res);
859
859
  }
860
860
  return res;
package/MutableMap.ts CHANGED
@@ -2,6 +2,7 @@ import { IEqualityComparer, IDisposable, disposeSafe, defaultOf, IMap, equals, t
2
2
  import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.js";
3
3
  import { value as value_1, Option } from "./Option.js";
4
4
  import { int32 } from "./Int32.js";
5
+ import { setItem } from "./Array.js";
5
6
  import { FSharpRef } from "./Types.js";
6
7
  import { class_type, TypeInfo } from "./Reflection.js";
7
8
  import { getItemFromDict, tryGetValue } from "./MapUtil.js";
@@ -80,7 +81,7 @@ export class Dictionary<Key, Value> implements IMap<Key, Value>, Iterable<[Key,
80
81
  "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: [Key, Value][], arrayIndex: int32): void {
81
82
  const this$: Dictionary<Key, Value> = this;
82
83
  iterateIndexed<[Key, Value]>((i: int32, e: [Key, Value]): void => {
83
- array[arrayIndex + i] = e;
84
+ setItem(array, arrayIndex + i, e);
84
85
  }, this$);
85
86
  }
86
87
  "System.Collections.Generic.ICollection`1.get_Count"(): int32 {
package/MutableSet.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IMap, IEqualityComparer, IDisposable, disposeSafe, defaultOf, ISet, toIterator, IEnumerator, getEnumerator } from "./Util.js";
2
2
  import { iterate, map, iterateIndexed, concat } from "./Seq.js";
3
+ import { setItem } from "./Array.js";
3
4
  import { int32 } from "./Int32.js";
4
5
  import { some, Option } from "./Option.js";
5
6
  import { FSharpRef } from "./Types.js";
@@ -60,7 +61,7 @@ export class HashSet<T> implements ISet<T>, Iterable<T>, Iterable<T> {
60
61
  "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: T[], arrayIndex: int32): void {
61
62
  const this$: HashSet<T> = this;
62
63
  iterateIndexed<T>((i: int32, e: T): void => {
63
- array[arrayIndex + i] = e;
64
+ setItem(array, arrayIndex + i, e);
64
65
  }, this$);
65
66
  }
66
67
  "System.Collections.Generic.ICollection`1.get_Count"(): int32 {
package/Random.ts CHANGED
@@ -1,7 +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 { fill } from "./Array.js";
4
+ import { item, fill, setItem } from "./Array.js";
5
5
 
6
6
  function Native_random(): float64 {
7
7
  return Math.random();
@@ -91,13 +91,13 @@ export class Seeded implements IRandom {
91
91
  if (mk < 0) {
92
92
  mk = ((mk + this.MBIG) | 0);
93
93
  }
94
- mj = (this.seedArray[ii] | 0);
94
+ mj = (item(ii, this.seedArray) | 0);
95
95
  }
96
96
  for (let k = 1; k <= 4; k++) {
97
97
  for (let i_1 = 1; i_1 <= 55; i_1++) {
98
- this.seedArray[i_1] = ((this.seedArray[i_1] - this.seedArray[1 + ((i_1 + 30) % 55)]) | 0);
99
- if (this.seedArray[i_1] < 0) {
100
- this.seedArray[i_1] = ((this.seedArray[i_1] + this.MBIG) | 0);
98
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) - item(1 + ((i_1 + 30) % 55), this.seedArray)) | 0);
99
+ if (item(i_1, this.seedArray) < 0) {
100
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) + this.MBIG) | 0);
101
101
  }
102
102
  }
103
103
  }
@@ -133,7 +133,7 @@ export class Seeded implements IRandom {
133
133
  throw new Error("buffer");
134
134
  }
135
135
  for (let i = 0; i <= (buffer.length - 1); i++) {
136
- buffer[i] = ((Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
136
+ setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
137
137
  }
138
138
  }
139
139
  }
@@ -158,7 +158,7 @@ function Seeded__InternalSample(_: Seeded): int32 {
158
158
  if (locINextp >= 56) {
159
159
  locINextp = 1;
160
160
  }
161
- retVal = ((_.seedArray[locINext] - _.seedArray[locINextp]) | 0);
161
+ retVal = ((item(locINext, _.seedArray) - item(locINextp, _.seedArray)) | 0);
162
162
  if (retVal === _.MBIG) {
163
163
  retVal = ((retVal - 1) | 0);
164
164
  }
package/Set.ts CHANGED
@@ -4,7 +4,7 @@ import { int32 } from "./Int32.js";
4
4
  import { structuralHash, ISet, toIterator, IDisposable, disposeSafe, getEnumerator, isArrayLike, IEnumerator, IComparer } from "./Util.js";
5
5
  import { toString, Record } from "./Types.js";
6
6
  import { fold as fold_2, cons, singleton as singleton_1, empty as empty_1, ofArrayWithTail, tail, head, isEmpty as isEmpty_1, FSharpList } from "./List.js";
7
- import { fold as fold_1, fill } from "./Array.js";
7
+ import { fold as fold_1, fill, setItem } from "./Array.js";
8
8
  import { join } from "./String.js";
9
9
  import { exists as exists_1, cache, forAll as forAll_1, fold as fold_3, reduce, iterate as iterate_1, map as map_1 } from "./Seq.js";
10
10
  import { HashSet__get_Comparer, HashSet_$ctor_Z6150332D, HashSet } from "./MutableSet.js";
@@ -1420,7 +1420,7 @@ export function SetTreeModule_toList<T>(t: Option<SetTreeLeaf$1<T>>): FSharpList
1420
1420
  export function SetTreeModule_copyToArray<$a>(s: Option<SetTreeLeaf$1<$a>>, arr: $a[], i: int32): void {
1421
1421
  let j: int32 = i;
1422
1422
  SetTreeModule_iter<$a>((x: $a): void => {
1423
- arr[j] = x;
1423
+ setItem(arr, j, x);
1424
1424
  j = ((j + 1) | 0);
1425
1425
  }, s);
1426
1426
  }
package/String.ts CHANGED
@@ -568,6 +568,10 @@ export function substring(str: string, startIndex: number, length?: number) {
568
568
  return length != null ? str.substr(startIndex, length) : str.substr(startIndex);
569
569
  }
570
570
 
571
+ export function toCharArray2(str: string, startIndex: number, length: number) {
572
+ return substring(str, startIndex, length).split("")
573
+ }
574
+
571
575
  interface FormattableString {
572
576
  strs: TemplateStringsArray,
573
577
  args: any[],
@@ -2,7 +2,7 @@ import { int32 } from "./Int32.js";
2
2
  import { IDisposable, disposeSafe, defaultOf, toIterator, IEnumerator, getEnumerator, structuralHash, equals as equals_1, IEqualityComparer, compare, IComparer } from "./Util.js";
3
3
  import { class_type, TypeInfo } from "./Reflection.js";
4
4
  import { toArray, empty, singleton, append, enumerateWhile, delay } from "./Seq.js";
5
- import { initialize, copyTo, fill } from "./Array.js";
5
+ import { setItem, initialize, copyTo, fill, item as item_1 } from "./Array.js";
6
6
  import { max } from "./Double.js";
7
7
  import { FSharpRef } from "./Types.js";
8
8
 
@@ -89,7 +89,7 @@ export class Stack$1<T> implements Iterable<T> {
89
89
  const _: Stack$1<T> = this;
90
90
  return getEnumerator(delay<T>((): Iterable<T> => {
91
91
  let index: int32 = _.count - 1;
92
- return enumerateWhile<T>((): boolean => (index >= 0), delay<T>((): Iterable<T> => append<T>(singleton<T>(_.contents[index]), delay<T>((): Iterable<T> => {
92
+ return enumerateWhile<T>((): boolean => (index >= 0), delay<T>((): Iterable<T> => append<T>(singleton<T>(item_1(index, _.contents)), delay<T>((): Iterable<T> => {
93
93
  index = ((index - 1) | 0);
94
94
  return empty<T>();
95
95
  }))));
@@ -140,18 +140,18 @@ export function Stack$1__get_Count<T>(_: Stack$1<T>): int32 {
140
140
 
141
141
  export function Stack$1__Pop<T>(_: Stack$1<T>): T {
142
142
  _.count = ((_.count - 1) | 0);
143
- return _.contents[_.count];
143
+ return item_1(_.count, _.contents);
144
144
  }
145
145
 
146
146
  export function Stack$1__Peek<T>(_: Stack$1<T>): T {
147
- return _.contents[_.count - 1];
147
+ return item_1(_.count - 1, _.contents);
148
148
  }
149
149
 
150
150
  export function Stack$1__Contains_2B595<T>(_: Stack$1<T>, x: T): boolean {
151
151
  let found = false;
152
152
  let i = 0;
153
153
  while ((i < _.count) && !found) {
154
- if (equals_1(x, _.contents[i])) {
154
+ if (equals_1(x, item_1(i, _.contents))) {
155
155
  found = true;
156
156
  }
157
157
  else {
@@ -199,7 +199,7 @@ export function Stack$1__TrimExcess<T>(this$: Stack$1<T>): void {
199
199
  }
200
200
 
201
201
  export function Stack$1__ToArray<T>(_: Stack$1<T>): T[] {
202
- return initialize<T>(_.count, (i: int32): T => _.contents[(_.count - 1) - i]);
202
+ return initialize<T>(_.count, (i: int32): T => item_1((_.count - 1) - i, _.contents));
203
203
  }
204
204
 
205
205
  export class Queue$1<T> implements Iterable<T> {
@@ -267,7 +267,7 @@ export function Queue$1__Dequeue<T>(_: Queue$1<T>): T {
267
267
  if (_.count === 0) {
268
268
  throw new Error("Queue is empty");
269
269
  }
270
- const value: T = _.contents[_.head];
270
+ const value: T = item_1(_.head, _.contents);
271
271
  _.head = (((_.head + 1) % Queue$1__size<T>(_)) | 0);
272
272
  _.count = ((_.count - 1) | 0);
273
273
  return value;
@@ -277,7 +277,7 @@ export function Queue$1__Peek<T>(_: Queue$1<T>): T {
277
277
  if (_.count === 0) {
278
278
  throw new Error("Queue is empty");
279
279
  }
280
- return _.contents[_.head];
280
+ return item_1(_.head, _.contents);
281
281
  }
282
282
 
283
283
  export function Queue$1__TryDequeue_1F3DB691<T>(this$: Queue$1<T>, result: FSharpRef<T>): boolean {
@@ -304,7 +304,7 @@ export function Queue$1__Contains_2B595<T>(_: Queue$1<T>, x: T): boolean {
304
304
  let found = false;
305
305
  let i = 0;
306
306
  while ((i < _.count) && !found) {
307
- if (equals_1(x, _.contents[Queue$1__toIndex_Z524259A4<T>(_, i)])) {
307
+ if (equals_1(x, item_1(Queue$1__toIndex_Z524259A4<T>(_, i), _.contents))) {
308
308
  found = true;
309
309
  }
310
310
  else {
@@ -337,7 +337,7 @@ export function Queue$1__CopyTo_Z3B4C077E<T>(_: Queue$1<T>, target: T[], start:
337
337
  try {
338
338
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
339
339
  const item: T = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
340
- target[i] = item;
340
+ setItem(target, i, item);
341
341
  i = ((i + 1) | 0);
342
342
  }
343
343
  }
@@ -371,7 +371,7 @@ export function Queue$1__ensure_Z524259A4<T>(this$: Queue$1<T>, requiredSize: in
371
371
  export function Queue$1__toSeq<T>(this$: Queue$1<T>): Iterable<T> {
372
372
  return delay<T>((): Iterable<T> => {
373
373
  let i = 0;
374
- return enumerateWhile<T>((): boolean => (i < this$.count), delay<T>((): Iterable<T> => append<T>(singleton<T>(this$.contents[Queue$1__toIndex_Z524259A4<T>(this$, i)]), delay<T>((): Iterable<T> => {
374
+ return enumerateWhile<T>((): boolean => (i < this$.count), delay<T>((): Iterable<T> => append<T>(singleton<T>(item_1(Queue$1__toIndex_Z524259A4<T>(this$, i), this$.contents)), delay<T>((): Iterable<T> => {
375
375
  i = ((i + 1) | 0);
376
376
  return empty<T>();
377
377
  }))));