Socket
Socket
Sign inDemoInstall

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


Version published
Weekly downloads
21
increased by110%
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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc