@e-mc/types 0.10.18 → 0.10.19

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.10.18/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.19/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogArguments } from "./lib/logger";
@@ -197,10 +197,10 @@ const IMPORT_MAP: Record<string, string | undefined>;
197
197
 
198
198
  ## References
199
199
 
200
- - https://www.unpkg.com/@e-mc/types@0.10.18/index.d.ts
201
- - https://www.unpkg.com/@e-mc/types@0.10.18/lib/logger.d.ts
202
- - https://www.unpkg.com/@e-mc/types@0.10.18/lib/module.d.ts
203
- - https://www.unpkg.com/@e-mc/types@0.10.18/lib/object.d.ts
200
+ - https://www.unpkg.com/@e-mc/types@0.10.19/index.d.ts
201
+ - https://www.unpkg.com/@e-mc/types@0.10.19/lib/logger.d.ts
202
+ - https://www.unpkg.com/@e-mc/types@0.10.19/lib/module.d.ts
203
+ - https://www.unpkg.com/@e-mc/types@0.10.19/lib/object.d.ts
204
204
 
205
205
  * https://developer.mozilla.org/en-US/docs/Web/API/DOMException
206
206
  * 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.10.18',
2
+ VERSION = '0.10.19',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
package/index.js CHANGED
@@ -991,24 +991,23 @@ function asFunction(value, sync = true) {
991
991
  }
992
992
  return null;
993
993
  }
994
- function getEncoding(value, fallback = 'utf-8') {
994
+ function getEncoding(value, fallback) {
995
995
  if (typeof value === 'string') {
996
- switch (value = value.trim().toLowerCase()) {
997
- case 'utf8':
998
- case 'utf-8':
999
- case 'unicode-1-1-utf-8':
1000
- return 'utf-8';
1001
- case 'utf16le':
1002
- case 'utf-16le':
1003
- case 'utf16':
1004
- case 'utf-16':
1005
- return 'utf16le';
996
+ const result = value.trim().toLowerCase();
997
+ if (result.slice(0, 3) === 'utf') {
998
+ switch (result.slice(result[3] === '-' ? 4 : 3)) {
999
+ case '8':
1000
+ return 'utf-8';
1001
+ case '16le':
1002
+ case '16':
1003
+ return 'utf16le';
1004
+ }
1006
1005
  }
1007
- if (Buffer.isEncoding(value)) {
1008
- return value;
1006
+ else if (Buffer.isEncoding(result)) {
1007
+ return result;
1009
1008
  }
1010
1009
  }
1011
- return fallback;
1010
+ return fallback || 'utf-8';
1012
1011
  }
1013
1012
  function encryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
1014
1013
  if (checkCipherType(algorithm) && isString(data)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.10.18",
3
+ "version": "0.10.19",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",