fs-stream-sync 2.0.18 → 2.0.21

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
+ ## [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
+
8
+ **Note:** Version bump only for package fs-stream-sync
9
+
10
+
11
+
12
+
13
+
14
+ ## [2.0.20](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.19...fs-stream-sync@2.0.20) (2026-03-01)
15
+
16
+
17
+
18
+ ### 📚 Documentation
19
+
20
+ * 为多个包添加全面的 JSDoc 文档和 README 更新 ([0d149e8](https://github.com/bluelovers/ws-iconv/commit/0d149e856aa9b274aca7fd7562776860c9d00473))
21
+
22
+
23
+ ### ♻️ Chores
24
+
25
+ * Update jest config and add new files for testing ([f370583](https://github.com/bluelovers/ws-iconv/commit/f37058385c7bf24d3d0bc975c752f2f35cfe8356))
26
+
27
+
28
+
29
+ ## [2.0.19](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.18...fs-stream-sync@2.0.19) (2024-08-29)
30
+
31
+
32
+
33
+ ### 🛠 Build System
34
+
35
+ * update build ([263e72e](https://github.com/bluelovers/ws-iconv/commit/263e72e423867a305d52992f40543e2efd19a349))
36
+
37
+
38
+
6
39
  ## [2.0.18](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.17...fs-stream-sync@2.0.18) (2022-10-02)
7
40
 
8
41
 
package/README.md CHANGED
@@ -1,14 +1,43 @@
1
- # fs-stream-sync
1
+ # fs-stream-sync - 檔案系統流處理工具
2
2
 
3
- File System SyncWriteStream/SyncReadStream implementation from Node.js Core
3
+ 這個模組提供了檔案系統的同步和異步流處理功能,包括讀取和寫入流。
4
4
 
5
- ## install
5
+ ## 主要功能
6
6
 
7
- ```nodemon
7
+ - 同步和異步流處理
8
+ - 讀取和寫入流
9
+ - 完全相容於 Node.js 核心流
10
+ - 支援同步寫入流
11
+ - 跨平台相容性
12
+
13
+ ## 安裝 (Installation)
14
+
15
+ ```bash
16
+ # 使用 yarn / Using yarn
17
+ yarn add fs-stream-sync
18
+
19
+ # 使用 yarn-tool / Using yarn-tool
20
+ yarn-tool add fs-stream-sync
21
+ # yt 是 yarn-tool 的別名 / yt is an alias for yarn-tool
22
+ yt add fs-stream-sync
23
+
24
+ # 使用 pnpm / Using pnpm
25
+ pnpm add fs-stream-sync
26
+
27
+ # 使用 npm / Using npm
8
28
  npm install fs-stream-sync
9
29
  ```
10
30
 
11
- ## know issues
31
+ ## 已知問題
32
+
33
+ - 與 ReadStream/WriteStream 不完全相同
34
+ - 某些事件觸發不如預期
35
+ - 某些 API 仍為異步
36
+ - SyncWriteStream.write 無法追加
37
+
38
+ > 歡迎發送 PR,使這個模組更接近原始的 fs.stream
39
+
40
+ ## Known Issues (已知問題)
12
41
 
13
42
  - not 100% same as ReadStream/WriteStream
14
43
  - some event not trigger as expect
package/lib/errors.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import ErrnoException = NodeJS.ErrnoException;
3
2
  export declare class NodeLikeError extends Error {
4
3
  code: string;
package/lib/errors.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnumFsStreamErrorCode = exports.createError = exports.NodeLikeError = void 0;
3
+ exports.EnumFsStreamErrorCode = exports.NodeLikeError = void 0;
4
+ exports.createError = createError;
4
5
  class NodeLikeError extends Error {
5
6
  constructor(code, msg) {
6
7
  super(msg);
@@ -13,10 +14,9 @@ function createError(Err, code, msg) {
13
14
  e.code = code;
14
15
  return e;
15
16
  }
16
- exports.createError = createError;
17
17
  var EnumFsStreamErrorCode;
18
18
  (function (EnumFsStreamErrorCode) {
19
19
  EnumFsStreamErrorCode["ERR_STREAM_WRITE_AFTER_END"] = "ERR_STREAM_WRITE_AFTER_END";
20
20
  EnumFsStreamErrorCode["ERR_STREAM_DESTROYED"] = "ERR_STREAM_DESTROYED";
21
- })(EnumFsStreamErrorCode = exports.EnumFsStreamErrorCode || (exports.EnumFsStreamErrorCode = {}));
21
+ })(EnumFsStreamErrorCode || (exports.EnumFsStreamErrorCode = EnumFsStreamErrorCode = {}));
22
22
  //# sourceMappingURL=errors.js.map
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export type { PathLike } from 'fs';
3
2
  export type IFsPath = string | Buffer;
4
3
  export interface IFsStreamOptions {
package/lib/internal.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { ReadStream } from '../read';
3
2
  import { WriteStream } from '../write';
4
3
  import { SyncReadStream } from '../read-sync';
package/lib/internal.js CHANGED
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFsStreamData = exports._destroy = exports.closeFsStreamSync = exports._error_callback = exports.__close = exports._error_emit = exports.open = exports.SYM_FS_STREAM_DATA = void 0;
3
+ exports.SYM_FS_STREAM_DATA = void 0;
4
+ exports.open = open;
5
+ exports._error_emit = _error_emit;
6
+ exports.__close = __close;
7
+ exports._error_callback = _error_callback;
8
+ exports.closeFsStreamSync = closeFsStreamSync;
9
+ exports._destroy = _destroy;
10
+ exports.getFsStreamData = getFsStreamData;
4
11
  const fs_1 = require("fs");
5
12
  exports.SYM_FS_STREAM_DATA = Symbol('FsStreamData');
6
13
  function open(thisArgv, argv) {
@@ -19,24 +26,20 @@ function open(thisArgv, argv) {
19
26
  thisArgv.emit('open', thisArgv.fd);
20
27
  thisArgv.emit('ready');
21
28
  }
22
- exports.open = open;
23
29
  function _error_emit(thisArgv, e) {
24
30
  __close(thisArgv);
25
31
  thisArgv.emit('error', e);
26
32
  }
27
- exports._error_emit = _error_emit;
28
33
  function __close(thisArgv) {
29
34
  // @ts-ignore
30
35
  if (thisArgv.autoClose) {
31
36
  thisArgv.destroy();
32
37
  }
33
38
  }
34
- exports.__close = __close;
35
39
  function _error_callback(thisArgv, e, callback) {
36
40
  __close(thisArgv);
37
41
  callback(e);
38
42
  }
39
- exports._error_callback = _error_callback;
40
43
  function closeFsStreamSync(stream, cb, err) {
41
44
  let er;
42
45
  try {
@@ -53,7 +56,6 @@ function closeFsStreamSync(stream, cb, err) {
53
56
  stream.emit('close');
54
57
  }
55
58
  }
56
- exports.closeFsStreamSync = closeFsStreamSync;
57
59
  function _destroy(thisArgv, error, callback) {
58
60
  // @ts-ignore
59
61
  const isOpen = typeof thisArgv.fd !== 'number';
@@ -66,7 +68,6 @@ function _destroy(thisArgv, error, callback) {
66
68
  // @ts-ignore
67
69
  thisArgv.fd = null;
68
70
  }
69
- exports._destroy = _destroy;
70
71
  function emitErrorAndCloseNT(self, err) {
71
72
  emitErrorNT(self, err);
72
73
  emitCloseNT(self);
@@ -86,6 +87,5 @@ function emitErrorNT(self, err) {
86
87
  function getFsStreamData(thisArgv) {
87
88
  return thisArgv[exports.SYM_FS_STREAM_DATA] = thisArgv[exports.SYM_FS_STREAM_DATA] || {};
88
89
  }
89
- exports.getFsStreamData = getFsStreamData;
90
90
  exports.default = exports;
91
91
  //# sourceMappingURL=internal.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fs-stream-sync",
3
- "version": "2.0.18",
4
- "description": "File System SyncWriteStream/SyncReadStream implementation from Node.js Core",
3
+ "version": "2.0.21",
4
+ "description": "檔案系統同步讀寫流實作,相容於 Node.js Core fs 模組 (File System synchronous read/write stream implementation, compatible with Node.js Core fs module)",
5
5
  "keywords": [
6
6
  "File System",
7
7
  "ReadStream",
@@ -31,8 +31,10 @@
31
31
  "lib": "lib"
32
32
  },
33
33
  "scripts": {
34
+ "coverage": "yarn run test -- --coverage",
34
35
  "test": "echo \"Error: no test specified\"",
35
36
  "test:jest": "jest --passWithNoTests",
37
+ "test:jest:coverage": "yarn run test:jest -- --coverage",
36
38
  "test:jest:snapshot": "yarn run test:jest -- -u",
37
39
  "test:snapshot": "yarn run test -- -u",
38
40
  "test:tsd": "ynpx tsd",
@@ -41,11 +43,12 @@
41
43
  "prepublishOnly:check-bin": "ynpx --quiet @yarn-tool/check-pkg-bin",
42
44
  "prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
43
45
  "ncu": "ynpx --quiet yarn-tool -- ncu -u",
44
- "sort-package-json": "ynpx --quiet yarn-tool -- sort"
46
+ "sort-package-json": "ynpx --quiet yarn-tool -- sort",
47
+ "tsc:showConfig": "ynpx get-current-tsconfig -p"
45
48
  },
46
49
  "dependencies": {
47
50
  "@types/node": "*",
48
51
  "tslib": "^2"
49
52
  },
50
- "gitHead": "253aa6190c165c31a8e790065b05b19e627dea86"
53
+ "gitHead": "6bcfe6a585ad7e5657a40a5b0727c6281b564b60"
51
54
  }
package/read-sync.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PathLike } from "fs";
3
2
  import { IFsReadStreamOptions } from './lib/interface';
4
3
  import { ReadStream } from './read';
package/read-sync.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSyncReadStream = exports.SyncReadStream = exports.kMinPoolSpace = void 0;
3
+ exports.SyncReadStream = exports.kMinPoolSpace = void 0;
4
+ exports.createSyncReadStream = createSyncReadStream;
4
5
  const tslib_1 = require("tslib");
5
6
  const fs_1 = tslib_1.__importDefault(require("fs"));
6
7
  const internal_1 = require("./lib/internal");
@@ -105,6 +106,5 @@ exports.SyncReadStream = SyncReadStream;
105
106
  function createSyncReadStream(path, options) {
106
107
  return new SyncReadStream(path, options);
107
108
  }
108
- exports.createSyncReadStream = createSyncReadStream;
109
109
  exports.default = SyncReadStream;
110
110
  //# sourceMappingURL=read-sync.js.map
package/read.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PathLike } from "fs";
3
2
  import fs from 'fs';
4
3
  import { IFsReadStreamOptions, IFsStreamData, IFsStreamState, IFsWriteStreamOptions } from './lib/interface';
package/read.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createReadStream = exports.ReadStream = void 0;
3
+ exports.ReadStream = void 0;
4
+ exports.createReadStream = createReadStream;
4
5
  const tslib_1 = require("tslib");
5
6
  const fs_1 = tslib_1.__importDefault(require("fs"));
6
7
  const internal_1 = require("./lib/internal");
@@ -26,6 +27,5 @@ exports.ReadStream = ReadStream;
26
27
  function createReadStream(path, options) {
27
28
  return new ReadStream(path, options);
28
29
  }
29
- exports.createReadStream = createReadStream;
30
30
  exports.default = ReadStream;
31
31
  //# sourceMappingURL=read.js.map
package/write-sync.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { PathLike } from "fs";
4
2
  import { IFsWriteStreamOptions } from './lib/interface';
5
3
  import { WriteStream } from './write';
package/write-sync.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSyncWriteStream = exports.SyncWriteStream = void 0;
3
+ exports.SyncWriteStream = void 0;
4
+ exports.createSyncWriteStream = createSyncWriteStream;
4
5
  const tslib_1 = require("tslib");
5
6
  const fs_1 = tslib_1.__importDefault(require("fs"));
6
7
  const errors_1 = require("./lib/errors");
@@ -92,6 +93,5 @@ exports.SyncWriteStream = SyncWriteStream;
92
93
  function createSyncWriteStream(path, options) {
93
94
  return new SyncWriteStream(path, options);
94
95
  }
95
- exports.createSyncWriteStream = createSyncWriteStream;
96
96
  exports.default = SyncWriteStream;
97
97
  //# sourceMappingURL=write-sync.js.map
package/write.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import fs from "fs";
3
2
  import { PathLike } from 'fs';
4
3
  import { IFsPath, IFsStreamData, IFsStreamState, IFsWriteStreamOptions } from './lib/interface';
package/write.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWriteStream = exports.WriteStream = void 0;
3
+ exports.WriteStream = void 0;
4
+ exports.createWriteStream = createWriteStream;
4
5
  const tslib_1 = require("tslib");
5
6
  const fs_1 = tslib_1.__importDefault(require("fs"));
6
7
  const internal_1 = require("./lib/internal");
@@ -32,6 +33,5 @@ exports.WriteStream = WriteStream;
32
33
  function createWriteStream(path, options) {
33
34
  return new WriteStream(path, options);
34
35
  }
35
- exports.createWriteStream = createWriteStream;
36
36
  exports.default = WriteStream;
37
37
  //# sourceMappingURL=write.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,8BAA8B;;;AAE9B,iCAAsD;AAQrD,2FARQ,iBAAU,OAQR;AAGV,iGAXoB,uBAAgB,OAWpB;AAVjB,2CAAmE;AAQlE,+FARQ,0BAAc,OAQR;AAGd,qGAXwB,gCAAoB,OAWxB;AAVrB,6CAAsE;AAOrD,gGAPR,4BAAe,OAOQ;AAGT,sGAVG,kCAAqB,OAUH;AAT5C,mCAAyD;AAK5C,4FALJ,mBAAW,OAKI;AAGL,kGARG,yBAAiB,OAQH;AAIpC,kBAAe,OAAmC,CAAC","sourcesContent":["/// <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\nexport { IFsReadStreamOptions, IFsWriteStreamOptions, PathLike } from './lib/interface';\n\nexport {\n\tReadStream, WriteStream,\n\tSyncReadStream, SyncWriteStream,\n\n\tcreateReadStream, createWriteStream,\n\tcreateSyncReadStream, createSyncWriteStream\n}\n\nexport default exports as typeof import('./index');\n"]}
package/lib/errors.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAc,SAAQ,KAAK;IAIvC,YAAY,IAAY,EAAE,GAAI;QAE7B,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACjB,CAAC;CACD;AATD,sCASC;AAED,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;AALD,kCAKC;AAED,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAEhC,kFAAyD,CAAA;IACzD,sEAA6C,CAAA;AAC9C,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC","sourcesContent":["import ErrnoException = NodeJS.ErrnoException;\n\nexport class NodeLikeError extends Error\n{\n\tpublic code: string\n\n\tconstructor(code: string, msg?)\n\t{\n\t\tsuper(msg)\n\t\tthis.code = code\n\t}\n}\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\nexport enum EnumFsStreamErrorCode\n{\n\tERR_STREAM_WRITE_AFTER_END = 'ERR_STREAM_WRITE_AFTER_END',\n\tERR_STREAM_DESTROYED = 'ERR_STREAM_DESTROYED',\n}\n\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["interface.ts"],"names":[],"mappings":"","sourcesContent":["\nimport { URL } from \"url\";\nexport type { PathLike } from 'fs';\n\nexport type IFsPath = string | Buffer\n\nexport interface IFsStreamOptions\n{\n\tflags?: string;\n\t/**\n\t * @default null\n\t */\n\tencoding?: string;\n\t/**\n\t * @default null\n\t */\n\tfd?: number;\n\t/**\n\t * @default 0o666\n\t */\n\tmode?: number;\n\t/**\n\t * @default true\n\t */\n\tautoClose?: boolean;\n\tstart?: number;\n}\n\nexport interface IFsReadStreamOptions extends IFsStreamOptions\n{\n\t/**\n\t * @default Infinity\n\t */\n\tend?: number;\n\t/**\n\t * @default 64 * 1024\n\t */\n\thighWaterMark?: number;\n}\n\nexport type IFsWriteStreamOptions = IFsStreamOptions\n\nexport interface IFsStreamState\n{\n\tdestroyed: boolean,\n\tsync: boolean,\n}\n\nexport interface IFsStream\n{\n\tautoClose: boolean\n\tflags: string\n\tfd: number\n\tmode: number\n\tpos: number\n\tclosed: boolean\n\tdestroyed: boolean\n\n\t_writableState: IFsStreamState\n\t_readableState: IFsStreamState\n}\n\nexport interface IFsStreamData\n{\n\topened?: boolean\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":";;;AAMA,2BAA6C;AAEhC,QAAA,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA;AAIxD,SAAgB,IAAI,CAAC,QAAuB,EAAE,IAAY;IAEzD,IAAI,OAAO,QAAQ,CAAC,EAAE,KAAK,QAAQ,EACnC;QACC,IAAI,EAAU,CAAA;QACd,IACA;YACC,aAAa;YACb,EAAE,GAAG,IAAA,aAAQ,EAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;SAC3D;QACD,OAAO,EAAE,EACT;YACC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YACzB,OAAO;SACP;QAED,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;KACjB;IAED,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,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,CAAC;QAC/E,OAAO;KACP;IAED,iBAAiB,CAAC,QAAe,EAAE,QAAQ,CAAC,CAAA;IAC5C,aAAa;IACb,QAAQ,CAAC,EAAE,GAAG,IAAI,CAAC;AACpB,CAAC;AAfD,4BAeC;AAED,SAAS,mBAAmB,CAAC,IAAI,EAAE,GAAG;IAErC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACvB,WAAW,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,IAAI;IAExB,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,EACzD;QACC,OAAO;KACP;IACD,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,EACzD;QACC,OAAO;KACP;IACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,IAAI,EAAE,GAAG;IAE7B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAgB,eAAe,CAAC,QAAuB;IAEtD,OAAO,QAAQ,CAAC,0BAAkB,CAAC,GAAG,QAAQ,CAAC,0BAAkB,CAAC,IAAI,EAAE,CAAA;AACzE,CAAC;AAHD,0CAGC;AAED,kBAAe,OAAsC,CAAC","sourcesContent":["\nimport { ReadStream } from '../read';\nimport { WriteStream } from '../write';\nimport { SyncReadStream } from '../read-sync';\nimport { SyncWriteStream } from '../write-sync';\nimport { IFsStreamData } from './interface';\nimport fs, { openSync, closeSync } from 'fs';\n\nexport const SYM_FS_STREAM_DATA = Symbol('FsStreamData')\n\nexport type IThisFsStream = WriteStream | ReadStream | SyncWriteStream | SyncReadStream\n\nexport function open(thisArgv: IThisFsStream, argv?: any[])\n{\n\tif (typeof thisArgv.fd !== 'number')\n\t{\n\t\tlet fd: number\n\t\ttry\n\t\t{\n\t\t\t// @ts-ignore\n\t\t\tfd = openSync(thisArgv.path, thisArgv.flags, thisArgv.mode)\n\t\t}\n\t\tcatch (er)\n\t\t{\n\t\t\t_error_emit(thisArgv, er)\n\t\t\treturn;\n\t\t}\n\n\t\tthisArgv.fd = fd;\n\t}\n\n\tthisArgv.emit('open', thisArgv.fd);\n\tthisArgv.emit('ready');\n}\n\nexport function _error_emit<T extends Error>(thisArgv: IThisFsStream, e: T): void\n{\n\t__close(thisArgv)\n\tthisArgv.emit('error', e);\n}\n\nexport function __close(thisArgv: IThisFsStream): void\n{\n\t// @ts-ignore\n\tif (thisArgv.autoClose)\n\t{\n\t\tthisArgv.destroy();\n\t}\n}\n\nexport function _error_callback<T extends Error>(thisArgv: IThisFsStream, e: T, callback: Function): void\n{\n\t__close(thisArgv)\n\tcallback(e);\n}\n\nexport function closeFsStreamSync(stream: fs.WriteStream | fs.ReadStream | SyncWriteStream | SyncReadStream,\n\tcb: Function,\n\terr?,\n)\n{\n\tlet er\n\ttry\n\t{\n\t\t// @ts-ignore\n\t\tcloseSync(stream.fd)\n\t}\n\tcatch (e)\n\t{\n\t\ter = e || err;\n\t}\n\n\tcb(er)\n\t// @ts-ignore\n\tstream.closed = true;\n\tif (!er)\n\t{\n\t\tstream.emit('close');\n\t}\n}\n\nexport function _destroy(thisArgv: IThisFsStream, error: Error | null, callback: (error: Error | null) => void): void\n{\n\t// @ts-ignore\n\tconst isOpen = typeof thisArgv.fd !== 'number';\n\n\tif (isOpen)\n\t{\n\t\t// @ts-ignore\n\t\tthisArgv.once('open', closeFsStreamSync.bind(null, thisArgv, callback, error));\n\t\treturn;\n\t}\n\n\tcloseFsStreamSync(thisArgv as any, callback)\n\t// @ts-ignore\n\tthisArgv.fd = null;\n}\n\nfunction emitErrorAndCloseNT(self, err)\n{\n\temitErrorNT(self, err);\n\temitCloseNT(self);\n}\n\nfunction emitCloseNT(self)\n{\n\tif (self._writableState && !self._writableState.emitClose)\n\t{\n\t\treturn;\n\t}\n\tif (self._readableState && !self._readableState.emitClose)\n\t{\n\t\treturn;\n\t}\n\tself.emit('close');\n}\n\nfunction emitErrorNT(self, err)\n{\n\tself.emit('error', err);\n}\n\nexport function getFsStreamData(thisArgv: IThisFsStream): IFsStreamData\n{\n\treturn thisArgv[SYM_FS_STREAM_DATA] = thisArgv[SYM_FS_STREAM_DATA] || {}\n}\n\nexport default exports as typeof import('./internal');\n"]}
package/lib/util.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":"","sourcesContent":[""]}
package/read-sync.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-sync.js","sourceRoot":"","sources":["read-sync.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAGpB,6CAAqE;AACrE,sEAAsC;AACtC,iCAAmC;AAEtB,QAAA,aAAa,GAAG,GAAG,CAAC;AACjC,IAAI,IAAI,CAAC;AACT,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,SAAS,YAAY,CAAC,QAAgB;IAErC,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAC5B;QACC,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;KAC3B;SAED;QACC,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;KACpC;IACD,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;AACf,CAAC;AAED,MAAa,cAAe,SAAQ,iBAAU;IAE7C,YAAY,IAAc,EAAE,OAAuC;QAElE,aAAa;QACb,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACrB,CAAC;IAED,MAAM,KAAK,MAAM;QAEhB,OAAO,oBAAoB,CAAA;IAC5B,CAAC;IAED,IAAI;QAEH,IAAI,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,KAAK,SAAS,EAC9C;YACC,IAAI,CAAC,6BAAkB,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;YACtC,kBAAQ,CAAC,IAAI,CAAC,IAA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AI,IAAI,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,KAAmB,EAAE,QAAuC;QAEpE,kBAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACzC,CAAC;CACD;AAtHD,wCAsHC;AAED,SAAgB,oBAAoB,CAAC,IAAc,EAAE,OAAuC;IAE3F,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC;AAHD,oDAGC;AAED,kBAAe,cAAc,CAAA","sourcesContent":["import fs from 'fs';\nimport { PathLike } from \"fs\";\nimport { IFsReadStreamOptions } from './lib/interface';\nimport { getFsStreamData, SYM_FS_STREAM_DATA } from './lib/internal';\nimport internal from \"./lib/internal\";\nimport { ReadStream } from './read'\n\nexport const kMinPoolSpace = 128;\nlet pool;\nconst poolFragments = [];\n\nfunction allocNewPool(poolSize: number)\n{\n\tif (poolFragments.length > 0)\n\t{\n\t\tpool = poolFragments.pop();\n\t}\n\telse\n\t{\n\t\tpool = Buffer.allocUnsafe(poolSize);\n\t}\n\tpool.used = 0;\n}\n\nexport class SyncReadStream extends ReadStream\n{\n\tconstructor(path: PathLike, options?: string | IFsReadStreamOptions)\n\t{\n\t\t// @ts-ignore\n\t\tsuper(path, options)\n\t}\n\n\tstatic get create()\n\t{\n\t\treturn createSyncReadStream\n\t}\n\n\topen(): void\n\t{\n\t\tif (typeof getFsStreamData(this) !== 'boolean')\n\t\t{\n\t\t\tthis[SYM_FS_STREAM_DATA].opened = true\n\t\t\tinternal.open(this)\n\t\t\tthis.read();\n\t\t}\n\t\telse if (this[SYM_FS_STREAM_DATA].opened === true)\n\t\t{\n\t\t\tthis[SYM_FS_STREAM_DATA].opened = false\n\t\t\tthis.emit('open', this.fd);\n\t\t\tthis.emit('ready');\n\t\t}\n\t}\n\n\t_read(n: number)\n\t{\n\t\tif (typeof this.fd !== 'number')\n\t\t{\n\t\t\treturn this.once('open', function ()\n\t\t\t{\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis._read(n);\n\t\t\t});\n\t\t}\n\n\t\tif (this.destroyed)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif (!pool || pool.length - pool.used < kMinPoolSpace)\n\t\t{\n\t\t\t// discard the old pool.\n\t\t\tallocNewPool(this.readableHighWaterMark);\n\t\t}\n\n\t\tconst thisPool = pool;\n\t\tlet toRead = Math.min(pool.length - pool.used, n);\n\t\tconst start = pool.used;\n\n\t\tif (this.pos !== undefined)\n\t\t{\n\t\t\ttoRead = Math.min(this.end - this.pos + 1, toRead);\n\t\t}\n\t\telse\n\t\t{\n\t\t\ttoRead = Math.min(this.end - this.bytesRead + 1, toRead);\n\t\t}\n\n\t\t// already read everything we were supposed to read!\n\t\t// treat as EOF.\n\t\tif (toRead <= 0)\n\t\t{\n\t\t\treturn this.push(null);\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\t// the actual read.\n\t\t\tlet bytesRead = fs.readSync(this.fd, pool, pool.used, toRead, this.pos);\n\n\t\t\tlet b = null;\n\t\t\t// Now that we know how much data we have actually read, re-wind the\n\t\t\t// 'used' field if we can, and otherwise allow the remainder of our\n\t\t\t// reservation to be used as a new pool later.\n\t\t\tif (start + toRead === thisPool.used && thisPool === pool)\n\t\t\t{\n\t\t\t\tthisPool.used += bytesRead - toRead;\n\t\t\t}\n\t\t\telse if (toRead - bytesRead > kMinPoolSpace)\n\t\t\t{\n\t\t\t\tpoolFragments.push(thisPool.slice(start + bytesRead, start + toRead));\n\t\t\t}\n\n\t\t\tif (bytesRead > 0)\n\t\t\t{\n\t\t\t\tthis.bytesRead += bytesRead;\n\t\t\t\tb = thisPool.slice(start, start + bytesRead);\n\t\t\t}\n\n\t\t\tthis.push(b);\n\t\t}\n\t\tcatch (er)\n\t\t{\n\t\t\tif (this.autoClose)\n\t\t\t{\n\t\t\t\tthis.destroy();\n\t\t\t}\n\t\t\tthis.emit('error', er);\n\t\t}\n\n\t\t// move the pool positions, and internal position for reading.\n\t\tif (this.pos !== undefined)\n\t\t{\n\t\t\tthis.pos += toRead;\n\t\t}\n\t\tpool.used += toRead;\n\t}\n\n\t_destroy(error: Error | null, callback: (error: Error | null) => void): void\n\t{\n\t\tinternal._destroy(this, error, callback)\n\t}\n}\n\nexport function createSyncReadStream(path: PathLike, options?: string | IFsReadStreamOptions)\n{\n\treturn new SyncReadStream(path, options)\n}\n\nexport default SyncReadStream\n"]}
package/read.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["read.ts"],"names":[],"mappings":";;;;AACA,oDAAoB;AAEpB,6CAAqE;AAErE,aAAa;AACb,MAAa,UAAW,SAAQ,YAAE,CAAC,UAAU;IAiB5C,YAAY,IAAc,EAAE,OAAwC;QAEnE,aAAa;QACb,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAEpB,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IAED,MAAM,KAAK,MAAM;QAEhB,OAAO,gBAAgB,CAAA;IACxB,CAAC;IAED,IAAI;QAEH,IAAI,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,KAAK,SAAS,EAC9C;YACC,IAAI,CAAC,6BAAkB,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;YACtC,aAAa;YACb,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACvC;IACF,CAAC;CACD;AAvCD,gCAuCC;AAED,SAAgB,gBAAgB,CAAC,IAAc,EAAE,OAAuC;IAEvF,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC;AAHD,4CAGC;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { PathLike } from \"fs\";\nimport fs from 'fs';\nimport { IFsReadStreamOptions, IFsStreamData, IFsStreamState, IFsWriteStreamOptions } from './lib/interface';\nimport { getFsStreamData, SYM_FS_STREAM_DATA } from './lib/internal';\n\n// @ts-ignore\nexport class ReadStream extends fs.ReadStream\n{\n\tprotected autoClose: boolean\n\tprotected flags: string\n\tfd: number\n\tprotected mode: number\n\tprotected pos: number\n\tprotected closed: boolean\n\tprotected destroyed: boolean\n\n\tprotected _writableState: IFsStreamState\n\tprotected _readableState: IFsStreamState\n\n\tprotected [SYM_FS_STREAM_DATA]: IFsStreamData\n\n\tprotected end: number\n\n\tconstructor(path: PathLike, options?: string | IFsWriteStreamOptions)\n\t{\n\t\t// @ts-ignore\n\t\tsuper(path, options)\n\n\t\tgetFsStreamData(this)\n\t}\n\n\tstatic get create()\n\t{\n\t\treturn createReadStream\n\t}\n\n\topen()\n\t{\n\t\tif (typeof getFsStreamData(this) !== 'boolean')\n\t\t{\n\t\t\tthis[SYM_FS_STREAM_DATA].opened = true\n\t\t\t// @ts-ignore\n\t\t\tfs.ReadStream.prototype.open.call(this)\n\t\t}\n\t}\n}\n\nexport function createReadStream(path: PathLike, options?: string | IFsReadStreamOptions)\n{\n\treturn new ReadStream(path, options)\n}\n\nexport default ReadStream\n"]}
package/write-sync.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"write-sync.js","sourceRoot":"","sources":["write-sync.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;AAEb,oDAAoB;AAEpB,yCAAoE;AASpE,6CAAqE;AACrE,sEAAsC;AACtC,mCAAqC;AAErC,MAAa,eAAgB,SAAQ,mBAAW;IAE/C,YAAY,IAAc,EAAE,OAAwC;QAEnE,aAAa;QACb,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACrB,CAAC;IAED,MAAM,KAAK,MAAM;QAEhB,OAAO,qBAAqB,CAAA;IAC7B,CAAC;IAED,IAAI;QAEH,IAAI,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,KAAK,SAAS,EAC9C;YACC,IAAI,CAAC,6BAAkB,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;YACtC,kBAAQ,CAAC,IAAI,CAA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YAAY,IAAI,KAAK,CAAC;SAC3B;QACD,OAAO,CAAC,EACR;YACC,kBAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;SAC3C;QAED,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAC1B;YACC,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC;SACzB;IACF,CAAC;IAED,KAAK,CAAC,EAAa;QAElB,IAAI,EAAE,EACN;YACC,IAAI,IAAI,CAAC,MAAM,EACf;gBACC,EAAE,EAAE,CAAC;gBACL,OAAO;aACP;iBAED;gBACC,aAAa;gBACb,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;aACrB;SACD;QAED,4CAA4C;QAC5C,uBAAuB;QACvB,IAAI,CAAC,IAAI,CAAC,SAAS,EACnB;YACC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;QAED,+CAA+C;QAC/C,6CAA6C;QAC7C,IAAI,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC;IAED,QAAQ,CAAC,KAAmB,EAAE,QAAuC;QAEpE,kBAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACzC,CAAC;CACD;AAvHD,0CAuHC;AAED,SAAgB,qBAAqB,CAAC,IAAc,EAAE,OAAwC;IAE7F,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AAC1C,CAAC;AAHD,sDAGC;AAED,kBAAe,eAAe,CAAA","sourcesContent":["'use strict';\n\nimport fs from \"fs\";\nimport { PathLike } from \"fs\";\nimport { EnumFsStreamErrorCode, NodeLikeError } from './lib/errors';\nimport {\n\tIFsStream,\n\tIFsStreamState,\n\tIFsStreamOptions,\n\tIFsWriteStreamOptions,\n\tIFsStreamData,\n\tIFsPath,\n} from './lib/interface';\nimport { getFsStreamData, SYM_FS_STREAM_DATA } from './lib/internal';\nimport internal from \"./lib/internal\";\nimport { WriteStream } from './write'\n\nexport class SyncWriteStream extends WriteStream\n{\n\tconstructor(path: PathLike, options?: string | IFsWriteStreamOptions)\n\t{\n\t\t// @ts-ignore\n\t\tsuper(path, options)\n\t}\n\n\tstatic get create()\n\t{\n\t\treturn createSyncWriteStream\n\t}\n\n\topen(): void\n\t{\n\t\tif (typeof getFsStreamData(this) !== 'boolean')\n\t\t{\n\t\t\tthis[SYM_FS_STREAM_DATA].opened = true\n\t\t\tinternal.open(this)\n\t\t}\n\t\telse if (this[SYM_FS_STREAM_DATA].opened === true)\n\t\t{\n\t\t\tthis[SYM_FS_STREAM_DATA].opened = false\n\t\t\tthis.emit('open', this.fd);\n\t\t\tthis.emit('ready');\n\t\t}\n\t}\n\n\twrite(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;\n\twrite(chunk: any, encoding?: string, cb?: (error: Error | null | undefined) => void): boolean;\n\twrite(chunk: any, ...argv)\n\t{\n\t\t/*\n\t\tif (this.closed)\n\t\t{\n\t\t\tthrow new NodeLikeError(EnumFsStreamErrorCode.ERR_STREAM_WRITE_AFTER_END, `write after end`)\n\t\t}\n\t\t*/\n\t\tif (this._writableState.destroyed)\n\t\t{\n\t\t\tthrow new NodeLikeError(EnumFsStreamErrorCode.ERR_STREAM_DESTROYED, `Cannot call write after a stream was destroyed`)\n\t\t}\n\n\t\t//console.dir({chunk,argv} );\n\n\t\treturn super.write(chunk, ...argv)\n\t}\n\n\t/**\n\t * @fixme a unknow bug make stream.write only run once\n\t */\n\t_write(chunk: Buffer, encoding: string, callback: Function)\n\t{\n\t\tlet self = this\n\n\t\t//console.dir({chunk, encoding, callback} );\n\n\t\tif (!(chunk instanceof Buffer))\n\t\t{\n\t\t\treturn this.emit('error', new Error('Invalid data'));\n\t\t}\n\n\t\tif (typeof this.fd !== 'number')\n\t\t{\n\t\t\treturn this.once('open', function ()\n\t\t\t{\n\t\t\t\tself._write(chunk, encoding, callback);\n\t\t\t});\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tlet bytes = fs.writeSync(this.fd, chunk, 0, chunk.length, this.pos);\n\n\t\t\tthis.bytesWritten += bytes;\n\t\t}\n\t\tcatch (e)\n\t\t{\n\t\t\tinternal._error_callback(this, e, callback)\n\t\t}\n\n\t\tif (this.pos !== undefined)\n\t\t{\n\t\t\tthis.pos += chunk.length;\n\t\t}\n\t}\n\n\tclose(cb?: Function)\n\t{\n\t\tif (cb)\n\t\t{\n\t\t\tif (this.closed)\n\t\t\t{\n\t\t\t\tcb();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.on('close', cb);\n\t\t\t}\n\t\t}\n\n\t\t// If we are not autoClosing, we should call\n\t\t// destroy on 'finish'.\n\t\tif (!this.autoClose)\n\t\t{\n\t\t\tthis.on('finish', this.destroy.bind(this));\n\t\t}\n\n\t\t// we use end() instead of destroy() because of\n\t\t// https://github.com/nodejs/node/issues/2006\n\t\tthis.end();\n\t}\n\n\t_destroy(error: Error | null, callback: (error: Error | null) => void): void\n\t{\n\t\tinternal._destroy(this, error, callback)\n\t}\n}\n\nexport function createSyncWriteStream(path: PathLike, options?: string | IFsWriteStreamOptions)\n{\n\treturn new SyncWriteStream(path, options)\n}\n\nexport default SyncWriteStream\n"]}
package/write.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.js","sourceRoot":"","sources":["write.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAGpB,6CAAqE;AAErE,aAAa;AACb,MAAa,WAAY,SAAQ,YAAE,CAAC,WAAW;IAyB9C,YAAY,IAAc,EAAE,OAAwC;QAEnE,aAAa;QACb,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAEpB,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IAED,MAAM,KAAK,MAAM;QAEhB,OAAO,iBAAiB,CAAA;IACzB,CAAC;IAED,IAAI;QAEH,IAAI,CAAC,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAC,MAAM,EACjC;YACC,MAAM,IAAI,GAAG,IAAI,CAAA;YAEjB,IAAI,CAAC,6BAAkB,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;YAEtC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAEjB,OAAO,CAAC,QAAQ,CAAC;oBAEhB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACnB,CAAC,CAAC,CAAA;YACH,CAAC,CAAC,CAAA;YACF,aAAa;YACb,YAAE,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACxC;IACF,CAAC;CAED;AA1DD,kCA0DC;AAED,SAAgB,iBAAiB,CAAC,IAAc,EAAE,OAAwC;IAEzF,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACtC,CAAC;AAHD,8CAGC;AAED,kBAAe,WAAW,CAAA","sourcesContent":["import fs from \"fs\";\nimport { PathLike } from 'fs';\nimport { IFsPath, IFsStreamData, IFsStreamState, IFsWriteStreamOptions } from './lib/interface';\nimport { getFsStreamData, SYM_FS_STREAM_DATA } from './lib/internal';\n\n// @ts-ignore\nexport class WriteStream extends fs.WriteStream\n{\n\tprotected autoClose: boolean\n\tprotected flags: string\n\tfd: number\n\tprotected mode: number\n\tprotected pos: number\n\tprotected closed: boolean\n\tprotected destroyed: boolean\n\n\tprotected _writableState: IFsStreamState\n\tprotected _readableState: IFsStreamState\n\n\tprotected [SYM_FS_STREAM_DATA]: IFsStreamData\n\n\t/**\n\t * The number of bytes written so far. Does not include data that is still queued for writing.\n\t */\n\tpublic bytesWritten: number\n\n\t/**\n\t * The path to the file the stream is writing to as specified in the first argument to fs.createWriteStream(). If path is passed as a string, then writeStream.path will be a string. If path is passed as a Buffer, then writeStream.path will be a Buffer.\n\t */\n\tpublic readonly path: IFsPath\n\n\tconstructor(path: PathLike, options?: string | IFsWriteStreamOptions)\n\t{\n\t\t// @ts-ignore\n\t\tsuper(path, options)\n\n\t\tgetFsStreamData(this)\n\t}\n\n\tstatic get create()\n\t{\n\t\treturn createWriteStream\n\t}\n\n\topen()\n\t{\n\t\tif (!getFsStreamData(this).opened)\n\t\t{\n\t\t\tconst self = this\n\n\t\t\tthis[SYM_FS_STREAM_DATA].opened = true\n\n\t\t\tthis.once('open', function ()\n\t\t\t{\n\t\t\t\tprocess.nextTick(function ()\n\t\t\t\t{\n\t\t\t\t\tself.emit('ready')\n\t\t\t\t})\n\t\t\t})\n\t\t\t// @ts-ignore\n\t\t\tfs.WriteStream.prototype.open.call(this)\n\t\t}\n\t}\n\n}\n\nexport function createWriteStream(path: PathLike, options?: string | IFsWriteStreamOptions)\n{\n\treturn new WriteStream(path, options)\n}\n\nexport default WriteStream\n"]}