From OO to Clojure Workshop!
Watch my free workshop to help you learn Clojure faster and shift your paradigm to functional.
Inspired by Clojure's multimethods, multimethod.js provides a functional alternative to classical, prototype based polymorphism.
Multimethod iterates through each 'method' registered with
whenand performs an equality test on the
dispatchValueand 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.