coop

    0.4.0 • Public • Published

    Co-Op provides Pythonic cooperative multiple inheritance to Javascript and Node.js.

    Build Status

    Installation

    npm install coop
    

    Usage

    Creating a class is similar to Mootools:

    var Class = require('coop').Class;
    var MyClass = new Class({
      initialize: function(me) {
        this.me = me;
      }
    });

    Inheritance

    ...is a little different from Mootools. But orders of magnitude more powerful.

    var MySubClass = new Class([MyClass, MyOtherClass], {
      initialize: function (me) {
        this.super_initialize(MySubClass, arguments);
      }
    })

    Metaclasses

    Make your own subclass of Class, and override new, just like you do in Python:

    var MyMetaClass = new Class([Class], {
      __new__: function (klass) {
        var instance = this.super___new__(MyMetaClass, arguments);
     
        registerMyClass( instance );
     
        return instance;
      }
    })
     
    var MyClass = new MyMetaClass({
      initialize: function () { /* ... */ }
    })
     

    Install

    npm i coop

    DownloadsWeekly Downloads

    45

    Version

    0.4.0

    License

    MIT/X11

    Last publish

    Collaborators

    • teh_senaus