@e-mc/module 0.10.12 → 0.10.14

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 +3 -7
  2. package/README.md +7 -7
  3. package/index.js +30 -32
  4. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
1
  Copyright 2024 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
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
-
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.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.10.12/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.14/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogStatus } from "./squared";
@@ -407,14 +407,14 @@ interface LoggerModule {
407
407
 
408
408
  ## References
409
409
 
410
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/core.d.ts
411
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/logger.d.ts
412
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/module.d.ts
413
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/node.d.ts
414
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/settings.d.ts
410
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/core.d.ts
411
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/logger.d.ts
412
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/module.d.ts
413
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/node.d.ts
414
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/settings.d.ts
415
415
 
416
416
  * https://www.npmjs.com/package/@types/node
417
417
 
418
418
  ## LICENSE
419
419
 
420
- BSD 3-Clause
420
+ MIT
package/index.js CHANGED
@@ -138,7 +138,6 @@ const MEMORY_CACHE_DISK = {
138
138
  include: null,
139
139
  exclude: null
140
140
  };
141
- const SUPPORTED_CANPARSE = (0, types_1.supported)(19, 9) || (0, types_1.supported)(18, 17, 0, true);
142
141
  const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
143
142
  const REGEXP_PROTOCOL = /^([a-z][a-z\d+-.]*):\/\/[^@:[\]\\^<>|\s]/i;
144
143
  const REGEXP_CLIESCAPE = /[^\w+-.,/:@]/g;
@@ -960,7 +959,7 @@ class Module extends EventEmitter {
960
959
  this[_g] = null;
961
960
  }
962
961
  static get VERSION() {
963
- return "0.10.12";
962
+ return "0.10.14";
964
963
  }
965
964
  static get LOG_TYPE() {
966
965
  return types_1.LOG_TYPE;
@@ -1460,35 +1459,35 @@ class Module extends EventEmitter {
1460
1459
  return cacheKey ? crypto.randomUUID() : '';
1461
1460
  }
1462
1461
  static asHash(data, algorithm, digest) {
1463
- if (!algorithm && !digest) {
1464
- return crypto.createHash("sha256").update(data).digest("hex");
1465
- }
1466
- let options;
1467
- if ((0, types_1.isObject)(algorithm)) {
1468
- options = { ...algorithm };
1469
- if ('algorithm' in options) {
1470
- algorithm = options.algorithm;
1471
- delete options.algorithm;
1462
+ try {
1463
+ if (!algorithm && !digest) {
1464
+ return crypto.createHash("sha256").update(data).digest("hex");
1472
1465
  }
1473
- else {
1474
- algorithm = undefined;
1466
+ let options;
1467
+ if ((0, types_1.isObject)(algorithm)) {
1468
+ options = { ...algorithm };
1469
+ if ('algorithm' in options) {
1470
+ algorithm = options.algorithm;
1471
+ delete options.algorithm;
1472
+ }
1473
+ else {
1474
+ algorithm = undefined;
1475
+ }
1476
+ if ('digest' in options) {
1477
+ digest = options.digest;
1478
+ delete options.digest;
1479
+ }
1480
+ else {
1481
+ digest = undefined;
1482
+ }
1475
1483
  }
1476
- if ('digest' in options) {
1477
- digest = options.digest;
1478
- delete options.digest;
1484
+ else if ((0, types_1.isObject)(digest)) {
1485
+ options = digest;
1486
+ digest = undefined;
1479
1487
  }
1480
- else {
1488
+ else if (typeof digest !== 'string') {
1481
1489
  digest = undefined;
1482
1490
  }
1483
- }
1484
- else if ((0, types_1.isObject)(digest)) {
1485
- options = digest;
1486
- digest = undefined;
1487
- }
1488
- else if (typeof digest !== 'string') {
1489
- digest = undefined;
1490
- }
1491
- try {
1492
1491
  return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
1493
1492
  }
1494
1493
  catch {
@@ -1560,9 +1559,6 @@ class Module extends EventEmitter {
1560
1559
  return filename || '';
1561
1560
  }
1562
1561
  static isURL(value, ...exclude) {
1563
- if (exclude.length === 0 && SUPPORTED_CANPARSE) {
1564
- return URL.canParse(value);
1565
- }
1566
1562
  const match = REGEXP_PROTOCOL.exec(value);
1567
1563
  return !!match && !exclude.includes(match[1].toLowerCase());
1568
1564
  }
@@ -1684,11 +1680,13 @@ class Module extends EventEmitter {
1684
1680
  if (typeof values[values.length - 1] === 'boolean') {
1685
1681
  normalize = values.pop();
1686
1682
  }
1687
- const paths = values.map(item => typeof item === 'string' ? item.trim() : '').filter(item => item).map(value => this.toPosix(value, normalize));
1683
+ const paths = values.filter(item => (0, types_1.isString)(item)).map(value => this.toPosix(value, normalize));
1688
1684
  let result = paths[0] || '';
1689
1685
  for (let i = 1; i < paths.length; ++i) {
1690
1686
  const trailing = paths[i];
1691
- result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
1687
+ if (trailing) {
1688
+ result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
1689
+ }
1692
1690
  }
1693
1691
  return result;
1694
1692
  }
@@ -2770,7 +2768,7 @@ class Module extends EventEmitter {
2770
2768
  dir = dir.substring(ensureDir(PROCESS_CWD).length);
2771
2769
  }
2772
2770
  else {
2773
- this.formatMessage(1, "WARN!", 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
2771
+ this.formatMessage(1, "WARN!", "Not permitted to set absolute path", dir, { ...this.LOG_STYLE_WARN, newline: true });
2774
2772
  dir = VALUES["temp.dir"];
2775
2773
  }
2776
2774
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.10.12",
3
+ "version": "0.10.14",
4
4
  "description": "Module base class for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,10 +17,10 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD-3-Clause",
20
+ "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.10.12",
23
+ "@e-mc/types": "0.10.14",
24
24
  "chalk": "4.1.2",
25
25
  "file-type": "^18.7.0",
26
26
  "js-yaml": "^4.1.0",