github gvergnaud/ts-pattern v5.2.0

17 days ago

The main thing

new P.string.length(n) pattern

P.string.length(len) matches strings with exactly len characters.

const fn = (input: string) =>
  match(input)
    .with(P.string.length(2), () => '🎉')
    .otherwise(() => '❌');

console.log(fn('ok')); // logs '🎉'

What's Changed

New Contributors

Full Changelog: v5.1.2...v5.2.0

Don't miss a new ts-pattern release

NewReleases is sending notifications on new releases.