diff --git a/README.md b/README.md index b312dfa..63e1a6d 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ func main() { - [Cryptor](#user-content-cryptor) - [Datetime](#user-content-datetime) - [Datastructure](#user-content-datastructure) +- [EventBus](#user-content-eventbus) +- [Enum](#user-content-enum) - [Fileutil](#user-content-fileutil) - [Formatter](#user-content-formatter) - [Function](#user-content-function) @@ -766,7 +768,7 @@ import "github.com/duke-git/lancet/v2/eventbus" [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/eventbus.md#SetErrorHandler)] [[play](https://go.dev/play/p/gmB0gnFe5mc)] -

10. Package enum provides a simple enum implementation.        Index

+

10. Package enum provides a simple enum implementation.        Index

```go import "github.com/duke-git/lancet/v2/enum" @@ -789,43 +791,43 @@ import "github.com/duke-git/lancet/v2/enum" - **Valid** : Checks if the enum item is valid. If a custom check function is provided, it will be used to validate the value. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Valid)] [[play](https://go.dev/play/p/pA3lYY2VSm3)] -- **MarshalJSON** : Implementation of json.Marshaler interface.

+- **MarshalJSON** : Implementation of json.Marshaler interface. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#MarshalJSON)] [[play](https://go.dev/play/p/zIZEdAnneB5)] -- **NewRegistry** : Creates a new enum registry..

+- **NewRegistry** : Creates a new enum registry. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#NewRegistry)] [[play](https://go.dev/play/p/ABEXsYfJKMo)] -- **Add** : Adds enum items to the registry.

+- **Add** : Adds enum items to the registry. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Add)] [[play](https://go.dev/play/p/ABEXsYfJKMo)] -- **Remove** : Removes an enum item from the registry by its value.

+- **Remove** : Removes an enum item from the registry by its value. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Remove)] [[play](https://go.dev/play/p/dSG84wQ3TuC)] -- **Update** : Updates the name of an enum item in the registry by its value.

+- **Update** : Updates the name of an enum item in the registry by its value. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Update)] [[play](https://go.dev/play/p/Ol0moT1J9Xl)] -- **GetByValue** : Retrieves an enum item by its value.

+- **GetByValue** : Retrieves an enum item by its value. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#GetByValue)] [[play](https://go.dev/play/p/niJ1U2KlE_m)] -- **GetByName** : Retrieves an enum item by its name.

+- **GetByName** : Retrieves an enum item by its name. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#GetByName)] [[play](https://go.dev/play/p/49ie_gpqH0m)] -- **Items** : Returns a slice of all enum items in the registry.

+- **Items** : Returns a slice of all enum items in the registry. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Items)] [[play](https://go.dev/play/p/lAJFAradbvQ)] - **Contains** : Checks if an enum item with the given value exists in the registry.

[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Contains)] [[play](https://go.dev/play/p/_T-lPYkZn2j)] -- **Size** : Returns the number of enum items in the registry.

+- **Size** : Returns the number of enum items in the registry. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Size)] [[play](https://go.dev/play/p/TeDArWhlQe2)] -- **Range** : Iterates over all enum items in the registry and applies the given function.

+- **Range** : Iterates over all enum items in the registry and applies the given function. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Range)] [[play](https://go.dev/play/p/GPsZbQbefWN)] -- **SortedItems** : Returns a slice of all enum items sorted by the given less function.

+- **SortedItems** : Returns a slice of all enum items sorted by the given less function. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#SortedItems)] [[play](https://go.dev/play/p/tN9RE_m_WEI)] -- **Filter** : Returns a slice of enum items that satisfy the given predicate function.

+- **Filter** : Returns a slice of enum items that satisfy the given predicate function. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Filter)] [[play](https://go.dev/play/p/uTUpTdcyoCU)] diff --git a/README_zh-CN.md b/README_zh-CN.md index 939e7b6..e50b18b 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -83,6 +83,8 @@ func main() { - [Cryptor](#user-content-cryptor) - [Datetime](#user-content-datetime) - [Datastructure](#user-content-datastructure) +- [EventBus](#user-content-eventbus) +- [Enum](#user-content-enum) - [Fileutil](#user-content-fileutil) - [Formatter](#user-content-formatter) - [Function](#user-content-function) @@ -776,7 +778,7 @@ import "github.com/duke-git/lancet/v2/eventbus" [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/eventbus.md#SetErrorHandler)] [[play](https://go.dev/play/p/gmB0gnFe5mc)] -

10. Enum实现一个简单枚举工具包。.        Index

+

10. Enum实现一个简单枚举工具包。.        Index

```go import "github.com/duke-git/lancet/v2/enum" @@ -799,43 +801,43 @@ import "github.com/duke-git/lancet/v2/enum" - **Valid** : 检查枚举项是否有效。如果提供了自定义检查函数,将使用该函数验证值。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Valid)] [[play](https://go.dev/play/p/pA3lYY2VSm3)] -- **MarshalJSON** : 枚举项实现 json.Marshaler 接口。

+- **MarshalJSON** : 枚举项实现 json.Marshaler 接口。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#MarshalJSON)] [[play](https://go.dev/play/p/zIZEdAnneB5)] -- **NewRegistry** : Registry 定义了一个通用的枚举注册表结构体。

+- **NewRegistry** : Registry 定义了一个通用的枚举注册表结构体。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#NewRegistry)] [[play](https://go.dev/play/p/ABEXsYfJKMo)] -- **Add** : 向枚举注册表添加枚举项。

+- **Add** : 向枚举注册表添加枚举项。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Add)] [[play](https://go.dev/play/p/ABEXsYfJKMo)] -- **Remove** : 在枚举注册表中删除枚举项。

+- **Remove** : 在枚举注册表中删除枚举项。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Remove)] [[play](https://go.dev/play/p/dSG84wQ3TuC)] -- **Update** : 在枚举注册表中更新枚举项。

+- **Update** : 在枚举注册表中更新枚举项。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Update)] [[play](https://go.dev/play/p/Ol0moT1J9Xl)] -- **GetByValue** : 在枚举注册表中通过值获取枚举项。

+- **GetByValue** : 在枚举注册表中通过值获取枚举项。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#GetByValue)] [[play](https://go.dev/play/p/niJ1U2KlE_m)] -- **GetByName** : 在枚举注册表中通过名称获取枚举项。

+- **GetByName** : 在枚举注册表中通过名称获取枚举项。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#GetByName)] [[play](https://go.dev/play/p/49ie_gpqH0m)] -- **Items** : 返回枚举注册表中的枚举项。

+- **Items** : 返回枚举注册表中的枚举项。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Items)] [[play](https://go.dev/play/p/lAJFAradbvQ)] -- **Contains** : 检查注册表中是否存在具有给定值的枚举项。

+- **Contains** : 检查注册表中是否存在具有给定值的枚举项。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Contains)] [[play](https://go.dev/play/p/_T-lPYkZn2j)] -- **Size** : 返回注册表中枚举项的数目。

+- **Size** : 返回注册表中枚举项的数目。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Size)] [[play](https://go.dev/play/p/TeDArWhlQe2)] - **Range** : 遍历注册表中的所有枚举项,并应用给定的函数。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Range)] [[play](https://go.dev/play/p/GPsZbQbefWN)] -- **SortedItems** : 返回按给定比较函数排序的所有枚举项的切片。

+- **SortedItems** : 返回按给定比较函数排序的所有枚举项的切片。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#SortedItems)] [[play](https://go.dev/play/p/tN9RE_m_WEI)] -- **Filter** : 返回满足给定谓词函数的枚举项切片。

+- **Filter** : 返回满足给定谓词函数的枚举项切片。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Filter)] [[play](https://go.dev/play/p/uTUpTdcyoCU)]