Skip to content

it-ony/inherit.js

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

Build Status NPM version Dependency Status

inherit.js - Inheritance javascript library

inherit.js is an inheritance javascript library, which supports base method calls an easy way along the inheritance path.

Usage

Declare a class

var YourClass = inherit.Base.inherit({
    ctor: function(foo, bar) {
        // constructor
        this.foo = foo;
        this.bar = bar;
    },
    publicFunction: function() {
        // function declaration
    }
});

Inherit from your class

var DerivedClass = YourClass.inherit({
    ctor: function(foo, bar) {
        // call base ctor
        this.base.ctor.call(this, foo, bar);
    },
    anotherPublicFunction: function(){
        // your code goes here
    },
    // overwrite method
    publicFunction: function() {
        // call base method
        this.base.publicFunction.callBase(this);

        // do other stuff
    }
});

Create instances

var foo = new YourClass("foo", "bar");
var bar = new DerivedClass("bar", "foo");

About

inherit.js is an inheritance javascript library

Resources

Stars

Watchers

Forks

Packages

No packages published