fs-stream-sync 2.0.21 → 2.0.22

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,16 @@
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
+ ## [2.0.22](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.21...fs-stream-sync@2.0.22) (2026-03-02)
7
+
8
+
9
+
10
+ ### 📚 Documentation
11
+
12
+ * 為檔案系統相關套件新增雙語 JSDoc 註解與型別標註 ([83f3845](https://github.com/bluelovers/ws-iconv/commit/83f38456ccc0f5eca4f2a6505bee4caf7e634ba6))
13
+
14
+
15
+
6
16
  ## [2.0.21](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.20...fs-stream-sync@2.0.21) (2026-03-01)
7
17
 
8
18
  **Note:** Version bump only for package fs-stream-sync
package/index.d.ts CHANGED
@@ -1,8 +1,62 @@
1
+ /**
2
+ * fs-stream-sync - 檔案系統同步流處理模組
3
+ * File System Synchronous Stream Processing Module
4
+ *
5
+ * 提供同步檔案讀寫流功能,相容於 Node.js 核心 fs 模組
6
+ * Provides synchronous file read/write streams, compatible with Node.js core fs module
7
+ *
8
+ * @module fs-stream-sync
9
+ * @author bluelovers
10
+ */
1
11
  import { ReadStream, createReadStream } from './read';
2
12
  import { SyncReadStream, createSyncReadStream } from './read-sync';
3
13
  import { SyncWriteStream, createSyncWriteStream } from './write-sync';
4
14
  import { WriteStream, createWriteStream } from './write';
15
+ /**
16
+ * 重新導出介面類型
17
+ * Re-export interface types
18
+ */
5
19
  export { IFsReadStreamOptions, IFsWriteStreamOptions, PathLike } from './lib/interface';
6
- export { ReadStream, WriteStream, SyncReadStream, SyncWriteStream, createReadStream, createWriteStream, createSyncReadStream, createSyncWriteStream };
20
+ /**
21
+ * 導出所有流類別和建立函數
22
+ * Export all stream classes and factory functions
23
+ */
24
+ export {
25
+ /**
26
+ * 讀取流類別 / Read stream class
27
+ */
28
+ ReadStream,
29
+ /**
30
+ * 寫入流類別 / Write stream class
31
+ */
32
+ WriteStream,
33
+ /**
34
+ * 同步讀取流類別 / Synchronous read stream class
35
+ */
36
+ SyncReadStream,
37
+ /**
38
+ * 同步寫入流類別 / Synchronous write stream class
39
+ */
40
+ SyncWriteStream,
41
+ /**
42
+ * 建立讀取流 / Create read stream
43
+ */
44
+ createReadStream,
45
+ /**
46
+ * 建立寫入流 / Create write stream
47
+ */
48
+ createWriteStream,
49
+ /**
50
+ * 建立同步讀取流 / Create synchronous read stream
51
+ */
52
+ createSyncReadStream,
53
+ /**
54
+ * 建立同步寫入流 / Create synchronous write stream
55
+ */
56
+ createSyncWriteStream };
57
+ /**
58
+ * 預設導出 - 模組所有匯出內容
59
+ * Default export - all module exports
60
+ */
7
61
  declare const _default: typeof import("./index");
8
62
  export default _default;
package/index.js CHANGED
@@ -1,7 +1,17 @@
1
1
  "use strict";
2
- /// <reference types="node" />
2
+ /**
3
+ * fs-stream-sync - 檔案系統同步流處理模組
4
+ * File System Synchronous Stream Processing Module
5
+ *
6
+ * 提供同步檔案讀寫流功能,相容於 Node.js 核心 fs 模組
7
+ * Provides synchronous file read/write streams, compatible with Node.js core fs module
8
+ *
9
+ * @module fs-stream-sync
10
+ * @author bluelovers
11
+ */
3
12
  Object.defineProperty(exports, "__esModule", { value: true });
4
13
  exports.createSyncWriteStream = exports.createSyncReadStream = exports.createWriteStream = exports.createReadStream = exports.SyncWriteStream = exports.SyncReadStream = exports.WriteStream = exports.ReadStream = void 0;
14
+ /// <reference types="node" />
5
15
  const read_1 = require("./read");
6
16
  Object.defineProperty(exports, "ReadStream", { enumerable: true, get: function () { return read_1.ReadStream; } });
7
17
  Object.defineProperty(exports, "createReadStream", { enumerable: true, get: function () { return read_1.createReadStream; } });
@@ -14,5 +24,9 @@ Object.defineProperty(exports, "createSyncWriteStream", { enumerable: true, get:
14
24
  const write_1 = require("./write");
15
25
  Object.defineProperty(exports, "WriteStream", { enumerable: true, get: function () { return write_1.WriteStream; } });
16
26
  Object.defineProperty(exports, "createWriteStream", { enumerable: true, get: function () { return write_1.createWriteStream; } });
27
+ /**
28
+ * 預設導出 - 模組所有匯出內容
29
+ * Default export - all module exports
30
+ */
17
31
  exports.default = exports;
18
32
  //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,8BAA8B;AAE9B,iCAAsD;AAmBrD,2FAnBQ,iBAAU,OAmBR;AAiBV,iGApCoB,uBAAgB,OAoCpB;AAnCjB,2CAAmE;AA0BlE,+FA1BQ,0BAAc,OA0BR;AAiBd,qGA3CwB,gCAAoB,OA2CxB;AA1CrB,6CAAsE;AA6BrE,gGA7BQ,4BAAe,OA6BR;AAiBf,sGA9CyB,kCAAqB,OA8CzB;AA7CtB,mCAAyD;AAoBxD,4FApBQ,mBAAW,OAoBR;AAiBX,kGArCqB,yBAAiB,OAqCrB;AAWlB;;;GAGG;AACH,kBAAe,OAAmC,CAAC","sourcesContent":["/**\n * fs-stream-sync - 檔案系統同步流處理模組\n * File System Synchronous Stream Processing Module\n *\n * 提供同步檔案讀寫流功能,相容於 Node.js 核心 fs 模組\n * Provides synchronous file read/write streams, compatible with Node.js core fs module\n *\n * @module fs-stream-sync\n * @author bluelovers\n */\n\n/// <reference types=\"node\" />\n\nimport { ReadStream, createReadStream } from './read';\nimport { SyncReadStream, createSyncReadStream } from './read-sync';\nimport { SyncWriteStream, createSyncWriteStream } from './write-sync';\nimport { WriteStream, createWriteStream } from './write';\n\n/**\n * 重新導出介面類型\n * Re-export interface types\n */\nexport { IFsReadStreamOptions, IFsWriteStreamOptions, PathLike } from './lib/interface';\n\n/**\n * 導出所有流類別和建立函數\n * Export all stream classes and factory functions\n */\nexport {\n\t/**\n\t * 讀取流類別 / Read stream class\n\t */\n\tReadStream,\n\t/**\n\t * 寫入流類別 / Write stream class\n\t */\n\tWriteStream,\n\t/**\n\t * 同步讀取流類別 / Synchronous read stream class\n\t */\n\tSyncReadStream,\n\t/**\n\t * 同步寫入流類別 / Synchronous write stream class\n\t */\n\tSyncWriteStream,\n\n\t/**\n\t * 建立讀取流 / Create read stream\n\t */\n\tcreateReadStream,\n\t/**\n\t * 建立寫入流 / Create write stream\n\t */\n\tcreateWriteStream,\n\t/**\n\t * 建立同步讀取流 / Create synchronous read stream\n\t */\n\tcreateSyncReadStream,\n\t/**\n\t * 建立同步寫入流 / Create synchronous write stream\n\t */\n\tcreateSyncWriteStream\n}\n\n/**\n * 預設導出 - 模組所有匯出內容\n * Default export - all module exports\n */\nexport default exports as typeof import('./index');\n"]}
package/lib/errors.d.ts CHANGED
@@ -1,10 +1,56 @@
1
+ /**
2
+ * 檔案系統流錯誤處理
3
+ * File System Stream Error Handling
4
+ *
5
+ * 定義錯誤類型和錯誤碼列舉
6
+ * Defines error classes and error code enums
7
+ */
1
8
  import ErrnoException = NodeJS.ErrnoException;
9
+ /**
10
+ * Node.js 風格錯誤類別
11
+ * Node.js style error class
12
+ *
13
+ * 擴展 Error 類別,加入錯誤碼屬性
14
+ * Extends Error class with code property
15
+ */
2
16
  export declare class NodeLikeError extends Error {
17
+ /**
18
+ * 錯誤碼 / Error code
19
+ */
3
20
  code: string;
21
+ /**
22
+ * 構造函數
23
+ * Constructor
24
+ *
25
+ * @param {string} code - 錯誤碼 / Error code
26
+ * @param {string} [msg] - 錯誤訊息 / Error message
27
+ */
4
28
  constructor(code: string, msg?: any);
5
29
  }
30
+ /**
31
+ * 建立錯誤物件
32
+ * Create error object
33
+ *
34
+ * 使用指定的錯誤類別和錯誤碼建立錯誤物件
35
+ * Creates error object with specified error class and code
36
+ *
37
+ * @param {new (msg?) => T} Err - 錯誤類別 / Error class
38
+ * @param {string} code - 錯誤碼 / Error code
39
+ * @param {string} [msg] - 錯誤訊息 / Error message
40
+ * @returns {T} 錯誤物件 / Error object
41
+ */
6
42
  export declare function createError<T extends ErrnoException>(Err: new (msg?: any) => T, code: string, msg?: any): T;
43
+ /**
44
+ * 檔案流錯誤碼列舉
45
+ * File stream error code enum
46
+ */
7
47
  export declare enum EnumFsStreamErrorCode {
48
+ /**
49
+ * 寫入在結束後嘗試 / Write after end
50
+ */
8
51
  ERR_STREAM_WRITE_AFTER_END = "ERR_STREAM_WRITE_AFTER_END",
52
+ /**
53
+ * 流已銷毀 / Stream destroyed
54
+ */
9
55
  ERR_STREAM_DESTROYED = "ERR_STREAM_DESTROYED"
10
56
  }
package/lib/errors.js CHANGED
@@ -1,22 +1,65 @@
1
1
  "use strict";
2
+ /**
3
+ * 檔案系統流錯誤處理
4
+ * File System Stream Error Handling
5
+ *
6
+ * 定義錯誤類型和錯誤碼列舉
7
+ * Defines error classes and error code enums
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  exports.EnumFsStreamErrorCode = exports.NodeLikeError = void 0;
4
11
  exports.createError = createError;
12
+ /**
13
+ * Node.js 風格錯誤類別
14
+ * Node.js style error class
15
+ *
16
+ * 擴展 Error 類別,加入錯誤碼屬性
17
+ * Extends Error class with code property
18
+ */
5
19
  class NodeLikeError extends Error {
20
+ /**
21
+ * 構造函數
22
+ * Constructor
23
+ *
24
+ * @param {string} code - 錯誤碼 / Error code
25
+ * @param {string} [msg] - 錯誤訊息 / Error message
26
+ */
6
27
  constructor(code, msg) {
7
28
  super(msg);
8
29
  this.code = code;
9
30
  }
10
31
  }
11
32
  exports.NodeLikeError = NodeLikeError;
33
+ /**
34
+ * 建立錯誤物件
35
+ * Create error object
36
+ *
37
+ * 使用指定的錯誤類別和錯誤碼建立錯誤物件
38
+ * Creates error object with specified error class and code
39
+ *
40
+ * @param {new (msg?) => T} Err - 錯誤類別 / Error class
41
+ * @param {string} code - 錯誤碼 / Error code
42
+ * @param {string} [msg] - 錯誤訊息 / Error message
43
+ * @returns {T} 錯誤物件 / Error object
44
+ */
12
45
  function createError(Err, code, msg) {
13
46
  let e = new Err(msg);
14
47
  e.code = code;
15
48
  return e;
16
49
  }
50
+ /**
51
+ * 檔案流錯誤碼列舉
52
+ * File stream error code enum
53
+ */
17
54
  var EnumFsStreamErrorCode;
18
55
  (function (EnumFsStreamErrorCode) {
56
+ /**
57
+ * 寫入在結束後嘗試 / Write after end
58
+ */
19
59
  EnumFsStreamErrorCode["ERR_STREAM_WRITE_AFTER_END"] = "ERR_STREAM_WRITE_AFTER_END";
60
+ /**
61
+ * 流已銷毀 / Stream destroyed
62
+ */
20
63
  EnumFsStreamErrorCode["ERR_STREAM_DESTROYED"] = "ERR_STREAM_DESTROYED";
21
64
  })(EnumFsStreamErrorCode || (exports.EnumFsStreamErrorCode = EnumFsStreamErrorCode = {}));
22
65
  //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA4CH,kCAKC;AA7CD;;;;;;GAMG;AACH,MAAa,aAAc,SAAQ,KAAK;IAOvC;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,GAAI;QAE7B,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACjB,CAAC;CACD;AAnBD,sCAmBC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,WAAW,CAA2B,GAAoB,EAAE,IAAY,EAAE,GAAI;IAE7F,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC,CAAC,IAAI,GAAG,IAAI,CAAA;IACb,OAAO,CAAC,CAAA;AACT,CAAC;AAED;;;GAGG;AACH,IAAY,qBAUX;AAVD,WAAY,qBAAqB;IAEhC;;OAEG;IACH,kFAAyD,CAAA;IACzD;;OAEG;IACH,sEAA6C,CAAA;AAC9C,CAAC,EAVW,qBAAqB,qCAArB,qBAAqB,QAUhC","sourcesContent":["/**\n * 檔案系統流錯誤處理\n * File System Stream Error Handling\n *\n * 定義錯誤類型和錯誤碼列舉\n * Defines error classes and error code enums\n */\n\nimport ErrnoException = NodeJS.ErrnoException;\n\n/**\n * Node.js 風格錯誤類別\n * Node.js style error class\n *\n * 擴展 Error 類別,加入錯誤碼屬性\n * Extends Error class with code property\n */\nexport class NodeLikeError extends Error\n{\n\t/**\n\t * 錯誤碼 / Error code\n\t */\n\tpublic code: string\n\n\t/**\n\t * 構造函數\n\t * Constructor\n\t *\n\t * @param {string} code - 錯誤碼 / Error code\n\t * @param {string} [msg] - 錯誤訊息 / Error message\n\t */\n\tconstructor(code: string, msg?)\n\t{\n\t\tsuper(msg)\n\t\tthis.code = code\n\t}\n}\n\n/**\n * 建立錯誤物件\n * Create error object\n *\n * 使用指定的錯誤類別和錯誤碼建立錯誤物件\n * Creates error object with specified error class and code\n *\n * @param {new (msg?) => T} Err - 錯誤類別 / Error class\n * @param {string} code - 錯誤碼 / Error code\n * @param {string} [msg] - 錯誤訊息 / Error message\n * @returns {T} 錯誤物件 / Error object\n */\nexport function createError<T extends ErrnoException>(Err: new (msg?) => T, code: string, msg?)\n{\n\tlet e = new Err(msg)\n\te.code = code\n\treturn e\n}\n\n/**\n * 檔案流錯誤碼列舉\n * File stream error code enum\n */\nexport enum EnumFsStreamErrorCode\n{\n\t/**\n\t * 寫入在結束後嘗試 / Write after end\n\t */\n\tERR_STREAM_WRITE_AFTER_END = 'ERR_STREAM_WRITE_AFTER_END',\n\t/**\n\t * 流已銷毀 / Stream destroyed\n\t */\n\tERR_STREAM_DESTROYED = 'ERR_STREAM_DESTROYED',\n}\n\n"]}
@@ -1,51 +1,135 @@
1
+ /**
2
+ * 檔案系統流介面定義
3
+ * File System Stream Interface Definitions
4
+ *
5
+ * 定義了檔案讀寫流所需的類型與介面
6
+ * Defines types and interfaces for file read/write streams
7
+ */
1
8
  export type { PathLike } from 'fs';
9
+ /**
10
+ * 檔案路徑類型 - 支援字串或 Buffer
11
+ * File path type - supports string or Buffer
12
+ */
2
13
  export type IFsPath = string | Buffer;
14
+ /**
15
+ * 檔案流基礎選項介面
16
+ * File stream base options interface
17
+ */
3
18
  export interface IFsStreamOptions {
19
+ /**
20
+ * 檔案開啟標誌 / File open flags
21
+ * @example 'r' - 讀取, 'w' - 寫入, 'a' - 追加
22
+ */
4
23
  flags?: string;
5
24
  /**
25
+ * 編碼格式 / Encoding format
6
26
  * @default null
7
27
  */
8
28
  encoding?: string;
9
29
  /**
30
+ * 檔案描述符 / File descriptor
10
31
  * @default null
11
32
  */
12
33
  fd?: number;
13
34
  /**
35
+ * 檔案權限模式 / File permission mode
14
36
  * @default 0o666
15
37
  */
16
38
  mode?: number;
17
39
  /**
40
+ * 是否自動關閉 / Auto close flag
18
41
  * @default true
19
42
  */
20
43
  autoClose?: boolean;
44
+ /**
45
+ * 開始位置(位元組)/ Start position in bytes
46
+ */
21
47
  start?: number;
22
48
  }
49
+ /**
50
+ * 讀取流選項介面
51
+ * Read stream options interface
52
+ */
23
53
  export interface IFsReadStreamOptions extends IFsStreamOptions {
24
54
  /**
55
+ * 結束位置(位元組)/ End position in bytes
25
56
  * @default Infinity
26
57
  */
27
58
  end?: number;
28
59
  /**
60
+ * 高水位線(內部緩衝區大小)/ High water mark (internal buffer size)
29
61
  * @default 64 * 1024
30
62
  */
31
63
  highWaterMark?: number;
32
64
  }
65
+ /**
66
+ * 寫入流選項類型
67
+ * Write stream options type
68
+ */
33
69
  export type IFsWriteStreamOptions = IFsStreamOptions;
70
+ /**
71
+ * 流狀態介面
72
+ * Stream state interface
73
+ */
34
74
  export interface IFsStreamState {
75
+ /**
76
+ * 是否已銷毀 / Whether stream is destroyed
77
+ */
35
78
  destroyed: boolean;
79
+ /**
80
+ * 是否為同步模式 / Whether in sync mode
81
+ */
36
82
  sync: boolean;
37
83
  }
84
+ /**
85
+ * 檔案流介面
86
+ * File stream interface
87
+ */
38
88
  export interface IFsStream {
89
+ /**
90
+ * 自動關閉標誌 / Auto close flag
91
+ */
39
92
  autoClose: boolean;
93
+ /**
94
+ * 檔案開啟標誌 / File open flags
95
+ */
40
96
  flags: string;
97
+ /**
98
+ * 檔案描述符 / File descriptor
99
+ */
41
100
  fd: number;
101
+ /**
102
+ * 檔案權限模式 / File permission mode
103
+ */
42
104
  mode: number;
105
+ /**
106
+ * 當前位置 / Current position
107
+ */
43
108
  pos: number;
109
+ /**
110
+ * 是否已關閉 / Whether closed
111
+ */
44
112
  closed: boolean;
113
+ /**
114
+ * 是否已銷毀 / Whether destroyed
115
+ */
45
116
  destroyed: boolean;
117
+ /**
118
+ * 可寫狀態 / Writable state
119
+ */
46
120
  _writableState: IFsStreamState;
121
+ /**
122
+ * 可讀狀態 / Readable state
123
+ */
47
124
  _readableState: IFsStreamState;
48
125
  }
126
+ /**
127
+ * 流資料介面
128
+ * Stream data interface
129
+ */
49
130
  export interface IFsStreamData {
131
+ /**
132
+ * 是否已開啟 / Whether opened
133
+ */
50
134
  opened?: boolean;
51
135
  }
package/lib/interface.js CHANGED
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * 檔案系統流介面定義
4
+ * File System Stream Interface Definitions
5
+ *
6
+ * 定義了檔案讀寫流所需的類型與介面
7
+ * Defines types and interfaces for file read/write streams
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["interface.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG","sourcesContent":["/**\n * 檔案系統流介面定義\n * File System Stream Interface Definitions\n *\n * 定義了檔案讀寫流所需的類型與介面\n * Defines types and interfaces for file read/write streams\n */\n\nimport { URL } from \"url\";\nexport type { PathLike } from 'fs';\n\n/**\n * 檔案路徑類型 - 支援字串或 Buffer\n * File path type - supports string or Buffer\n */\nexport type IFsPath = string | Buffer\n\n/**\n * 檔案流基礎選項介面\n * File stream base options interface\n */\nexport interface IFsStreamOptions\n{\n\t/**\n\t * 檔案開啟標誌 / File open flags\n\t * @example 'r' - 讀取, 'w' - 寫入, 'a' - 追加\n\t */\n\tflags?: string;\n\t/**\n\t * 編碼格式 / Encoding format\n\t * @default null\n\t */\n\tencoding?: string;\n\t/**\n\t * 檔案描述符 / File descriptor\n\t * @default null\n\t */\n\tfd?: number;\n\t/**\n\t * 檔案權限模式 / File permission mode\n\t * @default 0o666\n\t */\n\tmode?: number;\n\t/**\n\t * 是否自動關閉 / Auto close flag\n\t * @default true\n\t */\n\tautoClose?: boolean;\n\t/**\n\t * 開始位置(位元組)/ Start position in bytes\n\t */\n\tstart?: number;\n}\n\n/**\n * 讀取流選項介面\n * Read stream options interface\n */\nexport interface IFsReadStreamOptions extends IFsStreamOptions\n{\n\t/**\n\t * 結束位置(位元組)/ End position in bytes\n\t * @default Infinity\n\t */\n\tend?: number;\n\t/**\n\t * 高水位線(內部緩衝區大小)/ High water mark (internal buffer size)\n\t * @default 64 * 1024\n\t */\n\thighWaterMark?: number;\n}\n\n/**\n * 寫入流選項類型\n * Write stream options type\n */\nexport type IFsWriteStreamOptions = IFsStreamOptions\n\n/**\n * 流狀態介面\n * Stream state interface\n */\nexport interface IFsStreamState\n{\n\t/**\n\t * 是否已銷毀 / Whether stream is destroyed\n\t */\n\tdestroyed: boolean,\n\t/**\n\t * 是否為同步模式 / Whether in sync mode\n\t */\n\tsync: boolean,\n}\n\n/**\n * 檔案流介面\n * File stream interface\n */\nexport interface IFsStream\n{\n\t/**\n\t * 自動關閉標誌 / Auto close flag\n\t */\n\tautoClose: boolean\n\t/**\n\t * 檔案開啟標誌 / File open flags\n\t */\n\tflags: string\n\t/**\n\t * 檔案描述符 / File descriptor\n\t */\n\tfd: number\n\t/**\n\t * 檔案權限模式 / File permission mode\n\t */\n\tmode: number\n\t/**\n\t * 當前位置 / Current position\n\t */\n\tpos: number\n\t/**\n\t * 是否已關閉 / Whether closed\n\t */\n\tclosed: boolean\n\t/**\n\t * 是否已銷毀 / Whether destroyed\n\t */\n\tdestroyed: boolean\n\n\t/**\n\t * 可寫狀態 / Writable state\n\t */\n\t_writableState: IFsStreamState\n\t/**\n\t * 可讀狀態 / Readable state\n\t */\n\t_readableState: IFsStreamState\n}\n\n/**\n * 流資料介面\n * Stream data interface\n */\nexport interface IFsStreamData\n{\n\t/**\n\t * 是否已開啟 / Whether opened\n\t */\n\topened?: boolean\n}\n"]}
package/lib/internal.d.ts CHANGED
@@ -1,17 +1,107 @@
1
+ /**
2
+ * 檔案系統流內部工具函數
3
+ * File System Stream Internal Utility Functions
4
+ *
5
+ * 提供開啟、關閉、銷毀流等核心功能
6
+ * Provides core functions for opening, closing, and destroying streams
7
+ */
1
8
  import { ReadStream } from '../read';
2
9
  import { WriteStream } from '../write';
3
10
  import { SyncReadStream } from '../read-sync';
4
11
  import { SyncWriteStream } from '../write-sync';
5
12
  import { IFsStreamData } from './interface';
6
13
  import fs from 'fs';
14
+ /**
15
+ * 流資料符號鍵 / Stream data symbol key
16
+ * 用於存取流的內部資料 / Used to access stream's internal data
17
+ */
7
18
  export declare const SYM_FS_STREAM_DATA: unique symbol;
19
+ /**
20
+ * 檔案流類型聯合 / File stream type union
21
+ */
8
22
  export type IThisFsStream = WriteStream | ReadStream | SyncWriteStream | SyncReadStream;
23
+ /**
24
+ * 開啟檔案流
25
+ * Open file stream
26
+ *
27
+ * 使用同步方式開啟檔案並發送相關事件
28
+ * Opens file synchronously and emits relevant events
29
+ *
30
+ * @param {IThisFsStream} thisArgv - 流實例 / Stream instance
31
+ * @param {any[]} [argv] - 額外參數 / Additional arguments
32
+ */
9
33
  export declare function open(thisArgv: IThisFsStream, argv?: any[]): void;
34
+ /**
35
+ * 發射錯誤事件
36
+ * Emit error event
37
+ *
38
+ * 關閉流並發射錯誤事件
39
+ * Closes stream and emits error event
40
+ *
41
+ * @param {IThisFsStream} thisArgv - 流實例 / Stream instance
42
+ * @param {T} e - 錯誤物件 / Error object
43
+ */
10
44
  export declare function _error_emit<T extends Error>(thisArgv: IThisFsStream, e: T): void;
45
+ /**
46
+ * 內部關閉函數
47
+ * Internal close function
48
+ *
49
+ * 根據 autoClose 設定決定是否銷毀流
50
+ * Destroys stream based on autoClose setting
51
+ *
52
+ * @param {IThisFsStream} thisArgv - 流實例 / Stream instance
53
+ */
11
54
  export declare function __close(thisArgv: IThisFsStream): void;
55
+ /**
56
+ * 錯誤回調處理
57
+ * Error callback handler
58
+ *
59
+ * 關閉流並執行錯誤回調
60
+ * Closes stream and executes error callback
61
+ *
62
+ * @param {IThisFsStream} thisArgv - 流實例 / Stream instance
63
+ * @param {T} e - 錯誤物件 / Error object
64
+ * @param {Function} callback - 回調函數 / Callback function
65
+ */
12
66
  export declare function _error_callback<T extends Error>(thisArgv: IThisFsStream, e: T, callback: Function): void;
67
+ /**
68
+ * 同步關閉檔案流
69
+ * Close file stream synchronously
70
+ *
71
+ * 同步關閉檔案描述符並發送關閉事件
72
+ * Closes file descriptor synchronously and emits close event
73
+ *
74
+ * @param {fs.WriteStream | fs.ReadStream | SyncWriteStream | SyncReadStream} stream - 流實例 / Stream instance
75
+ * @param {Function} cb - 回調函數 / Callback function
76
+ * @param {any} [err] - 錯誤物件 / Error object
77
+ */
13
78
  export declare function closeFsStreamSync(stream: fs.WriteStream | fs.ReadStream | SyncWriteStream | SyncReadStream, cb: Function, err?: any): void;
79
+ /**
80
+ * 銷毀流
81
+ * Destroy stream
82
+ *
83
+ * 處理流的銷毀邏輯,包括關閉檔案描述符
84
+ * Handles stream destruction logic including closing file descriptor
85
+ *
86
+ * @param {IThisFsStream} thisArgv - 流實例 / Stream instance
87
+ * @param {Error | null} error - 錯誤物件或 null / Error object or null
88
+ * @param {(error: Error | null) => void} callback - 完成回調 / Completion callback
89
+ */
14
90
  export declare function _destroy(thisArgv: IThisFsStream, error: Error | null, callback: (error: Error | null) => void): void;
91
+ /**
92
+ * 取得流資料
93
+ * Get stream data
94
+ *
95
+ * 取得或初始化流的內部資料物件
96
+ * Gets or initializes stream's internal data object
97
+ *
98
+ * @param {IThisFsStream} thisArgv - 流實例 / Stream instance
99
+ * @returns {IFsStreamData} 流資料物件 / Stream data object
100
+ */
15
101
  export declare function getFsStreamData(thisArgv: IThisFsStream): IFsStreamData;
102
+ /**
103
+ * 預設導出 - 內部模組
104
+ * Default export - internal module
105
+ */
16
106
  declare const _default: typeof import("./internal");
17
107
  export default _default;