gzjs-utils
Version:
smart js utils
36 lines (35 loc) • 1.13 kB
TypeScript
import { EnumItem } from "./index";
type SimpleType = string | number | boolean | undefined | null;
interface ET extends EnumItem {
}
type ExtType = {
eq?(val: SimpleType | ET | any): boolean;
};
/**
* 构建并返回传入的对象
* @param valueField
* @param textField
* @param obj
* @param props
*/
declare function build<KT extends string, ES>(valueField: KT, textField: KT, obj: ES, props?: KT[] | KT): { [K in keyof ES]: ES[K] & ET & Required<ExtType>; } & {
/**
* 获取枚举项
* @param key
*/
get<K_1 = { [k in keyof ES]: ES[k]; }>(key: K_1 | string | number): ES[keyof ES] & ET & Required<ExtType> & { [P in KT]: any; };
/**
* 枚举列表
*/
list: (ES[keyof ES] & ET & Required<ExtType> & { [P in KT]: any; })[];
/**
* 获取枚举名称
* @param value 枚举项名称或者 枚举类对象
* @param defaultValue 默认值
*/
getLabel(value: SimpleType | (ES[keyof ES] & ET & Required<ExtType> & { [P in KT]: any; }), defaultValue?: string): string;
};
declare const EnumBuilder: {
build: typeof build;
};
export default EnumBuilder;