@e-mc/compress 0.10.6 → 0.11.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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +10 -10
  3. package/index.js +10 -10
  4. package/package.json +3 -3
package/LICENSE CHANGED
@@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,
8
8
 
9
9
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
10
 
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @e-mc/compress
2
2
 
3
- * NodeJS 16
4
- * ES2020
3
+ * NodeJS 16 LTS
4
+ * ES2021
5
5
 
6
6
  ## General Usage
7
7
 
@@ -9,16 +9,16 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.10.6/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.0/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IModule, ModuleConstructor } from "./index";
16
16
  import type { BufferResult, CompressFormat, CompressLevel, ReadableOptions, TryFileCompressor } from "./compress";
17
17
  import type { CompressModule, CompressSettings } from "./settings";
18
18
 
19
- import type { WriteStream } from "fs";
20
- import type { Readable } from "stream";
21
- import type { BrotliCompress, Gzip } from "zlib";
19
+ import type { WriteStream } from "node:fs";
20
+ import type { Readable } from "node:stream";
21
+ import type { BrotliCompress, Gzip } from "node:zlib";
22
22
 
23
23
  interface ICompress extends IModule {
24
24
  module: CompressModule;
@@ -116,12 +116,12 @@ instance.tryImage("/tmp/image.png", "/path/output/compressed.png", options)
116
116
 
117
117
  ## References
118
118
 
119
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/squared.d.ts
120
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/compress.d.ts
121
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/settings.d.ts
119
+ - https://www.unpkg.com/@e-mc/types@0.11.0/lib/squared.d.ts
120
+ - https://www.unpkg.com/@e-mc/types@0.11.0/lib/compress.d.ts
121
+ - https://www.unpkg.com/@e-mc/types@0.11.0/lib/settings.d.ts
122
122
 
123
123
  * https://www.npmjs.com/package/@types/node
124
124
 
125
125
  ## LICENSE
126
126
 
127
- BSD 3-Clause
127
+ BSD 3-Clause
package/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  var _a;
3
- const path = require("path");
4
- const fs = require("fs");
5
- const stream = require("stream");
6
- const zlib = require("zlib");
3
+ const path = require("node:path");
4
+ const fs = require("node:fs");
5
+ const stream = require("node:stream");
6
+ const zlib = require("node:zlib");
7
7
  const wawoff2 = require("wawoff2");
8
8
  const types_1 = require("@e-mc/types");
9
9
  const module_1 = require("@e-mc/module");
10
10
  const { toSfnt, toWoff } = require('woff2sfnt-sfnt2woff');
11
11
  const kChunkSize = Symbol('chunkSize');
12
12
  const CACHE_IMAGE = {};
13
- const CACHE_FONT = {};
13
+ const CACHE_FONT = Object.create(null);
14
14
  const CACHE_FONTFROM = {};
15
15
  const CACHE_FONTTO = {};
16
16
  const CACHE_INIT = [false, false];
@@ -149,7 +149,7 @@ class Compress extends module_1 {
149
149
  }
150
150
  }
151
151
  getReadable(file, options) {
152
- if (file instanceof Buffer) {
152
+ if (Buffer.isBuffer(file)) {
153
153
  return stream.Readable.from(file);
154
154
  }
155
155
  try {
@@ -256,14 +256,14 @@ class Compress extends module_1 {
256
256
  output = typeof file === 'string' ? file : '';
257
257
  }
258
258
  options ||= {};
259
- const { filename, startTime = process.hrtime(), timeout = 0, sessionId, broadcastId } = options;
259
+ const { filename, startTime = process.hrtime.bigint(), timeout = 0, sessionId, broadcastId } = options;
260
260
  let format = options.format, hash = options.etag;
261
261
  if (!format) {
262
262
  return Promise.reject((0, types_1.errorValue)("Missing option \"format\"", output || filename));
263
263
  }
264
264
  const cache = this.settings.cache ? !!(hash && (hash = module_1.asHash(hash)) || Buffer.isBuffer(file) && (hash = module_1.asHash(file))) : false;
265
265
  return new Promise((resolve, reject) => {
266
- let timer = null, startLength = 0, aborted;
266
+ let timer = null, startLength = 0, aborted = false;
267
267
  const endProcess = (err, data = null, ext, result, fromCache) => {
268
268
  if (timer) {
269
269
  clearTimeout(timer);
@@ -509,7 +509,7 @@ class Compress extends module_1 {
509
509
  else {
510
510
  options ||= {};
511
511
  }
512
- const { filename, startTime = process.hrtime(), timeout = 0, sessionId, broadcastId } = options;
512
+ const { filename, startTime = process.hrtime.bigint(), timeout = 0, sessionId, broadcastId } = options;
513
513
  let plugin = options.plugin;
514
514
  if ((0, types_1.isString)(plugin)) {
515
515
  if (types_1.IMPORT_MAP[plugin]) {
@@ -544,7 +544,7 @@ class Compress extends module_1 {
544
544
  }
545
545
  const startLength = Buffer.byteLength(data);
546
546
  return new Promise(async (resolve, reject) => {
547
- let timer = null, hash, cacheKey, aborted;
547
+ let timer = null, hash, cacheKey, aborted = false;
548
548
  const failed = (err) => {
549
549
  aborted = true;
550
550
  if (timer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/compress",
3
- "version": "0.10.6",
3
+ "version": "0.11.0",
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": "BSD-3-Clause",
24
24
  "homepage": "https://github.com/anpham6/e-mc#readme",
25
25
  "dependencies": {
26
- "@e-mc/module": "0.10.6",
27
- "@e-mc/types": "0.10.6",
26
+ "@e-mc/module": "0.11.0",
27
+ "@e-mc/types": "0.11.0",
28
28
  "wawoff2": "^2.0.1",
29
29
  "woff2sfnt-sfnt2woff": "^1.0.0"
30
30
  }