@airpower/enum 1.6.5 → 1.6.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/enum",
3
3
  "type": "module",
4
- "version": "1.6.5",
4
+ "version": "1.6.6",
5
5
  "description": "AirPower-Enum 是一个基于 TypeScript 的封装的类似 Java 枚举类的枚举字典处理工具。",
6
6
  "author": {
7
7
  "name": "Hamm",
@@ -26,15 +26,8 @@
26
26
  "oop",
27
27
  "class"
28
28
  ],
29
- "exports": {
30
- ".": {
31
- "types": "./dist/index.d.ts",
32
- "import": "./dist/main.es.js",
33
- "require": "./dist/main.cjs.js"
34
- }
35
- },
36
- "main": "dist/main.cjs.js",
37
- "module": "dist/main.es.js",
29
+ "main": "dist/main.js",
30
+ "module": "dist/main.js",
38
31
  "types": "dist/index.d.ts",
39
32
  "files": [
40
33
  "assets",
package/dist/main.cjs.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class Enum {
4
- /**
5
- * ### 枚举的值
6
- */
7
- key;
8
- /**
9
- * ### 枚举的描述
10
- */
11
- label;
12
- /**
13
- * ### 实例化创建一个枚举项目
14
- * @param key 枚举值
15
- * @param label 枚举描述
16
- */
17
- constructor(key, label) {
18
- this.key = key;
19
- if (label) {
20
- this.label = label;
21
- }
22
- }
23
- /**
24
- * ### 查找一个枚举选项
25
- * @param key `Key`
26
- */
27
- static get(key) {
28
- return this.toArray().find((item) => item.key === key) || null;
29
- }
30
- /**
31
- * ### 获取一个枚举的标签
32
- * @param key `Key`
33
- * @param defaultLabel 默认标签
34
- */
35
- static getLabel(key, defaultLabel = "-") {
36
- const item = this.get(key);
37
- return item?.label || defaultLabel;
38
- }
39
- /**
40
- * ### 将枚举转为数组
41
- * @returns 枚举数组
42
- */
43
- static toArray() {
44
- return Object.values(this).filter((item) => item instanceof this);
45
- }
46
- /**
47
- * ### 判断 `Key` 是否相等
48
- * @param key `Key`
49
- */
50
- equalsKey(key) {
51
- return this.key === key;
52
- }
53
- }
54
- exports.Enum = Enum;
package/dist/main.umd.js DELETED
@@ -1,58 +0,0 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.AirPowerEnum = {}));
3
- })(this, function(exports2) {
4
- "use strict";
5
- class Enum {
6
- /**
7
- * ### 枚举的值
8
- */
9
- key;
10
- /**
11
- * ### 枚举的描述
12
- */
13
- label;
14
- /**
15
- * ### 实例化创建一个枚举项目
16
- * @param key 枚举值
17
- * @param label 枚举描述
18
- */
19
- constructor(key, label) {
20
- this.key = key;
21
- if (label) {
22
- this.label = label;
23
- }
24
- }
25
- /**
26
- * ### 查找一个枚举选项
27
- * @param key `Key`
28
- */
29
- static get(key) {
30
- return this.toArray().find((item) => item.key === key) || null;
31
- }
32
- /**
33
- * ### 获取一个枚举的标签
34
- * @param key `Key`
35
- * @param defaultLabel 默认标签
36
- */
37
- static getLabel(key, defaultLabel = "-") {
38
- const item = this.get(key);
39
- return item?.label || defaultLabel;
40
- }
41
- /**
42
- * ### 将枚举转为数组
43
- * @returns 枚举数组
44
- */
45
- static toArray() {
46
- return Object.values(this).filter((item) => item instanceof this);
47
- }
48
- /**
49
- * ### 判断 `Key` 是否相等
50
- * @param key `Key`
51
- */
52
- equalsKey(key) {
53
- return this.key === key;
54
- }
55
- }
56
- exports2.Enum = Enum;
57
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
58
- });
File without changes