@e-mc/compress 0.9.21 → 0.9.23

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 CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.9.21/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.23/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { CompressLevel } from "./squared";
@@ -120,9 +120,9 @@ instance.tryImage("/tmp/image.png", "/path/output/compressed.png", options)
120
120
 
121
121
  ## References
122
122
 
123
- - https://www.unpkg.com/@e-mc/types@0.9.21/lib/squared.d.ts
124
- - https://www.unpkg.com/@e-mc/types@0.9.21/lib/compress.d.ts
125
- - https://www.unpkg.com/@e-mc/types@0.9.21/lib/settings.d.ts
123
+ - https://www.unpkg.com/@e-mc/types@0.9.23/lib/squared.d.ts
124
+ - https://www.unpkg.com/@e-mc/types@0.9.23/lib/compress.d.ts
125
+ - https://www.unpkg.com/@e-mc/types@0.9.23/lib/settings.d.ts
126
126
 
127
127
  * https://www.npmjs.com/package/@types/node
128
128
 
package/index.js CHANGED
@@ -178,10 +178,15 @@ class Compress extends module_1 {
178
178
  if (options) {
179
179
  ({ level, chunkSize, mimeType } = options);
180
180
  }
181
- const params = { [zlib.constants.BROTLI_PARAM_QUALITY]: level ?? this.level.br };
182
- let brotli = this.module.brotli;
181
+ let brotli = this.module.brotli, params = {};
183
182
  if ((0, types_1.isPlainObject)(brotli)) {
184
- brotli = (0, types_1.isPlainObject)(brotli.params) ? { ...brotli, params: Object.assign(params, brotli.params) } : { ...brotli, params };
183
+ if ((0, types_1.isPlainObject)(brotli.params)) {
184
+ brotli = (0, types_1.cloneObject)(brotli, true);
185
+ params = brotli.params;
186
+ }
187
+ else {
188
+ brotli = { ...brotli, params };
189
+ }
185
190
  }
186
191
  else {
187
192
  brotli = { params };
@@ -198,6 +203,12 @@ class Compress extends module_1 {
198
203
  else {
199
204
  brotli.chunkSize ??= this.chunkSize;
200
205
  }
206
+ if (typeof level === 'number') {
207
+ params[zlib.constants.BROTLI_PARAM_QUALITY] = level;
208
+ }
209
+ else {
210
+ params[zlib.constants.BROTLI_PARAM_QUALITY] ??= this.level.br;
211
+ }
201
212
  return this.getReadable(file).pipe(zlib.createBrotliCompress(brotli));
202
213
  }
203
214
  createWriteStreamAsGzip(file, output, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/compress",
3
- "version": "0.9.21",
3
+ "version": "0.9.23",
4
4
  "description": "Compress constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "license": "MIT",
24
24
  "homepage": "https://github.com/anpham6/e-mc#readme",
25
25
  "dependencies": {
26
- "@e-mc/module": "0.9.21",
27
- "@e-mc/types": "0.9.21",
26
+ "@e-mc/module": "0.9.23",
27
+ "@e-mc/types": "0.9.23",
28
28
  "tinify": "^1.8.0",
29
29
  "wawoff2": "^2.0.1",
30
30
  "woff2sfnt-sfnt2woff": "^1.0.0"
@@ -13,7 +13,7 @@ node_worker_threads_1.parentPort.on('message', async (value) => {
13
13
  catch {
14
14
  transform = require(plugin);
15
15
  }
16
- transform(options, metadata)(index_1.asBuffer(data))
16
+ void transform(options, metadata)(index_1.asBuffer(data))
17
17
  .then(result => {
18
18
  try {
19
19
  PORT.postMessage(result, [result.buffer]);
@@ -21,10 +21,6 @@ node_worker_threads_1.parentPort.on('message', async (value) => {
21
21
  catch {
22
22
  PORT.postMessage(result);
23
23
  }
24
- })
25
- .catch((err) => {
26
- console.error(err);
27
- PORT.postMessage(null);
28
24
  });
29
25
  }
30
26
  catch (err) {