🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

extendable

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extendable

Extend constructors using backbone's .extend signature

0.1.0
latest
Source
npm
Version published
Weekly downloads
21
-19.23%
Maintainers
1
Weekly downloads
 
Created
Source

Extend your JavaScript constructors in the same as you are used to in backbone.js

Build Status

var extend = require('extendable')
  , EventEmitter = require('events').EventEmitter;

function Awesomeness() {
  var self = this;

  setTimeout(function () {
    self.render(self.data);
  }, 100);

  EventEmitter.call(this);
}

Awesomeness.prototype = new EventEmitter;
Awesomeness.prototype.constructor = Awesomeness;

Awesomeness.prototype.data = 'bar';
Awesomeness.prototype.render = function render() {
  // does nothing
};

Awesomeness.extend = extend;

And you can now use it

var SuperAwesome = Awesomeness.extend({
    data: 'trololol'

  , render: function render(data) {
      console.log(data);
    }
});

new SuperAwesome();
// outputs "trololo" after 100 ms

License

MIT

Keywords

backbone

FAQs

Package last updated on 27 Oct 2014

Did you know?

Socket

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