Sequoia / js-multimethod

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multimethods in JavaScript

This is a project I created while learning about Clojure. Multimethods seem pretty cool and I wanted implement them in JavaScript to learn more about them & understand them better, i.e. Just For Fun.

Features

Basic

  • register (attach) methods
  • dispatch to methods

More general stuff

  • de-register (detach) methods [2018-05-23]
  • default method [2018-05-23]

Dispatch hierarchy

  • "derive" method ("is a" type hierarchy of dispatch types) [2018-06-19]
  • resolve a child type to a parent type for function dispatch [2018-06-19]

Multiple dispatch!!

  • basic 2-item dispatch
  • each item respects hierarchy

Utility

  • get methods map
  • get dispatcher
  • "handles" function to see if a call is handle-able (what to do if there's a default method?) [2018-06-19]

"Phase II" 😏

  • Underive
  • method to pass a dispatch hierarchy in/replace one (for sharing) (low priority)
  • get dispatch hierarchy
  • replace methods (hold on this 'til later; not currently clear it's a problem to just allow methods to be overwritten)

About


Languages

Language:JavaScript 100.0%