enum-plus has released a new version!

enum-plus has released a new version!

enum-plus v3.0 Released ๐Ÿš€

image

> Follow our public account to get timely delivery of technical insights!

The enum-plus v3.0 milestone upgrade is here โ€” a major version introducing new features, enhancements, and breaking changes.

๐Ÿ“„ Full documentation: https://juejin.cn/post/7567630238701092902

โญ Star on GitHub: https://github.com/shijistar/enum-plus

---

๐Ÿ”ฅ Major New Features

1. Simplified Enum Initialization

No more `as const` needed in v3.0+.

// Before
const WeekEnum = Enum({
  Monday: { value: 1, label: 'ๆ˜ŸๆœŸไธ€' },
  Tuesday: { value: 2, label: 'ๆ˜ŸๆœŸไบŒ' },
} as const);

// Now
const WeekEnum = Enum({
  Monday: { value: 1, label: 'ๆ˜ŸๆœŸไธ€' },
  Tuesday: { value: 2, label: 'ๆ˜ŸๆœŸไบŒ' },
});

---

2. `enum.named` โ€” Item Lookup by Key

Quickly access enum items without `.find()`.

const monday = WeekEnum.named.Monday;

---

3. `enum.meta` โ€” Aggregate Custom Fields

Directly access custom field values for all members.

ColorEnum.meta.hex; // ['#FF0000', '#00FF00', '#0000FF']

---

4. Updated `enum.values` Behavior

Returns raw member values, not objects.

Use `enum.items` for the old behavior.

WeekEnum.values; // [1, 2, 3, 4, 5, 6, 7]

---

5. `enum.labels` โ€” Read-Only Label Array

WeekEnum.labels; // ['ๆ˜ŸๆœŸไธ€', 'ๆ˜ŸๆœŸไบŒ', ...]

---

6. `enum.toList` โ€” Unified List Conversion

Replaces `toSelect`, `toMenu`, and `toFilter` (now plugins).

WeekEnum.toList();
// [ { value: 1, label: 'Monday' }, { value: 2, label: 'Tuesday' } ]

WeekEnum.toList({ valueField: 'id', labelField: 'name' });
// [ { id: 1, name: 'Monday' }, { id: 2, name: 'Tuesday' } ]

---

7. `enum.toMap` โ€” Key/Value Mapping

Replaces `enum.toValueMap`.

WeekEnum.toMap();
// { "1": 'Monday', "2": 'Tuesday' }

WeekEnum.toMap({ keySelector: 'key', valueSelector: 'value' });
// { "Monday": 1, "Tuesday": 2 }

---

8. `Enum.isEnum` โ€” Instance Check

Enum.isEnum(WeekEnum); // true

---

9. `enum.findBy` โ€” Search by Any Field

WeekEnum.findBy('value', 1);
WeekEnum.findBy('key', 'Monday');

---

10. Improved `instanceof` Type Assertions

if (value instanceof WeekEnum) {
  console.log(value); // type narrowed
}

---

11. `Enum.install` โ€” Plugin Installation

Enum.install(plugin);

---

12. Global Configuration via `Enum.config`

  • `autoLabel` โ€” toggle automatic label generation
  • `labelPrefix` โ€” set label prefix

---

โš™ Internal Changes

  • Removed proxy in `EnumItemClass` โ†’ replaced with getters (avoids circular references)
  • Unified Jest & e2e tests
  • Removed `private member` syntax (serialization friendly)
  • Dropped warning for modified enum items

---

๐Ÿ“ฆ Plugin System

Now supports modular expansions via npm:

  • `@enum-plus/plugin-antd` โ€” Ant Design bindings (`toSelect`, `toMenu`, etc.)
  • `@enum-plus/plugin-i18next` โ€” i18next localization
  • `@enum-plus/plugin-react-i18next` โ€” react-i18next support
  • `@enum-plus/plugin-react` โ€” React integration with language reactivity
  • `@enum-plus/plugin-i18next-vue` โ€” Vue with i18next
  • `@enum-plus/plugin-vue-i18n` โ€” Vue with vue-i18n

> ๐Ÿ’ก Missing a plugin? Refer to the Plugin Development Guide.

---

โš  Breaking Changes

  • `values` now returns raw values
  • Symbol renames:
  • `ENUM_COLLECTION` โ†’ `IS_ENUM`
  • `ENUM_ITEM` โ†’ `IS_ENUM_ITEM`
  • `ENUM_ITEMS` โ†’ `IS_ENUM_ITEMS`
  • `toSelect`, `toMenu`, `toFilter`, `toValueMap` moved to plugins
  • Removed deprecated:
  • `options`, `menus`, `filters`, `valuesEnum`

---

๐Ÿ› Bug Fixes

  • Fixed sourcemap parsing under `lib` folder
image

---

๐Ÿ“– Read original article:

Read Original

Open in WeChat

---

> ๐Ÿ’ฌ Pro Tip for Teams:

> For streamlined multi-platform release notes or docs, consider AiToEarnๅฎ˜็ฝ‘ โ€” an open-source AI content monetization platform that lets you generate, publish, and track updates across Douyin, Kwai, WeChat, Bilibili, Xiaohongshu, Facebook, Instagram, LinkedIn, Threads, YouTube, Pinterest, and X (Twitter).

> Explore AiToEarnๆ–‡ๆกฃ and AIๆจกๅž‹ๆŽ’ๅ for integration examples.

---

Would you like me to also prepare a concise Markdown changelog version of this so you can drop it straight into your GitHub releases page? That would make it more developer-friendly.

Read more

Translate the following blog post title into English, concise and natural. Return plain text only without quotes. ๅ“ˆไฝ›ๅคงๅญฆ R ็ผ–็จ‹่ฏพ็จ‹ไป‹็ป

Harvard CS50: Introduction to Programming with R Harvard University offers exceptional beginner-friendly computer science courses. Weโ€™re excited to announce the release of Harvard CS50โ€™s Introduction to Programming in R, a powerful language widely used for statistical computing, data science, and graphics. This course was developed by Carter Zenke.