@e-mc/module 0.11.3 → 0.11.4

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 +11 -7
  2. package/index.js +9 -9
  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.11.3/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.4/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogStatus } from "./squared";
@@ -225,13 +225,17 @@ interface ModuleConstructor {
225
225
  getMemUsage(format: true): string;
226
226
  getMemUsage(format?: boolean): number;
227
227
  formatCpuMem(start: CpuUsage, all?: boolean): string;
228
+ /** @deprecated */
228
229
  getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
230
+ /** @deprecated */
229
231
  getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
230
232
  checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
231
- checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
232
233
  checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: Omit<CheckSemVerOptions, "min" | "max" | "equals">): boolean;
234
+ /** @deprecated */
233
235
  sanitizeCmd(value: string): string;
236
+ /** @deprecated */
234
237
  sanitizeArgs(value: string, doubleQuote?: boolean): string;
238
+ /** @deprecated */
235
239
  sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
236
240
  purgeMemory(percent: number, parent: boolean): Promise<number>;
237
241
  purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
@@ -410,11 +414,11 @@ interface LoggerModule {
410
414
 
411
415
  ## References
412
416
 
413
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/core.d.ts
414
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/logger.d.ts
415
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/module.d.ts
416
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/node.d.ts
417
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/settings.d.ts
417
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/core.d.ts
418
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/logger.d.ts
419
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/module.d.ts
420
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/node.d.ts
421
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/settings.d.ts
418
422
 
419
423
  * https://www.npmjs.com/package/@types/node
420
424
 
package/index.js CHANGED
@@ -944,7 +944,7 @@ function isPathUNC(value) {
944
944
  const isMeterUnit = (type, ident) => (type & 256) === 256 && !ident;
945
945
  const formatLogMessage = (type, message, unit, ident) => isMeterUnit(type, ident) ? (unit + LOG_DIVIDER + message).trimEnd() : unit ? (message + (ident ? '' : ' ') + unit).trimStart() : message;
946
946
  const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
947
- const asFile = (value) => typeof value === 'string' ? value.trim() : value instanceof URL && value.protocol === 'file:' ? (0, node_url_1.fileURLToPath)(value) : '';
947
+ const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? (0, node_url_1.fileURLToPath)(value) : '';
948
948
  const wrapQuote = (value) => '"' + value.replaceAll('"', '\\"') + '"';
949
949
  const isFunction = (value) => typeof value === 'function';
950
950
  const isFileURL = (value) => /^file:\/\//i.test(value);
@@ -984,7 +984,7 @@ class Module extends EventEmitter {
984
984
  this[_g] = null;
985
985
  }
986
986
  static get VERSION() {
987
- return "0.11.3";
987
+ return "0.11.4";
988
988
  }
989
989
  static get LOG_TYPE() {
990
990
  return types_1.LOG_TYPE;
@@ -1074,7 +1074,7 @@ class Module extends EventEmitter {
1074
1074
  if (error && hideAbort(message)) {
1075
1075
  return;
1076
1076
  }
1077
- if (options.type) {
1077
+ if (typeof options.type === 'number') {
1078
1078
  type |= options.type;
1079
1079
  }
1080
1080
  const BROADCAST_OUT = VALUES["broadcast.out"];
@@ -1559,7 +1559,7 @@ class Module extends EventEmitter {
1559
1559
  filename = undefined;
1560
1560
  }
1561
1561
  if (typeof value === 'string') {
1562
- let pathname = value.trim(), convert = true;
1562
+ let pathname = PLATFORM_WIN32 ? value.trim() : value, convert = true;
1563
1563
  if (normalize) {
1564
1564
  pathname = path.normalize(pathname);
1565
1565
  convert = PLATFORM_WIN32;
@@ -1675,7 +1675,7 @@ class Module extends EventEmitter {
1675
1675
  return false;
1676
1676
  }
1677
1677
  static resolveFile(value) {
1678
- if (isFileURL(value = value instanceof URL ? value.toString() : value.trim())) {
1678
+ if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
1679
1679
  try {
1680
1680
  return (0, node_url_1.fileURLToPath)(value);
1681
1681
  }
@@ -1690,7 +1690,7 @@ class Module extends EventEmitter {
1690
1690
  }
1691
1691
  static resolvePath(value, base) {
1692
1692
  try {
1693
- if (this.isURL(value = value.trim())) {
1693
+ if (this.isURL(value)) {
1694
1694
  return isFileURL(value) ? (0, node_url_1.fileURLToPath)(value) : new URL(value).href;
1695
1695
  }
1696
1696
  if (base instanceof URL || this.isURL(base)) {
@@ -1722,7 +1722,7 @@ class Module extends EventEmitter {
1722
1722
  flags = flags ? 2 : 0;
1723
1723
  }
1724
1724
  if (typeof value === 'string') {
1725
- let result = value.trim();
1725
+ let result = PLATFORM_WIN32 ? value.trim() : value;
1726
1726
  result = flags & 1 ? path.resolve(result) : path.normalize(result);
1727
1727
  if ((flags & 2) && result.length > 0) {
1728
1728
  result = ensureDir(result);
@@ -3703,7 +3703,7 @@ class Module extends EventEmitter {
3703
3703
  if (typeof value === 'boolean') {
3704
3704
  queue = value;
3705
3705
  }
3706
- ({ type = types_1.STATUS_TYPE.UNKNOWN, value, timeStamp, duration } = type);
3706
+ value = type.value;
3707
3707
  }
3708
3708
  const output = Module.asString(value);
3709
3709
  if (output) {
@@ -3731,7 +3731,7 @@ class Module extends EventEmitter {
3731
3731
  from = timeStamp;
3732
3732
  timeStamp = 0;
3733
3733
  }
3734
- else if ((0, types_1.isObject)(timeStamp)) {
3734
+ else if ((0, types_1.isPlainObject)(timeStamp)) {
3735
3735
  ({ timeStamp, duration, from, source } = timeStamp);
3736
3736
  }
3737
3737
  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.11.3",
3
+ "version": "0.11.4",
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.11.3",
23
+ "@e-mc/types": "0.11.4",
24
24
  "chalk": "4.1.2",
25
25
  "file-type": "^18.7.0",
26
26
  "js-yaml": "^4.1.0",