@e-mc/module 0.10.8 → 0.10.9

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 (3) hide show
  1. package/README.md +6 -6
  2. package/index.js +10 -10
  3. package/package.json +2 -2
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.8/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.9/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogStatus } from "./squared";
@@ -407,11 +407,11 @@ interface LoggerModule {
407
407
 
408
408
  ## References
409
409
 
410
- - https://www.unpkg.com/@e-mc/types@0.10.8/lib/core.d.ts
411
- - https://www.unpkg.com/@e-mc/types@0.10.8/lib/logger.d.ts
412
- - https://www.unpkg.com/@e-mc/types@0.10.8/lib/module.d.ts
413
- - https://www.unpkg.com/@e-mc/types@0.10.8/lib/node.d.ts
414
- - https://www.unpkg.com/@e-mc/types@0.10.8/lib/settings.d.ts
410
+ - https://www.unpkg.com/@e-mc/types@0.10.9/lib/core.d.ts
411
+ - https://www.unpkg.com/@e-mc/types@0.10.9/lib/logger.d.ts
412
+ - https://www.unpkg.com/@e-mc/types@0.10.9/lib/module.d.ts
413
+ - https://www.unpkg.com/@e-mc/types@0.10.9/lib/node.d.ts
414
+ - https://www.unpkg.com/@e-mc/types@0.10.9/lib/settings.d.ts
415
415
 
416
416
  * https://www.npmjs.com/package/@types/node
417
417
 
package/index.js CHANGED
@@ -920,7 +920,7 @@ function truncateEnd(value, length) {
920
920
  const isMeterUnit = (type, ident) => (type & 256) === 256 && !ident;
921
921
  const formatLogMessage = (type, message, unit, ident) => isMeterUnit(type, ident) ? (unit + LOG_DIVIDER + message).trimEnd() : unit ? (message + (ident ? '' : ' ') + unit).trimStart() : message;
922
922
  const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
923
- const asFile = (value) => typeof value === 'string' ? value.trim() : value instanceof URL && value.protocol === 'file:' ? (0, url_1.fileURLToPath)(value) : '';
923
+ const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? (0, url_1.fileURLToPath)(value) : '';
924
924
  const wrapQuote = (value) => '"' + value.replaceAll('"', '\\"') + '"';
925
925
  const isFunction = (value) => typeof value === 'function';
926
926
  const isFileURL = (value) => /^file:\/\//i.test(value);
@@ -960,7 +960,7 @@ class Module extends EventEmitter {
960
960
  this[_g] = null;
961
961
  }
962
962
  static get VERSION() {
963
- return "0.10.8";
963
+ return "0.10.9";
964
964
  }
965
965
  static get LOG_TYPE() {
966
966
  return types_1.LOG_TYPE;
@@ -1048,7 +1048,7 @@ class Module extends EventEmitter {
1048
1048
  if (error && hideAbort(message)) {
1049
1049
  return;
1050
1050
  }
1051
- if (options.type) {
1051
+ if (typeof options.type === 'number') {
1052
1052
  type |= options.type;
1053
1053
  }
1054
1054
  const BROADCAST_OUT = VALUES["broadcast.out"];
@@ -1533,7 +1533,7 @@ class Module extends EventEmitter {
1533
1533
  filename = undefined;
1534
1534
  }
1535
1535
  if (typeof value === 'string') {
1536
- let pathname = value.trim(), convert = true;
1536
+ let pathname = PLATFORM_WIN32 ? value.trim() : value, convert = true;
1537
1537
  if (normalize) {
1538
1538
  pathname = path.normalize(pathname);
1539
1539
  convert = PLATFORM_WIN32;
@@ -1648,7 +1648,7 @@ class Module extends EventEmitter {
1648
1648
  return false;
1649
1649
  }
1650
1650
  static resolveFile(value) {
1651
- if (isFileURL(value = value instanceof URL ? value.toString() : value.trim())) {
1651
+ if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
1652
1652
  try {
1653
1653
  return (0, url_1.fileURLToPath)(value);
1654
1654
  }
@@ -1663,7 +1663,7 @@ class Module extends EventEmitter {
1663
1663
  }
1664
1664
  static resolvePath(value, base) {
1665
1665
  try {
1666
- if (this.isURL(value = value.trim())) {
1666
+ if (this.isURL(value)) {
1667
1667
  return isFileURL(value) ? (0, url_1.fileURLToPath)(value) : new URL(value).href;
1668
1668
  }
1669
1669
  if (base instanceof URL || this.isURL(base)) {
@@ -1695,7 +1695,7 @@ class Module extends EventEmitter {
1695
1695
  flags = flags ? 2 : 0;
1696
1696
  }
1697
1697
  if (typeof value === 'string') {
1698
- let result = value.trim();
1698
+ let result = PLATFORM_WIN32 ? value.trim() : value;
1699
1699
  result = flags & 1 ? path.resolve(result) : path.normalize(result);
1700
1700
  if ((flags & 2) && result.length > 0) {
1701
1701
  result = ensureDir(result);
@@ -3656,12 +3656,12 @@ class Module extends EventEmitter {
3656
3656
  }
3657
3657
  }
3658
3658
  writeLog(type, value, timeStamp, duration) {
3659
- let queue;
3659
+ let queue = false;
3660
3660
  if ((0, types_1.isObject)(type)) {
3661
3661
  if (typeof value === 'boolean') {
3662
3662
  queue = value;
3663
3663
  }
3664
- ({ type = types_1.STATUS_TYPE.UNKNOWN, value, timeStamp, duration } = type);
3664
+ value = type.value;
3665
3665
  }
3666
3666
  const output = Module.asString(value);
3667
3667
  if (output) {
@@ -3689,7 +3689,7 @@ class Module extends EventEmitter {
3689
3689
  from = timeStamp;
3690
3690
  timeStamp = 0;
3691
3691
  }
3692
- else if ((0, types_1.isObject)(timeStamp)) {
3692
+ else if ((0, types_1.isPlainObject)(timeStamp)) {
3693
3693
  ({ timeStamp, duration, from, source } = timeStamp);
3694
3694
  }
3695
3695
  const name = types_1.STATUS_TYPE[type] || types_1.STATUS_TYPE[type = 0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.10.8",
3
+ "version": "0.10.9",
4
4
  "description": "Module base class for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "license": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.10.8",
23
+ "@e-mc/types": "0.10.9",
24
24
  "chalk": "4.1.2",
25
25
  "file-type": "^18.7.0",
26
26
  "js-yaml": "^4.1.0",