compressing 1.9.1 → 1.10.0
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/README.md +4 -3
- package/lib/utils.js +16 -7
- package/lib/zip/uncompress_stream.js +38 -38
- package/package.json +10 -11
package/README.md
CHANGED
|
@@ -368,10 +368,11 @@ Although the API is streaming style(try to keep it handy), it still loads all da
|
|
|
368
368
|
|
|
369
369
|
## Contributors
|
|
370
370
|
|
|
371
|
-
|[<img src="https://avatars.githubusercontent.com/u/
|
|
371
|
+
|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/456108?v=4" width="100px;"/><br/><sub><b>shaoshuai0102</b></sub>](https://github.com/shaoshuai0102)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/32174276?v=4" width="100px;"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|[<img src="https://avatars.githubusercontent.com/u/9692408?v=4" width="100px;"/><br/><sub><b>DiamondYuan</b></sub>](https://github.com/DiamondYuan)<br/>|[<img src="https://avatars.githubusercontent.com/u/101238421?v=4" width="100px;"/><br/><sub><b>acyza</b></sub>](https://github.com/acyza)<br/>|
|
|
372
372
|
| :---: | :---: | :---: | :---: | :---: | :---: |
|
|
373
|
-
[<img src="https://avatars.githubusercontent.com/u/47357585?v=4" width="100px;"/><br/><sub><b>songhn233</b></sub>](https://github.com/songhn233)<br/>|[<img src="https://avatars.githubusercontent.com/u/
|
|
373
|
+
|[<img src="https://avatars.githubusercontent.com/u/13938334?v=4" width="100px;"/><br/><sub><b>bytemain</b></sub>](https://github.com/bytemain)<br/>|[<img src="https://avatars.githubusercontent.com/u/20432815?v=4" width="100px;"/><br/><sub><b>rickyes</b></sub>](https://github.com/rickyes)<br/>|[<img src="https://avatars.githubusercontent.com/u/8382136?v=4" width="100px;"/><br/><sub><b>Ryqsky</b></sub>](https://github.com/Ryqsky)<br/>|[<img src="https://avatars.githubusercontent.com/u/47357585?v=4" width="100px;"/><br/><sub><b>songhn233</b></sub>](https://github.com/songhn233)<br/>|[<img src="https://avatars.githubusercontent.com/u/160386?v=4" width="100px;"/><br/><sub><b>Infiltrator</b></sub>](https://github.com/Infiltrator)<br/>|[<img src="https://avatars.githubusercontent.com/u/13861843?v=4" width="100px;"/><br/><sub><b>ZeekoZhu</b></sub>](https://github.com/ZeekoZhu)<br/>|
|
|
374
|
+
[<img src="https://avatars.githubusercontent.com/u/6897780?v=4" width="100px;"/><br/><sub><b>killagu</b></sub>](https://github.com/killagu)<br/>|[<img src="https://avatars.githubusercontent.com/u/59508678?v=4" width="100px;"/><br/><sub><b>okaponta</b></sub>](https://github.com/okaponta)<br/>|[<img src="https://avatars.githubusercontent.com/u/9857273?v=4" width="100px;"/><br/><sub><b>ShadyZOZ</b></sub>](https://github.com/ShadyZOZ)<br/>
|
|
374
375
|
|
|
375
|
-
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `
|
|
376
|
+
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Aug 03 2023 01:39:37 GMT+0800`.
|
|
376
377
|
|
|
377
378
|
<!-- GITCONTRIBUTOR_END -->
|
package/lib/utils.js
CHANGED
|
@@ -118,11 +118,20 @@ exports.makeUncompressFn = StreamClass => {
|
|
|
118
118
|
entryCount++;
|
|
119
119
|
pump(stream, fs.createWriteStream(fullpath, { mode: opts.mode || header.mode }), err => {
|
|
120
120
|
if (err) return reject(err);
|
|
121
|
-
|
|
122
121
|
successCount++;
|
|
123
122
|
done();
|
|
124
123
|
});
|
|
125
124
|
});
|
|
125
|
+
} else if (header.type === 'symlink') {
|
|
126
|
+
// symlink
|
|
127
|
+
const src = path.join(destDir, header.name);
|
|
128
|
+
const target = path.resolve(path.dirname(src), header.linkname);
|
|
129
|
+
entryCount++;
|
|
130
|
+
fs.symlink(target, src, err => {
|
|
131
|
+
if (err) return reject(err);
|
|
132
|
+
successCount++;
|
|
133
|
+
stream.resume();
|
|
134
|
+
});
|
|
126
135
|
} else { // directory
|
|
127
136
|
mkdirp(path.join(destDir, header.name), err => {
|
|
128
137
|
if (err) return reject(err);
|
|
@@ -139,12 +148,12 @@ exports.streamToBuffer = stream => {
|
|
|
139
148
|
return new Promise((resolve, reject) => {
|
|
140
149
|
const chunks = [];
|
|
141
150
|
stream
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
.on('readable', () => {
|
|
152
|
+
let chunk;
|
|
153
|
+
while ((chunk = stream.read())) chunks.push(chunk);
|
|
154
|
+
})
|
|
155
|
+
.on('end', () => resolve(Buffer.concat(chunks)))
|
|
156
|
+
.on('error', err => reject(err));
|
|
148
157
|
});
|
|
149
158
|
};
|
|
150
159
|
|
|
@@ -56,8 +56,8 @@ class ZipUncompressStream extends UncompressBaseStream {
|
|
|
56
56
|
|
|
57
57
|
if (sourceType === 'stream') {
|
|
58
58
|
utils.streamToBuffer(opts.source)
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
.then(buf => yauzl.fromBuffer(buf, yauzlOpts, this[YAUZL_CALLBACK]))
|
|
60
|
+
.catch(e => this.emit('error', e));
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -65,12 +65,12 @@ class ZipUncompressStream extends UncompressBaseStream {
|
|
|
65
65
|
srcStream.unpipe(srcStream);
|
|
66
66
|
|
|
67
67
|
utils.streamToBuffer(srcStream)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
.then(buf => {
|
|
69
|
+
this._chunks.push(buf);
|
|
70
|
+
buf = Buffer.concat(this._chunks);
|
|
71
|
+
yauzl.fromBuffer(buf, yauzlOpts, this[YAUZL_CALLBACK]);
|
|
72
|
+
})
|
|
73
|
+
.catch(e => this.emit('error', e));
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -85,38 +85,38 @@ class ZipUncompressStream extends UncompressBaseStream {
|
|
|
85
85
|
zipFile.readEntry();
|
|
86
86
|
|
|
87
87
|
zipFile
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
.on('entry', entry => {
|
|
89
|
+
const mode = modeFromEntry(entry);
|
|
90
|
+
// fileName is buffer by default because decodeStrings = false
|
|
91
|
+
if (Buffer.isBuffer(entry.fileName)) {
|
|
92
|
+
if (this._zipFileNameEncoding === 'utf8') {
|
|
93
|
+
entry.fileName = entry.fileName.toString();
|
|
94
|
+
} else {
|
|
95
|
+
if (!iconv) {
|
|
96
|
+
iconv = require('iconv-lite');
|
|
97
|
+
}
|
|
98
|
+
entry.fileName = iconv.decode(entry.fileName, this._zipFileNameEncoding);
|
|
97
99
|
}
|
|
98
|
-
entry.fileName = iconv.decode(entry.fileName, this._zipFileNameEncoding);
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.on('error', err => this.emit('error', err));
|
|
101
|
+
// directory file names end with '/'
|
|
102
|
+
const type = /\/$/.test(entry.fileName) ? 'directory' : 'file';
|
|
103
|
+
const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);
|
|
104
|
+
|
|
105
|
+
const header = { name, type, yauzl: entry, mode };
|
|
106
|
+
|
|
107
|
+
if (type === 'file') {
|
|
108
|
+
zipFile.openReadStream(entry, (err, readStream) => {
|
|
109
|
+
if (err) return this.emit('error', err);
|
|
110
|
+
this.emit('entry', header, readStream, next);
|
|
111
|
+
});
|
|
112
|
+
} else { // directory
|
|
113
|
+
const placeholder = new stream.Readable({ read() {} });
|
|
114
|
+
this.emit('entry', header, placeholder, next);
|
|
115
|
+
setImmediate(() => placeholder.emit('end'));
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
.on('end', () => this.emit('finish'))
|
|
119
|
+
.on('error', err => this.emit('error', err));
|
|
120
120
|
|
|
121
121
|
function next() {
|
|
122
122
|
zipFile.readEntry();
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compressing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Everything you need for compressing and uncompressing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"contributor": "git-contributor",
|
|
8
8
|
"ts-test": "tsc -p ./test/fixtures/types/tsconfig.json",
|
|
9
|
-
"test": "egg-bin test --
|
|
10
|
-
"cov": "egg-bin cov --
|
|
9
|
+
"test": "egg-bin test --ts false && npm run ts-test",
|
|
10
|
+
"cov": "egg-bin cov --ts false",
|
|
11
11
|
"lint-fix": "eslint . --fix",
|
|
12
12
|
"lint": "eslint .",
|
|
13
13
|
"ci": "npm run lint && npm run ts-test && npm run cov"
|
|
@@ -50,17 +50,16 @@
|
|
|
50
50
|
"yazl": "^2.4.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/mocha": "
|
|
54
|
-
"@types/node": "
|
|
53
|
+
"@types/mocha": "10",
|
|
54
|
+
"@types/node": "20",
|
|
55
55
|
"dir-compare": "^1.3.0",
|
|
56
|
-
"egg-bin": "
|
|
57
|
-
"eslint": "
|
|
58
|
-
"eslint-config-egg": "
|
|
59
|
-
"git-contributor": "
|
|
56
|
+
"egg-bin": "6",
|
|
57
|
+
"eslint": "8",
|
|
58
|
+
"eslint-config-egg": "12",
|
|
59
|
+
"git-contributor": "2",
|
|
60
60
|
"mm": "^2.0.0",
|
|
61
61
|
"mz-modules": "^2.1.0",
|
|
62
|
-
"
|
|
63
|
-
"typescript": "^3.1.6",
|
|
62
|
+
"typescript": "5",
|
|
64
63
|
"uuid": "^3.0.1"
|
|
65
64
|
},
|
|
66
65
|
"engines": {
|