z-pattern-matching / z

Pattern Matching for Javascript
https://z-pattern-matching.github.io/
Apache License 2.0
1.72k stars 50 forks source link

fix matchValue object type checking #57

Closed mouadennaciri closed 1 year ago

mouadennaciri commented 5 years ago

typeof matchValue === 'object' returns true when the matchvalue is an array which reproduces this bug:

const result = matches({ data: 123 })(
  (x = [1, 2]) => 'Is array',
  (x = { data: 123 }) => 'is object'
)
// 'is array'