fs-stream-sync 2.0.5 → 2.0.11
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 +91 -0
- package/package.json +4 -4
- package/read-sync.js +2 -2
- package/read-sync.js.map +1 -1
- package/read.js +1 -1
- package/read.js.map +1 -1
- package/write-sync.d.ts +1 -0
- package/write-sync.js +2 -2
- package/write-sync.js.map +1 -1
- package/write.js +1 -1
- package/write.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,97 @@
|
|
|
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.11](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.9...fs-stream-sync@2.0.11) (2022-05-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ♻️ Chores
|
|
10
|
+
|
|
11
|
+
* update deps ([8874ec0](https://github.com/bluelovers/ws-iconv/commit/8874ec0576dc65e55d6710c61a1dc67e3142fa8f))
|
|
12
|
+
* update deps ([c039e94](https://github.com/bluelovers/ws-iconv/commit/c039e942f8562c9fdbba4e8d50c19afc20cc687f))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 🔖 Miscellaneous
|
|
16
|
+
|
|
17
|
+
* . ([4c58dc2](https://github.com/bluelovers/ws-iconv/commit/4c58dc215688d2bab1fb69a3c63eae6a9ad3a683))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [2.0.10](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.9...fs-stream-sync@2.0.10) (2022-05-11)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### ♻️ Chores
|
|
27
|
+
|
|
28
|
+
* update deps ([8874ec0](https://github.com/bluelovers/ws-iconv/commit/8874ec0576dc65e55d6710c61a1dc67e3142fa8f))
|
|
29
|
+
* update deps ([c039e94](https://github.com/bluelovers/ws-iconv/commit/c039e942f8562c9fdbba4e8d50c19afc20cc687f))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## [2.0.9](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.6...fs-stream-sync@2.0.9) (2021-12-29)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### 🛠 Build System
|
|
39
|
+
|
|
40
|
+
* update typescript ([141a8ee](https://github.com/bluelovers/ws-iconv/commit/141a8eefbaeeb45f235f5cdceadaeaeb05d9acc7))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### 🔖 Miscellaneous
|
|
44
|
+
|
|
45
|
+
* . ([c60df45](https://github.com/bluelovers/ws-iconv/commit/c60df451cb6728e0c28522bba043feaad4a883e0))
|
|
46
|
+
* . ([526ff7c](https://github.com/bluelovers/ws-iconv/commit/526ff7c919a83f407386c2e872170813bfc575d0))
|
|
47
|
+
* . ([a77b29a](https://github.com/bluelovers/ws-iconv/commit/a77b29ae69eb4e0c87d5120618c699273637510a))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## [2.0.8](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.6...fs-stream-sync@2.0.8) (2021-12-29)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### 🛠 Build System
|
|
57
|
+
|
|
58
|
+
* update typescript ([141a8ee](https://github.com/bluelovers/ws-iconv/commit/141a8eefbaeeb45f235f5cdceadaeaeb05d9acc7))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### 🔖 Miscellaneous
|
|
62
|
+
|
|
63
|
+
* . ([526ff7c](https://github.com/bluelovers/ws-iconv/commit/526ff7c919a83f407386c2e872170813bfc575d0))
|
|
64
|
+
* . ([a77b29a](https://github.com/bluelovers/ws-iconv/commit/a77b29ae69eb4e0c87d5120618c699273637510a))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## [2.0.7](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.6...fs-stream-sync@2.0.7) (2021-12-29)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### 🛠 Build System
|
|
74
|
+
|
|
75
|
+
* update typescript ([141a8ee](https://github.com/bluelovers/ws-iconv/commit/141a8eefbaeeb45f235f5cdceadaeaeb05d9acc7))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### 🔖 Miscellaneous
|
|
79
|
+
|
|
80
|
+
* . ([a77b29a](https://github.com/bluelovers/ws-iconv/commit/a77b29ae69eb4e0c87d5120618c699273637510a))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## [2.0.6](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.5...fs-stream-sync@2.0.6) (2021-12-06)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### ♻️ Chores
|
|
90
|
+
|
|
91
|
+
* **deps:** update deps ([64ec271](https://github.com/bluelovers/ws-iconv/commit/64ec2718aaa422a5d8761198824886410200c47f))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
6
97
|
## [2.0.5](https://github.com/bluelovers/ws-iconv/compare/fs-stream-sync@2.0.4...fs-stream-sync@2.0.5) (2021-08-13)
|
|
7
98
|
|
|
8
99
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fs-stream-sync",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "File System SyncWriteStream/SyncReadStream implementation from Node.js Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"File System",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lib": "lib"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"test": "echo \"Error: no test specified\"
|
|
33
|
+
"test": "echo \"Error: no test specified\"",
|
|
34
34
|
"prepublishOnly_": "yarn run prepublishOnly:check-bin && yarn run test",
|
|
35
35
|
"prepublishOnly:check-bin": "ynpx --quiet @yarn-tool/check-pkg-bin",
|
|
36
36
|
"prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@types/node": "*",
|
|
42
|
-
"tslib": "^2
|
|
42
|
+
"tslib": "^2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "6552242829a533ddf68c35d459d28224c3bc7c07"
|
|
45
45
|
}
|
package/read-sync.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSyncReadStream = exports.SyncReadStream = exports.kMinPoolSpace = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
6
|
const internal_1 = require("./lib/internal");
|
|
7
|
-
const internal_2 =
|
|
7
|
+
const internal_2 = tslib_1.__importDefault(require("./lib/internal"));
|
|
8
8
|
const read_1 = require("./read");
|
|
9
9
|
exports.kMinPoolSpace = 128;
|
|
10
10
|
let pool;
|
package/read-sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-sync.js","sourceRoot":"","sources":["read-sync.ts"],"names":[],"mappings":";;;;AAAA,
|
|
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,CA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M,GAAG,SAAS,GAAG,qBAAa,EAC3C;gBACC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;aACtE;YAED,IAAI,SAAS,GAAG,CAAC,EACjB;gBACC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC;gBAC5B,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;aAC7C;YAED,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;QACD,OAAO,EAAE,EACT;YACC,IAAI,IAAI,CAAC,SAAS,EAClB;gBACC,IAAI,CAAC,OAAO,EAAE,CAAC;aACf;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACvB;QAED,8DAA8D;QAC9D,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAC1B;YACC,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC;SACnB;QACD,IAAI,CAAC,IAAI,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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createReadStream = exports.ReadStream = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
6
|
const internal_1 = require("./lib/internal");
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
class ReadStream extends fs_1.default.ReadStream {
|
package/read.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["read.ts"],"names":[],"mappings":";;;;AACA,
|
|
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.d.ts
CHANGED
package/write-sync.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSyncWriteStream = exports.SyncWriteStream = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
6
|
const errors_1 = require("./lib/errors");
|
|
7
7
|
const internal_1 = require("./lib/internal");
|
|
8
|
-
const internal_2 =
|
|
8
|
+
const internal_2 = tslib_1.__importDefault(require("./lib/internal"));
|
|
9
9
|
const write_1 = require("./write");
|
|
10
10
|
class SyncWriteStream extends write_1.WriteStream {
|
|
11
11
|
constructor(path, options) {
|
package/write-sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-sync.js","sourceRoot":"","sources":["write-sync.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;AAEb,
|
|
1
|
+
{"version":3,"file":"write-sync.js","sourceRoot":"","sources":["write-sync.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;AAEb,oDAAoB;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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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWriteStream = exports.WriteStream = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
6
|
const internal_1 = require("./lib/internal");
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
class WriteStream extends fs_1.default.WriteStream {
|
package/write.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["write.ts"],"names":[],"mappings":";;;;AAAA,
|
|
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"]}
|