compressing 1.5.0 → 1.6.1
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/History.md +24 -0
- package/README.md +14 -14
- package/index.d.ts +10 -4
- package/lib/zip/uncompress_stream.js +11 -1
- package/package.json +7 -4
package/History.md
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
|
|
2
|
+
1.6.1 / 2022-07-11
|
|
3
|
+
==================
|
|
4
|
+
|
|
5
|
+
**fixes**
|
|
6
|
+
* [[`ba49232`](http://github.com/node-modules/compressing/commit/ba49232780a57c9a3800642d7d39ae1dcdfc9409)] - fix(types): onEntry stream type should ReadStream (#73) (Songhn <<songhn233@gmail.com>>)
|
|
7
|
+
|
|
8
|
+
**others**
|
|
9
|
+
* [[`054d4a4`](http://github.com/node-modules/compressing/commit/054d4a41ae4ca5d7b9b83e7298e32cc1d62d7ef4)] - 🤖 TEST: Use GitHub Action (#69) (fengmk2 <<fengmk2@gmail.com>>)
|
|
10
|
+
|
|
11
|
+
1.6.0 / 2022-06-13
|
|
12
|
+
==================
|
|
13
|
+
|
|
14
|
+
**features**
|
|
15
|
+
* [[`bd8ef44`](http://github.com/node-modules/compressing/commit/bd8ef44ade2f4b93d41ff2f78d6f17902d965798)] - feat: unzip should keep file mode (#68) (Artin <<lengthmin@gmail.com>>)
|
|
16
|
+
|
|
17
|
+
**others**
|
|
18
|
+
* [[`592e518`](http://github.com/node-modules/compressing/commit/592e5180dfbdbc6cb1becd1baf6a007ce7b7cd39)] - Create codeql-analysis.yml (fengmk2 <<fengmk2@gmail.com>>)
|
|
19
|
+
|
|
20
|
+
1.5.1 / 2020-05-11
|
|
21
|
+
==================
|
|
22
|
+
|
|
23
|
+
**fixes**
|
|
24
|
+
* [[`f516814`](http://github.com/node-modules/compressing/commit/f51681490aeea44a7b27ec0c09d3fb3d0385c5c0)] - fix: index.d.ts streamHeader.name wrong declearing (#46) (shadyzoz <<ShadyZOZ@users.noreply.github.com>>)
|
|
25
|
+
|
|
2
26
|
1.5.0 / 2019-12-04
|
|
3
27
|
==================
|
|
4
28
|
|
package/README.md
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
# compressing
|
|
2
2
|
|
|
3
3
|
[![NPM version][npm-image]][npm-url]
|
|
4
|
-
[![build status][travis-image]][travis-url]
|
|
5
4
|
[![Test coverage][codecov-image]][codecov-url]
|
|
6
|
-
[![David deps][david-image]][david-url]
|
|
7
|
-
[![Known Vulnerabilities][snyk-image]][snyk-url]
|
|
8
5
|
[![npm download][download-image]][download-url]
|
|
9
6
|
|
|
10
7
|
[npm-image]: https://img.shields.io/npm/v/compressing.svg?style=flat-square
|
|
11
8
|
[npm-url]: https://npmjs.org/package/compressing
|
|
12
|
-
[travis-image]: https://img.shields.io/travis/node-modules/compressing.svg?style=flat-square
|
|
13
|
-
[travis-url]: https://travis-ci.org/node-modules/compressing
|
|
14
9
|
[codecov-image]: https://codecov.io/gh/node-modules/compressing/branch/master/graph/badge.svg
|
|
15
10
|
[codecov-url]: https://codecov.io/gh/node-modules/compressing
|
|
16
|
-
[david-image]: https://img.shields.io/david/node-modules/compressing.svg?style=flat-square
|
|
17
|
-
[david-url]: https://david-dm.org/node-modules/compressing
|
|
18
|
-
[snyk-image]: https://snyk.io/test/npm/compressing/badge.svg?style=flat-square
|
|
19
|
-
[snyk-url]: https://snyk.io/test/npm/compressing
|
|
20
11
|
[download-image]: https://img.shields.io/npm/dm/compressing.svg?style=flat-square
|
|
21
12
|
[download-url]: https://npmjs.org/package/compressing
|
|
22
13
|
|
|
@@ -88,7 +79,6 @@ const destStream = fs.createWriteStream('path/to/destination.gz');
|
|
|
88
79
|
pump(sourceStream, gzipStream, destStream, handleError);
|
|
89
80
|
```
|
|
90
81
|
|
|
91
|
-
|
|
92
82
|
### Compress a dir
|
|
93
83
|
|
|
94
84
|
Use tar as an example, tgz and zip is same as gzip.
|
|
@@ -167,8 +157,7 @@ compressing.tgz.uncompress(stream, 'path/to/destination/dir')
|
|
|
167
157
|
.catch(handleError);
|
|
168
158
|
```
|
|
169
159
|
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
__Note: tar, tgz and zip have the same uncompressing API as above: destination should be a path of a directory, while that of gzip is slightly different: destination must be a file or filestream.__
|
|
172
161
|
|
|
173
162
|
And working with urllib is super easy. Let's download a tgz file and uncompress to a directory:
|
|
174
163
|
|
|
@@ -280,7 +269,7 @@ Use this API to uncompress a file. This is a convenient method, which wraps Unco
|
|
|
280
269
|
Params
|
|
281
270
|
|
|
282
271
|
- source {String|Buffer|Stream} - source to be uncompressed
|
|
283
|
-
- dest {String|Stream} - uncompressing destination. When uncompressing tar, tgz and zip, it should be a directory path (eg. `/path/to/xx`).
|
|
272
|
+
- dest {String|Stream} - uncompressing destination. When uncompressing tar, tgz and zip, it should be a directory path (eg. `/path/to/xx`). __When uncompressing gzip, it should be a file path or a writable stream.__
|
|
284
273
|
- opts {Object} - usually you don't need it
|
|
285
274
|
- opts.zipFileNameEncoding {String} - Only work on zip format, default is 'utf8'.
|
|
286
275
|
Major non-UTF8 encodings by languages:
|
|
@@ -374,4 +363,15 @@ Due to the design of the .zip file format, it's impossible to interpret a .zip f
|
|
|
374
363
|
|
|
375
364
|
Although the API is streaming style(try to keep it handy), it still loads all data into memory.
|
|
376
365
|
|
|
377
|
-
https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api
|
|
366
|
+
<https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api>
|
|
367
|
+
<!-- GITCONTRIBUTOR_START -->
|
|
368
|
+
|
|
369
|
+
## Contributors
|
|
370
|
+
|
|
371
|
+
|[<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/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<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/9692408?v=4" width="100px;"/><br/><sub><b>DiamondYuan</b></sub>](https://github.com/DiamondYuan)<br/>|[<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/8382136?v=4" width="100px;"/><br/><sub><b>Ryqsky</b></sub>](https://github.com/Ryqsky)<br/>|
|
|
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/9857273?v=4" width="100px;"/><br/><sub><b>ShadyZOZ</b></sub>](https://github.com/ShadyZOZ)<br/>
|
|
374
|
+
|
|
375
|
+
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jul 11 2022 08:28:25 GMT+0800`.
|
|
376
|
+
|
|
377
|
+
<!-- GITCONTRIBUTOR_END -->
|
package/index.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ interface streamEntryOpts {
|
|
|
12
12
|
|
|
13
13
|
interface streamHeader {
|
|
14
14
|
type: 'file' | 'directory',
|
|
15
|
-
name:
|
|
15
|
+
name: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface streamHeaderWithMode {
|
|
19
|
+
type: 'file' | 'directory',
|
|
20
|
+
name: string
|
|
21
|
+
mode: number
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
export namespace gzip {
|
|
@@ -79,7 +85,7 @@ export namespace tar {
|
|
|
79
85
|
});
|
|
80
86
|
|
|
81
87
|
on(event: string, listener: (...args: any[]) => void): this
|
|
82
|
-
on(event: 'entry', listener: (header:
|
|
88
|
+
on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
|
|
83
89
|
on(event: 'finish', listener: () => void): this
|
|
84
90
|
on(event: 'error', listener: (err: Error) => void): this
|
|
85
91
|
|
|
@@ -124,7 +130,7 @@ export namespace tgz {
|
|
|
124
130
|
});
|
|
125
131
|
|
|
126
132
|
on(event: string, listener: (...args: any[]) => void): this
|
|
127
|
-
on(event: 'entry', listener: (header:
|
|
133
|
+
on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
|
|
128
134
|
on(event: 'finish', listener: () => void): this
|
|
129
135
|
on(event: 'error', listener: (err: Error) => void): this
|
|
130
136
|
|
|
@@ -177,7 +183,7 @@ export namespace zip {
|
|
|
177
183
|
});
|
|
178
184
|
|
|
179
185
|
on(event: string, listener: (...args: any[]) => void): this
|
|
180
|
-
on(event: 'entry', listener: (header:
|
|
186
|
+
on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
|
|
181
187
|
on(event: 'finish', listener: () => void): this
|
|
182
188
|
on(event: 'error', listener: (err: Error) => void): this
|
|
183
189
|
|
|
@@ -18,6 +18,15 @@ const STRIP_NAME = Symbol('ZipUncompressStream#stripName');
|
|
|
18
18
|
// - support "absolute path"
|
|
19
19
|
const DEFAULTS = { lazyEntries: true, decodeStrings: false };
|
|
20
20
|
|
|
21
|
+
// from: https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/node/zip.ts#L51
|
|
22
|
+
function modeFromEntry(entry) {
|
|
23
|
+
const attr = entry.externalFileAttributes >> 16 || 33188;
|
|
24
|
+
|
|
25
|
+
return [ 448 /* S_IRWXU */, 56 /* S_IRWXG */, 7 /* S_IRWXO */ ]
|
|
26
|
+
.map(mask => attr & mask)
|
|
27
|
+
.reduce((a, b) => a + b, attr & 61440 /* S_IFMT */);
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
class ZipUncompressStream extends UncompressBaseStream {
|
|
22
31
|
constructor(opts) {
|
|
23
32
|
opts = opts || {};
|
|
@@ -77,6 +86,7 @@ class ZipUncompressStream extends UncompressBaseStream {
|
|
|
77
86
|
|
|
78
87
|
zipFile
|
|
79
88
|
.on('entry', entry => {
|
|
89
|
+
const mode = modeFromEntry(entry);
|
|
80
90
|
// fileName is buffer by default because decodeStrings = false
|
|
81
91
|
if (Buffer.isBuffer(entry.fileName)) {
|
|
82
92
|
if (this._zipFileNameEncoding === 'utf8') {
|
|
@@ -92,7 +102,7 @@ class ZipUncompressStream extends UncompressBaseStream {
|
|
|
92
102
|
const type = /\/$/.test(entry.fileName) ? 'directory' : 'file';
|
|
93
103
|
const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);
|
|
94
104
|
|
|
95
|
-
const header = { name, type, yauzl: entry };
|
|
105
|
+
const header = { name, type, yauzl: entry, mode };
|
|
96
106
|
|
|
97
107
|
if (type === 'file') {
|
|
98
108
|
zipFile.openReadStream(entry, (err, readStream) => {
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compressing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Everything you need for compressing and uncompressing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"contributor": "git-contributor",
|
|
7
8
|
"ts-test": "tsc -p ./test/fixtures/types/tsconfig.json",
|
|
8
9
|
"test": "egg-bin test && npm run ts-test",
|
|
9
10
|
"cov": "egg-bin cov",
|
|
10
|
-
"lint": "eslint .",
|
|
11
|
+
"lint": "eslint . --fix",
|
|
11
12
|
"ci": "npm run lint && npm run ts-test && npm run cov"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
@@ -52,9 +53,10 @@
|
|
|
52
53
|
"@types/node": "^10.12.9",
|
|
53
54
|
"dir-compare": "^1.3.0",
|
|
54
55
|
"egg-bin": "^1.9.1",
|
|
55
|
-
"egg-ci": "^1.
|
|
56
|
+
"egg-ci": "^2.1.0",
|
|
56
57
|
"eslint": "^3.10.2",
|
|
57
58
|
"eslint-config-egg": "^3.2.0",
|
|
59
|
+
"git-contributor": "^1.1.0",
|
|
58
60
|
"mm": "^2.0.0",
|
|
59
61
|
"mz-modules": "^2.1.0",
|
|
60
62
|
"power-assert": "^1.4.2",
|
|
@@ -66,7 +68,8 @@
|
|
|
66
68
|
"node": ">= 4.0.0"
|
|
67
69
|
},
|
|
68
70
|
"ci": {
|
|
69
|
-
"version": "
|
|
71
|
+
"version": "10, 12, 14, 16, 18",
|
|
72
|
+
"os": "linux, macos",
|
|
70
73
|
"license": {
|
|
71
74
|
"year": "2017",
|
|
72
75
|
"fullname": "node-modules and other contributors"
|