Socket
Socket
Sign inDemoInstall

extend-me

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    extend-me

Yet another Backbone-like class extender


Version published
Weekly downloads
44
decreased by-72.84%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

extend-me

Yet another Backbone-like class extender

Synopsis

var Base = require('extend-me').Base;

var Parabola = Base.extend({
    initialize: function (a, b) {
        this.a = a;
        this.b = b;
    },
    calculate: function(x) {
        return this.a * Math.pow(x, 2) + (this.b * x);
    }
});

var ParabolaWithIntercept = Parabola.extend({
    initialize: function(a, b, c) {
        this.c = c;
    },
    calculate: function(x) {
        var y = Parabola.prototype.calculate.apply(this, arguments);
        return y + this.c;
    }
});

var parabola = new ParabolaWithIntercept(3, 2, 1),
    y = ParabolaWithIntercept(-3); // yields 22

Constructors

The initialize methods at each level of inheritance are the constructors. Instantiating a derived class will automatically call initialize on all ancestor classes that implement it, starting with the most distant ancestor all the way to and including the derived class in question. Each initialize method is called with the same parameters passed to the constructor.

If you intend to instantiate the base class (Parabola in the above) directly (i.e., it is not "abstract"), include the following in the constructor:

function Parabola() {
    this.initialize.apply(this, arguments);
}

To add initialization code to be executed before or after this chain of initialize calls, you an define methods preInitialize and postInitialize.

API documentation

Detailed API docs can be found here.

Regarding the git submodule jsdoc-template

See the note Regarding submodules for important information on cloning this repo or re-purposing its build template.

FAQs

Last updated on 20 Nov 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc