K

Multi-Class

A JavaScript library to make multiple class inheritance easy.

Posted: August 3, 2020
Find more posts about:

Multi-Class!

In a very OOP oriented project, I found myself needing to inherit characteristics from various parent classes, and JavaScript does not provide multi-inheritance out of the box for the Class syntactic sugar. This library allows you to pass in a list of classes you wish to extend, and it gives back a single super class with all of those characteristics.

All code lives in a single function and sits at a tiny 279B when minified and gzipped. Testing is done with the Baretest testing library.

What I learned

I had to dig into the plumbing of the JavaScript language deeper than I ever expected to. I became familiar with different ways of inspecting hidden values on objects and their prototypes, and I learned to publish an npm package to be used by other developers.