@e-mc/types 0.11.0 → 0.11.1

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.
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.0/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.1/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogArguments } from "./lib/logger";
@@ -47,7 +47,7 @@ function convertTime(value: number | string): number;
47
47
  function convertTime(value: HighResolutionTime, format: true): string;
48
48
  function convertTime(value: HighResolutionTime, format?: boolean): number;
49
49
  function hasGlob(value: string): boolean;
50
- function escapePattern(value: unknown, lookBehind?: boolean): string;
50
+ function escapePattern(value: unknown, lookBehind?: boolean, reserved?: boolean): string;
51
51
  function renameExt(value: string, ext: string, when?: string): string;
52
52
  function formatSize(value: string): number;
53
53
  function formatSize(value: number, options?: BytesOptions): string;
@@ -69,6 +69,7 @@ function validateUUID(value: unknown): boolean;
69
69
  function randomString(format: string, dictionary?: string): string;
70
70
  function errorValue(value: string, hint?: string): Error;
71
71
  function errorMessage(title: number | string, value: string, hint?: string): Error;
72
+ function supported(major: number, minor: number, lts: boolean): boolean;
72
73
  function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
73
74
  function importESM<T = unknown>(name: string, isDefault?: boolean, fromPath?: boolean): Promise<T>;
74
75
  function purgeMemory(percent?: number): number;
@@ -197,10 +198,10 @@ const IMPORT_MAP: Record<string, string | undefined>;
197
198
 
198
199
  ## References
199
200
 
200
- - https://www.unpkg.com/@e-mc/types@0.11.0/index.d.ts
201
- - https://www.unpkg.com/@e-mc/types@0.11.0/lib/logger.d.ts
202
- - https://www.unpkg.com/@e-mc/types@0.11.0/lib/module.d.ts
203
- - https://www.unpkg.com/@e-mc/types@0.11.0/lib/node.d.ts
201
+ - https://www.unpkg.com/@e-mc/types@0.11.1/index.d.ts
202
+ - https://www.unpkg.com/@e-mc/types@0.11.1/lib/logger.d.ts
203
+ - https://www.unpkg.com/@e-mc/types@0.11.1/lib/module.d.ts
204
+ - https://www.unpkg.com/@e-mc/types@0.11.1/lib/node.d.ts
204
205
 
205
206
  * https://developer.mozilla.org/en-US/docs/Web/API/DOMException
206
207
  * https://www.npmjs.com/package/@types/bytes
