UNPKG

to-factory

Version:

Convert classes into factory functions so they can be called with or without new.

11 lines (9 loc) 213 B
function toFactory(Class) { const Factory = function(...args) { return new Class(...args) } Factory.__proto__ = Class Factory.prototype = Class.prototype return Factory } module.exports = toFactory