protoclass

0.0.6 • Public • Published

protoclass is a thin class library that helps create, and extend prototypes.

Example

 
var protoclass = require("protoclass");
 
 
function Animal(name) {
  this.name = name;
}
 
protoclass(Animal);
 
function Cat(name) {
  Cat.parent.apply(this, arguments);
}
 
Animal.extend(Cat, {
  meow: function() {
    console.log(this.name + ": meow");
  }
});
 
 
console.log(Class.prototype.constructor == Class); // true
console.log(Class.parent == Animal); // true
consoele.log(Class.name); // Cat

API

fn protoclass([superclass,] subclass[, mixins])

fn.superclass

fn.super

super prototype

function Vehicle() {
  
}
 
protoclass(Vehicle, {
  drive: function () {
 
  }
});
 
 
function Car () {
  Vehicle.superclass.apply(this, argumments);
}
 
Vehicle.extend(Car, {
  drive: function () {
    Car.__super__.drive.call(this);
  }
});

fn.extend(subclass[, mixins])

fn.mixin(mixins)

copies the the mixins over to the prototype

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.6
    5,503
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.6
    5,503
  • 0.0.5
    278
  • 0.0.4
    2
  • 0.0.2
    13
  • 0.0.1
    2

Package Sidebar

Install

npm i protoclass

Weekly Downloads

2,487

Version

0.0.6

License

BSD

Last publish

Collaborators

  • architectd