package/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.11.0',
2
+ VERSION = '0.11.1',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
package/index.d.ts CHANGED
@@ -308,7 +308,7 @@ declare namespace types {
308
308
  function convertTime(value: HighResolutionTime, format: true): string;
309
309
  function convertTime(value: HighResolutionTime, format?: boolean): number;
310
310
  function hasGlob(value: string): boolean;
311
- function escapePattern(value: unknown, lookBehind?: boolean): string;
311
+ function escapePattern(value: unknown, symbols?: boolean): string;
312
312
  function renameExt(value: string, ext: string, when?: string): string;
313
313
  function formatSize(value: string): number;
314
314
  function formatSize(value: number, options?: BytesOptions): string;
@@ -330,6 +330,7 @@ declare namespace types {
330
330
  function randomString(format: string, dictionary?: string): string;
331
331
  function errorValue(value: string, hint?: string): Error;
332
332
  function errorMessage(title: number | string, value: string, hint?: string): Error;
333
+ function supported(major: number, minor: number, lts: boolean): boolean;
333
334
  function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
334
335
  function importESM<T = unknown>(name: string, isDefault?: boolean, fromPath?: boolean): Promise<T>;
335
336
  function purgeMemory(percent?: number): number;
package/index.js CHANGED
@@ -64,7 +64,6 @@ class AbortError extends Error {
64
64
  }
65
65
  }
66
66
  const PATTERN_CHARS = {
67
- '-': '\\x2d',
68
67
  '&': '\\x26',
69
68
  '!': '\\x21',
70
69
  '#': '\\x23',
@@ -107,6 +106,9 @@ function fromObject(value, typedArray) {
107
106
  if (value instanceof RegExp) {
108
107
  return new RegExp(value);
109
108
  }
109
+ if (value instanceof URL) {
110
+ return new URL(value);
111
+ }
110
112
  if (typedArray) {
111
113
  if (value instanceof Buffer) {
112
114
  return Buffer.from(value);
@@ -690,20 +692,20 @@ function convertTime(value, format) {
690
692
  else {
691
693
  return parseTime(value);
692
694
  }
693
- return (format ? formatTime(result) : result);
695
+ return format ? formatTime(result) : result;
694
696
  }
695
697
  function hasGlob(value) {
696
698
  return REGEXP_GLOB.test(value);
697
699
  }
698
- function escapePattern(value, lookBehind) {
700
+ function escapePattern(value, symbols) {
699
701
  switch (typeof value) {
700
702
  case 'string': {
701
703
  let result = '', j = 0;
702
704
  for (let i = 0, length = value.length, ch; i < length; ++i) {
703
- if (lookBehind && value[i - 1] === '\\') {
704
- continue;
705
- }
706
705
  switch (ch = value[i]) {
706
+ case '-':
707
+ ch = '\\x2d';
708
+ break;
707
709
  case '.':
708
710
  case '+':
709
711
  case '*':
@@ -721,7 +723,7 @@ function escapePattern(value, lookBehind) {
721
723
  ch = '\\' + ch;
722
724
  break;
723
725
  default:
724
- if (!(ch = PATTERN_CHARS[ch])) {
726
+ if (!(symbols && (ch = PATTERN_CHARS[ch]))) {
725
727
  continue;
726
728
  }
727
729
  break;
@@ -1040,10 +1042,12 @@ function errorValue(value, hint) {
1040
1042
  return new Error(value + (hint ? ` (${hint})` : ''));
1041
1043
  }
1042
1044
  function errorMessage(title, value, hint) {
1043
- return new Error((title !== '' ? title + ': ' : '') + value + (hint ? ` (${hint})` : ''));
1045
+ return new Error((isString(title) || typeof title === 'number' ? title + ': ' : '') + value + (hint ? ` (${hint})` : ''));
1044
1046
  }
1045
1047
  function purgeMemory(percent) {
1046
1048
  CACHE_COERCED = new WeakSet();
1049
+ INCREMENT_COUNT = 65536;
1050
+ LOG_CURRENT = null;
1047
1051
  }
1048
1052
  function incrementUUID(restart) {
1049
1053
  if (restart || INCREMENT_COUNT === 65536) {
@@ -1060,10 +1064,14 @@ function hashKey(data, algorithm = 'md5', encoding = 'base64') {
1060
1064
  return crypto.randomUUID();
1061
1065
  }
1062
1066
  }
1063
- function supported(major, minor = 0, patch = 0, lts) {
1067
+ function supported(major, minor = 0, patch = 0, lts = false) {
1064
1068
  if (VER_MAJOR < major) {
1065
1069
  return false;
1066
1070
  }
1071
+ if (typeof patch === 'boolean') {
1072
+ lts = patch;
1073
+ patch = 0;
1074
+ }
1067
1075
  if (VER_MAJOR === major) {
1068
1076
  if (VER_MINOR < minor) {
1069
1077
  return false;
@@ -1090,4 +1098,4 @@ async function importESM(name, isDefault, fromPath) {
1090
1098
  }
1091
1099
  exports.generateUUID = crypto.randomUUID.bind(crypto);
1092
1100
  SUPPORTED_DOMEXCEPTION = supported(17);
1093
- SUPPORTED_HASHSINGLE = supported(20, 12, 0, true) || supported(21, 7);
1101
+ SUPPORTED_HASHSINGLE = supported(20, 12, true) || supported(21, 7);
package/lib/squared.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="type.d.ts" />
2
2
 
3
- import type { BinaryToTextEncoding } from "crypto";
3
+ import type { BinaryToTextEncoding } from "node:crypto";
4
4
 
5
5
  interface Asset extends MimeTypeAction {
6
6
  uri?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,8 @@
20
20
  "license": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "bytes": "^3.1.2"
23
+ "bytes": "^3.1.2",
24
+ "chalk": "4.1.2"
24
25
  },
25
26
  "devDependencies": {
26
27
  "typescript": "5.7.2"