uniconst 1.0.0
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/LICENSE +21 -0
- package/README.md +52 -0
- package/README.zh_CN.md +52 -0
- package/dist/index.d.mts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +44 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kiccer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Uniconst
|
|
2
|
+
|
|
3
|
+
Uniconst is a lightweight TypeScript utility library designed to manage constant mappings in a type-safe and structured manner. It provides an intuitive class-based API for handling constants with associated labels, values, and additional metadata such as colors.
|
|
4
|
+
|
|
5
|
+
## 📌 Features
|
|
6
|
+
|
|
7
|
+
* **Type Safety**: Built with TypeScript generics to ensure compile-time type checking.
|
|
8
|
+
* **Flexible Data Structure**: Supports extensible constant items with customizable fields.
|
|
9
|
+
* **Utility Methods**: Offers convenient methods for retrieving values, extracting options, and mapping labels.
|
|
10
|
+
* **Scalable Design**: Easily integrable into various applications including UI frameworks, backend services, and configuration systems.
|
|
11
|
+
|
|
12
|
+
## 🛠️ Usage
|
|
13
|
+
|
|
14
|
+
Create a constant definition object and instantiate the `Uniconst` class:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import Uniconst from 'uniconst';
|
|
18
|
+
|
|
19
|
+
const Status = new Uniconst({
|
|
20
|
+
PENDING: { label: 'Pending', value: 0 },
|
|
21
|
+
APPROVED: { label: 'Approved', value: 1 },
|
|
22
|
+
REJECTED: { label: 'Rejected', value: 2 }
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
console.log(Status.get('PENDING')); // { label: 'Pending', value: 0 }
|
|
26
|
+
console.log(Status.getOptions()); // Array of all options
|
|
27
|
+
console.log(Status.toLabelMap()); // { '0': 'Pending', '1': 'Approved', '2': 'Rejected' }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## ✅ Benefits
|
|
31
|
+
|
|
32
|
+
* **Strong Typing**: Ensures that only valid keys and values are accessed.
|
|
33
|
+
* **Extensible**: You can add custom fields to your constant items without breaking existing logic.
|
|
34
|
+
* **Clean Abstraction**: Encapsulates common patterns for working with labeled constants.
|
|
35
|
+
|
|
36
|
+
## 📦 Installation
|
|
37
|
+
|
|
38
|
+
If you plan to publish this package to npm, install it via:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install uniconst
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or if using yarn:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
yarn add uniconst
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 📄 License
|
|
51
|
+
|
|
52
|
+
MIT License — See LICENSE for details.
|
package/README.zh_CN.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Uniconst
|
|
2
|
+
|
|
3
|
+
Uniconst 是一个轻量级的 TypeScript 工具库,旨在以类型安全且结构化的方式管理常量映射。它提供了一个基于类的直观 API,用于处理带有相关标签、值以及附加元数据(如颜色)的常量。
|
|
4
|
+
|
|
5
|
+
## 📌 特性
|
|
6
|
+
|
|
7
|
+
* **类型安全**:使用 TypeScript 泛型确保编译时类型检查。
|
|
8
|
+
* **灵活的数据结构**:支持带有可扩展字段的常量项。
|
|
9
|
+
* **实用方法**:提供便捷的方法用于获取值、提取选项和映射标签。
|
|
10
|
+
* **可扩展的设计**:易于集成到各种应用中,包括 UI 框架、后端服务和配置系统。
|
|
11
|
+
|
|
12
|
+
## 🛠️ 使用方法
|
|
13
|
+
|
|
14
|
+
创建一个常量定义对象并实例化 `Uniconst` 类:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import Uniconst from 'uniconst';
|
|
18
|
+
|
|
19
|
+
const Status = new Uniconst({
|
|
20
|
+
PENDING: { label: 'Pending', value: 0 },
|
|
21
|
+
APPROVED: { label: 'Approved', value: 1 },
|
|
22
|
+
REJECTED: { label: 'Rejected', value: 2 }
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
console.log(Status.get('PENDING')); // { label: 'Pending', value: 0 }
|
|
26
|
+
console.log(Status.getOptions()); // 所有选项的数组
|
|
27
|
+
console.log(Status.toLabelMap()); // { '0': 'Pending', '1': 'Approved', '2': 'Rejected' }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## ✅ 优势
|
|
31
|
+
|
|
32
|
+
* **强类型**:确保只能访问有效的键和值。
|
|
33
|
+
* **可扩展性**:可以向常量项中添加自定义字段而不破坏现有逻辑。
|
|
34
|
+
* **清晰的抽象**:封装了处理带标签常量的常见模式。
|
|
35
|
+
|
|
36
|
+
## 📦 Installation
|
|
37
|
+
|
|
38
|
+
如果你计划将此包发布到 npm,可以通过以下方式安装:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install uniconst
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
或使用 yarn:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
yarn add uniconst
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 📄 许可证
|
|
51
|
+
|
|
52
|
+
MIT License — 详情请查看 LICENSE 文件。
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface UniconstItem {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string | number;
|
|
4
|
+
color: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
interface UniconstOptions {
|
|
8
|
+
[key: string]: UniconstItem;
|
|
9
|
+
}
|
|
10
|
+
interface UniconstMaps {
|
|
11
|
+
[key: UniconstItem['value']]: UniconstItem['label'];
|
|
12
|
+
}
|
|
13
|
+
declare class Uniconst<T extends UniconstOptions> {
|
|
14
|
+
private readonly __source;
|
|
15
|
+
constructor(__source: T);
|
|
16
|
+
/**
|
|
17
|
+
* 根据键获取对应的值
|
|
18
|
+
*
|
|
19
|
+
* 此方法通过泛型K来限制可以访问的属性类型,确保类型安全
|
|
20
|
+
* 它利用了TypeScript的索引访问特性,以键值的形式获取对象的属性
|
|
21
|
+
*
|
|
22
|
+
* @param key - 要获取的属性的键,必须是对象T的有效键
|
|
23
|
+
* @returns 返回对象T中与键K对应的值
|
|
24
|
+
*/
|
|
25
|
+
get<K extends keyof T>(key: K): T[K];
|
|
26
|
+
/**
|
|
27
|
+
* 获取选项数组
|
|
28
|
+
*
|
|
29
|
+
* 此方法用于获取当前源数据中的所有选项这些选项是源数据对象的值的集合
|
|
30
|
+
* 如果源数据为空或者不存在,将返回一个空数组
|
|
31
|
+
*
|
|
32
|
+
* @returns {UniconstItem[]} 一个包含所有选项的数组如果源数据为空,则返回空数组
|
|
33
|
+
*/
|
|
34
|
+
getOptions(): UniconstItem[];
|
|
35
|
+
/**
|
|
36
|
+
* 将当前对象的选项转换为标签映射
|
|
37
|
+
* 此方法主要用于生成一个映射对象,其中键是选项的值,值是选项的标签
|
|
38
|
+
* @returns {UniconstMaps} 返回一个对象,其中每个选项的值映射到其对应的标签
|
|
39
|
+
*/
|
|
40
|
+
toLabelMap(): UniconstMaps;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Uniconst as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface UniconstItem {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string | number;
|
|
4
|
+
color: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
interface UniconstOptions {
|
|
8
|
+
[key: string]: UniconstItem;
|
|
9
|
+
}
|
|
10
|
+
interface UniconstMaps {
|
|
11
|
+
[key: UniconstItem['value']]: UniconstItem['label'];
|
|
12
|
+
}
|
|
13
|
+
declare class Uniconst<T extends UniconstOptions> {
|
|
14
|
+
private readonly __source;
|
|
15
|
+
constructor(__source: T);
|
|
16
|
+
/**
|
|
17
|
+
* 根据键获取对应的值
|
|
18
|
+
*
|
|
19
|
+
* 此方法通过泛型K来限制可以访问的属性类型,确保类型安全
|
|
20
|
+
* 它利用了TypeScript的索引访问特性,以键值的形式获取对象的属性
|
|
21
|
+
*
|
|
22
|
+
* @param key - 要获取的属性的键,必须是对象T的有效键
|
|
23
|
+
* @returns 返回对象T中与键K对应的值
|
|
24
|
+
*/
|
|
25
|
+
get<K extends keyof T>(key: K): T[K];
|
|
26
|
+
/**
|
|
27
|
+
* 获取选项数组
|
|
28
|
+
*
|
|
29
|
+
* 此方法用于获取当前源数据中的所有选项这些选项是源数据对象的值的集合
|
|
30
|
+
* 如果源数据为空或者不存在,将返回一个空数组
|
|
31
|
+
*
|
|
32
|
+
* @returns {UniconstItem[]} 一个包含所有选项的数组如果源数据为空,则返回空数组
|
|
33
|
+
*/
|
|
34
|
+
getOptions(): UniconstItem[];
|
|
35
|
+
/**
|
|
36
|
+
* 将当前对象的选项转换为标签映射
|
|
37
|
+
* 此方法主要用于生成一个映射对象,其中键是选项的值,值是选项的标签
|
|
38
|
+
* @returns {UniconstMaps} 返回一个对象,其中每个选项的值映射到其对应的标签
|
|
39
|
+
*/
|
|
40
|
+
toLabelMap(): UniconstMaps;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Uniconst as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
default: () => index_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var Uniconst = class {
|
|
27
|
+
constructor(__source) {
|
|
28
|
+
this.__source = __source;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 根据键获取对应的值
|
|
32
|
+
*
|
|
33
|
+
* 此方法通过泛型K来限制可以访问的属性类型,确保类型安全
|
|
34
|
+
* 它利用了TypeScript的索引访问特性,以键值的形式获取对象的属性
|
|
35
|
+
*
|
|
36
|
+
* @param key - 要获取的属性的键,必须是对象T的有效键
|
|
37
|
+
* @returns 返回对象T中与键K对应的值
|
|
38
|
+
*/
|
|
39
|
+
get(key) {
|
|
40
|
+
return this.__source[key];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 获取选项数组
|
|
44
|
+
*
|
|
45
|
+
* 此方法用于获取当前源数据中的所有选项这些选项是源数据对象的值的集合
|
|
46
|
+
* 如果源数据为空或者不存在,将返回一个空数组
|
|
47
|
+
*
|
|
48
|
+
* @returns {UniconstItem[]} 一个包含所有选项的数组如果源数据为空,则返回空数组
|
|
49
|
+
*/
|
|
50
|
+
getOptions() {
|
|
51
|
+
return Object.values(this.__source) ?? [];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 将当前对象的选项转换为标签映射
|
|
55
|
+
* 此方法主要用于生成一个映射对象,其中键是选项的值,值是选项的标签
|
|
56
|
+
* @returns {UniconstMaps} 返回一个对象,其中每个选项的值映射到其对应的标签
|
|
57
|
+
*/
|
|
58
|
+
toLabelMap() {
|
|
59
|
+
return this.getOptions().reduce((obj, item) => {
|
|
60
|
+
return { ...obj, [item.value]: item.label };
|
|
61
|
+
}, {});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var index_default = Uniconst;
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["interface UniconstItem {\r\n label: string\r\n value: string | number\r\n color: string\r\n [key: string]: any\r\n}\r\n\r\ninterface UniconstOptions {\r\n [key: string]: UniconstItem\r\n}\r\n\r\ninterface UniconstMaps {\r\n [key: UniconstItem['value']]: UniconstItem['label']\r\n}\r\n\r\nclass Uniconst<T extends UniconstOptions> {\r\n constructor (\r\n private readonly __source: T\r\n ) {}\r\n\r\n /**\r\n * 根据键获取对应的值\r\n *\r\n * 此方法通过泛型K来限制可以访问的属性类型,确保类型安全\r\n * 它利用了TypeScript的索引访问特性,以键值的形式获取对象的属性\r\n *\r\n * @param key - 要获取的属性的键,必须是对象T的有效键\r\n * @returns 返回对象T中与键K对应的值\r\n */\r\n get<K extends keyof T> (key: K): T[K] {\r\n return this.__source[key]\r\n }\r\n\r\n /**\r\n * 获取选项数组\r\n *\r\n * 此方法用于获取当前源数据中的所有选项这些选项是源数据对象的值的集合\r\n * 如果源数据为空或者不存在,将返回一个空数组\r\n *\r\n * @returns {UniconstItem[]} 一个包含所有选项的数组如果源数据为空,则返回空数组\r\n */\r\n getOptions (): UniconstItem[] {\r\n return Object.values(this.__source) ?? []\r\n }\r\n\r\n /**\r\n * 将当前对象的选项转换为标签映射\r\n * 此方法主要用于生成一个映射对象,其中键是选项的值,值是选项的标签\r\n * @returns {UniconstMaps} 返回一个对象,其中每个选项的值映射到其对应的标签\r\n */\r\n toLabelMap (): UniconstMaps {\r\n return this.getOptions().reduce((obj, item) => {\r\n return { ...obj, [item.value]: item.label }\r\n }, {}) as UniconstMaps\r\n }\r\n}\r\n\r\nexport default Uniconst\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,IAAM,WAAN,MAA0C;AAAA,EACtC,YACqB,UACnB;AADmB;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWH,IAAwB,KAAc;AAClC,WAAO,KAAK,SAAS,GAAG;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAA8B;AAC1B,WAAO,OAAO,OAAO,KAAK,QAAQ,KAAK,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAA4B;AACxB,WAAO,KAAK,WAAW,EAAE,OAAO,CAAC,KAAK,SAAS;AAC3C,aAAO,EAAE,GAAG,KAAK,CAAC,KAAK,KAAK,GAAG,KAAK,MAAM;AAAA,IAC9C,GAAG,CAAC,CAAC;AAAA,EACT;AACJ;AAEA,IAAO,gBAAQ;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var Uniconst = class {
|
|
3
|
+
constructor(__source) {
|
|
4
|
+
this.__source = __source;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 根据键获取对应的值
|
|
8
|
+
*
|
|
9
|
+
* 此方法通过泛型K来限制可以访问的属性类型,确保类型安全
|
|
10
|
+
* 它利用了TypeScript的索引访问特性,以键值的形式获取对象的属性
|
|
11
|
+
*
|
|
12
|
+
* @param key - 要获取的属性的键,必须是对象T的有效键
|
|
13
|
+
* @returns 返回对象T中与键K对应的值
|
|
14
|
+
*/
|
|
15
|
+
get(key) {
|
|
16
|
+
return this.__source[key];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 获取选项数组
|
|
20
|
+
*
|
|
21
|
+
* 此方法用于获取当前源数据中的所有选项这些选项是源数据对象的值的集合
|
|
22
|
+
* 如果源数据为空或者不存在,将返回一个空数组
|
|
23
|
+
*
|
|
24
|
+
* @returns {UniconstItem[]} 一个包含所有选项的数组如果源数据为空,则返回空数组
|
|
25
|
+
*/
|
|
26
|
+
getOptions() {
|
|
27
|
+
return Object.values(this.__source) ?? [];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 将当前对象的选项转换为标签映射
|
|
31
|
+
* 此方法主要用于生成一个映射对象,其中键是选项的值,值是选项的标签
|
|
32
|
+
* @returns {UniconstMaps} 返回一个对象,其中每个选项的值映射到其对应的标签
|
|
33
|
+
*/
|
|
34
|
+
toLabelMap() {
|
|
35
|
+
return this.getOptions().reduce((obj, item) => {
|
|
36
|
+
return { ...obj, [item.value]: item.label };
|
|
37
|
+
}, {});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var index_default = Uniconst;
|
|
41
|
+
export {
|
|
42
|
+
index_default as default
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["interface UniconstItem {\r\n label: string\r\n value: string | number\r\n color: string\r\n [key: string]: any\r\n}\r\n\r\ninterface UniconstOptions {\r\n [key: string]: UniconstItem\r\n}\r\n\r\ninterface UniconstMaps {\r\n [key: UniconstItem['value']]: UniconstItem['label']\r\n}\r\n\r\nclass Uniconst<T extends UniconstOptions> {\r\n constructor (\r\n private readonly __source: T\r\n ) {}\r\n\r\n /**\r\n * 根据键获取对应的值\r\n *\r\n * 此方法通过泛型K来限制可以访问的属性类型,确保类型安全\r\n * 它利用了TypeScript的索引访问特性,以键值的形式获取对象的属性\r\n *\r\n * @param key - 要获取的属性的键,必须是对象T的有效键\r\n * @returns 返回对象T中与键K对应的值\r\n */\r\n get<K extends keyof T> (key: K): T[K] {\r\n return this.__source[key]\r\n }\r\n\r\n /**\r\n * 获取选项数组\r\n *\r\n * 此方法用于获取当前源数据中的所有选项这些选项是源数据对象的值的集合\r\n * 如果源数据为空或者不存在,将返回一个空数组\r\n *\r\n * @returns {UniconstItem[]} 一个包含所有选项的数组如果源数据为空,则返回空数组\r\n */\r\n getOptions (): UniconstItem[] {\r\n return Object.values(this.__source) ?? []\r\n }\r\n\r\n /**\r\n * 将当前对象的选项转换为标签映射\r\n * 此方法主要用于生成一个映射对象,其中键是选项的值,值是选项的标签\r\n * @returns {UniconstMaps} 返回一个对象,其中每个选项的值映射到其对应的标签\r\n */\r\n toLabelMap (): UniconstMaps {\r\n return this.getOptions().reduce((obj, item) => {\r\n return { ...obj, [item.value]: item.label }\r\n }, {}) as UniconstMaps\r\n }\r\n}\r\n\r\nexport default Uniconst\r\n"],"mappings":";AAeA,IAAM,WAAN,MAA0C;AAAA,EACtC,YACqB,UACnB;AADmB;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWH,IAAwB,KAAc;AAClC,WAAO,KAAK,SAAS,GAAG;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAA8B;AAC1B,WAAO,OAAO,OAAO,KAAK,QAAQ,KAAK,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAA4B;AACxB,WAAO,KAAK,WAAW,EAAE,OAAO,CAAC,KAAK,SAAS;AAC3C,aAAO,EAAE,GAAG,KAAK,CAAC,KAAK,KAAK,GAAG,KAAK,MAAM;AAAA,IAC9C,GAAG,CAAC,CAAC;AAAA,EACT;AACJ;AAEA,IAAO,gBAAQ;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uniconst",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A lightweight TypeScript utility for unified constant management with value-label mapping and type-safe access",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"constant",
|
|
7
|
+
"uniconst",
|
|
8
|
+
"typescript",
|
|
9
|
+
"enum",
|
|
10
|
+
"utility",
|
|
11
|
+
"mapping",
|
|
12
|
+
"label-map"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/kiccer/uniconst#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/kiccer/uniconst/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/kiccer/uniconst.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "kiccer <1072907338@qq.com>",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"main": "dist/index.cjs",
|
|
31
|
+
"module": "dist/index.mjs",
|
|
32
|
+
"types": "dist/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"README.zh_CN.md"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"prepublishOnly": "npm run build",
|
|
41
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"tsup": "^8.5.0",
|
|
45
|
+
"typescript": "^5.8.3"
|
|
46
|
+
}
|
|
47
|
+
}
|