0.1.7 • Published 3 years ago

define-js v0.1.7

Weekly downloads
12
License
ISC
Repository
github
Last release
3 years ago

define-js

javascript inheritance like class-based languages

Installation

npm install define-js

Usage

var define = require('define-js');

var SuperFunction = function(value){ // super constructor

    var ivar = value;
    this.method = function(){

        console.log(ivar);
    };
};

module.exports = define(function(init, sṵper){

  return function(value){ // your constructor

    var self = init(value).self(this); // initialize super function with arguments and this scope
    //or var self = init.apply(this, arguments).self();
    self.method = function (){ // override a method of super object

      sṵper.method();
    };
  };
})
.extend(SuperFunction /*the function you want to inherit from*/)
.parameters("Value" /*parameters to be passed when instantiating the prototype object*/);
0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago