multimethod.js

Eric Normand's Newsletter
Software design, functional programming, and software engineering practices
Over 5,000 subscribers

Reference: multimethod.js

Kris Jordan:

Inspired by Clojure's multimethods, multimethod.js provides a functional alternative to classical, prototype based polymorphism.

multimethod.js builds functions which dispatch on arbitrary predicates in Javascript using a fluent style.

Multimethod iterates through each 'method' registered with when and performs an equality test on the dispatchValue and each method's match value.

I wonder whether a linear search for the dispatch value will scale. I prefer to see some kind of hash-map based solution. Is it possible to serialize the object to JSON and use the resulting String as a key?

Still, I enjoy seeing inter-language cross-pollination. It is also a nice translation from a functional language to a prototype language. The fluent interface does the job extremely well.

Kris Jordan deserves a follow on GitHub.

Sean Allen
Sean Allen
Your friendly reminder that if you aren't reading Eric's newsletter, you are missing out…
👍 ❤️
Nicolas Hery
Nicolas Hery
Lots of great content in the latest newsletter! Really glad I subscribed. Thanks, Eric, for your work.
👍 ❤️
Mathieu Gagnon
Mathieu Gagnon
Eric's newsletter is so simply great. Love it!
👍 ❤️