@fable-org/fable-library-js 2.3.0 → 2.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- last_commit_released: c977d78b39225a51c7bd051a1fe363ed0ccbe201
2
+ last_commit_released: 7f915f1dd66b9a5fbbd56f858b07d39b98519b65
3
3
  updaters:
4
4
  - package.json:
5
5
  file: package.json
@@ -15,6 +15,19 @@ All notable changes to this project will be documented in this file.
15
15
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
16
16
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
17
17
 
18
+ ## 2.4.0 - 2026-07-05
19
+
20
+ ### 🚀 Features
21
+
22
+ * *(js/ts)* Add `System.IO.Path` and `System.IO.File` API support ([ec99fac5](https://github.com/fable-compiler/Fable/commit/ec99fac5fd7a9428ee54f66f878ef4edad0904cb))
23
+ * *(js/ts/python)* Add Environment and Console.Error support ([6e082f95](https://github.com/fable-compiler/Fable/commit/6e082f955140676da3388a43b55378ea4ad20f1c))
24
+
25
+ ### 🐞 Bug Fixes
26
+
27
+ * *(js/ts)* DateTime.ToString() and %A are now consistent across all DateTimeKind values (#4714) ([de98b0e4](https://github.com/fable-compiler/Fable/commit/de98b0e466c8824b0ba8b941d20efae70d232abb))
28
+
29
+ <strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/c977d78b39225a51c7bd051a1fe363ed0ccbe201..7f915f1dd66b9a5fbbd56f858b07d39b98519b65)</small></strong>
30
+
18
31
  ## 2.3.0 - 2026-06-30
19
32
 
20
33
  ### 🚀 Features
package/Date.js CHANGED
@@ -478,7 +478,7 @@ function dateToString_Y(date) {
478
478
  function dateToStringWithKind(date, format) {
479
479
  const utc = date.kind === DateTimeKind.Utc;
480
480
  if (typeof format !== "string") {
481
- return utc ? date.toUTCString() : date.toLocaleString();
481
+ return dateToString_d(date) + " " + dateToString_T(date);
482
482
  }
483
483
  else if (format.length === 1) {
484
484
  switch (format) {
package/Environment.js ADDED
@@ -0,0 +1,3 @@
1
+ export function getEnvironmentVariable(name) {
2
+ return process.env[name];
3
+ }
package/File.js ADDED
@@ -0,0 +1,27 @@
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 { readFileSync, writeFileSync } from "node:fs";
6
+ // byte[] is represented as a plain JS/TS array of numbers, not a typed array
7
+ // (see e.g. BitConverter.ts), so convert the Buffer returned by readFileSync.
8
+ export function readAllBytes(path) {
9
+ return Array.from(readFileSync(path));
10
+ }
11
+ export function readAllLines(path) {
12
+ const lines = readFileSync(path, "utf8").split(/\r\n|\r|\n/);
13
+ if (lines[lines.length - 1] === "") {
14
+ lines.pop();
15
+ }
16
+ return lines;
17
+ }
18
+ export function readAllText(path) {
19
+ return readFileSync(path, "utf8");
20
+ }
21
+ export function writeAllBytes(path, bytes) {
22
+ // Convert back from the plain array representation to a typed array Node's fs accepts.
23
+ writeFileSync(path, Uint8Array.from(bytes));
24
+ }
25
+ export function writeAllLines(path, lines) {
26
+ writeFileSync(path, lines.join("\n"));
27
+ }
package/Path.js ADDED
@@ -0,0 +1,31 @@
1
+ // This library doesn't depend on @types/node (to stay browser-compatible),
2
+ // so these Node.js built-in imports 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 { basename, extname, join } from "node:path";
6
+ // @ts-ignore
7
+ import { tmpdir } from "node:os";
8
+ // @ts-ignore
9
+ import { writeFileSync } from "node:fs";
10
+ // Mirrors the format of .NET's Path.GetRandomFileName(): 8 random hex chars,
11
+ // a dot, then 3 more random hex chars.
12
+ export function getRandomFileName() {
13
+ const nameBytes = new Uint8Array(4);
14
+ crypto.getRandomValues(nameBytes);
15
+ const name = Array.from(nameBytes, (b) => b.toString(16).padStart(2, "0")).join("");
16
+ const extBytes = new Uint8Array(2);
17
+ crypto.getRandomValues(extBytes);
18
+ const ext = Array.from(extBytes, (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 3);
19
+ return `${name}.${ext}`;
20
+ }
21
+ export function getFileNameWithoutExtension(path) {
22
+ return basename(path, extname(path));
23
+ }
24
+ export function hasExtension(path) {
25
+ return extname(path) !== "";
26
+ }
27
+ export function getTempFileName() {
28
+ const path = join(tmpdir(), getRandomFileName());
29
+ writeFileSync(path, "");
30
+ return path;
31
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "name": "@fable-org/fable-library-js",
6
- "version": "2.3.0",
6
+ "version": "2.4.0",
7
7
  "description": "Core library used by F# projects compiled with fable.io",
8
8
  "author": "Fable Contributors",
9
9
  "license": "MIT",