mjhm / lodash-match-pattern

Deep JSON pattern matching library
MIT License
50 stars 3 forks source link

Match anything? #43

Closed robross0606 closed 3 years ago

robross0606 commented 3 years ago

In one of my use cases, I need to follow a configuration pattern that requires a lodash-patch-pattern. However, in one of the "handlers" I need it to match any object. I tried using { ... } as the matching pattern but this doesn't work:

matchPattern: Error parsing pattern: Expected "<-", "<=", "}", [a-zA-Z], or quoted string but "." found. line:1 column:2 {...} -^---

I also tried using an empty matcher (''), null and undefined matchers. None works. I know this seems odd, but Is there a way to have the declared pattern match "any" object?

robross0606 commented 3 years ago

I think I just figured out that this works as a pattern match:

const matches = matchPattern(message, '_.isObject')