Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
/*! clutility - v0.0.1 - The minimalistic class and inheritance utility for javascript | ||
/*! clutility - v0.0.2 - The minimalistic class and inheritance utility for javascript | ||
(c) Michel Weststrate - MIT licensed. | ||
@@ -34,10 +34,7 @@ https://github.com/mweststrate/clutility */ | ||
var clazzConstructor = props.initialize; | ||
if (!clazzConstructor) { | ||
if (superclazz) { | ||
clazzConstructor = function(){ | ||
superclazz.apply(this, arguments); | ||
}; | ||
} | ||
else | ||
clazzConstructor = function(){}; | ||
clazzConstructor = function(){ | ||
superclazz.apply(this, arguments); | ||
}; | ||
} | ||
@@ -52,18 +49,15 @@ else if (extractFunctionArgumentNames(clazzConstructor)[0] === "$super") { | ||
/* | ||
make sure clazzConstructor inherits from superclazz, | ||
without invoking the actual superclass constructor, so that no | ||
state of "new superclazz()" is shared through the prototype chain | ||
without explicitly invoking the super initializer | ||
setup the prototype chain | ||
*/ | ||
var proto = clazzConstructor.prototype = new superclazz(); | ||
*/ | ||
var tmpConstuctor = function() { | ||
this.constructor = clazzConstructor; | ||
}; | ||
tmpConstuctor.prototype = superclazz.prototype; | ||
var proto = clazzConstructor.prototype = new tmpConstuctor(); | ||
/* | ||
remove any internal state from the prototype so that it is not accidentally shared. | ||
If a subclass is dependent on internal state, it should call the super constractor in | ||
it's initialize section | ||
*/ | ||
for(var key in proto) if (proto.hasOwnProperty(key)) | ||
delete proto[key]; | ||
proto.constructor = clazzConstructor; //weird flaw in JS, if you set up a prototype, restore constructor ref afterwards | ||
var superproto = superclazz.prototype; | ||
/* | ||
fill the prototype | ||
@@ -76,3 +70,3 @@ */ | ||
else if (isFunction(member) && extractFunctionArgumentNames(member)[0] === "$super") { | ||
var supermethod = superproto[key]; | ||
var supermethod = superclazz.prototype[key]; | ||
if (!supermethod || !isFunction(supermethod)) | ||
@@ -79,0 +73,0 @@ throw new Error("No super method found for '" + key + "'"); |
@@ -1,4 +0,4 @@ | ||
/*! clutility - v0.0.1 - The minimalistic class and inheritance utility for javascript | ||
/*! clutility - v0.0.2 - The minimalistic class and inheritance utility for javascript | ||
(c) Michel Weststrate - MIT licensed. | ||
https://github.com/mweststrate/clutility */ | ||
!function(){function a(a,g){if(!a)throw new Error("Super class not defined");g=1==arguments.length?a:g,a=arguments.length>1?a:Object,e(g)&&(g=g(a.prototype));var h=g.initialize;if(h){if("$super"===b(h)[0]){var i=h;h=function(){i.apply(this,[c(a,this)].concat(f.call(arguments)))}}}else h=a?function(){a.apply(this,arguments)}:function(){};var j=h.prototype=new a;for(var k in j)j.hasOwnProperty(k)&&delete j[k];j.constructor=h;var l=a.prototype;return d(g,function(a,d){if("initialize"!==d&&g.hasOwnProperty(d))if(e(a)&&"$super"===b(a)[0]){var h=l[d];if(!h||!e(h))throw new Error("No super method found for '"+d+"'");j[d]=function(){return a.apply(this,[c(h,this)].concat(f.call(arguments)))}}else j[d]=a}),h}function b(a){return a.toString().replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s))/gm,"").match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].split(/,/)}function c(a,b){return a.bind?a.bind(b):function(){return a.apply(b,arguments)}}function d(a,b){for(var c in a)b(a[c],c)}function e(a){return"function"==typeof a||!1}var f=Array.prototype.slice;"undefined"!=typeof exports?module.exports=a:"undefined"==typeof window||window.clutility||(window.clutility=a)}(); | ||
!function(){function a(a,g){if(!a)throw new Error("Super class not defined");g=1==arguments.length?a:g,a=arguments.length>1?a:Object,e(g)&&(g=g(a.prototype));var h=g.initialize;if(h){if("$super"===b(h)[0]){var i=h;h=function(){i.apply(this,[c(a,this)].concat(f.call(arguments)))}}}else h=function(){a.apply(this,arguments)};var j=function(){this.constructor=h};j.prototype=a.prototype;var k=h.prototype=new j;return d(g,function(d,h){if("initialize"!==h&&g.hasOwnProperty(h))if(e(d)&&"$super"===b(d)[0]){var i=a.prototype[h];if(!i||!e(i))throw new Error("No super method found for '"+h+"'");k[h]=function(){return d.apply(this,[c(i,this)].concat(f.call(arguments)))}}else k[h]=d}),h}function b(a){return a.toString().replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s))/gm,"").match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].split(/,/)}function c(a,b){return a.bind?a.bind(b):function(){return a.apply(b,arguments)}}function d(a,b){for(var c in a)b(a[c],c)}function e(a){return"function"==typeof a||!1}var f=Array.prototype.slice;"undefined"!=typeof exports?module.exports=a:"undefined"==typeof window||window.clutility||(window.clutility=a)}(); |
{ | ||
"name": "clutility", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "The minimalistic class and inheritance utility for javascript", | ||
@@ -5,0 +5,0 @@ "preferGlobal": false, |
clutility | ||
========= | ||
The minimalistic class and inheritance utility for javascript. | ||
<img src="logo/logo.png" style="float: right; padding: 0 0 20px 20px; width:250px" align="right"/> | ||
clutility is a minimal class declaration system that supports just a few concepts: | ||
Clutility is a minimal class declaration utility that supports just a few concepts: | ||
1. Create classes (constructors) | ||
@@ -11,3 +12,3 @@ 2. Inherit classes from other classes | ||
More details can be found below. Show me the code first! How do I use it? | ||
More details can be found below. Take a glance at the code first! | ||
@@ -14,0 +15,0 @@ # Usage |
Sorry, the diff of this file is not supported yet
225
15589
99