News for hackers. Stuff that matters.

Show HN: OCaml-like pattern-matching with vanilla JavaScript (no transpiler)

A few years back I wrote a little library that implements OCaml-inspired pattern matching using just plan JavaScript destructuring syntax. I don't think I ever shared it here. Thought you might find it interesting.

I did this just for fun, don't use it in prod. It's very inefficient. Have a look at the source for a chuckle, it's a single 145 line file.

Link: https://github.com/mrkev/fnMatch

Playground: https://aykev.dev/fnMatch/

( 1 comment | on HN )
Re:Show HN: OCaml-like pattern-matching with vanilla JavaScr... by zogrodea on Wednesday July 24, 2024 @04:39PM (#41061790)
That looks pretty great! I would love to use this at work if functional programming idioms were already familiar to the team and I didn't face resistance introducing them. Thank you for sharing and developing the library.