@glutinum/cli 0.13.0 → 0.14.1
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/README.md +19 -1
- package/dist/Glutinum.Converter/Abbreviations.js +246 -0
- package/dist/Glutinum.Converter/FsharpAST.js +87 -28
- package/dist/Glutinum.Converter/Generate.js +55 -8
- package/dist/Glutinum.Converter/GlueAST.js +333 -34
- package/dist/Glutinum.Converter/Log.js +7 -8
- package/dist/Glutinum.Converter/Merge.js +683 -31
- package/dist/Glutinum.Converter/Packages.js +308 -0
- package/dist/Glutinum.Converter/Printer.js +323 -186
- package/dist/Glutinum.Converter/Read.js +279 -6
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +13 -7
- package/dist/Glutinum.Converter/Reader/Declaration.js +102 -17
- package/dist/Glutinum.Converter/Reader/Documentation.js +168 -73
- package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +7 -51
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +64 -15
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +165 -0
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +30 -5
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +122 -4
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +83 -7
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +8 -8
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +11 -9
- package/dist/Glutinum.Converter/Reader/NamedTupleMember.js +3 -2
- package/dist/Glutinum.Converter/Reader/Node.js +24 -10
- package/dist/Glutinum.Converter/Reader/Parameters.js +110 -7
- package/dist/Glutinum.Converter/Reader/Report.js +31 -12
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +4 -3
- package/dist/Glutinum.Converter/Reader/TypeNode.js +1524 -253
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +75 -20
- package/dist/Glutinum.Converter/Reader/TypeParameters.js +8 -5
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +184 -50
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +32 -13
- package/dist/Glutinum.Converter/Reader/Types.js +180 -0
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +99 -43
- package/dist/Glutinum.Converter/Reader/Utils.js +1143 -55
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +59 -14
- package/dist/Glutinum.Converter/Transform.js +8292 -1119
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +3 -3
- package/dist/Glutinum.Converter/TypeScript.js +3 -3
- package/dist/Glutinum.Converter/Utils/Keywords.js +6 -6
- package/dist/Glutinum.Converter/Utils/List.js +3 -3
- package/dist/Glutinum.Converter/Utils/Naming.js +61 -12
- package/dist/Glutinum.Converter/Utils/String.js +7 -3
- package/dist/Program.js +230 -72
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
- package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/AsyncIterable.fs.js +29 -29
- package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
- package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/Promise.fs +842 -766
- package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/Promise.fs.js +26 -12
- package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/PromiseImpl.fs +31 -31
- package/dist/fable_modules/{Fable.Promise.3.2.0 → Fable.Promise.3.2.1}/PromiseImpl.fs.js +5 -5
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AssemblyInfo.fs +4 -4
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Async.fs +89 -9
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Async.fs.js +13 -12
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOption.fs +50 -4
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOptionCE.fs +30 -39
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOptionCE.fs.js +10 -10
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResult.fs +52 -8
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultCE.fs +26 -42
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultCE.fs.js +3 -3
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOption.fs +17 -5
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOptionCE.fs +31 -33
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOptionCE.fs.js +3 -3
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidation.fs +1 -6
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidationCE.fs +10 -18
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidationCE.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/List.fs +68 -10
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/List.fs.js +47 -41
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Option.fs +133 -2
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/OptionOp.fs +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Result.fs +87 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Result.fs.js +8 -8
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultCE.fs +8 -23
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultCE.fs.js +5 -5
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOption.fs +1 -1
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOption.fs.js +10 -10
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOptionCE.fs +7 -18
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOptionCE.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/Validation.fs +0 -5
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValidationCE.fs +7 -13
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValidationCE.fs.js +3 -3
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValueOption.fs +1 -4
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.1 → FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0}/FsToolkit.ErrorHandling.AssemblyInfo.fs +4 -4
- package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +4 -4
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Array.js +192 -86
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Async.js +58 -53
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/AsyncBuilder.js +29 -8
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/BigInt.js +71 -46
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/BitConverter.js +2 -2
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Boolean.js +4 -3
- package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Char.js +64 -31
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Choice.js +2 -2
- package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
- package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Date.js +197 -112
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/DateOffset.js +46 -62
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/DateOnly.js +6 -6
- package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Decimal.js +39 -13
- package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Double.js +10 -3
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Encoding.js +20 -8
- package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Event.js +10 -1
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
- package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Guid.js +33 -12
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Int32.js +17 -17
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/List.js +170 -106
- package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MailboxProcessor.js +13 -6
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Map.js +65 -61
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MapUtil.js +22 -4
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MutableMap.js +28 -16
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/MutableSet.js +7 -7
- package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Numeric.js +44 -3
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Observable.js +5 -3
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Option.js +11 -20
- package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Random.js +22 -20
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Range.js +12 -12
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Reflection.js +50 -22
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/RegExp.js +68 -30
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Result.js +6 -6
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Seq.js +229 -104
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Seq2.js +1 -1
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Set.js +153 -113
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/String.js +238 -50
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/System.Collections.Generic.js +30 -14
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/System.Text.js +69 -31
- package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/TimeOnly.js +6 -6
- package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/TimeSpan.js +18 -15
- package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Types.js +14 -24
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Uri.js +44 -21
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Util.js +49 -12
- package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/lib/big.js +14 -11
- package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
- package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
- package/package.json +4 -4
- package/src/Glutinum.Converter/js/bootstrap.js +109 -2
- package/src/Glutinum.Converter/js/host.js +144 -0
- package/src/Glutinum.Converter/js/npm.js +137 -0
- package/src/Glutinum.Converter/js/resolve.js +402 -0
- package/dist/Glutinum.Converter/FsharpAST.js.map +0 -1
- package/dist/Glutinum.Converter/Generate.js.map +0 -1
- package/dist/Glutinum.Converter/GlueAST.js.map +0 -1
- package/dist/Glutinum.Converter/Log.js.map +0 -1
- package/dist/Glutinum.Converter/Merge.js.map +0 -1
- package/dist/Glutinum.Converter/Printer.js.map +0 -1
- package/dist/Glutinum.Converter/Read.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/Declaration.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/Documentation.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/EnumDeclaration.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/NamedTupleMember.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/Node.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/Parameters.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/Report.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/TypeNode.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/TypeParameters.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/Utils.js.map +0 -1
- package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +0 -1
- package/dist/Glutinum.Converter/Transform.js.map +0 -1
- package/dist/Glutinum.Converter/TypeScript.Extensions.js.map +0 -1
- package/dist/Glutinum.Converter/TypeScript.js.map +0 -1
- package/dist/Glutinum.Converter/Utils/Keywords.js.map +0 -1
- package/dist/Glutinum.Converter/Utils/List.js.map +0 -1
- package/dist/Glutinum.Converter/Utils/Naming.js.map +0 -1
- package/dist/Glutinum.Converter/Utils/String.js.map +0 -1
- package/dist/Program.js.map +0 -1
- package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs +0 -57
- package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs.js.map +0 -1
- package/dist/fable_modules/Fable.Promise.3.2.0/Fable.Promise.fableproj +0 -20
- package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs.js.map +0 -1
- package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js +0 -26
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/FsToolkit.ErrorHandling.fableproj +0 -51
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs +0 -186
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js +0 -18
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs +0 -19
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js +0 -31
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs +0 -22
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js +0 -18
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs.js.map +0 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValueOptionCE.fs +0 -165
- package/dist/fable_modules/fable-library-js.4.14.0/Array.d.ts +0 -123
- package/dist/fable_modules/fable-library-js.4.14.0/Async.d.ts +0 -32
- package/dist/fable_modules/fable-library-js.4.14.0/AsyncBuilder.d.ts +0 -59
- package/dist/fable_modules/fable-library-js.4.14.0/BigInt.d.ts +0 -115
- package/dist/fable_modules/fable-library-js.4.14.0/BitConverter.d.ts +0 -27
- package/dist/fable_modules/fable-library-js.4.14.0/Boolean.d.ts +0 -3
- package/dist/fable_modules/fable-library-js.4.14.0/CHANGELOG.md +0 -37
- package/dist/fable_modules/fable-library-js.4.14.0/Char.d.ts +0 -65
- package/dist/fable_modules/fable-library-js.4.14.0/Choice.d.ts +0 -121
- package/dist/fable_modules/fable-library-js.4.14.0/Date.d.ts +0 -70
- package/dist/fable_modules/fable-library-js.4.14.0/DateOffset.d.ts +0 -63
- package/dist/fable_modules/fable-library-js.4.14.0/DateOnly.d.ts +0 -18
- package/dist/fable_modules/fable-library-js.4.14.0/Decimal.d.ts +0 -45
- package/dist/fable_modules/fable-library-js.4.14.0/Double.d.ts +0 -11
- package/dist/fable_modules/fable-library-js.4.14.0/Encoding.d.ts +0 -12
- package/dist/fable_modules/fable-library-js.4.14.0/Event.d.ts +0 -31
- package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.d.ts +0 -7
- package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.js +0 -27
- package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.CompilerServices.d.ts +0 -12
- package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.d.ts +0 -17
- package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.js +0 -69
- package/dist/fable_modules/fable-library-js.4.14.0/Global.d.ts +0 -24
- package/dist/fable_modules/fable-library-js.4.14.0/Global.js +0 -8
- package/dist/fable_modules/fable-library-js.4.14.0/Guid.d.ts +0 -10
- package/dist/fable_modules/fable-library-js.4.14.0/Int32.d.ts +0 -28
- package/dist/fable_modules/fable-library-js.4.14.0/List.d.ts +0 -143
- package/dist/fable_modules/fable-library-js.4.14.0/Long.d.ts +0 -3
- package/dist/fable_modules/fable-library-js.4.14.0/Long.js +0 -46
- package/dist/fable_modules/fable-library-js.4.14.0/MailboxProcessor.d.ts +0 -25
- package/dist/fable_modules/fable-library-js.4.14.0/Map.d.ts +0 -178
- package/dist/fable_modules/fable-library-js.4.14.0/MapUtil.d.ts +0 -10
- package/dist/fable_modules/fable-library-js.4.14.0/MutableMap.d.ts +0 -52
- package/dist/fable_modules/fable-library-js.4.14.0/MutableSet.d.ts +0 -39
- package/dist/fable_modules/fable-library-js.4.14.0/Native.d.ts +0 -2
- package/dist/fable_modules/fable-library-js.4.14.0/Native.js +0 -8
- package/dist/fable_modules/fable-library-js.4.14.0/Numeric.d.ts +0 -19
- package/dist/fable_modules/fable-library-js.4.14.0/Observable.d.ts +0 -32
- package/dist/fable_modules/fable-library-js.4.14.0/Option.d.ts +0 -28
- package/dist/fable_modules/fable-library-js.4.14.0/Random.d.ts +0 -37
- package/dist/fable_modules/fable-library-js.4.14.0/Range.d.ts +0 -12
- package/dist/fable_modules/fable-library-js.4.14.0/Reflection.d.ts +0 -119
- package/dist/fable_modules/fable-library-js.4.14.0/RegExp.d.ts +0 -10
- package/dist/fable_modules/fable-library-js.4.14.0/Result.d.ts +0 -37
- package/dist/fable_modules/fable-library-js.4.14.0/Seq.d.ts +0 -165
- package/dist/fable_modules/fable-library-js.4.14.0/Seq2.d.ts +0 -18
- package/dist/fable_modules/fable-library-js.4.14.0/Set.d.ts +0 -190
- package/dist/fable_modules/fable-library-js.4.14.0/String.d.ts +0 -50
- package/dist/fable_modules/fable-library-js.4.14.0/System.Collections.Generic.d.ts +0 -79
- package/dist/fable_modules/fable-library-js.4.14.0/System.Text.d.ts +0 -38
- package/dist/fable_modules/fable-library-js.4.14.0/SystemException.d.ts +0 -5
- package/dist/fable_modules/fable-library-js.4.14.0/SystemException.js +0 -5
- package/dist/fable_modules/fable-library-js.4.14.0/TimeOnly.d.ts +0 -15
- package/dist/fable_modules/fable-library-js.4.14.0/TimeSpan.d.ts +0 -34
- package/dist/fable_modules/fable-library-js.4.14.0/Timer.d.ts +0 -19
- package/dist/fable_modules/fable-library-js.4.14.0/Types.d.ts +0 -58
- package/dist/fable_modules/fable-library-js.4.14.0/Unicode.13.0.0.d.ts +0 -2
- package/dist/fable_modules/fable-library-js.4.14.0/Uri.d.ts +0 -29
- package/dist/fable_modules/fable-library-js.4.14.0/Util.d.ts +0 -207
- package/dist/fable_modules/fable-library-js.4.14.0/lib/big.d.ts +0 -5
- package/dist/fable_modules/fable-library-js.4.14.0/package.json +0 -24
- package/dist/fable_modules/project_cracked.json +0 -1
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncOptionOp.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOp.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncResultOptionOp.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/AsyncValidationOp.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOp.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ResultOptionOp.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/ValidationOp.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +0 -0
- /package/dist/fable_modules/{FsToolkit.ErrorHandling.4.16.0 → FsToolkit.ErrorHandling.5.2.0}/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +0 -0
- /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.4.14.0 → fable-library-js.5.17.2}/big.d.ts +0 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DateTimeOffset as an offset-only Temporal.ZonedDateTime.
|
|
3
|
+
*
|
|
4
|
+
* .NET DateTimeOffset is a wall-clock date+time plus an explicit UTC offset (a
|
|
5
|
+
* TimeSpan of whole minutes). A ZonedDateTime whose time zone is a fixed offset
|
|
6
|
+
* (e.g. "-08:00") carries the wall-clock, the offset, and the absolute instant
|
|
7
|
+
* natively — so there is no extra metadata to stamp and no re-stamping after
|
|
8
|
+
* operations (arithmetic returns a ZonedDateTime that keeps the offset).
|
|
9
|
+
*
|
|
10
|
+
* The offset is exchanged with the rest of the runtime as a TimeSpan (Temporal
|
|
11
|
+
* .Duration), matching how .NET types it. Equality/comparison are by instant
|
|
12
|
+
* (offset-independent), matching .NET '=='; EqualsExact also compares the offset.
|
|
13
|
+
*
|
|
14
|
+
* Formatting and parsing run on the Temporal value's own fields (see
|
|
15
|
+
* DateTimeFormat.ts) rather than through a JS Date, which would truncate every
|
|
16
|
+
* value to milliseconds.
|
|
17
|
+
*/
|
|
18
|
+
import { fromFloat64 } from "./BigInt.js";
|
|
19
|
+
import { Exception, DateTimeKind, padWithZeros } from "./Util.js";
|
|
20
|
+
import { fromTicks as TimeSpan_fromTicks, fromUnits as TimeSpan_fromUnits, totalNanoseconds as TimeSpan_totalNanoseconds, } from "./TimeSpanTemporal.js";
|
|
21
|
+
import { dateTime, create as createDateTime, getTicks as DateTime_getTicks } from "./DateTimeTemporal.js";
|
|
22
|
+
import * as Format from "./DateTimeFormat.js";
|
|
23
|
+
export const ZonedDateTime = Temporal.ZonedDateTime;
|
|
24
|
+
// Generic equality/comparison/hashing dispatch (Util.ts) uses .NET-style methods.
|
|
25
|
+
const proto = Temporal.ZonedDateTime.prototype;
|
|
26
|
+
proto.Equals = function (other) { return equals(this, other); };
|
|
27
|
+
proto.CompareTo = function (other) { return compare(this, other); };
|
|
28
|
+
proto.GetHashCode = function () { return hash(this); };
|
|
29
|
+
// Lets String.Format format this value without String.ts importing this module (see String.ts)
|
|
30
|
+
proto[Symbol.for("Fable.DateTimeFormattable")] = function (format) { return toString(this, format); };
|
|
31
|
+
const nsPerMinute = 60000000000n;
|
|
32
|
+
// Nanoseconds between the Unix epoch (1970-01-01) and DateTime.MinValue (0001-01-01)
|
|
33
|
+
const epochToMinValueNs = 62135596800000n * 1000000n;
|
|
34
|
+
function hostTimeZone() {
|
|
35
|
+
return Temporal.Now.timeZoneId();
|
|
36
|
+
}
|
|
37
|
+
// .NET DateTimeOffset has 100ns (tick) precision; Temporal instants are
|
|
38
|
+
// nanosecond-precise. Floors, so the tick count from year 1 is floored too.
|
|
39
|
+
function truncateToTicks(epochNs) {
|
|
40
|
+
const remainder = epochNs % 100n;
|
|
41
|
+
return remainder >= 0n ? epochNs - remainder : epochNs - remainder - 100n;
|
|
42
|
+
}
|
|
43
|
+
function checkOffsetInRange(offsetNs) {
|
|
44
|
+
if (offsetNs % nsPerMinute !== 0n) {
|
|
45
|
+
throw new Exception("Offset must be specified in whole minutes.");
|
|
46
|
+
}
|
|
47
|
+
if (offsetNs > 14n * 60n * nsPerMinute || offsetNs < -14n * 60n * nsPerMinute) {
|
|
48
|
+
throw new Exception("Offset must be within plus or minus 14 hours.");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function offsetNanosecondsToZoneString(offsetNs) {
|
|
52
|
+
const sign = offsetNs < 0n ? "-" : "+";
|
|
53
|
+
const abs = offsetNs < 0n ? -offsetNs : offsetNs;
|
|
54
|
+
const totalMinutes = Number(abs / nsPerMinute);
|
|
55
|
+
return `${sign}${padWithZeros(Math.trunc(totalMinutes / 60), 2)}:${padWithZeros(totalMinutes % 60, 2)}`;
|
|
56
|
+
}
|
|
57
|
+
function offsetToNanoseconds(offset) {
|
|
58
|
+
return TimeSpan_totalNanoseconds(offset);
|
|
59
|
+
}
|
|
60
|
+
function fromEpoch(epochNs, offsetNs = 0n) {
|
|
61
|
+
if (offsetNs === 0n)
|
|
62
|
+
return new Temporal.ZonedDateTime(epochNs, "UTC");
|
|
63
|
+
checkOffsetInRange(offsetNs);
|
|
64
|
+
return new Temporal.ZonedDateTime(epochNs, offsetNanosecondsToZoneString(offsetNs));
|
|
65
|
+
}
|
|
66
|
+
export function offset(d) {
|
|
67
|
+
return TimeSpan_fromTicks(BigInt(d.offsetNanoseconds) / 100n);
|
|
68
|
+
}
|
|
69
|
+
export function create(year, month, day, h, m, s, ms, offset) {
|
|
70
|
+
// Overload without milliseconds: the 7th argument is the offset
|
|
71
|
+
if (offset == null) {
|
|
72
|
+
offset = ms;
|
|
73
|
+
ms = 0;
|
|
74
|
+
}
|
|
75
|
+
const offsetNs = offsetToNanoseconds(offset);
|
|
76
|
+
checkOffsetInRange(offsetNs);
|
|
77
|
+
return Temporal.ZonedDateTime.from({
|
|
78
|
+
year, month, day, hour: h, minute: m, second: s, millisecond: ms,
|
|
79
|
+
timeZone: offsetNanosecondsToZoneString(offsetNs),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// Offset (ns) of the host time zone for a given wall-clock, DST-aware. Resolved
|
|
83
|
+
// through Temporal rather than `new Date(year, ...)`, which maps years 0-99 into
|
|
84
|
+
// 1900-1999 and would pick that era's rules.
|
|
85
|
+
function hostOffsetNanoseconds(d) {
|
|
86
|
+
return BigInt(d.toZonedDateTime(hostTimeZone()).offsetNanoseconds);
|
|
87
|
+
}
|
|
88
|
+
export function fromDate(date, offset) {
|
|
89
|
+
const kind = date.kind ?? DateTimeKind.Unspecified;
|
|
90
|
+
let offsetNs;
|
|
91
|
+
switch (kind) {
|
|
92
|
+
case DateTimeKind.Utc:
|
|
93
|
+
if (offset != null && offsetToNanoseconds(offset) !== 0n) {
|
|
94
|
+
throw new Exception("The UTC Offset for Utc DateTime instances must be 0.");
|
|
95
|
+
}
|
|
96
|
+
offsetNs = 0n;
|
|
97
|
+
break;
|
|
98
|
+
case DateTimeKind.Local:
|
|
99
|
+
offsetNs = hostOffsetNanoseconds(date);
|
|
100
|
+
if (offset != null && offsetToNanoseconds(offset) !== offsetNs) {
|
|
101
|
+
throw new Exception("The UTC Offset of the local dateTime parameter does not match the offset argument.");
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
offsetNs = offset != null ? offsetToNanoseconds(offset) : hostOffsetNanoseconds(date);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
checkOffsetInRange(offsetNs);
|
|
109
|
+
return Temporal.ZonedDateTime.from({
|
|
110
|
+
year: date.year, month: date.month, day: date.day,
|
|
111
|
+
hour: date.hour, minute: date.minute, second: date.second,
|
|
112
|
+
millisecond: date.millisecond, microsecond: date.microsecond, nanosecond: date.nanosecond,
|
|
113
|
+
timeZone: offsetNanosecondsToZoneString(offsetNs),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export function fromTicks(ticks, offset) {
|
|
117
|
+
const offsetNs = offsetToNanoseconds(offset);
|
|
118
|
+
// ticks are the local wall-clock ticks; the instant is that minus the offset
|
|
119
|
+
const localNs = BigInt(ticks) * 100n - epochToMinValueNs;
|
|
120
|
+
return fromEpoch(localNs - offsetNs, offsetNs);
|
|
121
|
+
}
|
|
122
|
+
export function fromUnixTimeMilliseconds(ms) {
|
|
123
|
+
return fromEpoch(BigInt(ms) * 1000000n);
|
|
124
|
+
}
|
|
125
|
+
export function fromUnixTimeSeconds(seconds) {
|
|
126
|
+
return fromEpoch(BigInt(seconds) * 1000000000n);
|
|
127
|
+
}
|
|
128
|
+
export function minValue() {
|
|
129
|
+
return fromEpoch(-epochToMinValueNs);
|
|
130
|
+
}
|
|
131
|
+
export function maxValue() {
|
|
132
|
+
// 9999-12-31T23:59:59.9999999 UTC
|
|
133
|
+
return fromEpoch(253402300799999999900n, 0n);
|
|
134
|
+
}
|
|
135
|
+
export function dayOfWeek(d) {
|
|
136
|
+
return d.dayOfWeek % 7;
|
|
137
|
+
}
|
|
138
|
+
export function timeOfDay(d) {
|
|
139
|
+
// Elapsed since midnight (local wall-clock). DateTimeOffset values are tick-aligned, so this is too.
|
|
140
|
+
return d.startOfDay().until(d);
|
|
141
|
+
}
|
|
142
|
+
export function date(d) {
|
|
143
|
+
return createDateTime(d.year, d.month, d.day, 0, 0, 0, 0, DateTimeKind.Unspecified);
|
|
144
|
+
}
|
|
145
|
+
export function dateTimeProp(d) {
|
|
146
|
+
return dateTime(d.toPlainDateTime(), DateTimeKind.Unspecified);
|
|
147
|
+
}
|
|
148
|
+
export function toUniversalTime(d) {
|
|
149
|
+
return fromEpoch(d.epochNanoseconds);
|
|
150
|
+
}
|
|
151
|
+
export function toLocalTime(d) {
|
|
152
|
+
const local = d.withTimeZone(hostTimeZone());
|
|
153
|
+
return fromEpoch(local.epochNanoseconds, BigInt(local.offsetNanoseconds));
|
|
154
|
+
}
|
|
155
|
+
export function utcDateTime(d) {
|
|
156
|
+
return dateTime(d.withTimeZone("UTC").toPlainDateTime(), DateTimeKind.Utc);
|
|
157
|
+
}
|
|
158
|
+
export function localDateTime(d) {
|
|
159
|
+
return dateTime(d.withTimeZone(hostTimeZone()).toPlainDateTime(), DateTimeKind.Local);
|
|
160
|
+
}
|
|
161
|
+
export function add(d, ts) {
|
|
162
|
+
return d.add(ts);
|
|
163
|
+
}
|
|
164
|
+
export function addYears(d, v) {
|
|
165
|
+
return d.add({ years: v });
|
|
166
|
+
}
|
|
167
|
+
export function addMonths(d, v) {
|
|
168
|
+
return d.add({ months: v });
|
|
169
|
+
}
|
|
170
|
+
export function addDays(d, v) {
|
|
171
|
+
return d.add(TimeSpan_fromUnits(v, "days"));
|
|
172
|
+
}
|
|
173
|
+
export function addHours(d, v) {
|
|
174
|
+
return d.add(TimeSpan_fromUnits(v, "hours"));
|
|
175
|
+
}
|
|
176
|
+
export function addMinutes(d, v) {
|
|
177
|
+
return d.add(TimeSpan_fromUnits(v, "minutes"));
|
|
178
|
+
}
|
|
179
|
+
export function addSeconds(d, v) {
|
|
180
|
+
return d.add(TimeSpan_fromUnits(v, "seconds"));
|
|
181
|
+
}
|
|
182
|
+
export function addMilliseconds(d, v) {
|
|
183
|
+
return d.add(TimeSpan_fromUnits(v, "milliseconds"));
|
|
184
|
+
}
|
|
185
|
+
export function addTicks(d, v) {
|
|
186
|
+
return d.add(TimeSpan_fromTicks(v));
|
|
187
|
+
}
|
|
188
|
+
// Split rather than returning a union — see the note in DateTimeTemporal.ts.
|
|
189
|
+
export function subtractDate(d, that) {
|
|
190
|
+
return TimeSpan_fromTicks((d.epochNanoseconds - that.epochNanoseconds) / 100n); // instant difference
|
|
191
|
+
}
|
|
192
|
+
export function subtractTimeSpan(d, ts) {
|
|
193
|
+
return d.subtract(ts);
|
|
194
|
+
}
|
|
195
|
+
export function equals(d1, d2) {
|
|
196
|
+
return d1.epochNanoseconds === d2.epochNanoseconds;
|
|
197
|
+
}
|
|
198
|
+
export function equalsExact(d1, d2) {
|
|
199
|
+
return d1.epochNanoseconds === d2.epochNanoseconds && d1.offsetNanoseconds === d2.offsetNanoseconds;
|
|
200
|
+
}
|
|
201
|
+
export function compare(d1, d2) {
|
|
202
|
+
const a = d1.epochNanoseconds, b = d2.epochNanoseconds;
|
|
203
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
204
|
+
}
|
|
205
|
+
export const compareTo = compare;
|
|
206
|
+
export function op_Addition(x, y) {
|
|
207
|
+
return add(x, y);
|
|
208
|
+
}
|
|
209
|
+
export function hash(d) {
|
|
210
|
+
return Number(d.epochNanoseconds % 2147483647n);
|
|
211
|
+
}
|
|
212
|
+
export function toOffset(d, offset) {
|
|
213
|
+
return fromEpoch(d.epochNanoseconds, offsetToNanoseconds(offset));
|
|
214
|
+
}
|
|
215
|
+
export function getUtcTicks(d) {
|
|
216
|
+
return DateTime_getTicks(utcDateTime(d));
|
|
217
|
+
}
|
|
218
|
+
export function getTicks(d) {
|
|
219
|
+
return DateTime_getTicks(dateTimeProp(d));
|
|
220
|
+
}
|
|
221
|
+
export function toUnixTimeMilliseconds(d) {
|
|
222
|
+
return fromFloat64(d.epochMilliseconds);
|
|
223
|
+
}
|
|
224
|
+
export function toUnixTimeSeconds(d) {
|
|
225
|
+
return fromFloat64(Math.floor(d.epochMilliseconds / 1000));
|
|
226
|
+
}
|
|
227
|
+
export function now() {
|
|
228
|
+
const z = Temporal.Now.zonedDateTimeISO(hostTimeZone());
|
|
229
|
+
return fromEpoch(truncateToTicks(z.epochNanoseconds), BigInt(z.offsetNanoseconds));
|
|
230
|
+
}
|
|
231
|
+
export function utcNow() {
|
|
232
|
+
return fromEpoch(truncateToTicks(Temporal.Now.instant().epochNanoseconds));
|
|
233
|
+
}
|
|
234
|
+
// --- Formatting and parsing ---
|
|
235
|
+
// Wall-clock fields for the formatter, with the sub-second component in .NET
|
|
236
|
+
// ticks so "O" and the f/F specifiers can print all 7 digits.
|
|
237
|
+
function toDateInfo(z) {
|
|
238
|
+
return {
|
|
239
|
+
year: z.year,
|
|
240
|
+
month: z.month,
|
|
241
|
+
day: z.day,
|
|
242
|
+
hour: z.hour,
|
|
243
|
+
minute: z.minute,
|
|
244
|
+
second: z.second,
|
|
245
|
+
tick: z.millisecond * 10000 + z.microsecond * 10 + Math.trunc(z.nanosecond / 100),
|
|
246
|
+
dayOfWeek: z.dayOfWeek % 7,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
export function toString(d, format, _provider) {
|
|
250
|
+
const offsetString = () => offsetNanosecondsToZoneString(BigInt(d.offsetNanoseconds));
|
|
251
|
+
return Format.dateToString({
|
|
252
|
+
info: toDateInfo(d),
|
|
253
|
+
utcInfo: () => toDateInfo(d.withTimeZone("UTC")),
|
|
254
|
+
// A fixed-offset zone renders as .NET's "O" exactly: ISO wall-clock plus
|
|
255
|
+
// the numeric offset, with no [zone] annotation.
|
|
256
|
+
roundTrip: () => d.toString({ fractionalSecondDigits: 7, timeZoneName: "never" }),
|
|
257
|
+
sortable: () => d.toPlainDateTime().toString({ smallestUnit: "second" }),
|
|
258
|
+
defaultSuffix: " " + offsetString(),
|
|
259
|
+
// K/z print the value's own offset, never the host zone's, so Local is
|
|
260
|
+
// passed as the kind and that offset stands in for the host one.
|
|
261
|
+
kind: DateTimeKind.Local,
|
|
262
|
+
hostOffsetString: offsetString,
|
|
263
|
+
}, format);
|
|
264
|
+
}
|
|
265
|
+
export function parse(str) {
|
|
266
|
+
const [parsed, offsetMatch] = Format.parseRaw(str);
|
|
267
|
+
// parseRaw resolves the instant through JS Date, which truncates at the
|
|
268
|
+
// millisecond, so the digits below that are recovered from the input separately.
|
|
269
|
+
const epochNs = BigInt(parsed.getTime()) * 1000000n + BigInt(Format.subMillisecondTicks(str)) * 100n;
|
|
270
|
+
const offsetNs = offsetMatch == null
|
|
271
|
+
? BigInt(new Temporal.Instant(epochNs).toZonedDateTimeISO(hostTimeZone()).offsetNanoseconds)
|
|
272
|
+
: (offsetMatch === "Z" ? 0n : BigInt(offsetMatch) * nsPerMinute);
|
|
273
|
+
return fromEpoch(epochNs, offsetNs);
|
|
274
|
+
}
|
|
275
|
+
export function tryParse(v, defValue) {
|
|
276
|
+
try {
|
|
277
|
+
defValue.contents = parse(v);
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DateTime as an extended Temporal.PlainDateTime.
|
|
3
|
+
*
|
|
4
|
+
* .NET DateTime is a wall-clock date+time (no offset) plus a Kind (Utc | Local |
|
|
5
|
+
* Unspecified) that is metadata only. PlainDateTime models the wall-clock exactly
|
|
6
|
+
* and, unlike the JS Date representation, is tick (100ns) precise and DST-agnostic
|
|
7
|
+
* for arithmetic — which matches .NET, where DateTime math operates on the raw
|
|
8
|
+
* wall-clock ticks.
|
|
9
|
+
*
|
|
10
|
+
* Kind has no Temporal home, so it is attached to the instance as a `kind` property
|
|
11
|
+
* (Temporal objects are extensible). Because Temporal operations return fresh,
|
|
12
|
+
* un-stamped instances, every operation must funnel through `dateTime(...)` to
|
|
13
|
+
* re-stamp the kind.
|
|
14
|
+
*
|
|
15
|
+
* Formatting, parsing and time-zone conversion are done on the Temporal value
|
|
16
|
+
* itself (see DateTimeFormat.ts), never by round-tripping through a JS Date —
|
|
17
|
+
* that would silently truncate every value to milliseconds. The one exception is
|
|
18
|
+
* the four ToLong/ShortDate/TimeString members, which are host-locale display
|
|
19
|
+
* strings with no .NET-defined layout and no sub-second component.
|
|
20
|
+
*/
|
|
21
|
+
import { toInt64 } from "./BigInt.js";
|
|
22
|
+
import { DateTimeKind } from "./Util.js";
|
|
23
|
+
import { fromTicks as TimeSpan_fromTicks, fromUnits as TimeSpan_fromUnits, totalNanoseconds as TimeSpan_totalNanoseconds, } from "./TimeSpanTemporal.js";
|
|
24
|
+
import * as Format from "./DateTimeFormat.js";
|
|
25
|
+
export const PlainDateTime = Temporal.PlainDateTime;
|
|
26
|
+
// Generic equality/comparison/hashing dispatch (Util.ts) uses .NET-style methods.
|
|
27
|
+
const proto = Temporal.PlainDateTime.prototype;
|
|
28
|
+
proto.Equals = function (other) { return Temporal.PlainDateTime.compare(this, other) === 0; };
|
|
29
|
+
proto.CompareTo = function (other) { return Temporal.PlainDateTime.compare(this, other); };
|
|
30
|
+
proto.GetHashCode = function () { return hash(this); };
|
|
31
|
+
// Lets String.Format format this value without String.ts importing this module (see String.ts)
|
|
32
|
+
proto[Symbol.for("Fable.DateTimeFormattable")] = function (format) { return toString(this, format); };
|
|
33
|
+
const minDateTime = new Temporal.PlainDateTime(1, 1, 1);
|
|
34
|
+
export function getKind(value) {
|
|
35
|
+
return value.kind ?? DateTimeKind.Unspecified;
|
|
36
|
+
}
|
|
37
|
+
export function dateTime(value, kind = DateTimeKind.Unspecified) {
|
|
38
|
+
const d = value;
|
|
39
|
+
d.kind = kind;
|
|
40
|
+
return d;
|
|
41
|
+
}
|
|
42
|
+
// `dateTime` stamps in place, so anything handing out a value derived from a
|
|
43
|
+
// shared instance (a module constant, or the argument of SpecifyKind) has to
|
|
44
|
+
// copy first, or it would mutate the caller's value.
|
|
45
|
+
function copy(d) {
|
|
46
|
+
return new Temporal.PlainDateTime(d.year, d.month, d.day, d.hour, d.minute, d.second, d.millisecond, d.microsecond, d.nanosecond);
|
|
47
|
+
}
|
|
48
|
+
function hostTimeZone() {
|
|
49
|
+
return Temporal.Now.timeZoneId();
|
|
50
|
+
}
|
|
51
|
+
// Host-zone offset at this wall-clock, e.g. "+01:00". Unlike building a JS Date
|
|
52
|
+
// from the fields, this is correct for years 0-99 (which JS maps to 1900-1999).
|
|
53
|
+
function hostOffsetString(d) {
|
|
54
|
+
return d.toZonedDateTime(hostTimeZone()).offset;
|
|
55
|
+
}
|
|
56
|
+
// Wall-clock fields for the formatter. The sub-second component is carried in
|
|
57
|
+
// .NET ticks so that "O" and the f/F specifiers can print all 7 digits.
|
|
58
|
+
function toDateInfo(d) {
|
|
59
|
+
return {
|
|
60
|
+
year: d.year,
|
|
61
|
+
month: d.month,
|
|
62
|
+
day: d.day,
|
|
63
|
+
hour: d.hour,
|
|
64
|
+
minute: d.minute,
|
|
65
|
+
second: d.second,
|
|
66
|
+
tick: d.millisecond * 10000 + d.microsecond * 10 + Math.trunc(d.nanosecond / 100),
|
|
67
|
+
dayOfWeek: dayOfWeek(d),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Display-only bridge for the host-locale strings below. Sub-second precision is
|
|
71
|
+
// irrelevant to all four, but years 0-99 still need correcting.
|
|
72
|
+
function toJsDate(d) {
|
|
73
|
+
const jsDate = new Date(d.year, d.month - 1, d.day, d.hour, d.minute, d.second, d.millisecond);
|
|
74
|
+
jsDate.setFullYear(d.year, d.month - 1, d.day);
|
|
75
|
+
return jsDate;
|
|
76
|
+
}
|
|
77
|
+
export function create(year, month, day, h = 0, m = 0, s = 0, ms = 0, kind) {
|
|
78
|
+
return dateTime(new Temporal.PlainDateTime(year, month, day, h, m, s, ms), kind);
|
|
79
|
+
}
|
|
80
|
+
export function fromTicks(ticks, kind) {
|
|
81
|
+
return dateTime(minDateTime.add(TimeSpan_fromTicks(ticks)), kind);
|
|
82
|
+
}
|
|
83
|
+
export function getTicks(date) {
|
|
84
|
+
return toInt64(TimeSpan_totalNanoseconds(minDateTime.until(date, { largestUnit: "day" })) / 100n);
|
|
85
|
+
}
|
|
86
|
+
export function minValue() {
|
|
87
|
+
return dateTime(copy(minDateTime), DateTimeKind.Unspecified);
|
|
88
|
+
}
|
|
89
|
+
export function maxValue() {
|
|
90
|
+
return dateTime(new Temporal.PlainDateTime(9999, 12, 31, 23, 59, 59, 999, 999, 900), DateTimeKind.Unspecified);
|
|
91
|
+
}
|
|
92
|
+
// .NET DateTime has 100ns (tick) precision; Temporal.Now is nanosecond-precise.
|
|
93
|
+
function truncateToTicks(d) {
|
|
94
|
+
return d.round({ smallestUnit: "nanosecond", roundingIncrement: 100, roundingMode: "trunc" });
|
|
95
|
+
}
|
|
96
|
+
export function now() {
|
|
97
|
+
return dateTime(truncateToTicks(Temporal.Now.plainDateTimeISO()), DateTimeKind.Local);
|
|
98
|
+
}
|
|
99
|
+
export function utcNow() {
|
|
100
|
+
return dateTime(truncateToTicks(Temporal.Now.plainDateTimeISO("UTC")), DateTimeKind.Utc);
|
|
101
|
+
}
|
|
102
|
+
export function today() {
|
|
103
|
+
return date(now());
|
|
104
|
+
}
|
|
105
|
+
export function specifyKind(d, kind) {
|
|
106
|
+
// Kind is metadata: every tick of the wall-clock is preserved.
|
|
107
|
+
return dateTime(copy(d), kind);
|
|
108
|
+
}
|
|
109
|
+
export function dayOfWeek(d) {
|
|
110
|
+
// Temporal: Monday = 1 ... Sunday = 7, .NET: Sunday = 0 ... Saturday = 6
|
|
111
|
+
return d.dayOfWeek % 7;
|
|
112
|
+
}
|
|
113
|
+
export function date(d) {
|
|
114
|
+
return dateTime(d.with({ hour: 0, minute: 0, second: 0, millisecond: 0, microsecond: 0, nanosecond: 0 }), getKind(d));
|
|
115
|
+
}
|
|
116
|
+
export function timeOfDay(d) {
|
|
117
|
+
// Elapsed since midnight. DateTime values are tick-aligned, so this is too.
|
|
118
|
+
return d.with({ hour: 0, minute: 0, second: 0, millisecond: 0, microsecond: 0, nanosecond: 0 }).until(d);
|
|
119
|
+
}
|
|
120
|
+
export function add(d, ts) {
|
|
121
|
+
return dateTime(d.add(ts), getKind(d));
|
|
122
|
+
}
|
|
123
|
+
export function addYears(d, v) {
|
|
124
|
+
return dateTime(d.add({ years: v }), getKind(d));
|
|
125
|
+
}
|
|
126
|
+
export function addMonths(d, v) {
|
|
127
|
+
return dateTime(d.add({ months: v }), getKind(d));
|
|
128
|
+
}
|
|
129
|
+
export function addDays(d, v) {
|
|
130
|
+
return dateTime(d.add(TimeSpan_fromUnits(v, "days")), getKind(d));
|
|
131
|
+
}
|
|
132
|
+
export function addHours(d, v) {
|
|
133
|
+
return dateTime(d.add(TimeSpan_fromUnits(v, "hours")), getKind(d));
|
|
134
|
+
}
|
|
135
|
+
export function addMinutes(d, v) {
|
|
136
|
+
return dateTime(d.add(TimeSpan_fromUnits(v, "minutes")), getKind(d));
|
|
137
|
+
}
|
|
138
|
+
export function addSeconds(d, v) {
|
|
139
|
+
return dateTime(d.add(TimeSpan_fromUnits(v, "seconds")), getKind(d));
|
|
140
|
+
}
|
|
141
|
+
export function addMilliseconds(d, v) {
|
|
142
|
+
return dateTime(d.add(TimeSpan_fromUnits(v, "milliseconds")), getKind(d));
|
|
143
|
+
}
|
|
144
|
+
export function addTicks(d, v) {
|
|
145
|
+
return dateTime(d.add(TimeSpan_fromTicks(v)), getKind(d));
|
|
146
|
+
}
|
|
147
|
+
export function subtractDate(d, that) {
|
|
148
|
+
return that.until(d, { largestUnit: "day" });
|
|
149
|
+
}
|
|
150
|
+
export function subtractTimeSpan(d, ts) {
|
|
151
|
+
return dateTime(d.subtract(ts), getKind(d));
|
|
152
|
+
}
|
|
153
|
+
export function equals(d1, d2) {
|
|
154
|
+
return Temporal.PlainDateTime.compare(d1, d2) === 0;
|
|
155
|
+
}
|
|
156
|
+
export function compare(d1, d2) {
|
|
157
|
+
return Temporal.PlainDateTime.compare(d1, d2);
|
|
158
|
+
}
|
|
159
|
+
export const compareTo = compare;
|
|
160
|
+
export function op_Addition(x, y) {
|
|
161
|
+
return add(x, y);
|
|
162
|
+
}
|
|
163
|
+
export function hash(d) {
|
|
164
|
+
return Number(getTicks(d) % 2147483647n);
|
|
165
|
+
}
|
|
166
|
+
export function isLeapYear(year) {
|
|
167
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
168
|
+
}
|
|
169
|
+
export function daysInMonth(year, month) {
|
|
170
|
+
return month === 2
|
|
171
|
+
? (isLeapYear(year) ? 29 : 28)
|
|
172
|
+
: (month >= 8 ? (month % 2 === 0 ? 31 : 30) : (month % 2 === 0 ? 30 : 31));
|
|
173
|
+
}
|
|
174
|
+
// --- Host time zone ---
|
|
175
|
+
export function toUniversalTime(d) {
|
|
176
|
+
// .NET reads an Unspecified value as local time here.
|
|
177
|
+
return getKind(d) === DateTimeKind.Utc
|
|
178
|
+
? d
|
|
179
|
+
: dateTime(d.toZonedDateTime(hostTimeZone()).withTimeZone("UTC").toPlainDateTime(), DateTimeKind.Utc);
|
|
180
|
+
}
|
|
181
|
+
export function toLocalTime(d) {
|
|
182
|
+
// .NET reads an Unspecified value as UTC here — the mirror image of the above.
|
|
183
|
+
return getKind(d) === DateTimeKind.Local
|
|
184
|
+
? d
|
|
185
|
+
: dateTime(d.toZonedDateTime("UTC").withTimeZone(hostTimeZone()).toPlainDateTime(), DateTimeKind.Local);
|
|
186
|
+
}
|
|
187
|
+
export function isDaylightSavingTime(d) {
|
|
188
|
+
const tz = hostTimeZone();
|
|
189
|
+
const offsetAt = (month) => new Temporal.PlainDateTime(d.year, month, 1).toZonedDateTime(tz).offsetNanoseconds;
|
|
190
|
+
// The larger of the two mid-season offsets is the daylight-saving one.
|
|
191
|
+
return Math.max(offsetAt(1), offsetAt(7)) === d.toZonedDateTime(tz).offsetNanoseconds;
|
|
192
|
+
}
|
|
193
|
+
// --- Host-locale display strings (no .NET-defined layout) ---
|
|
194
|
+
export function toLongDateString(d) {
|
|
195
|
+
return toJsDate(d).toDateString();
|
|
196
|
+
}
|
|
197
|
+
export function toShortDateString(d) {
|
|
198
|
+
return toJsDate(d).toLocaleDateString();
|
|
199
|
+
}
|
|
200
|
+
export function toLongTimeString(d) {
|
|
201
|
+
return toJsDate(d).toLocaleTimeString();
|
|
202
|
+
}
|
|
203
|
+
export function toShortTimeString(d) {
|
|
204
|
+
return toJsDate(d).toLocaleTimeString().replace(/:\d\d(?!:)/, "");
|
|
205
|
+
}
|
|
206
|
+
// --- Formatting and parsing ---
|
|
207
|
+
export function toString(d, format, _provider) {
|
|
208
|
+
const kind = getKind(d);
|
|
209
|
+
return Format.dateToString({
|
|
210
|
+
info: toDateInfo(d),
|
|
211
|
+
utcInfo: () => toDateInfo(toUniversalTime(d)),
|
|
212
|
+
// An Unspecified DateTime prints no zone at all, which is what makes "O"
|
|
213
|
+
// round-trip it back to Unspecified.
|
|
214
|
+
roundTrip: () => d.toString({ fractionalSecondDigits: 7 })
|
|
215
|
+
+ (kind === DateTimeKind.Utc ? "Z" : kind === DateTimeKind.Local ? hostOffsetString(d) : ""),
|
|
216
|
+
sortable: () => d.toString({ smallestUnit: "second" }),
|
|
217
|
+
defaultSuffix: "",
|
|
218
|
+
kind,
|
|
219
|
+
hostOffsetString: () => hostOffsetString(d),
|
|
220
|
+
}, format);
|
|
221
|
+
}
|
|
222
|
+
export function parse(str, detectUTC = false) {
|
|
223
|
+
const [parsed, offset] = Format.parseRaw(str);
|
|
224
|
+
// .NET always parses DateTime as Local if there's offset info (even "Z")
|
|
225
|
+
// Newtonsoft.Json uses UTC if the offset is "Z"
|
|
226
|
+
const kind = offset != null
|
|
227
|
+
? (detectUTC && offset === "Z" ? DateTimeKind.Utc : DateTimeKind.Local)
|
|
228
|
+
: DateTimeKind.Unspecified;
|
|
229
|
+
// parseRaw resolves the instant through JS Date, which truncates at the
|
|
230
|
+
// millisecond, so the digits below that are recovered from the input separately.
|
|
231
|
+
const epochNs = BigInt(parsed.getTime()) * 1000000n + BigInt(Format.subMillisecondTicks(str)) * 100n;
|
|
232
|
+
const zone = kind === DateTimeKind.Utc ? "UTC" : hostTimeZone();
|
|
233
|
+
return dateTime(new Temporal.Instant(epochNs).toZonedDateTimeISO(zone).toPlainDateTime(), kind);
|
|
234
|
+
}
|
|
235
|
+
export function tryParse(v, defValue) {
|
|
236
|
+
try {
|
|
237
|
+
defValue.contents = parse(v);
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Decimal from "./lib/big.js";
|
|
2
2
|
import { symbol } from "./Numeric.js";
|
|
3
3
|
import { FSharpRef } from "./Types.js";
|
|
4
|
-
import { combineHashCodes } from "./Util.js";
|
|
4
|
+
import { Exception, combineHashCodes } from "./Util.js";
|
|
5
|
+
import { fromDecimal } from "./BigInt.js";
|
|
6
|
+
import * as bigInt from "./BigInt.js";
|
|
5
7
|
Decimal.prototype.GetHashCode = function () {
|
|
6
8
|
return combineHashCodes([this.s, this.e].concat(this.c));
|
|
7
9
|
};
|
|
@@ -34,13 +36,13 @@ export function equals(x, y) {
|
|
|
34
36
|
return !x.cmp(y);
|
|
35
37
|
}
|
|
36
38
|
export function abs(x) { return x.abs(); }
|
|
37
|
-
export function sign(x) { return x
|
|
38
|
-
export function max(x, y) { return x
|
|
39
|
-
export function min(x, y) { return x
|
|
40
|
-
export function maxMagnitude(x, y) { return abs(x)
|
|
41
|
-
export function minMagnitude(x, y) { return abs(x)
|
|
39
|
+
export function sign(x) { return x.lt(get_Zero) ? -1 : x.gt(get_Zero) ? 1 : 0; }
|
|
40
|
+
export function max(x, y) { return x.gt(y) ? x : y; }
|
|
41
|
+
export function min(x, y) { return x.lt(y) ? x : y; }
|
|
42
|
+
export function maxMagnitude(x, y) { return abs(x).gt(abs(y)) ? x : y; }
|
|
43
|
+
export function minMagnitude(x, y) { return abs(x).lt(abs(y)) ? x : y; }
|
|
42
44
|
export function clamp(x, min, max) {
|
|
43
|
-
return x
|
|
45
|
+
return x.lt(min) ? min : x.gt(max) ? max : x;
|
|
44
46
|
}
|
|
45
47
|
export function round(x, digits = 0) {
|
|
46
48
|
return x.round(digits, 2 /* ROUND_HALF_EVEN */);
|
|
@@ -107,12 +109,34 @@ export function parse(str) {
|
|
|
107
109
|
return defValue.contents;
|
|
108
110
|
}
|
|
109
111
|
else {
|
|
110
|
-
throw new
|
|
112
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
export function toNumber(x) {
|
|
114
116
|
return +x;
|
|
115
117
|
}
|
|
118
|
+
export function toChar(x) {
|
|
119
|
+
const n = toNumber(x);
|
|
120
|
+
if (n < 0 || n > 65535 || isNaN(n)) {
|
|
121
|
+
throw new Exception("Value was either too large or too small for a character.");
|
|
122
|
+
}
|
|
123
|
+
return String.fromCharCode(n);
|
|
124
|
+
}
|
|
125
|
+
export function toInt8(x) { return bigInt.toInt8(fromDecimal(x)); }
|
|
126
|
+
export function toUInt8(x) { return bigInt.toUInt8(fromDecimal(x)); }
|
|
127
|
+
export function toInt16(x) { return bigInt.toInt16(fromDecimal(x)); }
|
|
128
|
+
export function toUInt16(x) { return bigInt.toUInt16(fromDecimal(x)); }
|
|
129
|
+
export function toInt32(x) { return bigInt.toInt32(fromDecimal(x)); }
|
|
130
|
+
export function toUInt32(x) { return bigInt.toUInt32(fromDecimal(x)); }
|
|
131
|
+
export function toInt64(x) { return bigInt.toInt64(fromDecimal(x)); }
|
|
132
|
+
export function toUInt64(x) { return bigInt.toUInt64(fromDecimal(x)); }
|
|
133
|
+
export function toInt128(x) { return bigInt.toInt128(fromDecimal(x)); }
|
|
134
|
+
export function toUInt128(x) { return bigInt.toUInt128(fromDecimal(x)); }
|
|
135
|
+
export function toNativeInt(x) { return bigInt.toNativeInt(fromDecimal(x)); }
|
|
136
|
+
export function toUNativeInt(x) { return bigInt.toUNativeInt(fromDecimal(x)); }
|
|
137
|
+
export function toFloat16(x) { return toNumber(x); }
|
|
138
|
+
export function toFloat32(x) { return toNumber(x); }
|
|
139
|
+
export function toFloat64(x) { return toNumber(x); }
|
|
116
140
|
function decimalToHex(dec, bitSize) {
|
|
117
141
|
const hex = new Uint8Array(bitSize / 4 | 0);
|
|
118
142
|
let hexCount = 1;
|
|
@@ -183,21 +207,23 @@ export function fromParts(low, mid, high, isNegative, scale) {
|
|
|
183
207
|
}
|
|
184
208
|
export function getBits(d) {
|
|
185
209
|
const bitSize = 96;
|
|
186
|
-
const
|
|
210
|
+
const decStr = d.toString();
|
|
211
|
+
const absStr = decStr[0] === "-" ? decStr.slice(1) : decStr;
|
|
212
|
+
const dotPos = absStr.indexOf(".");
|
|
213
|
+
const scale = dotPos < 0 ? 0 : absStr.length - dotPos - 1;
|
|
214
|
+
const mantissaStr = absStr.replace(".", "");
|
|
215
|
+
const decDigits = Uint8Array.from(mantissaStr, ch => ch.charCodeAt(0) - 48);
|
|
187
216
|
const hexDigits = decimalToHex(decDigits, bitSize);
|
|
188
217
|
const low = getInt32Bits(hexDigits, 0);
|
|
189
218
|
const mid = getInt32Bits(hexDigits, 8);
|
|
190
219
|
const high = getInt32Bits(hexDigits, 16);
|
|
191
|
-
const decStr = d.toString();
|
|
192
|
-
const dotPos = decStr.indexOf(".");
|
|
193
|
-
const scale = dotPos < 0 ? 0 : decStr.length - dotPos - 1;
|
|
194
220
|
const signExp = ((scale & 0x7F) << 16) | (d.s < 0 ? 0x80000000 : 0);
|
|
195
221
|
return [low, mid, high, signExp];
|
|
196
222
|
}
|
|
197
223
|
// export function makeRangeStepFunction(step: Decimal, last: Decimal) {
|
|
198
224
|
// const stepComparedWithZero = step.cmp(get_Zero);
|
|
199
225
|
// if (stepComparedWithZero === 0) {
|
|
200
|
-
// throw new
|
|
226
|
+
// throw new Exception("The step of a range cannot be zero");
|
|
201
227
|
// }
|
|
202
228
|
// const stepGreaterThanZero = stepComparedWithZero > 0;
|
|
203
229
|
// return (x: Decimal) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This library doesn't depend on @types/node (to stay browser-compatible),
|
|
2
|
+
// so this Node.js built-in import can't be type-checked; the exported
|
|
3
|
+
// functions below still declare their own types for callers to rely on.
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import { existsSync, mkdirSync, statSync } from "node:fs";
|
|
6
|
+
export function exists(path) {
|
|
7
|
+
return existsSync(path) && statSync(path).isDirectory();
|
|
8
|
+
}
|
|
9
|
+
export function createDirectory(path) {
|
|
10
|
+
mkdirSync(path, { recursive: true });
|
|
11
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FSharpRef } from "./Types.js";
|
|
2
|
+
import { Exception } from "./Util.js";
|
|
2
3
|
export function tryParse(str, defValue) {
|
|
3
4
|
// TODO: test if value is valid and in range
|
|
4
5
|
if (str != null && /\S/.test(str)) {
|
|
@@ -16,7 +17,7 @@ export function parse(str) {
|
|
|
16
17
|
return defValue.contents;
|
|
17
18
|
}
|
|
18
19
|
else {
|
|
19
|
-
throw new
|
|
20
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
// JS Number.isFinite function evals false for NaN
|
|
@@ -30,15 +31,21 @@ export function isInfinity(x) {
|
|
|
30
31
|
return x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY;
|
|
31
32
|
}
|
|
32
33
|
export function max(x, y) {
|
|
33
|
-
return x
|
|
34
|
+
return Math.max(x, y);
|
|
34
35
|
}
|
|
35
36
|
export function min(x, y) {
|
|
36
|
-
return x
|
|
37
|
+
return Math.min(x, y);
|
|
37
38
|
}
|
|
38
39
|
export function maxMagnitude(x, y) {
|
|
40
|
+
if (Number.isNaN(x) || Number.isNaN(y)) {
|
|
41
|
+
return NaN;
|
|
42
|
+
}
|
|
39
43
|
return Math.abs(x) > Math.abs(y) ? x : y;
|
|
40
44
|
}
|
|
41
45
|
export function minMagnitude(x, y) {
|
|
46
|
+
if (Number.isNaN(x) || Number.isNaN(y)) {
|
|
47
|
+
return NaN;
|
|
48
|
+
}
|
|
42
49
|
return Math.abs(x) < Math.abs(y) ? x : y;
|
|
43
50
|
}
|
|
44
51
|
export function clamp(x, min, max) {
|