Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by30.77%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

FAQs

Package last updated on 20 Sep 2012

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