Skip to content

Commit 871a576

Browse files
committed
docs(core): update README
1 parent 291cdf5 commit 871a576

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ What other exciting features are there? Please continue to explore! Or you can c
6969
- Plugin system design, extending enum functionality through plugin installations
7070
- Supports type narrowing to enhance type safety<sup>_&nbsp;&nbsp;TypeScript_</sup>
7171
- Generates dropdowns from enums, compatible with UI libraries like [Ant Design](https://ant.design/components/overview), [Element Plus](https://element-plus.org/en-US/component/overview), [Material-UI](https://mui.com/material-ui) and more
72-
- Supports server-side rendering (SSR)
7372
- Compatible with various environments including Browsers, Node.js, React Native, Taro, and mini-programs
73+
- Supports server-side rendering (SSR)
7474
- Compatible with any front-end development framework, including vanilla projects
7575
- TypeScript‑oriented, providing excellent type inference and code completion capabilities
7676
- Zero dependencies
77-
- Lightweight (only 2KB+ minzipped)
77+
- Lightweight (2KB+ minzipped only)
7878

7979
## Installation
8080

@@ -355,26 +355,27 @@ WeekEnum.has('Birthday'); // false
355355

356356
Find an enum item by a specific field and its value. Returns the enum item object if found, otherwise returns `undefined`.
357357

358-
The `field` parameter can be one of the built-in fields: `key`, `value`, `label`, or any custom field defined in the enum.
358+
The `field` parameter can be one of the built-in fields: `key`, `value`, `label`, or any meta field defined in the enum item.
359359

360360
```js
361-
WeekEnum.findBy('value', 1); // { key: 'Monday', value: 1, label: 'Monday' }
362-
WeekEnum.findBy('key', 'Monday'); // { key: 'Monday', value: 1, label: 'Monday' }
361+
ColorEnum.findBy('value', 1); // { key: 'Red', value: 1, label: 'Red', hex: '#FF0000' }
362+
WeekEnum.findBy('key', 'Red'); // { key: 'Red', value: 1, label: 'Red' }
363+
WeekEnum.findBy('hex', '#FF0000'); // { key: 'Red', value: 1, label: 'Red', hex: '#FF0000' }
363364
```
364365

365-
> If you want to get the custom fields of a known enum item, it is recommended to use the `named` property to access it
366+
> If you need to get the meta fields of a known enum item, it is recommended to use the `named` and `raw` property, for example: `ColorEnum.named.Red.raw.hex`.
366367
367368
---
368369

369370
### 💎 &nbsp; label
370371

371372
<sup>**_\[F]_**</sup> &nbsp; `label(keyOrValue?: string | number): string | undefined`
372373

373-
Gets the display name of an enum item according to its value or key. If [localization](#localization) has been enabled, the localized text will be returned.
374+
Gets the display name of an enum item according to its value or key. If [localization](#localization) is enabled, the localized text will be returned.
374375

375376
```js
376377
WeekEnum.label(1); // Monday
377-
WeekEnum.label('Monday'); // Monday, here is label, not key
378+
WeekEnum.label('Monday'); // Monday, this is label, not key
378379
```
379380

380381
---
@@ -386,7 +387,7 @@ WeekEnum.label('Monday'); // Monday, here is label, not key
386387
Find the key of an enum item by its value. It's also known as [reverse mapping](https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings). If not found, `undefined` is returned.
387388

388389
```js
389-
WeekEnum.key(1); // Monday (here is key, not label)
390+
WeekEnum.key(1); // Monday (this is key, not label)
390391
```
391392

392393
---
@@ -580,7 +581,7 @@ Enum.localize = (key) => i18n.t(key);
580581

581582
### 💎 &nbsp; Enum.extends
582583

583-
<sup>**_\[F]_**</sup> &nbsp; `(obj: Record<string, unknown> | undefined) => void`
584+
<sup>**_\[F]_**</sup> &nbsp; `(obj: Record<string, Function>) => void`
584585

585586
Extend the `Enum` objects with custom methods. More details can be found in the [Extensibility](#extensibility) section.
586587

README.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
- 支持插件体系,可以通过安装插件扩展枚举功能
7070
- 支持数据类型约束,提高代码的类型安全性<sup>_&nbsp;&nbsp;TypeScript_</sup>
7171
- 枚举可以生成下拉框等 UI 组件,支持 [Ant Design](https://ant-design.antgroup.com/components/overview-cn)[Element Plus](https://element-plus.org/zh-CN/component/select.html)[Material-UI](https://mui.com/material-ui) 等多种组件库
72-
- 支持服务端渲染(SSR)
7372
- 支持 Web浏览器、Node.js、React Native、Taro、小程序等多种环境
73+
- 支持服务端渲染(SSR)
7474
- 兼容任何前端开发框架,支持无框架的纯原生项目
7575
- 面向 TypeScript 设计,具有良好的类型推导和代码补全能力
7676
- 零依赖项
@@ -576,7 +576,7 @@ Enum.localize = (key) => i18n.t(key);
576576

577577
### 💎 &nbsp; Enum.extends
578578

579-
<sup>**_\[方法]_**</sup> &nbsp; `(obj: Record<string, unknown> | undefined) => void`
579+
<sup>**_\[方法]_**</sup> &nbsp; `(obj: Record<string, Function>) => void`
580580

581581
为所有枚举对象添加全局扩展方法,请参考[全局扩展](#全局扩展)章节,了解更多详情。
582582

0 commit comments

Comments
 (0)