You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> `v3.0` is coming soon! Feel free to try the preview version [enum-plus@next](https://www.npmjs.com/package/enum-plus/v/next). The new version will bring more exciting features and improvements. For details, please refer to [v3 Release Notes](https://github.com/shijistar/enum-plus/issues/14).
33
+
32
34
## Introduction
33
35
34
36
`enum-plus` is an enhanced enum library that is fully compatible with the native `enum` and extends it with powerful features such as display text, localization, UI control binding, enum members traversal, and more useful extension methods. This lightweight, zero-dependency, TypeScript library works with any front-end framework.
@@ -85,39 +87,33 @@ yarn add enum-plus
85
87
86
88
This section shows the various ways to initialize enums using the `Enum` function. Understanding these different initialization formats allows you to choose the most convenient approach for your specific use case.
87
89
88
-
### 1. Simple `key-value` Format
90
+
### 1. Simple Key-Value Format
89
91
90
92
The simplest format is a direct mapping of keys to values. This is similar to the native enum format.
The standard format includes both a `value` and a `label`for each enummember. This is the most commonly used format and is recommended for most cases. This format allows you to specify a display text for each enum member, which can be used inUI components.
123
119
@@ -133,7 +129,7 @@ WeekEnum.Sunday; // 0
133
129
WeekEnum.label(0); // I love Sunday
134
130
```
135
131
136
-
### 4. Label-Only Format
132
+
### 3. Label-Only Format
137
133
138
134
This is useful when you want to use the key as the value.
The array format is useful when you need to create enums dynamically, such as from APIdata. This allows for flexibility in [custom field mapping](#custom-field-mapping) to adapt to different data structures.
0 commit comments