Replace/wrap a class constructor, while keeping the prototype, name and properties of the original class. Like extending a class, but suitable for use in decorators and such. Babel compatible. Adapted from autocreate - all credits to @pjeby.
npm i replace-constructor
const replace = require('replace-constructor')
class Original {
constructor(x, y) {
// ..
}
}
const Wrapped = replace(Original, function(x, y){
Original.call(this, x, y)
})
With npm do:
npm install replace-constructor