defjs

0.1.0 • Public • Published

def

def - A simple Ruby-style inheritance for JavaScript

Dependencies

ECMAScript 5: Object.create

Example

def ('Person') ({
    __init__: function (name) {
        this.name = name;
    },

    speak: function (text) {
        alert(text || 'Hi, my name is ' + this.name);
    }
});

def ('Friend') << Person ({
    kick: function () {
        this.speak("I kick u!");
    }
});

def ('Ninja') << Friend ({
    __init__: function (name) {
	    Friend.__init__(name)
    },

    kick: function () {
        this.speak('I kick u!');
    }
});

var ninjy = new Ninja("John");

ninjy.speak();
ninjy.kick();

Package Sidebar

Install

npm i defjs

Weekly Downloads

1

Version

0.1.0

License

none

Last publish

Collaborators

  • monolithed