replace-constructor

1.0.0 • Public • Published

replace-constructor

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 status Dependency status

example

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)
})

install

With npm do:

npm install replace-constructor

license

MIT (permission pending) © Vincent Weevers, ISC © PJ Eby

Readme

Keywords

Package Sidebar

Install

npm i replace-constructor

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • vweevers