Releases: locphan87/match-values
Releases · locphan87/match-values
Modern, Type-Safe, and Consistent
This release marks a major milestone for match-values, focusing on full TypeScript support, a more consistent API, and an improved developer experience.
🚀 Features & Improvements
- Full Type Safety: The library is now fully type-safe with generics (
<T, R>), providing robust type inference for both matched values and return types. - Consistent Default Cases: The
lastsymbol is now the single, consistent way to define a default case for both object and conditional patterns. - Simplified Object Matching: The logic for object-based matching is now simpler and more robust, using direct property lookups instead of iteration.
- JSDoc Everything: The entire library is now documented with JSDoc comments, providing better inline help in supported editors.
- Function Overloads: The
matchandlazyMatchfunctions now use overloads for the best possible type inference.
💥 BREAKING CHANGES
-
Default Case for Object Patterns: The string literal
'_'is no longer supported for default cases in object patterns. You must now use thelastsymbol.Before:
match('c', { a: 1, b: 2, _: 3 });
After:
import { match, last } from 'match-values'; match('c', { a: 1, b: 2, [last]: 3 });
-
Error Messages: Error messages have been updated to be more descriptive. If you have tests that rely on specific error messages, they may need to be updated.
v2.1.1
What's Changed
- Fix the source map issue
Commits
- fix: Failed to parse source map by @locphan87 in #31
- docs: update usage & var names by @locphan87 in #30
Full Changelog: v2.1.0...v2.1.1
v2.1.0
What's Changed
- Update dependencies, remove unused packages
- Improve type safety
- Improve unit tests
Breaking Changes
- The
_symbol is replaced bylastfor the last branch
Commits
- feat: publish test results to gh-pages by @locphan87 in #17
- chore(deps): bump tmpl from 1.0.4 to 1.0.5 by @dependabot in #18
- chore(deps): bump ansi-regex from 5.0.0 to 5.0.1 by @dependabot in #19
- chore(deps): bump minimist from 1.2.5 to 1.2.6 by @dependabot in #20
- chore(deps): bump json5 from 2.2.0 to 2.2.3 by @dependabot in #22
- chore(deps): bump minimatch from 3.0.4 to 3.1.2 by @dependabot in #21
- chore: clean up dependencies by @locphan87 in #26
- Create SECURITY.md by @locphan87 in #27
- chore: update types and tests by @locphan87 in #28
Full Changelog: v2.0.0...v2.1.0
Match conditions
- Add new feature matchCond to allow matching values based on its conditions (predicate functions)
- Remove match arrays and objects
- Update test cases
Match structural values
New features
- match an array
- match an object
Breaking changes
- force the default branch as the last branch