Skip to content

Releases: locphan87/match-values

Modern, Type-Safe, and Consistent

18 Oct 08:03

Choose a tag to compare

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 last symbol 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 match and lazyMatch functions 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 the last symbol.

    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

16 Jun 15:22

Choose a tag to compare

What's Changed

  • Fix the source map issue

Commits

Full Changelog: v2.1.0...v2.1.1

v2.1.0

06 Mar 18:34
f81212d

Choose a tag to compare

What's Changed

  • Update dependencies, remove unused packages
  • Improve type safety
  • Improve unit tests

Breaking Changes

  • The _ symbol is replaced by last for the last branch

Commits

Full Changelog: v2.0.0...v2.1.0

Match conditions

31 Jul 04:15
e637ab8

Choose a tag to compare

  • 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

25 Apr 08:19

Choose a tag to compare

New features

  • match an array
  • match an object

Breaking changes

  • force the default branch as the last branch

v1.0.1

05 Jan 06:58

Choose a tag to compare

Fix bugs:

  • allow null/undefined as a match result #1