0.1.1 • Published 11 years ago

extasy v0.1.1

Weekly downloads
4
License
-
Repository
github
Last release
11 years ago

extasy

Build Status

Extend function inspired by coffeescript, typescript and google closure inheritance patterns.

Install

npm install extasy

Docs

Yuidocs documentation here

  • link only works when checkout repo and preview README locally

Full Example

var extend = require('./lib/main.js');

function Parent() {};
Parent.prototype.foo = function(x, y) {
	return x + y;
};

function Child() {};
// must extend before overwriting prototype methods!
extend(Child, Parent);
Child.prototype.foo = function(x, y) {
	return 2 + this.super_.foo(x, y);
};

/*--------------------------------------
no tests throw an error
---------------------------------------*/
var ChildInst = new Child();

var assert = require('assert');
assert(ChildInst.constructor === Child);
assert(ChildInst.super_ === Parent.prototype);
assert(Object.getPrototypeOf(ChildInst) === Child.prototype);
assert(Object.getPrototypeOf(Object.getPrototypeOf(ChildInst)) === Parent.prototype);
assert(ChildInst instanceof Child);
assert(ChildInst instanceof Parent);

console.log('ok');
0.1.1

11 years ago

0.1.0

11 years ago

0.0.8

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago