Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

vweevers/replace-constructor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Replace/wrap a class constructor

Resources

License

Stars

Watchers

Forks

Packages

No packages published