derives

1.1.1 • Public • Published

derives

也试着写个派生

特性

1.支持_super

2.不污染全局对象

3.逻辑比较绕@_@..

4.能export函数。。。。

var derives = require("derives");
 
//从Object派生类
var ClassA = derives(null, function(_super) {
    console.log("hello from A");
}, {
    fn: function() {
        //xxx
    }
});
 
//从ClassA派生ClassB
var ClassB = derives(ClassA, function(_super) {
    ClassA.call(this);
    console.log("hello from B");
}, {
    fn: function(_super) {
        //xxx
    }
});
 
var b = new ClassB();
b.fn();

Readme

Keywords

Package Sidebar

Install

npm i derives

Weekly Downloads

1

Version

1.1.1

License

BSD

Last publish

Collaborators

  • zhangyuanwei