@flex-development/mlly 1.0.0-beta.1 → 1.0.0-beta.2

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,3 +1,9 @@
1
+ ## [1.0.0-beta.2](https://github.com/flex-development/mlly/compare/1.0.0-beta.1...1.0.0-beta.2) (2026-02-02)
2
+
3
+ ### :sparkles: Features
4
+
5
+ - [[`a799aef`](https://github.com/flex-development/mlly/commit/a799aef04f5fa6033297c362474047acaaeb0e1f)] **ts:** generic fs methods
6
+
1
7
  ## [1.0.0-beta.1](https://github.com/flex-development/mlly/compare/1.0.0-alpha.20...1.0.0-beta.1) (2026-02-02)
2
8
 
3
9
  ### ⚠ BREAKING CHANGES
@@ -1253,3 +1259,4 @@
1253
1259
  - [[`0266ca9`](https://github.com/flex-development/mlly/commit/0266ca9a5593d0c66e950ba1fe2c8f6df8422ff9)] **resolve:** sort `RESOLVE_EXTENSIONS` according to priority
1254
1260
  - [[`36c4b74`](https://github.com/flex-development/mlly/commit/36c4b7475c9bb6c924f5e75c8d6d215a8d23e79c)] **specifiers:** [`toBareSpecifier`] improve `exports` path search
1255
1261
 
1262
+
package/README.md CHANGED
@@ -84,11 +84,11 @@
84
84
  - [`PatternMatch`](#patternmatch)
85
85
  - [`ProtocolMap`](#protocolmap)
86
86
  - [`Protocol`](#protocol)
87
- - [`ReadFile`](#readfile)
88
- - [`Realpath`](#realpath)
87
+ - [`ReadFile<[T]>`](#readfilet)
88
+ - [`Realpath<[T]>`](#realpatht)
89
89
  - [`ResolveAliasOptions`](#resolvealiasoptions)
90
90
  - [`ResolveModuleOptions`](#resolvemoduleoptions)
91
- - [`Stat`](#stat)
91
+ - [`Stat<[T]>`](#statt)
92
92
  - [`Stats`](#stats)
93
93
  - Additional Documentation
94
94
  - [Resolution Algorithm](./docs/resolution-algorithm.md)
@@ -1138,11 +1138,11 @@ The file system API (`interface`).
1138
1138
 
1139
1139
  #### Properties
1140
1140
 
1141
- - `readFile` ([`ReadFile`](#readfile))
1141
+ - `readFile` ([`ReadFile`](#readfilet))
1142
1142
  — read the entire contents of a file
1143
- - `realpath` ([`Realpath`](#realpath))
1143
+ - `realpath` ([`Realpath`](#realpatht))
1144
1144
  — compute a canonical pathname by resolving `.`, `..`, and symbolic links
1145
- - `stat` ([`Stat`](#stat))
1145
+ - `stat` ([`Stat`](#statt))
1146
1146
  — get information about a directory or file
1147
1147
 
1148
1148
  ### `GetSourceContext`
@@ -1372,10 +1372,15 @@ They will be added to this union automatically.
1372
1372
  type Protocol = ProtocolMap[keyof ProtocolMap]
1373
1373
  ```
1374
1374
 
1375
- ### `ReadFile`
1375
+ ### `ReadFile<[T]>`
1376
1376
 
1377
1377
  Read the entire contents of a file (`interface`).
1378
1378
 
1379
+ #### Type Parameters
1380
+
1381
+ - `T` ([`Awaitable<Buffer | string>`](#awaitablet), optional)
1382
+ — the file contents
1383
+
1379
1384
  #### Parameters
1380
1385
 
1381
1386
  - `id` ([`ModuleId`](#moduleid))
@@ -1383,15 +1388,20 @@ Read the entire contents of a file (`interface`).
1383
1388
 
1384
1389
  #### Returns
1385
1390
 
1386
- ([`Awaitable<Buffer | string>`](#awaitablet)) The file contents
1391
+ (`T`) The file contents
1387
1392
 
1388
- ### `Realpath`
1393
+ ### `Realpath<[T]>`
1389
1394
 
1390
1395
  Compute a canonical pathname by resolving `.`, `..`, and symbolic links (`interface`).
1391
1396
 
1392
1397
  > 👉 **Note**: A canonical pathname is not necessarily unique.
1393
1398
  > Hard links and bind mounts can expose an entity through many pathnames.
1394
1399
 
1400
+ #### Type Parameters
1401
+
1402
+ - `T` ([`Awaitable<string>`](#awaitablet), optional)
1403
+ — the canonical pathname
1404
+
1395
1405
  #### Parameters
1396
1406
 
1397
1407
  - `id` ([`ModuleId`](#moduleid))
@@ -1399,7 +1409,7 @@ Compute a canonical pathname by resolving `.`, `..`, and symbolic links (`interf
1399
1409
 
1400
1410
  #### Returns
1401
1411
 
1402
- ([`Awaitable<string>`](#awaitablet)) The canonical pathname
1412
+ (`T`) The canonical pathname
1403
1413
 
1404
1414
  ### `ResolveAliasOptions`
1405
1415
 
@@ -1451,10 +1461,15 @@ Options for path alias resolution (`interface`).
1451
1461
  - `preserveSymlinks?` (`boolean` | `null` | `undefined`)
1452
1462
  — whether to keep symlinks instead of resolving them
1453
1463
 
1454
- ### `Stat`
1464
+ ### `Stat<[T]>`
1455
1465
 
1456
1466
  Get information about a directory or file (`interface`).
1457
1467
 
1468
+ #### Type Parameters
1469
+
1470
+ - `T` ([`Awaitable<Stats>`](#stats), optional)
1471
+ — the info
1472
+
1458
1473
  #### Parameters
1459
1474
 
1460
1475
  - `id` ([`ModuleId`](#moduleid))
@@ -1462,7 +1477,7 @@ Get information about a directory or file (`interface`).
1462
1477
 
1463
1478
  #### Returns
1464
1479
 
1465
- ([`Awaitable<Stats>`](#stats)) The info
1480
+ (`T`) The info
1466
1481
 
1467
1482
  ### `Stats`
1468
1483
 
@@ -5,20 +5,24 @@
5
5
  import type { Awaitable, ModuleId } from '@flex-development/mlly';
6
6
  /**
7
7
  * Read the entire contents of a file.
8
+ *
9
+ * @see {@linkcode Awaitable}
10
+ * @see {@linkcode Buffer}
11
+ *
12
+ * @template {Awaitable<Buffer | string>} [T]
13
+ * The file contents
8
14
  */
9
- interface ReadFile {
15
+ interface ReadFile<T extends Awaitable<Buffer | string> = Awaitable<Buffer | string>> {
10
16
  /**
11
- * @see {@linkcode Awaitable}
12
- * @see {@linkcode Buffer}
13
17
  * @see {@linkcode ModuleId}
14
18
  *
15
19
  * @this {void}
16
20
  *
17
21
  * @param {ModuleId} id
18
22
  * The module id
19
- * @return {Awaitable<Buffer | string>}
23
+ * @return {T}
20
24
  * The file contents
21
25
  */
22
- (this: void, id: ModuleId): Awaitable<Buffer | string>;
26
+ (this: void, id: ModuleId): T;
23
27
  }
24
28
  export type { ReadFile as default };
@@ -8,19 +8,23 @@ import type { Awaitable, ModuleId } from '@flex-development/mlly';
8
8
  *
9
9
  * > 👉 **Note**: A canonical pathname is not necessarily unique.
10
10
  * > Hard links and bind mounts can expose an entity through many pathnames.
11
+ *
12
+ * @see {@linkcode Awaitable}
13
+ *
14
+ * @template {Awaitable<string>} [T]
15
+ * The canonical pathname
11
16
  */
12
- interface Realpath {
17
+ interface Realpath<T extends Awaitable<string> = Awaitable<string>> {
13
18
  /**
14
- * @see {@linkcode Awaitable}
15
19
  * @see {@linkcode ModuleId}
16
20
  *
17
21
  * @this {void}
18
22
  *
19
23
  * @param {ModuleId} id
20
24
  * The module id
21
- * @return {Awaitable<string>}
25
+ * @return {T}
22
26
  * The canonical pathname
23
27
  */
24
- (this: void, id: ModuleId): Awaitable<string>;
28
+ (this: void, id: ModuleId): T;
25
29
  }
26
30
  export type { Realpath as default };
@@ -5,20 +5,24 @@
5
5
  import type { Awaitable, ModuleId, Stats } from '@flex-development/mlly';
6
6
  /**
7
7
  * Get information about a directory or file.
8
+ *
9
+ * @see {@linkcode Awaitable}
10
+ * @see {@linkcode Stats}
11
+ *
12
+ * @template {Awaitable<Stats>} [T]
13
+ * The info
8
14
  */
9
- interface Stat {
15
+ interface Stat<T extends Awaitable<Stats> = Awaitable<Stats>> {
10
16
  /**
11
- * @see {@linkcode Awaitable}
12
17
  * @see {@linkcode ModuleId}
13
- * @see {@linkcode Stats}
14
18
  *
15
19
  * @this {void}
16
20
  *
17
21
  * @param {ModuleId} id
18
22
  * The module id
19
- * @return {Awaitable<Stats>}
23
+ * @return {T}
20
24
  * The info
21
25
  */
22
- (this: void, id: ModuleId): Awaitable<Stats>;
26
+ (this: void, id: ModuleId): T;
23
27
  }
24
28
  export type { Stat as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flex-development/mlly",
3
3
  "description": "ECMAScript module utilities",
4
- "version": "1.0.0-beta.1",
4
+ "version": "1.0.0-beta.2",
5
5
  "keywords": [
6
6
  "ecmascript",
7
7
  "esm",