extendable

Extend constructors using backbone's .extend signature

This project has been renamed to extendible. This project will not receive any updates anymore
Last updated 10 years ago by V1 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install extendable 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.1.0                                ...           latest (10 years ago)

8 Versions

  • 0.1.0 [deprecated]           ...           10 years ago
  • 0.0.6 [deprecated]           ...           11 years ago
  • 0.0.5 [deprecated]           ...           11 years ago
  • 0.0.4 [deprecated]           ...           11 years ago
  • 0.0.3 [deprecated]           ...           12 years ago
  • 0.0.2 [deprecated]           ...           12 years ago
  • 0.0.1 [deprecated]           ...           12 years ago
  • 0.0.0 [deprecated]           ...           12 years ago
Maintainers (1)
Downloads
Total 8
Today 0
This Week 0
This Month 8
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE