@fable-org/fable-library-js 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.js CHANGED
@@ -9,6 +9,342 @@
9
9
  */
10
10
  import { toInt64, toFloat64 } from "./BigInt.js";
11
11
  import { compareDates, dateOffset, padWithZeros } from "./Util.js";
12
+ const shortDays = [
13
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
14
+ ];
15
+ const longDays = [
16
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
17
+ ];
18
+ const shortMonths = [
19
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
20
+ ];
21
+ const longMonths = [
22
+ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
23
+ ];
24
+ function parseRepeatToken(format, pos, patternChar) {
25
+ let tokenLength = 0;
26
+ let internalPos = pos;
27
+ while (internalPos < format.length && format[internalPos] === patternChar) {
28
+ internalPos++;
29
+ tokenLength++;
30
+ }
31
+ return tokenLength;
32
+ }
33
+ function parseNextChar(format, pos) {
34
+ if (pos >= format.length - 1) {
35
+ return -1;
36
+ }
37
+ return format.charCodeAt(pos + 1);
38
+ }
39
+ function parseQuotedString(format, pos) {
40
+ let beginPos = pos;
41
+ // Get the character used to quote the string
42
+ const quoteChar = format[pos];
43
+ let result = "";
44
+ let foundQuote = false;
45
+ while (pos < format.length) {
46
+ pos++;
47
+ const currentChar = format[pos];
48
+ if (currentChar === quoteChar) {
49
+ foundQuote = true;
50
+ break;
51
+ }
52
+ else if (currentChar === "\\") {
53
+ if (pos < format.length) {
54
+ pos++;
55
+ result += format[pos];
56
+ }
57
+ else {
58
+ // This means that '\' is the last character in the string.
59
+ throw new Error("Invalid string format");
60
+ }
61
+ }
62
+ else {
63
+ result += currentChar;
64
+ }
65
+ }
66
+ if (!foundQuote) {
67
+ // We could not find the matching quote
68
+ throw new Error(`Invalid string format could not find matching quote for ${quoteChar}`);
69
+ }
70
+ return [result, pos - beginPos + 1];
71
+ }
72
+ function dateToStringWithCustomFormat(date, format, utc) {
73
+ let cursorPos = 0;
74
+ let tokenLength = 0;
75
+ let result = "";
76
+ const localizedDate = utc ? DateTime(date.getTime(), 1 /* DateKind.UTC */) : date;
77
+ while (cursorPos < format.length) {
78
+ const token = format[cursorPos];
79
+ switch (token) {
80
+ case "d":
81
+ tokenLength = parseRepeatToken(format, cursorPos, "d");
82
+ cursorPos += tokenLength;
83
+ switch (tokenLength) {
84
+ case 1:
85
+ result += localizedDate.getDate();
86
+ break;
87
+ case 2:
88
+ result += padWithZeros(localizedDate.getDate(), 2);
89
+ break;
90
+ case 3:
91
+ result += shortDays[dayOfWeek(localizedDate)];
92
+ break;
93
+ case 4:
94
+ result += longDays[dayOfWeek(localizedDate)];
95
+ break;
96
+ default:
97
+ break;
98
+ }
99
+ break;
100
+ case "f":
101
+ tokenLength = parseRepeatToken(format, cursorPos, "f");
102
+ cursorPos += tokenLength;
103
+ if (tokenLength <= 3) {
104
+ const precision = 10 ** (3 - tokenLength);
105
+ result += padWithZeros(Math.floor(millisecond(localizedDate) / precision), tokenLength);
106
+ }
107
+ else if (tokenLength <= 7) {
108
+ // JavaScript Date only support precision to the millisecond
109
+ // so we fill the rest of the precision with 0 as if the date didn't have
110
+ // milliseconds provided to it.
111
+ // This is to have the same behavior as .NET when doing:
112
+ // DateTime(1, 2, 3, 4, 5, 6, DateTimeKind.Utc).ToString("fffff") => 00000
113
+ result += ("" + millisecond(localizedDate)).padEnd(tokenLength, "0");
114
+ }
115
+ break;
116
+ case "F":
117
+ tokenLength = parseRepeatToken(format, cursorPos, "F");
118
+ cursorPos += tokenLength;
119
+ if (tokenLength <= 3) {
120
+ const precision = 10 ** (3 - tokenLength);
121
+ const value = Math.floor(millisecond(localizedDate) / precision);
122
+ if (value != 0) {
123
+ result += padWithZeros(value, tokenLength);
124
+ }
125
+ }
126
+ else if (tokenLength <= 7) {
127
+ // JavaScript Date only support precision to the millisecond
128
+ // so we can't go beyond that.
129
+ // We also need to pad start with 0 if the value is not 0
130
+ const value = millisecond(localizedDate);
131
+ if (value != 0) {
132
+ result += padWithZeros(value, 3);
133
+ }
134
+ }
135
+ break;
136
+ case "g":
137
+ tokenLength = parseRepeatToken(format, cursorPos, "g");
138
+ cursorPos += tokenLength;
139
+ if (tokenLength <= 2) {
140
+ result += "A.D.";
141
+ }
142
+ break;
143
+ case "h":
144
+ tokenLength = parseRepeatToken(format, cursorPos, "h");
145
+ cursorPos += tokenLength;
146
+ switch (tokenLength) {
147
+ case 1:
148
+ result += hour(localizedDate) % 12;
149
+ break;
150
+ case 2:
151
+ result += padWithZeros(hour(localizedDate) % 12, 2);
152
+ break;
153
+ default:
154
+ break;
155
+ }
156
+ break;
157
+ case "H":
158
+ tokenLength = parseRepeatToken(format, cursorPos, "H");
159
+ cursorPos += tokenLength;
160
+ switch (tokenLength) {
161
+ case 1:
162
+ result += hour(localizedDate);
163
+ break;
164
+ case 2:
165
+ result += padWithZeros(hour(localizedDate), 2);
166
+ break;
167
+ default:
168
+ break;
169
+ }
170
+ break;
171
+ case "K":
172
+ tokenLength = parseRepeatToken(format, cursorPos, "K");
173
+ cursorPos += tokenLength;
174
+ switch (tokenLength) {
175
+ case 1:
176
+ switch (kind(localizedDate)) {
177
+ case 1 /* DateKind.UTC */:
178
+ result += "Z";
179
+ break;
180
+ case 2 /* DateKind.Local */:
181
+ result += dateOffsetToString(localizedDate.getTimezoneOffset() * -60000);
182
+ break;
183
+ case 0 /* DateKind.Unspecified */:
184
+ break;
185
+ }
186
+ break;
187
+ default:
188
+ break;
189
+ }
190
+ break;
191
+ case "m":
192
+ tokenLength = parseRepeatToken(format, cursorPos, "m");
193
+ cursorPos += tokenLength;
194
+ switch (tokenLength) {
195
+ case 1:
196
+ result += minute(localizedDate);
197
+ break;
198
+ case 2:
199
+ result += padWithZeros(minute(localizedDate), 2);
200
+ break;
201
+ default:
202
+ break;
203
+ }
204
+ break;
205
+ case "M":
206
+ tokenLength = parseRepeatToken(format, cursorPos, "M");
207
+ cursorPos += tokenLength;
208
+ switch (tokenLength) {
209
+ case 1:
210
+ result += month(localizedDate);
211
+ break;
212
+ case 2:
213
+ result += padWithZeros(month(localizedDate), 2);
214
+ break;
215
+ case 3:
216
+ result += shortMonths[month(localizedDate) - 1];
217
+ break;
218
+ case 4:
219
+ result += longMonths[month(localizedDate) - 1];
220
+ break;
221
+ default:
222
+ break;
223
+ }
224
+ break;
225
+ case "s":
226
+ tokenLength = parseRepeatToken(format, cursorPos, "s");
227
+ cursorPos += tokenLength;
228
+ switch (tokenLength) {
229
+ case 1:
230
+ result += second(localizedDate);
231
+ break;
232
+ case 2:
233
+ result += padWithZeros(second(localizedDate), 2);
234
+ break;
235
+ default:
236
+ break;
237
+ }
238
+ break;
239
+ case "t":
240
+ tokenLength = parseRepeatToken(format, cursorPos, "t");
241
+ cursorPos += tokenLength;
242
+ switch (tokenLength) {
243
+ case 1:
244
+ result += localizedDate.getHours() < 12 ? "A" : "P";
245
+ break;
246
+ case 2:
247
+ result += localizedDate.getHours() < 12 ? "AM" : "PM";
248
+ break;
249
+ default:
250
+ break;
251
+ }
252
+ break;
253
+ case "y":
254
+ tokenLength = parseRepeatToken(format, cursorPos, "y");
255
+ cursorPos += tokenLength;
256
+ switch (tokenLength) {
257
+ case 1:
258
+ result += localizedDate.getFullYear() % 100;
259
+ break;
260
+ case 2:
261
+ result += padWithZeros(localizedDate.getFullYear() % 100, 2);
262
+ break;
263
+ case 3:
264
+ result += padWithZeros(localizedDate.getFullYear(), 3);
265
+ break;
266
+ case 4:
267
+ result += padWithZeros(localizedDate.getFullYear(), 4);
268
+ break;
269
+ case 5:
270
+ result += padWithZeros(localizedDate.getFullYear(), 5);
271
+ break;
272
+ default:
273
+ break;
274
+ }
275
+ break;
276
+ case "z":
277
+ tokenLength = parseRepeatToken(format, cursorPos, "z");
278
+ cursorPos += tokenLength;
279
+ let utcOffsetText = "";
280
+ switch (kind(localizedDate)) {
281
+ case 1 /* DateKind.UTC */:
282
+ utcOffsetText = "+00:00";
283
+ break;
284
+ case 2 /* DateKind.Local */:
285
+ utcOffsetText = dateOffsetToString(localizedDate.getTimezoneOffset() * -60000);
286
+ break;
287
+ case 0 /* DateKind.Unspecified */:
288
+ utcOffsetText = dateOffsetToString(toLocalTime(localizedDate).getTimezoneOffset() * -60000);
289
+ break;
290
+ }
291
+ const sign = utcOffsetText[0] === "-" ? "-" : "+";
292
+ const hours = parseInt(utcOffsetText.substring(1, 3), 10);
293
+ const minutes = parseInt(utcOffsetText.substring(4, 6), 10);
294
+ switch (tokenLength) {
295
+ case 1:
296
+ result += `${sign}${hours}`;
297
+ break;
298
+ case 2:
299
+ result += `${sign}${padWithZeros(hours, 2)}`;
300
+ break;
301
+ default:
302
+ result += `${sign}${padWithZeros(hours, 2)}:${padWithZeros(minutes, 2)}`;
303
+ break;
304
+ }
305
+ break;
306
+ case ":":
307
+ result += ":";
308
+ cursorPos++;
309
+ break;
310
+ case "/":
311
+ result += "/";
312
+ cursorPos++;
313
+ break;
314
+ case "'":
315
+ case '"':
316
+ const [quotedString, quotedStringLenght] = parseQuotedString(format, cursorPos);
317
+ result += quotedString;
318
+ cursorPos += quotedStringLenght;
319
+ break;
320
+ case "%":
321
+ const nextChar = parseNextChar(format, cursorPos);
322
+ if (nextChar >= 0 && nextChar !== "%".charCodeAt(0)) {
323
+ cursorPos += 2;
324
+ result += dateToStringWithCustomFormat(localizedDate, String.fromCharCode(nextChar), utc);
325
+ }
326
+ else {
327
+ throw new Error("Invalid format string");
328
+ }
329
+ break;
330
+ case "\\":
331
+ const nextChar2 = parseNextChar(format, cursorPos);
332
+ if (nextChar2 >= 0) {
333
+ cursorPos += 2;
334
+ result += String.fromCharCode(nextChar2);
335
+ }
336
+ else {
337
+ throw new Error("Invalid format string");
338
+ }
339
+ break;
340
+ default:
341
+ cursorPos++;
342
+ result += token;
343
+ break;
344
+ }
345
+ }
346
+ return result;
347
+ }
12
348
  export function kind(value) {
13
349
  return value.kind || 0;
14
350
  }
@@ -54,45 +390,6 @@ function dateToISOStringWithOffset(dateWithOffset, offset) {
54
390
  const str = dateWithOffset.toISOString();
55
391
  return str.substring(0, str.length - 1) + dateOffsetToString(offset);
56
392
  }
57
- function dateToStringWithCustomFormat(date, format, utc) {
58
- return format.replace(/(\w)\1*/g, (match) => {
59
- let rep = Number.NaN;
60
- switch (match.substring(0, 1)) {
61
- case "y":
62
- const y = utc ? date.getUTCFullYear() : date.getFullYear();
63
- rep = match.length < 4 ? y % 100 : y;
64
- break;
65
- case "M":
66
- rep = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
67
- break;
68
- case "d":
69
- rep = utc ? date.getUTCDate() : date.getDate();
70
- break;
71
- case "H":
72
- rep = utc ? date.getUTCHours() : date.getHours();
73
- break;
74
- case "h":
75
- const h = utc ? date.getUTCHours() : date.getHours();
76
- rep = h > 12 ? h % 12 : h;
77
- break;
78
- case "m":
79
- rep = utc ? date.getUTCMinutes() : date.getMinutes();
80
- break;
81
- case "s":
82
- rep = utc ? date.getUTCSeconds() : date.getSeconds();
83
- break;
84
- case "f":
85
- rep = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
86
- break;
87
- }
88
- if (Number.isNaN(rep)) {
89
- return match;
90
- }
91
- else {
92
- return padWithZeros(rep, match.length);
93
- }
94
- });
95
- }
96
393
  function dateToStringWithOffset(date, format) {
97
394
  const d = new Date(date.getTime() + (date.offset ?? 0));
98
395
  if (typeof format !== "string") {
package/List.js CHANGED
@@ -4,7 +4,7 @@ import { disposeSafe, isArrayLike, defaultOf, toIterator, getEnumerator, compare
4
4
  import { Record } from "./Types.js";
5
5
  import { class_type, record_type, option_type } from "./Reflection.js";
6
6
  import { SR_inputSequenceTooLong, SR_inputSequenceEmpty, SR_inputMustBeNonNegative, SR_notEnoughElements, SR_differentLengths, SR_keyNotFoundAlt, SR_indexOutOfBounds, SR_inputWasEmpty } from "./Global.js";
7
- 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";
7
+ 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";
8
8
  export class FSharpList extends Record {
9
9
  constructor(head, tail) {
10
10
  super();
@@ -345,7 +345,7 @@ export function toArray(xs) {
345
345
  loop: while (true) {
346
346
  const i = i_mut, xs_1 = xs_1_mut;
347
347
  if (!FSharpList__get_IsEmpty(xs_1)) {
348
- res[i] = FSharpList__get_Head(xs_1);
348
+ setItem(res, i, FSharpList__get_Head(xs_1));
349
349
  i_mut = (i + 1);
350
350
  xs_1_mut = FSharpList__get_Tail(xs_1);
351
351
  continue loop;
@@ -454,7 +454,7 @@ export function toSeq(xs) {
454
454
  export function ofArrayWithTail(xs, tail_1) {
455
455
  let res = tail_1;
456
456
  for (let i = xs.length - 1; i >= 0; i--) {
457
- res = FSharpList_Cons_305B8EAC(xs[i], res);
457
+ res = FSharpList_Cons_305B8EAC(item_1(i, xs), res);
458
458
  }
459
459
  return res;
460
460
  }
package/Map.js CHANGED
@@ -2,7 +2,7 @@ import { record_type, bool_type, list_type, option_type, class_type } from "./Re
2
2
  import { some, value as value_1 } from "./Option.js";
3
3
  import { structuralHash, compare, toIterator, equals, disposeSafe, getEnumerator, isArrayLike } from "./Util.js";
4
4
  import { singleton, ofArrayWithTail, head, tail, isEmpty as isEmpty_1, fold as fold_1, empty as empty_1, FSharpList, cons } from "./List.js";
5
- import { map as map_2, fill } from "./Array.js";
5
+ import { map as map_2, item, fill, setItem } from "./Array.js";
6
6
  import { Record } from "./Types.js";
7
7
  import { tryPick as tryPick_1, pick as pick_1, iterate as iterate_1, compareWith, map as map_1, unfold } from "./Seq.js";
8
8
  import { format, join } from "./String.js";
@@ -750,7 +750,7 @@ export function MapTreeModule_toList(m) {
750
750
  export function MapTreeModule_copyToArray(m, arr, i) {
751
751
  let j = i;
752
752
  MapTreeModule_iter((x, y) => {
753
- arr[j] = [x, y];
753
+ setItem(arr, j, [x, y]);
754
754
  j = ((j + 1) | 0);
755
755
  }, m);
756
756
  }
@@ -782,7 +782,7 @@ export function MapTreeModule_mkFromEnumerator(comparer_mut, acc_mut, e_mut) {
782
782
  export function MapTreeModule_ofArray(comparer, arr) {
783
783
  let res = MapTreeModule_empty();
784
784
  for (let idx = 0; idx <= (arr.length - 1); idx++) {
785
- const forLoopVar = arr[idx];
785
+ const forLoopVar = item(idx, arr);
786
786
  res = MapTreeModule_add(comparer, forLoopVar[0], forLoopVar[1], res);
787
787
  }
788
788
  return res;
package/MutableMap.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { disposeSafe, defaultOf, equals, toIterator, getEnumerator } from "./Util.js";
2
2
  import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.js";
3
3
  import { value as value_1 } from "./Option.js";
4
+ import { setItem } from "./Array.js";
4
5
  import { FSharpRef } from "./Types.js";
5
6
  import { class_type } from "./Reflection.js";
6
7
  import { getItemFromDict, tryGetValue } from "./MapUtil.js";
@@ -75,7 +76,7 @@ export class Dictionary {
75
76
  "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
76
77
  const this$ = this;
77
78
  iterateIndexed((i, e) => {
78
- array[arrayIndex + i] = e;
79
+ setItem(array, arrayIndex + i, e);
79
80
  }, this$);
80
81
  }
81
82
  "System.Collections.Generic.ICollection`1.get_Count"() {
package/MutableSet.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { disposeSafe, defaultOf, toIterator, getEnumerator } from "./Util.js";
2
2
  import { iterate, map, iterateIndexed, concat } from "./Seq.js";
3
+ import { setItem } from "./Array.js";
3
4
  import { some } from "./Option.js";
4
5
  import { FSharpRef } from "./Types.js";
5
6
  import { class_type } from "./Reflection.js";
@@ -55,7 +56,7 @@ export class HashSet {
55
56
  "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
56
57
  const this$ = this;
57
58
  iterateIndexed((i, e) => {
58
- array[arrayIndex + i] = e;
59
+ setItem(array, arrayIndex + i, e);
59
60
  }, this$);
60
61
  }
61
62
  "System.Collections.Generic.ICollection`1.get_Count"() {
package/Random.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { class_type } from "./Reflection.js";
2
2
  import { fromFloat64, op_Addition, toInt32, toFloat64, compare, fromInt32, toInt64 } from "./BigInt.js";
3
- import { fill } from "./Array.js";
3
+ import { item, fill, setItem } from "./Array.js";
4
4
  function Native_random() {
5
5
  return Math.random();
6
6
  }
@@ -73,13 +73,13 @@ export class Seeded {
73
73
  if (mk < 0) {
74
74
  mk = ((mk + this.MBIG) | 0);
75
75
  }
76
- mj = (this.seedArray[ii] | 0);
76
+ mj = (item(ii, this.seedArray) | 0);
77
77
  }
78
78
  for (let k = 1; k <= 4; k++) {
79
79
  for (let i_1 = 1; i_1 <= 55; i_1++) {
80
- this.seedArray[i_1] = ((this.seedArray[i_1] - this.seedArray[1 + ((i_1 + 30) % 55)]) | 0);
81
- if (this.seedArray[i_1] < 0) {
82
- this.seedArray[i_1] = ((this.seedArray[i_1] + this.MBIG) | 0);
80
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) - item(1 + ((i_1 + 30) % 55), this.seedArray)) | 0);
81
+ if (item(i_1, this.seedArray) < 0) {
82
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) + this.MBIG) | 0);
83
83
  }
84
84
  }
85
85
  }
@@ -115,7 +115,7 @@ export class Seeded {
115
115
  throw new Error("buffer");
116
116
  }
117
117
  for (let i = 0; i <= (buffer.length - 1); i++) {
118
- buffer[i] = ((Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
118
+ setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
119
119
  }
120
120
  }
121
121
  }
@@ -137,7 +137,7 @@ function Seeded__InternalSample(_) {
137
137
  if (locINextp >= 56) {
138
138
  locINextp = 1;
139
139
  }
140
- retVal = ((_.seedArray[locINext] - _.seedArray[locINextp]) | 0);
140
+ retVal = ((item(locINext, _.seedArray) - item(locINextp, _.seedArray)) | 0);
141
141
  if (retVal === _.MBIG) {
142
142
  retVal = ((retVal - 1) | 0);
143
143
  }
package/Set.js CHANGED
@@ -3,7 +3,7 @@ import { some, value as value_3 } from "./Option.js";
3
3
  import { structuralHash, toIterator, disposeSafe, getEnumerator, isArrayLike } from "./Util.js";
4
4
  import { toString, Record } from "./Types.js";
5
5
  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";
6
- import { fold as fold_1, fill } from "./Array.js";
6
+ import { fold as fold_1, fill, setItem } from "./Array.js";
7
7
  import { join } from "./String.js";
8
8
  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";
9
9
  import { HashSet__get_Comparer, HashSet_$ctor_Z6150332D, HashSet } from "./MutableSet.js";
@@ -1337,7 +1337,7 @@ export function SetTreeModule_toList(t) {
1337
1337
  export function SetTreeModule_copyToArray(s, arr, i) {
1338
1338
  let j = i;
1339
1339
  SetTreeModule_iter((x) => {
1340
- arr[j] = x;
1340
+ setItem(arr, j, x);
1341
1341
  j = ((j + 1) | 0);
1342
1342
  }, s);
1343
1343
  }
package/String.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare function trimStart(str: string, ...chars: string[]): any;
38
38
  export declare function trimEnd(str: string, ...chars: string[]): any;
39
39
  export declare function filter(pred: (char: string) => boolean, x: string): string;
40
40
  export declare function substring(str: string, startIndex: number, length?: number): string;
41
+ export declare function toCharArray2(str: string, startIndex: number, length: number): string[];
41
42
  interface FormattableString {
42
43
  strs: TemplateStringsArray;
43
44
  args: any[];
package/String.js CHANGED
@@ -527,6 +527,9 @@ export function substring(str, startIndex, length) {
527
527
  }
528
528
  return length != null ? str.substr(startIndex, length) : str.substr(startIndex);
529
529
  }
530
+ export function toCharArray2(str, startIndex, length) {
531
+ return substring(str, startIndex, length).split("");
532
+ }
530
533
  export function fmt(strs, ...args) {
531
534
  return ({ strs, args });
532
535
  }
@@ -1,7 +1,7 @@
1
1
  import { disposeSafe, defaultOf, toIterator, getEnumerator, structuralHash, equals as equals_1, compare } from "./Util.js";
2
2
  import { class_type } from "./Reflection.js";
3
3
  import { toArray, empty, singleton, append, enumerateWhile, delay } from "./Seq.js";
4
- import { initialize, copyTo, fill } from "./Array.js";
4
+ import { setItem, initialize, copyTo, fill, item as item_1 } from "./Array.js";
5
5
  import { max } from "./Double.js";
6
6
  export class Comparer$1 {
7
7
  constructor(comparison) {
@@ -68,7 +68,7 @@ export class Stack$1 {
68
68
  const _ = this;
69
69
  return getEnumerator(delay(() => {
70
70
  let index = _.count - 1;
71
- return enumerateWhile(() => (index >= 0), delay(() => append(singleton(_.contents[index]), delay(() => {
71
+ return enumerateWhile(() => (index >= 0), delay(() => append(singleton(item_1(index, _.contents)), delay(() => {
72
72
  index = ((index - 1) | 0);
73
73
  return empty();
74
74
  }))));
@@ -111,16 +111,16 @@ export function Stack$1__get_Count(_) {
111
111
  }
112
112
  export function Stack$1__Pop(_) {
113
113
  _.count = ((_.count - 1) | 0);
114
- return _.contents[_.count];
114
+ return item_1(_.count, _.contents);
115
115
  }
116
116
  export function Stack$1__Peek(_) {
117
- return _.contents[_.count - 1];
117
+ return item_1(_.count - 1, _.contents);
118
118
  }
119
119
  export function Stack$1__Contains_2B595(_, x) {
120
120
  let found = false;
121
121
  let i = 0;
122
122
  while ((i < _.count) && !found) {
123
- if (equals_1(x, _.contents[i])) {
123
+ if (equals_1(x, item_1(i, _.contents))) {
124
124
  found = true;
125
125
  }
126
126
  else {
@@ -162,7 +162,7 @@ export function Stack$1__TrimExcess(this$) {
162
162
  }
163
163
  }
164
164
  export function Stack$1__ToArray(_) {
165
- return initialize(_.count, (i) => _.contents[(_.count - 1) - i]);
165
+ return initialize(_.count, (i) => item_1((_.count - 1) - i, _.contents));
166
166
  }
167
167
  export class Queue$1 {
168
168
  constructor(initialContents, initialCount) {
@@ -217,7 +217,7 @@ export function Queue$1__Dequeue(_) {
217
217
  if (_.count === 0) {
218
218
  throw new Error("Queue is empty");
219
219
  }
220
- const value = _.contents[_.head];
220
+ const value = item_1(_.head, _.contents);
221
221
  _.head = (((_.head + 1) % Queue$1__size(_)) | 0);
222
222
  _.count = ((_.count - 1) | 0);
223
223
  return value;
@@ -226,7 +226,7 @@ export function Queue$1__Peek(_) {
226
226
  if (_.count === 0) {
227
227
  throw new Error("Queue is empty");
228
228
  }
229
- return _.contents[_.head];
229
+ return item_1(_.head, _.contents);
230
230
  }
231
231
  export function Queue$1__TryDequeue_1F3DB691(this$, result) {
232
232
  if (this$.count === 0) {
@@ -250,7 +250,7 @@ export function Queue$1__Contains_2B595(_, x) {
250
250
  let found = false;
251
251
  let i = 0;
252
252
  while ((i < _.count) && !found) {
253
- if (equals_1(x, _.contents[Queue$1__toIndex_Z524259A4(_, i)])) {
253
+ if (equals_1(x, item_1(Queue$1__toIndex_Z524259A4(_, i), _.contents))) {
254
254
  found = true;
255
255
  }
256
256
  else {
@@ -279,7 +279,7 @@ export function Queue$1__CopyTo_Z3B4C077E(_, target, start) {
279
279
  try {
280
280
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
281
281
  const item = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
282
- target[i] = item;
282
+ setItem(target, i, item);
283
283
  i = ((i + 1) | 0);
284
284
  }
285
285
  }
@@ -309,7 +309,7 @@ export function Queue$1__ensure_Z524259A4(this$, requiredSize) {
309
309
  export function Queue$1__toSeq(this$) {
310
310
  return delay(() => {
311
311
  let i = 0;
312
- return enumerateWhile(() => (i < this$.count), delay(() => append(singleton(this$.contents[Queue$1__toIndex_Z524259A4(this$, i)]), delay(() => {
312
+ return enumerateWhile(() => (i < this$.count), delay(() => append(singleton(item_1(Queue$1__toIndex_Z524259A4(this$, i), this$.contents)), delay(() => {
313
313
  i = ((i + 1) | 0);
314
314
  return empty();
315
315
  }))));
package/System.Text.d.ts CHANGED
@@ -20,11 +20,19 @@ export declare function StringBuilder__Append_4E60E31B(x: StringBuilder, o: any)
20
20
  export declare function StringBuilder__Append_Z372E4D23(x: StringBuilder, cs: string[]): StringBuilder;
21
21
  export declare function StringBuilder__Append_43A65C09(x: StringBuilder, s: StringBuilder): StringBuilder;
22
22
  export declare function StringBuilder__AppendFormat_433E080(x: StringBuilder, fmt: string, o: any): StringBuilder;
23
+ export declare function StringBuilder__AppendFormat_Z3B30EC65(x: StringBuilder, fmt: string, o1: any, o2: any): StringBuilder;
24
+ export declare function StringBuilder__AppendFormat_10D165E0(x: StringBuilder, fmt: string, o1: any, o2: any, o3: any): StringBuilder;
25
+ export declare function StringBuilder__AppendFormat_Z17053F5(x: StringBuilder, fmt: string, arr: any[]): StringBuilder;
23
26
  export declare function StringBuilder__AppendFormat_Z696D8D1B(x: StringBuilder, provider: any, fmt: string, o: any): StringBuilder;
27
+ export declare function StringBuilder__AppendFormat_26802C9E(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any): StringBuilder;
28
+ export declare function StringBuilder__AppendFormat_Z471ADCBB(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any, o3: any): StringBuilder;
29
+ export declare function StringBuilder__AppendFormat_6C2E3E6E(x: StringBuilder, provider: any, fmt: string, arr: any[]): StringBuilder;
24
30
  export declare function StringBuilder__AppendLine(x: StringBuilder): StringBuilder;
25
31
  export declare function StringBuilder__AppendLine_Z721C83C5(x: StringBuilder, s: string): StringBuilder;
32
+ export declare function StringBuilder__Clear(x: StringBuilder): StringBuilder;
33
+ export declare function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32): string;
34
+ export declare function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32, value: string): void;
26
35
  export declare function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: string, newValue: string): StringBuilder;
27
36
  export declare function StringBuilder__Replace_Z384F8060(x: StringBuilder, oldValue: string, newValue: string): StringBuilder;
28
37
  export declare function StringBuilder__get_Length(x: StringBuilder): int32;
29
38
  export declare function StringBuilder__ToString_Z37302880(x: StringBuilder, firstIndex: int32, length: int32): string;
30
- export declare function StringBuilder__Clear(x: StringBuilder): StringBuilder;