@vope/utils 1.3.0 → 1.3.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/cjs/encoding.js CHANGED
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utf8_first_prefix = /^1{2,}/g;
4
4
  const utf8_other_prefix = /^10/;
5
- var Encodes;
6
- (function (Encodes) {
7
- Encodes["UTF_8"] = "utf-8";
8
- Encodes["UTF_16LE"] = "utf-16le";
9
- Encodes["UTF_16BE"] = "utf-16be";
10
- Encodes["GBK"] = "gbk";
11
- })(Encodes || (Encodes = {}));
5
+ const Encodes = {
6
+ UTF_8: 'utf-8',
7
+ UTF_16LE: 'utf-16le',
8
+ UTF_16BE: 'utf-16be',
9
+ GBK: 'gbk'
10
+ };
12
11
  const defaults = {
13
12
  utf8: [0xef, 0xbb, 0xbf],
14
13
  };
@@ -65,7 +65,7 @@ class MemoryBasic {
65
65
  * 检测存储是否包含某种类型
66
66
  */
67
67
  includes(type) {
68
- return type in this.memorys;
68
+ return this.memorys.has(type);
69
69
  }
70
70
  /**
71
71
  * 获取指定类型存储数据
package/lib/encoding.js CHANGED
@@ -1,12 +1,11 @@
1
1
  const utf8_first_prefix = /^1{2,}/g;
2
2
  const utf8_other_prefix = /^10/;
3
- var Encodes;
4
- (function (Encodes) {
5
- Encodes["UTF_8"] = "utf-8";
6
- Encodes["UTF_16LE"] = "utf-16le";
7
- Encodes["UTF_16BE"] = "utf-16be";
8
- Encodes["GBK"] = "gbk";
9
- })(Encodes || (Encodes = {}));
3
+ const Encodes = {
4
+ UTF_8: 'utf-8',
5
+ UTF_16LE: 'utf-16le',
6
+ UTF_16BE: 'utf-16be',
7
+ GBK: 'gbk'
8
+ };
10
9
  const defaults = {
11
10
  utf8: [0xef, 0xbb, 0xbf],
12
11
  };
@@ -60,7 +60,7 @@ export default class MemoryBasic {
60
60
  * 检测存储是否包含某种类型
61
61
  */
62
62
  includes(type) {
63
- return type in this.memorys;
63
+ return this.memorys.has(type);
64
64
  }
65
65
  /**
66
66
  * 获取指定类型存储数据
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vope/utils",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,16 +1,10 @@
1
- declare enum Encodes {
2
- UTF_8 = "utf-8",
3
- UTF_16LE = "utf-16le",
4
- UTF_16BE = "utf-16be",
5
- GBK = "gbk"
6
- }
7
1
  /**
8
2
  * 根据文件内容判断文件的编码
9
3
  * @param uint 文件内容Uint8Array格式
10
4
  * @param limit 用于约束GBK和utf_8的判定上限
11
5
  */
12
6
  declare const getEncoding: (uint: Uint8Array, limit?: number) => {
13
- encoding: Encodes;
7
+ encoding: "utf-8" | "utf-16le" | "utf-16be" | "gbk";
14
8
  offset: number;
15
9
  };
16
10
  export default getEncoding;