@magnusopera/fscript 0.86.1 → 0.86.3
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/dist/FScript.Language/Ast.js +2 -2
- package/dist/FScript.Language/BuiltinFunctions.js +106 -61
- package/dist/FScript.Language/BuiltinSignatures.js +6 -6
- package/dist/FScript.Language/BuiltinTypes.js +1 -1
- package/dist/FScript.Language/Error.js +2 -2
- package/dist/FScript.Language/Eval.js +52 -60
- package/dist/FScript.Language/Execution.js +6 -6
- package/dist/FScript.Language/ExportSignatures.js +5 -5
- package/dist/FScript.Language/HostInterop.js +8 -8
- package/dist/FScript.Language/IncludeResolver.js +10 -10
- package/dist/FScript.Language/Interactive.js +7 -7
- package/dist/FScript.Language/Lexer.js +19 -11
- package/dist/FScript.Language/Parser.js +16 -16
- package/dist/FScript.Language/Pretty.js +4 -4
- package/dist/FScript.Language/Span.js +2 -2
- package/dist/FScript.Language/TaskFunctions.js +2 -2
- package/dist/FScript.Language/TaskSharingAnalysis.js +207 -197
- package/dist/FScript.Language/Token.js +2 -2
- package/dist/FScript.Language/TypeInfer.js +188 -168
- package/dist/FScript.Language/Types.js +8 -8
- package/dist/FScript.Language/Value.js +2 -2
- package/dist/Library.js +13 -13
- package/dist/fable_modules/fable-library-js.5.24.0/Async.js +363 -0
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/AsyncBuilder.js +70 -10
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/CHANGELOG.md +90 -1
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/CollectionUtil.js +10 -16
- package/dist/fable_modules/fable-library-js.5.24.0/DateOnlyTemporal.js +146 -0
- package/dist/fable_modules/fable-library-js.5.24.0/DateTimeFormat.js +523 -0
- package/dist/fable_modules/fable-library-js.5.24.0/DateTimeOffsetTemporal.js +283 -0
- package/dist/fable_modules/fable-library-js.5.24.0/DateTimeTemporal.js +243 -0
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Decimal.js +100 -11
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Encoding.js +23 -16
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Guid.js +3 -1
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/MailboxProcessor.js +23 -3
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/MutableMap.js +5 -1
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/MutableSet.js +5 -1
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Numeric.js +38 -1
- package/dist/fable_modules/fable-library-js.5.24.0/Stopwatch.js +65 -0
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/String.js +43 -9
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/System.Text.js +9 -9
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Task.js +22 -0
- package/dist/fable_modules/fable-library-js.5.24.0/TimeOnlyTemporal.js +142 -0
- package/dist/fable_modules/fable-library-js.5.24.0/TimeSpanTemporal.js +259 -0
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Util.js +15 -3
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/big.d.ts +1 -0
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/lib/big.js +111 -64
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/package.json +1 -1
- package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/quotation.js +47 -0
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
- package/dist/fable_modules/fable-library-js.5.13.0/Async.js +0 -163
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Array.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/BigInt.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/BitConverter.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Boolean.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Char.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Choice.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/ConditionalWeakTable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Date.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/DateOffset.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/DateOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Directory.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Double.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Environment.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Event.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/FSharp.Collections.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/FSharp.Core.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/File.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Global.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Int32.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/List.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Long.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Map.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/MapUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Native.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Observable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Option.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Path.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Random.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Range.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Reflection.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/RegExp.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Result.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Seq.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Seq2.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Set.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/System.Collections.Generic.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/System.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/TaskBuilder.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/TimeOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/TimeSpan.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Types.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/Uri.js +0 -0
package/dist/fable_modules/{fable-library-js.5.13.0 → fable-library-js.5.24.0}/CollectionUtil.js
RENAMED
|
@@ -161,22 +161,16 @@ export function clear(col) {
|
|
|
161
161
|
if (typeof col["System.Collections.Generic.ICollection`1.Clear"] === "function") {
|
|
162
162
|
return col["System.Collections.Generic.ICollection`1.Clear"](); // collection
|
|
163
163
|
}
|
|
164
|
+
else if (Array.isArray(col)) {
|
|
165
|
+
col.length = 0;
|
|
166
|
+
}
|
|
167
|
+
else if (ArrayBuffer.isView(col)) {
|
|
168
|
+
// TODO: throw for typed arrays?
|
|
169
|
+
}
|
|
170
|
+
else if (typeof col.clear === "function") {
|
|
171
|
+
col.clear(); // map, set
|
|
172
|
+
}
|
|
164
173
|
else {
|
|
165
|
-
|
|
166
|
-
if (ArrayBuffer.isView(col)) {
|
|
167
|
-
// TODO: throw for typed arrays?
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
col.splice(0); // array, resize array
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
if (typeof col.clear === "function") {
|
|
175
|
-
col.clear(); // map, set
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
// TODO: throw for other collections?
|
|
179
|
-
}
|
|
180
|
-
}
|
|
174
|
+
// TODO: throw for other collections?
|
|
181
175
|
}
|
|
182
176
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { dateTime as DateTime_stamp } from "./DateTimeTemporal.js";
|
|
2
|
+
import { fromDate as DateTimeOffset_fromDate } from "./DateTimeOffsetTemporal.js";
|
|
3
|
+
import { Exception, DateTimeKind, padWithZeros } from "./Util.js";
|
|
4
|
+
export const PlainDate = Temporal.PlainDate;
|
|
5
|
+
// The generic equality/comparison/hashing helpers in Util.ts dispatch at runtime
|
|
6
|
+
// on .NET-style Equals/CompareTo/GetHashCode methods (with a special case for JS
|
|
7
|
+
// Date, which Temporal.PlainDate cannot benefit from). Attach them so DateOnly
|
|
8
|
+
// also works in generic contexts: records, tuples, erased generics, etc.
|
|
9
|
+
const proto = Temporal.PlainDate.prototype;
|
|
10
|
+
proto.Equals = function (other) { return this.equals(other); };
|
|
11
|
+
proto.CompareTo = function (other) { return Temporal.PlainDate.compare(this, other); };
|
|
12
|
+
proto.GetHashCode = function () { return dayNumber(this); };
|
|
13
|
+
// Lets String.Format format this value without String.ts importing this module (see String.ts)
|
|
14
|
+
proto[Symbol.for("Fable.DateTimeFormattable")] = function (format) { return toString(this, format); };
|
|
15
|
+
export function create(year, month, day) {
|
|
16
|
+
return new Temporal.PlainDate(year, month, day);
|
|
17
|
+
}
|
|
18
|
+
export function maxValue() {
|
|
19
|
+
return new Temporal.PlainDate(9999, 12, 31);
|
|
20
|
+
}
|
|
21
|
+
export function minValue() {
|
|
22
|
+
return new Temporal.PlainDate(1, 1, 1);
|
|
23
|
+
}
|
|
24
|
+
export function dayNumber(d) {
|
|
25
|
+
return minValue().until(d).days;
|
|
26
|
+
}
|
|
27
|
+
export function fromDayNumber(dayNumber) {
|
|
28
|
+
return minValue().add({ days: dayNumber });
|
|
29
|
+
}
|
|
30
|
+
export function fromDateTime(d) {
|
|
31
|
+
// Under the Temporal representation a DateTime is a PlainDateTime (kind-agnostic wall-clock)
|
|
32
|
+
return new Temporal.PlainDate(d.year, d.month, d.day);
|
|
33
|
+
}
|
|
34
|
+
export function dayOfWeek(d) {
|
|
35
|
+
// Temporal: Monday = 1 ... Sunday = 7, .NET: Sunday = 0 ... Saturday = 6
|
|
36
|
+
return d.dayOfWeek % 7;
|
|
37
|
+
}
|
|
38
|
+
export function toDateTime(d, time, kind = DateTimeKind.Unspecified) {
|
|
39
|
+
return DateTime_stamp(d.toPlainDateTime(time), kind);
|
|
40
|
+
}
|
|
41
|
+
export function toDateTimeOffset(d, time, offset) {
|
|
42
|
+
return DateTimeOffset_fromDate(DateTime_stamp(d.toPlainDateTime(time), DateTimeKind.Unspecified), offset);
|
|
43
|
+
}
|
|
44
|
+
export function addDays(d, v) {
|
|
45
|
+
return d.add({ days: v });
|
|
46
|
+
}
|
|
47
|
+
export function addMonths(d, v) {
|
|
48
|
+
return d.add({ months: v });
|
|
49
|
+
}
|
|
50
|
+
export function addYears(d, v) {
|
|
51
|
+
return d.add({ years: v });
|
|
52
|
+
}
|
|
53
|
+
export function equals(x, y) {
|
|
54
|
+
return x.equals(y);
|
|
55
|
+
}
|
|
56
|
+
export function compare(x, y) {
|
|
57
|
+
return Temporal.PlainDate.compare(x, y);
|
|
58
|
+
}
|
|
59
|
+
export function hash(d) {
|
|
60
|
+
return dayNumber(d);
|
|
61
|
+
}
|
|
62
|
+
export function toString(d, format = "d", _provider) {
|
|
63
|
+
switch (format) {
|
|
64
|
+
case "d":
|
|
65
|
+
return `${padWithZeros(d.month, 2)}/${padWithZeros(d.day, 2)}/${padWithZeros(d.year, 4)}`;
|
|
66
|
+
case "o":
|
|
67
|
+
case "O":
|
|
68
|
+
// PlainDate.toString() is the ISO yyyy-MM-dd round-trip format
|
|
69
|
+
return d.toString();
|
|
70
|
+
default:
|
|
71
|
+
throw new Exception("Custom formats are not supported");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function parse(str) {
|
|
75
|
+
function fail() {
|
|
76
|
+
throw new Exception(`String '${str}' was not recognized as a valid DateOnly.`);
|
|
77
|
+
}
|
|
78
|
+
// Allowed separators: . , / -
|
|
79
|
+
// TODO whitespace alone as the separator
|
|
80
|
+
//
|
|
81
|
+
// Whitespace around separators
|
|
82
|
+
//
|
|
83
|
+
// Allowed format types:
|
|
84
|
+
// yyyy/mm/dd
|
|
85
|
+
// mm/dd/yyyy
|
|
86
|
+
// mm/dd
|
|
87
|
+
// mm/yyyy
|
|
88
|
+
// yyyy/mm
|
|
89
|
+
const r = /^\s*(\d{1,4})(?:\s*[.,-\/]\s*(\d{1,2}))?\s*[.,-\/]\s*(\d{1,4})\s*$/.exec(str);
|
|
90
|
+
if (r != null) {
|
|
91
|
+
let y = 0;
|
|
92
|
+
let m = 0;
|
|
93
|
+
let d = 1;
|
|
94
|
+
if (r[2] == null) {
|
|
95
|
+
if (r[1].length < 3) {
|
|
96
|
+
if (r[3].length < 3) {
|
|
97
|
+
// 12/30 = December 30, {CurrentYear}
|
|
98
|
+
y = Temporal.Now.plainDateISO().year;
|
|
99
|
+
m = +r[1];
|
|
100
|
+
d = +r[3];
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// 12/2000 = December 1, 2000
|
|
104
|
+
m = +r[1];
|
|
105
|
+
y = +r[3];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
if (r[3].length > 2)
|
|
110
|
+
fail();
|
|
111
|
+
// 2000/12 = December 1, 2000
|
|
112
|
+
y = +r[1];
|
|
113
|
+
m = +r[3];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// 2000/1/30 or 1/30/2000
|
|
118
|
+
const yearFirst = r[1].length > 2;
|
|
119
|
+
const yTmp = r[yearFirst ? 1 : 3];
|
|
120
|
+
y = +yTmp;
|
|
121
|
+
// year 0-29 is 2000-2029, 30-99 is 1930-1999
|
|
122
|
+
if (yTmp.length < 3)
|
|
123
|
+
y += y >= 30 ? 1900 : 2000;
|
|
124
|
+
m = +r[yearFirst ? 2 : 1];
|
|
125
|
+
d = +r[yearFirst ? 3 : 2];
|
|
126
|
+
}
|
|
127
|
+
if (y > 0) {
|
|
128
|
+
try {
|
|
129
|
+
return new Temporal.PlainDate(y, m, d);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return fail();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return fail();
|
|
137
|
+
}
|
|
138
|
+
export function tryParse(v, defValue) {
|
|
139
|
+
try {
|
|
140
|
+
defValue.contents = parse(v);
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|