fs-realpath-native 1.0.3 → 1.0.6

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
@@ -3,6 +3,39 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.6](https://github.com/bluelovers/ws-iconv/compare/fs-realpath-native@1.0.5...fs-realpath-native@1.0.6) (2026-03-02)
7
+
8
+
9
+
10
+ ### 📚 Documentation
11
+
12
+ * 為檔案系統相關套件新增雙語 JSDoc 註解與型別標註 ([83f3845](https://github.com/bluelovers/ws-iconv/commit/83f38456ccc0f5eca4f2a6505bee4caf7e634ba6))
13
+
14
+
15
+
16
+ ## [1.0.5](https://github.com/bluelovers/ws-iconv/compare/fs-realpath-native@1.0.4...fs-realpath-native@1.0.5) (2026-03-01)
17
+
18
+ **Note:** Version bump only for package fs-realpath-native
19
+
20
+
21
+
22
+
23
+
24
+ ## [1.0.4](https://github.com/bluelovers/ws-iconv/compare/fs-realpath-native@1.0.3...fs-realpath-native@1.0.4) (2026-03-01)
25
+
26
+
27
+
28
+ ### 📚 Documentation
29
+
30
+ * 为多个包添加全面的 JSDoc 文档和 README 更新 ([0d149e8](https://github.com/bluelovers/ws-iconv/commit/0d149e856aa9b274aca7fd7562776860c9d00473))
31
+
32
+
33
+ ### ♻️ Chores
34
+
35
+ * Update jest config and add new files for testing ([f370583](https://github.com/bluelovers/ws-iconv/commit/f37058385c7bf24d3d0bc975c752f2f35cfe8356))
36
+
37
+
38
+
6
39
  ## [1.0.3](https://github.com/bluelovers/ws-iconv/compare/fs-realpath-native@1.0.2...fs-realpath-native@1.0.3) (2024-08-29)
7
40
 
8
41
 
package/README.md CHANGED
@@ -1,12 +1,64 @@
1
- # README.md
1
+ # fs-realpath-native
2
2
 
3
-
3
+ File system real path resolution with sync/async operations and error handling.
4
+ 檔案系統實體路徑處理,支援同步/異步操作和錯誤處理。
4
5
 
5
- ## install
6
+ ## Features / 主要功能
7
+
8
+ - Real path resolution / 實體路徑解析
9
+ - Sync and async operations / 同步和異步操作
10
+ - Error handling (ENOENT safe) / 錯誤處理(安全處理路徑不存在)
11
+ - Encoding options support / 支援不同編碼選項
12
+ - Compatible with Node.js fs module / 完全相容於 Node.js fs 模組
13
+
14
+ ## Install / 安裝
6
15
 
7
16
  ```bash
8
- yarn add fs-realpath
9
- yarn-tool add fs-realpath
10
- yt add fs-realpath
17
+ yarn add fs-realpath-native
18
+ yarn-tool add fs-realpath-native
19
+ yt add fs-realpath-native
20
+ pnpm add fs-realpath-native
21
+ npm install fs-realpath-native
11
22
  ```
12
23
 
24
+ ## Quick Start / 快速開始
25
+
26
+ ```typescript
27
+ import {
28
+ fsRealpathNativeSync,
29
+ fsRealpathNativeAsync,
30
+ tryFsRealpathNativeSync,
31
+ tryFsRealpathNativeAsync
32
+ } from 'fs-realpath-native';
33
+
34
+ // Synchronous / 同步
35
+ const realPath = fsRealpathNativeSync('./symlink-to-file');
36
+ console.log(realPath);
37
+
38
+ // Asynchronous / 異步
39
+ const realPathAsync = await fsRealpathNativeAsync('./symlink-to-file');
40
+ console.log(realPathAsync);
41
+
42
+ // Safe version (returns original path if not exists) / 安全版本(路徑不存在時返回原路徑)
43
+ const safePath = tryFsRealpathNativeSync('./maybe-not-exists');
44
+ console.log(safePath);
45
+ ```
46
+
47
+ ## API
48
+
49
+ ### `fsRealpathNativeSync(path, options?)`
50
+ Resolves the real path synchronously using native OS methods.
51
+ 使用原生作業系統方法同步解析實體路徑。
52
+
53
+ ### `fsRealpathNativeAsync(path, options?)`
54
+ Resolves the real path asynchronously using native OS methods.
55
+ 使用原生作業系統方法異步解析實體路徑。
56
+
57
+ ### `tryFsRealpathNativeSync(path, options?)`
58
+ Safely resolves the real path synchronously. Returns original path if not exists.
59
+ 安全地同步解析實體路徑。如果路徑不存在則返回原路徑。
60
+
61
+ ### `tryFsRealpathNativeAsync(path, options?)`
62
+ Safely resolves the real path asynchronously. Returns original path if not exists.
63
+ 安全地異步解析實體路徑。如果路徑不存在則返回原路徑。
64
+
package/index.d.ts CHANGED
@@ -1,15 +1,106 @@
1
+ /**
2
+ * fs-realpath-native - 檔案系統實體路徑處理
3
+ *
4
+ * 這個模組提供了檔案系統實體路徑處理的功能,包括同步和異步操作,以及錯誤處理。
5
+ *
6
+ * @module fs-realpath-native
7
+ * @author bluelovers
8
+ */
1
9
  import { BufferEncodingOption, EncodingOption, PathLike, realpathSync } from 'fs';
10
+ /** 同步解析實體路徑函數 */
2
11
  export declare const fsRealpathNativeSync: typeof realpathSync.native;
12
+ /**
13
+ * 異步解析實體路徑
14
+ *
15
+ * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。
16
+ *
17
+ * @param {PathLike} path 要解析的路徑
18
+ * @param {EncodingOption} [options] 編碼選項
19
+ * @returns {Promise<string>} Promise,解析為字串
20
+ */
3
21
  export declare function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;
22
+ /**
23
+ * 異步解析實體路徑
24
+ *
25
+ * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。
26
+ *
27
+ * @param {PathLike} path 要解析的路徑
28
+ * @param {BufferEncodingOption} options 編碼選項
29
+ * @returns {Promise<Buffer>} Promise,解析為緩衝區
30
+ */
4
31
  export declare function fsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
32
+ /**
33
+ * 異步解析實體路徑
34
+ *
35
+ * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。
36
+ *
37
+ * @param {PathLike} path 要解析的路徑
38
+ * @param {EncodingOption} [options] 編碼選項
39
+ * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區
40
+ */
5
41
  export declare function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
6
42
  /**
43
+ * 嘗試解析實體路徑(同步)
44
+ *
45
+ * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
46
+ *
47
+ * @param {PathLike} path 要解析的路徑
48
+ * @param {EncodingOption} [options] 編碼選項
49
+ * @returns {string} 解析後的路徑或原路徑
7
50
  * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts
8
51
  */
9
52
  export declare function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string;
53
+ /**
54
+ * 嘗試解析實體路徑(同步)
55
+ *
56
+ * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
57
+ *
58
+ * @param {PathLike} path 要解析的路徑
59
+ * @param {BufferEncodingOption} options 編碼選項
60
+ * @returns {Buffer} 解析後的路徑或原路徑
61
+ * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts
62
+ */
10
63
  export declare function tryFsRealpathNativeSync(path: PathLike, options: BufferEncodingOption): Buffer;
64
+ /**
65
+ * 嘗試解析實體路徑(同步)
66
+ *
67
+ * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
68
+ *
69
+ * @param {PathLike} path 要解析的路徑
70
+ * @param {EncodingOption} [options] 編碼選項
71
+ * @returns {string | Buffer} 解析後的路徑或原路徑
72
+ * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts
73
+ */
11
74
  export declare function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string | Buffer;
75
+ /**
76
+ * 嘗試解析實體路徑(異步)
77
+ *
78
+ * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
79
+ *
80
+ * @param {PathLike} path 要解析的路徑
81
+ * @param {EncodingOption} [options] 編碼選項
82
+ * @returns {Promise<string>} Promise,解析為字串
83
+ */
12
84
  export declare function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;
85
+ /**
86
+ * 嘗試解析實體路徑(異步)
87
+ *
88
+ * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
89
+ *
90
+ * @param {PathLike} path 要解析的路徑
91
+ * @param {BufferEncodingOption} options 編碼選項
92
+ * @returns {Promise<Buffer>} Promise,解析為緩衝區
93
+ */
13
94
  export declare function tryFsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
95
+ /**
96
+ * 嘗試解析實體路徑(異步)
97
+ *
98
+ * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
99
+ *
100
+ * @param {PathLike} path 要解析的路徑
101
+ * @param {EncodingOption} [options] 編碼選項
102
+ * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區
103
+ */
14
104
  export declare function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
105
+ /** 預設導出 - 嘗試解析實體路徑(同步)函數 */
15
106
  export default tryFsRealpathNativeSync;
package/index.js CHANGED
@@ -1,27 +1,70 @@
1
1
  "use strict";
2
+ /**
3
+ * fs-realpath-native - 檔案系統實體路徑處理
4
+ *
5
+ * 這個模組提供了檔案系統實體路徑處理的功能,包括同步和異步操作,以及錯誤處理。
6
+ *
7
+ * @module fs-realpath-native
8
+ * @author bluelovers
9
+ */
2
10
  Object.defineProperty(exports, "__esModule", { value: true });
3
11
  exports.fsRealpathNativeSync = void 0;
4
12
  exports.fsRealpathNativeAsync = fsRealpathNativeAsync;
5
13
  exports.tryFsRealpathNativeSync = tryFsRealpathNativeSync;
6
14
  exports.tryFsRealpathNativeAsync = tryFsRealpathNativeAsync;
7
15
  const fs_1 = require("fs");
16
+ /** 同步解析實體路徑函數 */
8
17
  exports.fsRealpathNativeSync = fs_1.realpathSync.native;
18
+ /**
19
+ * 異步解析實體路徑
20
+ *
21
+ * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。
22
+ *
23
+ * @param {PathLike} path 要解析的路徑
24
+ * @param {BufferEncodingOption | EncodingOption} [options] 編碼選項
25
+ * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區
26
+ */
9
27
  async function fsRealpathNativeAsync(path, options) {
28
+ // 使用同步函數來實現異步功能
10
29
  return (0, exports.fsRealpathNativeSync)(path, options);
11
30
  }
31
+ /**
32
+ * 嘗試解析實體路徑(同步)
33
+ *
34
+ * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
35
+ *
36
+ * @param {PathLike} path 要解析的路徑
37
+ * @param {BufferEncodingOption | EncodingOption} [options] 編碼選項
38
+ * @returns {string | Buffer} 解析後的路徑或原路徑
39
+ * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts
40
+ */
12
41
  function tryFsRealpathNativeSync(path, options) {
13
42
  try {
43
+ // 嘗試解析實體路徑
14
44
  path = fs_1.realpathSync.native(path, options);
15
45
  }
16
46
  catch (error) {
47
+ // 如果錯誤不是因為路徑不存在,則重新拋出錯誤
17
48
  if (error.code !== 'ENOENT') {
18
49
  throw error;
19
50
  }
20
51
  }
52
+ // 返回解析後的路徑或原路徑
21
53
  return path;
22
54
  }
55
+ /**
56
+ * 嘗試解析實體路徑(異步)
57
+ *
58
+ * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。
59
+ *
60
+ * @param {PathLike} path 要解析的路徑
61
+ * @param {BufferEncodingOption | EncodingOption} [options] 編碼選項
62
+ * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區
63
+ */
23
64
  async function tryFsRealpathNativeAsync(path, options) {
65
+ // 使用同步函數來實現異步功能
24
66
  return tryFsRealpathNativeSync(path, options);
25
67
  }
68
+ /** 預設導出 - 嘗試解析實體路徑(同步)函數 */
26
69
  exports.default = tryFsRealpathNativeSync;
27
70
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAOA,sDAKC;AAQD,0DAeC;AAKD,4DAGC;AA3CD,2BAAkF;AAErE,QAAA,oBAAoB,GAAG,iBAAY,CAAC,MAAM,CAAC;AAKjD,KAAK,UAAU,qBAAqB,CAAC,IAAc,EACzD,OAA+C;IAG/C,OAAO,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAc,CAAC,CAAA;AAClD,CAAC;AAQD,SAAgB,uBAAuB,CAAC,IAAc,EAAE,OAA+C;IAEtG,IACA,CAAC;QACA,IAAI,GAAG,iBAAY,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,KAAU,EACjB,CAAC;QACA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAC3B,CAAC;YACA,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,IAAW,CAAC;AACpB,CAAC;AAKM,KAAK,UAAU,wBAAwB,CAAC,IAAc,EAAE,OAA+C;IAE7G,OAAO,uBAAuB,CAAC,IAAI,EAAE,OAAc,CAAC,CAAA;AACrD,CAAC;AAED,kBAAe,uBAAuB,CAAA","sourcesContent":["import { BufferEncodingOption, EncodingOption, PathLike, realpathSync } from 'fs';\n\nexport const fsRealpathNativeSync = realpathSync.native;\n\nexport async function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;\nexport async function fsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;\nexport async function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;\nexport async function fsRealpathNativeAsync(path: PathLike,\n\toptions?: BufferEncodingOption | EncodingOption\n): Promise<string | Buffer>\n{\n\treturn fsRealpathNativeSync(path, options as any)\n}\n\n/**\n * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts\n */\nexport function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string;\nexport function tryFsRealpathNativeSync(path: PathLike, options: BufferEncodingOption): Buffer;\nexport function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string | Buffer;\nexport function tryFsRealpathNativeSync(path: PathLike, options?: BufferEncodingOption | EncodingOption): string | Buffer\n{\n\ttry\n\t{\n\t\tpath = realpathSync.native(path, options as any);\n\t}\n\tcatch (error: any)\n\t{\n\t\tif (error.code !== 'ENOENT')\n\t\t{\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\treturn path as any;\n}\n\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;\nexport async function tryFsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: BufferEncodingOption | EncodingOption): Promise<string | Buffer>\n{\n\treturn tryFsRealpathNativeSync(path, options as any)\n}\n\nexport default tryFsRealpathNativeSync\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA8CH,sDAMC;AA6CD,0DAkBC;AAyCD,4DAIC;AA9JD,2BAAkF;AAElF,iBAAiB;AACJ,QAAA,oBAAoB,GAAG,iBAAY,CAAC,MAAM,CAAC;AAgCxD;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CAAC,IAAc,EACzD,OAA+C;IAG/C,gBAAgB;IAChB,OAAO,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAc,CAAC,CAAA;AAClD,CAAC;AAmCD;;;;;;;;;GASG;AACH,SAAgB,uBAAuB,CAAC,IAAc,EAAE,OAA+C;IAEtG,IACA,CAAC;QACA,WAAW;QACX,IAAI,GAAG,iBAAY,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,KAAU,EACjB,CAAC;QACA,wBAAwB;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAC3B,CAAC;YACA,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED,eAAe;IACf,OAAO,IAAW,CAAC;AACpB,CAAC;AAgCD;;;;;;;;GAQG;AACI,KAAK,UAAU,wBAAwB,CAAC,IAAc,EAAE,OAA+C;IAE7G,gBAAgB;IAChB,OAAO,uBAAuB,CAAC,IAAI,EAAE,OAAc,CAAC,CAAA;AACrD,CAAC;AAED,4BAA4B;AAC5B,kBAAe,uBAAuB,CAAA","sourcesContent":["/**\n * fs-realpath-native - 檔案系統實體路徑處理\n * \n * 這個模組提供了檔案系統實體路徑處理的功能,包括同步和異步操作,以及錯誤處理。\n * \n * @module fs-realpath-native\n * @author bluelovers\n */\n\nimport { BufferEncodingOption, EncodingOption, PathLike, realpathSync } from 'fs';\n\n/** 同步解析實體路徑函數 */\nexport const fsRealpathNativeSync = realpathSync.native;\n\n/**\n * 異步解析實體路徑\n * \n * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {EncodingOption} [options] 編碼選項\n * @returns {Promise<string>} Promise,解析為字串\n */\nexport async function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;\n/**\n * 異步解析實體路徑\n * \n * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {BufferEncodingOption} options 編碼選項\n * @returns {Promise<Buffer>} Promise,解析為緩衝區\n */\nexport async function fsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;\n/**\n * 異步解析實體路徑\n * \n * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {EncodingOption} [options] 編碼選項\n * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區\n */\nexport async function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;\n/**\n * 異步解析實體路徑\n * \n * 這個函數會異步解析指定路徑的實體路徑,支援不同的編碼選項。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {BufferEncodingOption | EncodingOption} [options] 編碼選項\n * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區\n */\nexport async function fsRealpathNativeAsync(path: PathLike,\n\toptions?: BufferEncodingOption | EncodingOption\n): Promise<string | Buffer>\n{\n\t// 使用同步函數來實現異步功能\n\treturn fsRealpathNativeSync(path, options as any)\n}\n\n/**\n * 嘗試解析實體路徑(同步)\n * \n * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {EncodingOption} [options] 編碼選項\n * @returns {string} 解析後的路徑或原路徑\n * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts\n */\nexport function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string;\n/**\n * 嘗試解析實體路徑(同步)\n * \n * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {BufferEncodingOption} options 編碼選項\n * @returns {Buffer} 解析後的路徑或原路徑\n * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts\n */\nexport function tryFsRealpathNativeSync(path: PathLike, options: BufferEncodingOption): Buffer;\n/**\n * 嘗試解析實體路徑(同步)\n * \n * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {EncodingOption} [options] 編碼選項\n * @returns {string | Buffer} 解析後的路徑或原路徑\n * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts\n */\nexport function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string | Buffer;\n/**\n * 嘗試解析實體路徑(同步)\n * \n * 這個函數會嘗試解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {BufferEncodingOption | EncodingOption} [options] 編碼選項\n * @returns {string | Buffer} 解析後的路徑或原路徑\n * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts\n */\nexport function tryFsRealpathNativeSync(path: PathLike, options?: BufferEncodingOption | EncodingOption): string | Buffer\n{\n\ttry\n\t{\n\t\t// 嘗試解析實體路徑\n\t\tpath = realpathSync.native(path, options as any);\n\t}\n\tcatch (error: any)\n\t{\n\t\t// 如果錯誤不是因為路徑不存在,則重新拋出錯誤\n\t\tif (error.code !== 'ENOENT')\n\t\t{\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t// 返回解析後的路徑或原路徑\n\treturn path as any;\n}\n\n/**\n * 嘗試解析實體路徑(異步)\n * \n * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {EncodingOption} [options] 編碼選項\n * @returns {Promise<string>} Promise,解析為字串\n */\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;\n/**\n * 嘗試解析實體路徑(異步)\n * \n * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {BufferEncodingOption} options 編碼選項\n * @returns {Promise<Buffer>} Promise,解析為緩衝區\n */\nexport async function tryFsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;\n/**\n * 嘗試解析實體路徑(異步)\n * \n * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {EncodingOption} [options] 編碼選項\n * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區\n */\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;\n/**\n * 嘗試解析實體路徑(異步)\n * \n * 這個函數會嘗試異步解析指定路徑的實體路徑,如果路徑不存在則返回原路徑,不拋出錯誤。\n * \n * @param {PathLike} path 要解析的路徑\n * @param {BufferEncodingOption | EncodingOption} [options] 編碼選項\n * @returns {Promise<string | Buffer>} Promise,解析為字串或緩衝區\n */\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: BufferEncodingOption | EncodingOption): Promise<string | Buffer>\n{\n\t// 使用同步函數來實現異步功能\n\treturn tryFsRealpathNativeSync(path, options as any)\n}\n\n/** 預設導出 - 嘗試解析實體路徑(同步)函數 */\nexport default tryFsRealpathNativeSync\n\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fs-realpath-native",
3
- "version": "1.0.3",
4
- "description": "",
3
+ "version": "1.0.6",
4
+ "description": "File system real path resolution with sync/async operations and error handling / 檔案系統實體路徑處理,支援同步/異步操作和錯誤處理",
5
5
  "keywords": [
6
6
  "create-by-yarn-tool"
7
7
  ],
@@ -31,6 +31,7 @@
31
31
  "pretest": "echo pretest",
32
32
  "test": "jest --passWithNoTests",
33
33
  "test:jest": "jest --passWithNoTests",
34
+ "test:jest:coverage": "yarn run test:jest -- --coverage",
34
35
  "test:jest:snapshot": "yarn run test:jest -- -u",
35
36
  "test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
36
37
  "test:snapshot": "yarn run test -- -u",
@@ -61,6 +62,5 @@
61
62
  "sort-package-json": "yarn-tool sort",
62
63
  "tsc:showConfig": "ynpx get-current-tsconfig -p"
63
64
  },
64
- "packageManager": "yarn@1.22.19",
65
- "gitHead": "43bcf89adcf481e321b509f7510de10206e8030a"
65
+ "gitHead": "6c690c4123ff9db0f807fbc9a05f509a832aee69"
66
66
  }