Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    extendablepublic

    This package has been deprecated

    Author message:

    This project has been renamed to extendible. This project will not receive any updates anymore

    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

    install

    npm i extendable

    Downloadsweekly downloads

    66

    version

    0.1.0

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar