extends

0.0.4 • Public • Published

Extends

A method to extend classes in Javascript.

Features:

  • super method calling this._super()
  • static properties
  • object cloning with this.clone()

Examples:

var Class = function() {};

var Stuff = extend(Class, {
    statics: {
        COLOR_RED: 'red',
        COLOR_BLUE: 'blue'
    },
    
    setColor: function(color) {
        this.color = color;
    }
});

// extended classes will have a .extend method
var Ball = Stuff.extend({
    setColor: function(color) {
        this._super(color);
        this.updateBallColor();
    },
    updateBallColor: function() {
        // do something	
    }
});

Readme

Keywords

none

Package Sidebar

Install

npm i extends

Weekly Downloads

116

Version

0.0.4

License

none

Last publish

Collaborators

  • darlanalves