createEnum.js 178 B

123456789
  1. // 简单的模拟枚举
  2. export function createEnum(arr = []) {
  3. let obj = {}
  4. arr.forEach(v => {
  5. obj[obj[v.name] = v.value] = v.name;
  6. })
  7. return Object.freeze(obj);
  8. };