extasy
Extend function inspired by YUI, coffeescript, typescript and google closure inheritance patterns.
Last updated 6 years ago by techjacker .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install extasy 
SYNC missed versions from official npm registry.

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');

Current Tags

  • 0.1.1                                ...           latest (6 years ago)

9 Versions

  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.8                                ...           6 years ago
  • 0.0.6                                ...           6 years ago
  • 0.0.5                                ...           6 years ago
  • 0.0.4                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (1)
Dev Dependencies (8)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |