diff --git a/CHANGES.txt b/CHANGES.txt index 51c602b..4332f9e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -DEVELOPMENT VERSION +0.0.10 : 2014-03-09 Global: - Using Grunt for build tools. - Lots of reworking of the build tools - much less room for human error. diff --git a/bower.json b/bower.json index 19e72df..36d43f3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "o", - "version": "0.0.9", + "version": "0.0.10", "main": "o.js", "description": "JavaScript utility belt for rich objects and prototypes. Ooooh!", diff --git a/o.js b/o.js index 3a74a91..9104e58 100644 --- a/o.js +++ b/o.js @@ -1,4 +1,4 @@ -// o.js : DEVELOPMENT VERSION : http://o-js.com : MIT License +// o.js : 0.0.10 : http://o-js.com : MIT License (function() { diff --git a/o.min.js b/o.min.js index 602d684..b9ae9b1 100644 --- a/o.min.js +++ b/o.min.js @@ -1,2 +1,2 @@ -// o.js : DEVELOPMENT VERSION : http://o-js.com : MIT License +// o.js : 0.0.10 : http://o-js.com : MIT License (function(){var a=this,b=a.o,c={};a.o=c,a.oJS=c,c.noConflict=function(){return a.o=b,c};var d=function(a,b){return function(){var c=a.apply(this,arguments);return b.call(this),c}};c.after=d;var e=function(a,b){return function(){var c=this,d=Array.prototype.slice.call(arguments),e=function(){return a.apply(c,arguments)};return d.unshift(e),b.apply(c,d)}};c.around=e;var f=function(a,b){return function(){return b.call(this),a.apply(this,arguments)}};c.before=f;var g=function(a){return function(){delete this[a]}};c.clearer=g;var h=function(a){return Object.getPrototypeOf?Object.getPrototypeOf(a):Object.__proto__};c.getPrototypeOf=h;var i=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};c.has=i;var j=function(a,b,c){var d,e=i(a,b),f=a[b];try{d=c()}finally{e?a[b]=f:delete a[b]}return d};c.local=j;var k=function(){for(var a=Array.prototype.slice.call(arguments),b=a.shift();a.length;){var c=a.shift();for(var d in c)i(c,d)&&(b[d]=c[d])}return b};c.merge=k;var l=function(a){return function(){return i(this,a)&&void 0!==this[a]}};c.predicate=l;var m=function(a,b){return function(){return this[a][b].apply(this[a],arguments)}};c.proxy=m;var n=function(a){return a.charAt(0).toUpperCase()+a.slice(1)};c.ucFirst=n;var o=function(a,b){return b=b||{},b.augments&&(b.type=b.type||"object"),function(c){if(b.filter&&(c=b.filter.call(this,c)),b.type)if("string"==typeof b.type||b.type instanceof String){if(typeof c!==b.type)throw new Error(c+" failed validation.")}else if(b.type instanceof Function){if(!b.type(c))throw new Error(c+" failed validation.")}else b.type.coerce instanceof Function&&b.type.validate instanceof Function&&(b.coerce?c=b.type.coerce(c):b.type.validate(c));if(b.augments&&!(c instanceof b.augments))throw new Error(c+" failed validation.");var d=this[a];return this[a]=c,b.chain?this:d}};c.writer=o;var p=function(a){var b=Object.create(h(a));return b.constructor=a.constructor,k(b,a),b};c.clone=p;var q=function(a,b){return k(a.prototype,b),a};c.construct=q;var r=function(a,b){return b=b||{},b.writer=b.writer||o(a,b),b.predicate=b.predicate||l(a),function(){if(!b.predicate.call(this)){if(b.required)throw new Error(a+" is required.");if(b.devoid){var c=b.devoid;c instanceof Function&&(c=c.call(this)),b.writer.call(this,c)}else b.builder&&b.writer.call(this,this[b.builder].call(this))}return this[a]}};c.reader=r;var s;s=q(function(a){a=a||{},"function"==typeof a&&(a={validate:a}),a.validate&&(this._validateMethod=a.validate),a.coerce&&(this._coerceMethod=a.coerce),a.parent&&(this._parent=a.parent)},{check:function(a){return this._parent&&!this._parent.check(a)?!1:this._validateMethod?this._validateMethod(a)?!0:!1:!0},validate:function(a){if(!this.check(a))throw new Error(a+" failed validation.")},coerce:function(a){return a=this.coerceOnly(a),this.validate(a),a},coerceOnly:function(a){return this._parent&&(a=this._parent.coerceOnly(a)),this._coerceMethod&&(a=this._coerceMethod(a)),a},subtype:function(a){return"function"==typeof a&&(a={validate:a}),new s(k({parent:this},a))}}),c.Type=s;var t=function(a,b){return b=b||{},b.writer=b.writer||o(a,b),b.reader=b.reader||r(a,b),function(a){return void 0!==a?b.writer.call(this,a):b.reader.call(this)}};c.accessor=t;var u=function(a,b,c){var d=e(a,b);return childProto=Object.create(a.prototype),c&&k(childProto,c),d.prototype=childProto,d};c.augment=u;var v=u(s,function(a,b,c){c=c||{},c.validate=function(a){for(var c=0,d=b.length;d>c;c++)if(!b[c].check(a))return!1;return!0},a(c)});c.AllType=v;var w=u(s,function(a,b,c){c=c||{},c.validate=function(a){for(var c=0,d=b.length;d>c;c++)if(b[c].check(a))return!0;return!1},a(c)});c.AnyType=w;var x=u(s,function(a,b,c){c=c||{},c.validate=function(a){for(var c=0,d=b.length;d>c;c++)if(a===b[c])return!0;return!1},a(c)});c.EnumType=x;var y=u(s,function(a,b,c){c=c||{},c.validate=function(a){return a===b?!0:!1},a(c)});c.EqualType=y;var z=u(s,function(a,b,c){c=c||{},c.validate=function(a){return a instanceof b?!0:!1},c.coerce=function(a){return this.check(a)?a:new b(a)},a(c)});c.InstanceOfType=z;var A=u(s,function(a,b,c){c=c||{};var d=new w(b);c.validate=function(a){return d.check(a)?!1:!0},a(c)});c.NoneType=A;var B=u(A,function(a,b,c){a([b],c)});c.NotType=B;var C=u(s,function(a,b,c){c=c||{},c.validate=function(a){return typeof a===b?!0:!1},a(c)});c.TypeOfType=C;var D=new z(Array);c.arrayType=D;var E=new w([new C("boolean"),new z(Boolean)]);c.booleanType=E;var F=new z(Date);c.dateType=F;var G=new z(Function);c.functionType=G;var H=new y(null);c.nullType=H;var I=new w([new C("number"),new z(Number)]);c.numberType=I;var J=new z(Object);c.objectType=J;var K=I.subtype(function(a){return a>0?!0:!1});c.positiveType=K;var L=new z(RegExp);c.regExpType=L;var M=J.subtype(function(a){return a.constructor===Object?!0:!1});c.simpleObjectType=M;var N=new w([new C("string"),new z(String)]);c.stringType=N;var O=new z(s);c.typeType=O;var P=new y(void 0);c.undefinedType=P;var Q=u(s,function(a,b,c){c=c||{},c.validate=function(a){if(!D.check(a))return!1;for(var c=0,d=a.length;d>c;c++)if(!b.check(a[c]))return!1;return!0},c.coerce=function(a){if(!this.check(a))return a;for(var c=0,d=a.length;d>c;c++)a[c]=b.coerce(a[c]);return a},a(c)});c.ArrayOfType=Q;var R=u(s,function(a,b,c){c=c||{},c.validate=function(a){if(!J.check(a))return!1;if(D.check(b)){for(var c=0,d=b.length;d>c;c++)if(void 0===a[b[c]])return!1;return!0}if(M.check(b)){for(var e in b){if(void 0===a[e])return!1;if(!b[e].check(a[e]))return!1}return!0}return!1},a(c)});c.DuckType=R;var S=u(s,function(a,b,c){c=c||{},c.validate=function(a){if(!J.check(a))return!1;for(var c in a)if(!b.check(a[c]))return!1;return!0},c.coerce=function(a){if(!this.check(a))return a;for(var c in a)a[c]=b.coerce(a[c]);return a},a(c)});c.ObjectOfType=S;var T=u(s,function(a,b,c){c=c||{},c.validate=function(a){return N.check(a)?b.test(a):!1},a(c)});c.PatternType=T;var U=new B(P);c.definedType=U;var V=I.subtype(function(a){return Math.floor(a)===a+0?!0:!1});c.integerType=V;var W=I.subtype(function(a){return 0>a?!0:!1});c.negativeType=W;var X=N.subtype(function(a){return a.length>0?!0:!1});c.nonEmptyStringType=X;var Y=I.subtype(function(a){return 0!==a?!0:!1});c.nonZeroType=Y;var Z=new v([V,K]);c.positiveIntType=Z;var $=new w([E,X]),_={key:{type:X,required:!0},argKey:{type:new w([X,H]),devoid:function(){return this.key()}},valueKey:{type:X,devoid:function(){return"_"+this.key()}},devoid:{type:U},builder:{type:$,devoid:!1,filter:function(a){return a===!0&&(a="build"+n(this.key())),a}},required:{type:E,devoid:!1},type:{type:new w([new x(["undefined","object","boolean","number","string","function"]),O,G])},coerce:{type:E,devoid:!1},filter:{type:G},augments:{type:G},chain:{type:E,devoid:!1},reader:{type:$,devoid:!0,filter:function(a){return a===!0&&(a=this.key()),a}},writer:{type:$,devoid:!1,filter:function(a){return a===!0&&(a=this.key()),a}},predicate:{type:$,devoid:!1,filter:function(a){return a===!0&&(a="has"+n(this.key())),a}},clearer:{type:$,devoid:!1,filter:function(a){return a===!0&&(a="clear"+n(this.key())),a}},proxies:{type:new S(X)}},ab={},bb={};for(var cb in _)ab[cb]=o("_"+cb,_[cb]),bb[cb]=r("_"+cb,k({writer:ab[cb]},_[cb]));var db=q(function(a){this._originalArgs=p(a),ab.key.call(this,a.key);for(var b in a)ab[b].call(this,a[b])},k({readerMethod:r("_readerMethod",{type:G,devoid:function(){return r(this.valueKey(),{devoid:this.devoid(),builder:this.builder(),required:this.required(),writer:this.writerMethod(),predicate:this.predicateMethod()})}}),writerMethod:r("_writerMethod",{type:G,devoid:function(){return o(this.valueKey(),{type:this.type(),coerce:this.coerce(),filter:this.filter(),augments:this.augments(),chain:this.chain()})}}),accessorMethod:r("_accessorMethod",{type:G,devoid:function(){return t(this.valueKey(),{writer:this.writerMethod(),reader:this.readerMethod()})}}),predicateMethod:r("_predicateMethod",{type:G,devoid:function(){return l(this.valueKey())}}),clearerMethod:r("_clearerMethod",{type:G,devoid:function(){return g(this.valueKey())}}),proxyMethods:r("_proxyMethods",{type:new S(G),devoid:function(){var a={},b=this.proxies();if(void 0===b)return a;var c=this;for(var d in b)a[d]=function(a){return function(){var b=c.getValue(this);return b[a].apply(b,arguments)}}(b[d]);return a}}),getValue:function(a){return this.readerMethod().call(a)},setValue:function(a,b){return this.writerMethod().call(a,b)},hasValue:function(a){return this.predicateMethod().call(a)},clearValue:function(a){return this.clearerMethod().call(a)},setValueFromArgs:function(a,b){return null!==this.argKey()&&void 0!==b[this.argKey()]?this.setValue(a,b[this.argKey()]):void 0},install:function(a,b){null!==this.writer()&&this.writer()===this.reader()?a[this.writer()]=this.accessorMethod():(null!==this.writer()&&(a[this.writer()]=this.writerMethod()),null!==this.reader()&&(a[this.reader()]=this.readerMethod())),null!==this.predicate()&&(a[this.predicate()]=this.predicateMethod()),null!==this.clearer()&&(a[this.clearer()]=this.clearerMethod());var c=this.proxyMethods();for(var d in c)a[d]=c[d];return b&&this.setValue(a,b),a},rebuild:function(a){var b=this.constructor;return new b(k({},this._originalArgs,a))}},bb));c.Attribute=db;var eb=new z(db);c.attributeType=eb;var fb,gb;gb=q(function(a){for(var b=0,c=fb.length;c>b;b++)fb[b].setValueFromArgs(this,a)},{install:function(a,b){var c,g,h,i=this.requires();for(c=0,g=i.length;g>c;c++)if(void 0===a[i[c]])throw new Error(required[c]+" is required.");var j=this.traits();for(c=0,g=j.length;g>c;c++)j[c].install(a);var k=this.attributes();for(h in k)k[h].install(a);var l=this.methods();for(h in l)a[h]=l[h];var m=this.around();for(h in m)a[h]=e(a[h],m[h]);var n=this.before();for(h in n)a[h]=f(a[h],n[h]);var o=this.after();for(h in o)a[h]=d(a[h],o[h]);return b&&this.setFromArgs(a,b),a},setFromArgs:function(a,b){var c,d=this.attributes();for(c in d)d[c].filter()||d[c].setValueFromArgs(a,b);for(c in d)d[c].filter()&&d[c].setValueFromArgs(a,b)},buildType:function(){var a,b={},c=this.attributes();for(a in c){var d=c[a];d.reader()&&(b[d.reader()]=G),d.writer()&&(b[d.writer()]=G),d.predicate()&&(b[d.predicate()]=G),d.clearer()&&(b[d.clearer()]=G)}for(a in this.methods())b[a]=G;var e=/^_/m;for(a in b)a.match(e)&&delete b[a];b=new R(b);var f=this.traits();if(!f.length)return b;for(var g=[b],h=0,i=f.length;i>h;h++)g.push(f[h].type());return new v(g)}}),fb=[{key:"requires",type:new Q(U),devoid:function(){return[]}},{key:"traits",type:new Q(new z(gb)),devoid:function(){return[]}},{key:"attributes",type:new S(eb),devoid:function(){return{}},filter:function(a){var b={};for(var c in a){var d=a[c];eb.check(d)?d.key()!==c&&(d=d.rebuild({key:c})):d=new db(k({},d,{key:c})),b[c]=d}return b}},{key:"methods",type:new S(G),devoid:function(){return{}}},{key:"around",type:new S(G),devoid:function(){return{}}},{key:"before",type:new S(G),devoid:function(){return{}}},{key:"after",type:new S(G),devoid:function(){return{}}},{key:"type",type:O,builder:!0,argKey:null}];for(var hb=gb.prototype,ib=0,jb=fb.length;jb>ib;ib++)fb[ib]=new db(fb[ib]),fb[ib].install(hb);c.Trait=gb;var kb=new z(gb);c.traitType=kb;var lb=new gb({attributes:{type:{type:O,builder:!0,argKey:null},trait:{type:kb,required:!0}},methods:{buildType:function(){return new z(this)}}});c.classTrait=lb;var mb=q(function(a){var b=new gb(a),c=function(a){b.setFromArgs(this,a)};return b.install(c.prototype),lb.install(c,{trait:b}),c});c.Class=mb;var nb=lb.type().subtype({coerce:function(a){return this.check(a)?a:new mb(a)}});c.classType=nb}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index 7910e25..45fc145 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "o", - "version": "0.0.9", + "version": "0.0.10", "description": "JavaScript utility belt for rich objects and prototypes. Ooooh!", "homepage": "http://o-js.com",