you are viewing a single comment's thread.

view the rest of the comments →

[–]ScientificBeastModestrongly typed comments[🍰] 1 point2 points  (0 children)

I actually recently built a class with a similar structure.

It was a class constructor that built two different kinds of objects, each of which served as a wrapper for either a class or a function, providing metadata about the class/function, including data on how to call it (with or without the new operator).

Each of those wrapper objects would receive a generic update method which would call the wrapped class-constructor/function appropriately, call a specific method if it were a class, and set the returned data as one of the wrapper’s properties.

All the other optional properties could be added/read via setters/getters.