From cee84674f033f443bd40ec71039f48eb9158ab85 Mon Sep 17 00:00:00 2001 From: Aran Deltac Date: Fri, 16 Jan 2015 10:40:53 -0800 Subject: [PATCH] Release 0.0.11. --- CHANGES.txt | 2 +- bower.json | 2 +- o.js | 2 +- o.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7fbbf42..2962ffd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -DEVELOPMENT VERSION +0.0.11 : 2015-01-16 Global: - Added a .lvimrc file to enforce indentation style (requires the vim-localvimrc plugin). diff --git a/bower.json b/bower.json index 54d0012..eecdf9a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "o", - "version": "0.0.10", + "version": "0.0.11", "main": "o.js", "description": "JavaScript utility belt for rich objects and prototypes. Ooooh!", diff --git a/o.js b/o.js index d93893c..2150e4a 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.11 : http://o-js.com : MIT License (function() { diff --git a/o.min.js b/o.min.js index 4a4acde..5a7477c 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.11 : 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=new T(/^[A-Za-z_$][A-Za-z_$0-9]*$/);c.identifierType=V;var W=I.subtype(function(a){return Math.floor(a)===a+0?!0:!1});c.integerType=W;var X=I.subtype(function(a){return 0>a?!0:!1});c.negativeType=X;var Y=N.subtype(function(a){return a.length>0?!0:!1});c.nonEmptyStringType=Y;var Z=I.subtype(function(a){return 0!==a?!0:!1});c.nonZeroType=Z;var $=new v([W,K]);c.positiveIntType=$;var _=new w([E,V]),ab={key:{type:V,required:!0},argKey:{type:new w([V,H]),devoid:function(){return this.key()}},valueKey:{type:V,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(V)}},bb={},cb={};for(var db in ab)bb[db]=o("_"+db,ab[db]),cb[db]=r("_"+db,k({writer:bb[db]},ab[db]));var eb=q(function(a){a=a||{},this._originalArgs=p(a),bb.key.call(this,a.key);for(var b in a)bb[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))}},cb));c.Attribute=eb;var fb=new z(eb);c.attributeType=fb;var gb,hb;hb=q(function(a){a=a||{};for(var b=0,c=gb.length;c>b;b++)gb[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,c){var d=this.attributes();c||(c={});var e;for(e in d)c[e]||d[e].filter()||(d[e].setValueFromArgs(a,b),c[e]=!0);for(e in d)c[e]||d[e].filter()&&(d[e].setValueFromArgs(a,b),c[e]=!0);var f=this.traits();for(jb=0,kb=f.length;kb>jb;jb++)f[jb].setFromArgs(a,b,c)},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)}}),gb=[{key:"requires",type:new Q(U),devoid:function(){return[]}},{key:"traits",type:new Q(new z(hb)),devoid:function(){return[]}},{key:"attributes",type:new S(fb),devoid:function(){return{}},filter:function(a){var b={};for(var c in a){var d=a[c];fb.check(d)?d.key()!==c&&(d=d.rebuild({key:c})):d=new eb(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 ib=hb.prototype,jb=0,kb=gb.length;kb>jb;jb++)gb[jb]=new eb(gb[jb]),gb[jb].install(ib);c.Trait=hb;var lb=new z(hb);c.traitType=lb;var mb=new hb({attributes:{type:{type:O,builder:!0,argKey:null},trait:{type:lb,required:!0}},methods:{buildType:function(){return new z(this)}}});c.classTrait=mb;var nb=q(function(a){var b=new hb(a),c=function(a){a=a||{},b.setFromArgs(this,a)};return b.install(c.prototype),mb.install(c,{trait:b}),c});c.Class=nb;var ob=mb.type().subtype({coerce:function(a){return this.check(a)?a:new nb(a)}});c.classType=ob}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index eeb3f02..0c828b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "o", - "version": "0.0.10", + "version": "0.0.11", "description": "JavaScript utility belt for rich objects and prototypes. Ooooh!", "homepage": "http://o-js.com",