polyplug
Simple plugin system
This is prerelease software.
Usage
const polyplug = { this this } { // ... }
Assume A is the main class and B is the plugin class.
The above will merge B's prototype into A's, just like a mixin. This won't make instances of A instances of B, though.
This also assumes no instances of B will ever be created. Instead, plugin classes can declare initialize()
. When polyplug(A, B)
is called, the definition of B's initialize()
will be added to A's. Essentially, calling (new A).initialize()
will first call A.prototype.initialze()
followed by B.prototype.initialize
.
This initialize()
functionality is optional and can be missing from either A
or B
.
All members visible to Object.getOwnPropertyNames()
and Object.getOwnPropertySymbols
will be copied.
License
MIT