From a6dd16eac1f71140f5cd59d2873e28ffa6b83faa Mon Sep 17 00:00:00 2001 From: Aran Deltac Date: Tue, 8 Nov 2016 19:43:51 -0800 Subject: [PATCH] Release 0.1.0. --- 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 9c4f7a7..09a9ecb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -DEVELOPMENT VERSION +0.1.0 : 2016-11-08 Global: - Use a more condenced for loop, using `in`, when going over arrays. diff --git a/bower.json b/bower.json index eecdf9a..2cac6f5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "o", - "version": "0.0.11", + "version": "0.1.0", "main": "o.js", "description": "JavaScript utility belt for rich objects and prototypes. Ooooh!", diff --git a/o.js b/o.js index d62572c..7135275 100644 --- a/o.js +++ b/o.js @@ -1,4 +1,4 @@ -// o.js : DEVELOPMENT VERSION : http://o-js.com : MIT License +// o.js : 0.1.0 : http://o-js.com : MIT License (function() { diff --git a/o.min.js b/o.min.js index 60ec8df..2c7706b 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.1.0 : 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 s.validationDisabled?!0: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))}}),s.validationDisabled=!1,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=function(a){return a?j(s,"validationDisabled",function(){return s.validationDisabled=!0,a()}):void(s.validationDisabled=!0)};c.disableTypeValidation=v;var w=u(s,function(a,b,c){c=c||{},c.validate=function(a){for(var c in b)if(!b[c].check(a))return!1;return!0},a(c)});c.AllType=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(b[c].check(a))return!0;return!1},a(c)});c.AnyType=x;var y=u(s,function(a,b,c){c=c||{},c.validate=function(a){for(var c in b)if(a===b[c])return!0;return!1},a(c)});c.EnumType=y;var z=u(s,function(a,b,c){c=c||{},c.validate=function(a){return a===b?!0:!1},a(c)});c.EqualType=z;var A=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=A;var B=u(s,function(a,b,c){c=c||{};var d=new x(b);c.validate=function(a){return d.check(a)?!1:!0},a(c)});c.NoneType=B;var C=u(B,function(a,b,c){a([b],c)});c.NotType=C;var D=u(s,function(a,b,c){c=c||{},c.validate=function(a){return typeof a===b?!0:!1},a(c)});c.TypeOfType=D;var E=new A(Array);c.arrayType=E;var F=new x([new D("boolean"),new A(Boolean)]);c.booleanType=F;var G=new A(Date);c.dateType=G;var H=new A(Function);c.functionType=H;var I=new z(null);c.nullType=I;var J=new x([new D("number"),new A(Number)]);c.numberType=J;var K=new A(Object);c.objectType=K;var L=J.subtype(function(a){return a>0?!0:!1});c.positiveType=L;var M=new A(RegExp);c.regExpType=M;var N=K.subtype(function(a){return a.constructor===Object?!0:!1});c.simpleObjectType=N;var O=new x([new D("string"),new A(String)]);c.stringType=O;var P=new A(s);c.typeType=P;var Q=new z(void 0);c.undefinedType=Q;var R=u(s,function(a,b,c){c=c||{},c.validate=function(a){if(!E.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.ArrayOfType=R;var S=u(s,function(a,b,c){c=c||{},c.validate=function(a){if(!K.check(a))return!1;if(E.check(b)){for(var c in b)if(void 0===a[b[c]])return!1;return!0}if(N.check(b)){for(var d in b){if(void 0===a[d])return!1;if(!b[d].check(a[d]))return!1}return!0}return!1},a(c)});c.DuckType=S;var T=u(s,function(a,b,c){c=c||{},c.validate=function(a){if(!K.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=T;var U=u(s,function(a,b,c){c=c||{},c.validate=function(a){return O.check(a)?b.test(a):!1},a(c)});c.PatternType=U;var V=new C(Q);c.definedType=V;var W=new U(/^[A-Za-z_$][A-Za-z_$0-9]*$/);c.identifierType=W;var X=J.subtype(function(a){return Math.floor(a)===a+0?!0:!1});c.integerType=X;var Y=J.subtype(function(a){return 0>a?!0:!1});c.negativeType=Y;var Z=O.subtype(function(a){return a.length>0?!0:!1});c.nonEmptyStringType=Z;var $=J.subtype(function(a){return 0!==a?!0:!1});c.nonZeroType=$;var _=new w([X,L]);c.positiveIntType=_;var aa=new x([F,W]),ba={key:{type:W,required:!0},argKey:{type:new x([W,I]),devoid:function(){return this.key()}},valueKey:{type:W,devoid:function(){return"_"+this.key()}},devoid:{type:V},builder:{type:aa,devoid:!1,filter:function(a){return a===!0&&(a="build"+n(this.key())),a}},required:{type:F,devoid:!1},type:{type:new x([new y(["undefined","object","boolean","number","string","function"]),P,H])},coerce:{type:F,devoid:!1},filter:{type:H},augments:{type:H},chain:{type:F,devoid:!1},reader:{type:aa,devoid:!0,filter:function(a){return a===!0&&(a=this.key()),a}},writer:{type:aa,devoid:!1,filter:function(a){return a===!0&&(a=this.key()),a}},predicate:{type:aa,devoid:!1,filter:function(a){return a===!0&&(a="has"+n(this.key())),a}},clearer:{type:aa,devoid:!1,filter:function(a){return a===!0&&(a="clear"+n(this.key())),a}},proxies:{type:new T(W)}},ca={},da={};for(var ea in ba)ca[ea]=o("_"+ea,ba[ea]),da[ea]=r("_"+ea,k({writer:ca[ea]},ba[ea]));var fa=q(function(a){a=a||{},this._originalArgs=p(a),ca.key.call(this,a.key);for(var b in a)ca[b].call(this,a[b])},k({readerMethod:r("_readerMethod",{type:H,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:H,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:H,devoid:function(){return t(this.valueKey(),{writer:this.writerMethod(),reader:this.readerMethod()})}}),predicateMethod:r("_predicateMethod",{type:H,devoid:function(){return l(this.valueKey())}}),clearerMethod:r("_clearerMethod",{type:H,devoid:function(){return g(this.valueKey())}}),proxyMethods:r("_proxyMethods",{type:new T(H),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))}},da));c.Attribute=fa;var ga=new A(fa);c.attributeType=ga;var ha,ia;ia=q(function(a){"function"==typeof a&&(a=this.functionToArgs(a)),a=a||{};for(var b in ha)ha[b].setValueFromArgs(this,a)},{functionToArgs:function(a){var b={requires:[],traits:[],attributes:{},methods:{},around:{},before:{},after:{}},c={require:function(a){b.requires.push(a)},trait:function(a){b.traits.push(a)},attribute:function(a,c){b.attributes[a]=c},method:function(a,c){b.methods[a]=c},around:function(a,c){b.around[a]=c},before:function(a,c){b.before[a]=c},after:function(a,c){b.after[a]=c}};return a.apply(c),b},install:function(a,b){var c,g,h=this.requires();for(c in h)if(void 0===a[h[c]])throw new Error(required[c]+" is required.");var i=this.traits();for(c in i)i[c].install(a);var j=this.attributes();for(g in j)j[g].install(a);var k=this.methods();for(g in k)a[g]=k[g];var l=this.around();for(g in l)a[g]=e(a[g],l[g]);var m=this.before();for(g in m)a[g]=f(a[g],m[g]);var n=this.after();for(g in n)a[g]=d(a[g],n[g]);return b&&this.setFromArgs(a,b),a},setFromArgs:function(a,b,c){var d=this.attributes();c||(c={});var e,f;for(f in d)c[f]||d[f].filter()||(d[f].setValueFromArgs(a,b),c[f]=!0);for(f in d)c[f]||d[f].filter()&&(d[f].setValueFromArgs(a,b),c[f]=!0);var g=this.traits();for(e in g)g[e].setFromArgs(a,b,c)},buildType:function(){var a,b,c={},d=this.attributes();for(b in d){var e=d[b];e.reader()&&(c[e.reader()]=H),e.writer()&&(c[e.writer()]=H),e.predicate()&&(c[e.predicate()]=H),e.clearer()&&(c[e.clearer()]=H)}for(b in this.methods())c[b]=H;var f=/^_/m;for(b in c)b.match(f)&&delete c[b];c=new S(c);var g=this.traits();if(!g.length)return c;var h=[c];for(a in g)h.push(g[a].type());return new w(h)}}),ha=[{key:"requires",type:new R(V),devoid:function(){return[]}},{key:"traits",type:new R(new A(ia)),devoid:function(){return[]}},{key:"attributes",type:new T(ga),devoid:function(){return{}},filter:function(a){var b={};for(var c in a){var d=a[c];ga.check(d)?d.key()!==c&&(d=d.rebuild({key:c})):d=new fa(k({},d,{key:c})),b[c]=d}return b}},{key:"methods",type:new T(H),devoid:function(){return{}}},{key:"around",type:new T(H),devoid:function(){return{}}},{key:"before",type:new T(H),devoid:function(){return{}}},{key:"after",type:new T(H),devoid:function(){return{}}},{key:"type",type:P,builder:!0,argKey:null}];var ja=ia.prototype;for(var ka in ha)ha[ka]=new fa(ha[ka]),ha[ka].install(ja);c.Trait=ia;var la=new A(ia);c.traitType=la;var ma=new ia({attributes:{type:{type:P,builder:!0,argKey:null},trait:{type:la,required:!0}},methods:{buildType:function(){return new A(this)}}});c.classTrait=ma;var na=q(function(a){var b=new ia(a),c=function(a){a=a||{},b.setFromArgs(this,a)};return b.install(c.prototype),ma.install(c,{trait:b}),c});c.Class=na;var oa=ma.type().subtype({coerce:function(a){return this.check(a)?a:new na(a)}});c.classType=oa}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index 0c828b2..96f57c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "o", - "version": "0.0.11", + "version": "0.1.0", "description": "JavaScript utility belt for rich objects and prototypes. Ooooh!", "homepage": "http://o-js.com",