@pi-r/tinify 0.11.3 → 0.12.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 (2) hide show
  1. package/index.js +8 -6
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
- const tinify = require("tinify");
3
- const Compress = require("@e-mc/compress");
4
- const types_1 = require("@e-mc/types");
2
+
3
+ const tinify = require('tinify');
4
+ const Compress = require('@e-mc/compress');
5
+ const { errorMessage, isPlainObject, parseExpires } = require('@e-mc/types');
5
6
  const CACHE_APIKEY = {};
6
7
  const withinRange = (value = 0) => value > Date.now();
7
8
  function compress(options = {}) {
8
9
  let apiKey = options.apiKey, proxy = options.proxy, expires = options.expires;
9
- if (!apiKey && (0, types_1.isPlainObject)(this?.module)) {
10
+ if (!apiKey && isPlainObject(this?.module)) {
10
11
  const settings = this.module.tinify;
11
12
  if (settings) {
12
13
  apiKey ||= settings.api_key;
@@ -42,7 +43,7 @@ function compress(options = {}) {
42
43
  tinify.validate(err => {
43
44
  if (!err) {
44
45
  if (expires) {
45
- const offset = (0, types_1.parseExpires)(expires);
46
+ const offset = parseExpires(expires);
46
47
  if (offset > 0) {
47
48
  CACHE_APIKEY[cacheKey] = Date.now() + offset;
48
49
  }
@@ -56,9 +57,10 @@ function compress(options = {}) {
56
57
  }
57
58
  }
58
59
  else {
59
- reject((0, types_1.errorMessage)('tinify', "Missing API key"));
60
+ reject(errorMessage('tinify', "Missing API key"));
60
61
  }
61
62
  });
62
63
  };
63
64
  }
65
+
64
66
  module.exports = compress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/tinify",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
4
4
  "description": "TinyPNG compress function for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -19,8 +19,8 @@
19
19
  "license": "MIT",
20
20
  "homepage": "https://github.com/anpham6/pi-r#readme",
21
21
  "dependencies": {
22
- "@e-mc/compress": "^0.13.10",
23
- "@e-mc/types": "^0.13.10",
22
+ "@e-mc/compress": "^0.14.0",
23
+ "@e-mc/types": "^0.14.0",
24
24
  "tinify": "^1.8.2"
25
25
  }
26
26
  }