Created
July 23, 2013 18:27
-
-
Save jamesshore/6064853 to your computer and use it in GitHub Desktop.
The [jTypes](http://www.jtypes.com/) front-page example, formatted for visualizing on [Object Playground](http://www.objectplayground.com/).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! ------------------------------------------------------------------------ | |
// jTypes 2.1.1 | |
// ------------------------------------------------------------------------ | |
// | |
// Copyright 2013 Gaulinsoft Corporation | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
*/ | |
(function(W,R){var c=Object,la=c.prototype,H=c.create,Ka=c.defineProperties,m=c.defineProperty,B=c.freeze,wa=c.getPrototypeOf,aa=c.keys,ha=c.preventExtensions,e=c.seal,x=la.hasOwnProperty,La=la.toString,Q=Array,ma=Q.prototype,Q=Q.isArray,ia=ma.forEach,xa=ma.indexOf,na=String.prototype,Ma=na.match,Na=na.replace,Z=na.trim;if(!(H&&m&&B&&wa&&ha&&e&&Q&&ia&&xa&&Z))throw"jTypes Error: A browser that supports JavaScript 1.8.5 (MSIE 9+) is required.";var ba=function(a,b){a=a?"$$."+a:"$$";for(var c=[],d=0, | |
h=b.length;d<h;d++)c.push(k.type(b[d]));return"jTypes Error: "+k.format('"{0}({1})" has some invalid arguments.',a,c.join(", "))},n=function(a){return"jTypes Error: "+k.format.apply(k,arguments)},r=function(a,b){return m.call(c,k,a,{configurable:!1,enumerable:!1,value:b,writable:!1})},ha=function(a,b,S){return m.call(c,k,a,{configurable:!1,enumerable:!0,get:b||R,set:S||R})},ca="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ya=[],ca=ca+ca.toLowerCase(),e=function(a){a||(a=3);var b="";do for(var b="",c=0;c<a;c++)b+= | |
ca.charAt(Math.floor(ca.length*Math.random()));while(0<=xa.call(ya,b));ya.push(b);return"~"+b},za=e(3),Aa=e(3),$=e(3),Oa=e(3),Ba=e(3),Pa=e(3),Ca=e(3),Da=e(3),oa=e(3),pa=e(3),Ea=e(3),Qa=e(3),qa=e(3),Ra=e(3),da=e(3),ea=e(3);e(3);var fa=e(3),M=e(3),Fa=e(3),L=e(3),N=e(3),Q=0;Q++;Q++;Q++;Q++;Q++;var ra=e(3);e(3);var ja=e(3),e=0,X=e++,T=e++,U=e++,C=e++,O=e++,ka=e++,V=function(){},e={constructor:V,toString:function(){return"[object Instance]"}};B.call(c,e);V.prototype=e;B.call(c,V);var Sa=function(){return"[object Class]"}, | |
Ga=!0,P=!0,ga=!1,Ha=function(a,b,S,d,h,k,s,n,w,t,e){var q={},f=h[T],l=h[U];q[da]=!l&&s;q[ea]=!l&&w;q[fa]=!l&&(t||s||n);q[M]=f.substr(5);q[Fa]=e;q[L]=k;q[N]=h[ka];B.call(c,q);h[X]?l?m.call(c,b,f,{enumerable:!0,value:q}):h[C]?m.call(c,S,f,{enumerable:!0,value:q}):h[O]&&m.call(c,d,f,{enumerable:!0,value:q}):m.call(c,a,f,{enumerable:!0,value:q})},Ia=function(a,b,c){b=b[c];if(b[da]&&(a=x.call(a,c)&&a[c]||null,!a||a[L]!==b[L]))throw n('Class must implement the inherited abstract {1} "{0}" with the override modifier.', | |
b[M],b[L]);},sa=function(a,b,c,d,h,m,s,k){c||(c=b);var e=null;s?e=d[a]||null:k&&(e=h[a]||null);if(m){if(!e||e[L]!==b||!e[fa]||e[ea])throw n('"{0}" has no suitable {1} to override.',"~"===a.charAt(0)?a.substr(5):a,c);}else if(e&&e[da])throw n('"{0}" must implement the inherited abstract {1} with the override modifier.',"~"===a.charAt(0)?a.substr(5):a,b);},Ta=function(a,b,S,d,h,e,s,r,w,t,p){var q=Z.call(k.asString(e)).split(" ")||[],f=k.asString(q.pop());if(!Z.call(f))throw n('"" is not a valid {0} name.', | |
l);if(!Ma.call(f,/^(_|\$|[a-z])[_\$a-z0-9]*$/i))throw n('"{1}" is not a valid {0} name.',l,f);x.call(s,ja)&&(q=k.asString(s[ra]).split(" ")||[],s=s[ja]);var l="field";k.isFunction(s)?l="method":k.isSimpleObject(s)&&(l="property");for(var u=e=!1,g=!1,v=!1,z=!1,A=!1,F=!1,I=!1,G=!1,D=!1,J=0,H=q.length;J<H;J++){var y=q[J];if("field"!==l&&"abstract"===y)e=!0;else if("field"!==l&&"override"===y)u=!0;else if("private"===y)A=!0;else if("protected"===y)F=!0;else if("prototype"===y)G=!0;else if("public"=== | |
y)I=!0;else if("field"===l&&"readonly"===y)g=!0;else if("field"!==l&&"sealed"===y)v=!0;else if("static"===y)D=!0;else if("field"!==l&&"virtual"===y)z=!0;else if(y)throw n('"{1}" has an invalid {0} modifier "{2}".',l,f,y);}if("as"===f||"is"===f||"~constructor"===f||"constructor"===f||"prototype"===f||"__base"===f||"__self"===f||"__this"===f)throw n('"{1}" is not a valid {0} name.',"member",f);if(A&&F||A&&I||F&&I)throw n('"{0}" cannot have more than one access modifier.',f);if(G||D){if(G){if(D)throw n('"{0}" cannot have the {1} and {2} modifiers.', | |
f,"prototype","static");l="prototype";if(a[f]||b[f]||x.call(d,f)||S[f])throw n('"{0}" cannot have more than one definition or hide an inherited non-prototype member.',f);}else if(D&&(l="static",x.call(h,f)))throw n('"{0}" cannot have more than one static definition.',f);if(e||u||z)throw n('"{0}" cannot have the abstract, virtual, or override modifiers because it is {1}.',f,l);if(A||F||I)throw n('"{0}" cannot have the public, protected, or private modifiers because it is {1}.',f,l);if(g)throw n('"{0}" cannot have the readonly modifier because it is {1}.', | |
f,l);}else{if(x.call(a,f)||x.call(b,f)||x.call(d,f)||x.call(S,f))throw n('"{0}" cannot have more than one definition.',f);F||I||(A=!0)}if("method"===l||"property"===l){if(A&&(e||u||z))throw n('"{0}" cannot have the abstract, virtual, or override modifiers because it is {1}.',f,"private");if(e){if(v)throw n('"{0}" cannot have the {1} and {2} modifiers.',f,"abstract","sealed");if(z)throw n('"{0}" cannot have the {1} and {2} modifiers.',f,"abstract","virtual");if(!t)throw n('"{0}" cannot have the abstract modifier in a non-abstract class.', | |
f);}if(u){if(z)throw n('"{0}" cannot have the {1} and {2} modifiers.',f,"override","virtual");if(!r&&!w)throw n('"{0}" has no suitable {1} to override.',f,l);}else if(v)throw n('"{0}" cannot have the {1} modifier without the {2} modifier.',f,"sealed","override");if(p&&z)throw n('"{0}" cannot have the virtual modifier in a sealed class.',f);}t=null;A?t=a:F?t=b:I&&(t=S);switch(l){case "field":k.isReferenceType(s)&&(s=null);a={};a[qa]=g;a[M]=f;a[L]=l;a[N]=s;B.call(c,a);m.call(c,t,f,{enumerable:!0,value:a}); | |
break;case "method":(r||w)&&sa(f,l,null,r,w,u,F,I);a={};a[da]=e;a[ea]=v;a[fa]=z||e||u;a[M]=f;a[L]=l;a[N]=s;B.call(c,a);m.call(c,t,f,{enumerable:!0,value:a});break;case "property":d=[];h=[];var D=G=!1,K;for(K in s){p=Z.call(k.asString(K)).split(" ")||[];q=k.asString(p.pop());J=s[K];if(!Z.call(q))throw n('"{0}" must have at least one property accessor.',f);g=null;if("get"!==q){if("set"!==q)throw n('"{0}" cannot have a "{1}" property accessor.',f,q);if(D)throw n('"{0}" cannot have more than one definition for the {1} accessor.', | |
f,"set");D=!0;h[T]="~set_"+f;g=h;u&&(!G&&t["~get_"+f])&&(d[X]=!1,d[T]="~get_"+f,d[U]=A,d[C]=F,d[O]=I,d[ka]=function(){return this.__base[f]})}else{if(G)throw n('"{0}" cannot have more than one definition for the {1} accessor.',f,"get");G=!0;d[T]="~get_"+f;g=d;u&&(!D&&t["~set_"+f])&&(h[X]=!1,h[T]="~set_"+f,h[U]=A,h[C]=F,h[O]=I,h[ka]=function(a){this.__base[f]=a})}if(!k.isFunction(J))throw n('"{0}" must have a function for the {1} accessor.',f,q);g[U]=!1;g[C]=!1;g[O]=!1;g[ka]=J;J=0;for(H=p.length;J< | |
H;J++){var E=p[J];if("private"===E)g[U]=!0;else if("protected"===E)g[C]=!0;else if("public"===E)g[O]=!0;else if(y)throw n('"{0}" has an invalid modifier "{2}" on the {1} accessor.',f,q,y);}g[X]=g[U]||g[C]||g[O];if(g[X]){if(g[U]&&g[C]||g[U]&&g[O]||g[C]&&g[O])throw n('"{0}" cannot have more than one access modifier.',q);if(g[O]||g[C]&&!I||g[U]&&A)throw n('"{0}" must have a more restrictive access modifier on the {1} accessor.',f,q);}}if(!G&&!D)throw n('"{0}" must have at least one property accessor.', | |
f);s=d[X];y=h[X];if(s&&y)throw n('"{0}" cannot have access modifiers on both property accessors.',f);if(!D&&s)throw n('"{0}" must have both accessors to have an access modifier on the {1} accessor.',f,"get");if(!G&&y)throw n('"{0}" must have both accessors to have an access modifier on the {1} accessor.',f,"set");G=G||!!d[T];D=D||!!h[T];G&&((r||w)&&sa(d[T],l,"get accessor",r,w,u,s?d[C]:F,s?d[O]:I),Ha(t,a,b,S,d,l,e,u,v,z,G&&D));D&&((r||w)&&sa(h[T],l,"set accessor",r,w,u,y?h[C]:F,y?h[O]:I),Ha(t,a,b, | |
S,h,l,e,u,v,z,G&&D));break;case "prototype":case "static":g={},g[M]=f,g[L]=l,g[N]=s,B.call(c,g),G?d[f]=g:D&&(h[f]=g)}},Ua=function(a,b,c,d,h,m,s,e,k){a.configurable=b;a.enumerable=!0;a.get=function(){return d};a.set=k?function(a){if(k())throw n('"{0}" cannot be set because it is a read-only field.',c);d=a===m||s&&a===s||a===h?e:a}:function(a){d=a===m||s&&a===s||a===h?e:a}},Va=function(a,b,c,d,h,m){a.configurable=!1;a.enumerable=!0;a.get=function(){return d[c]};a.set=h?m?function(a){if(m())throw n('"{0}" cannot be set because it is a read-only field.', | |
b);if(a!==R&&null!==a&&k.type(a)!==h)throw n('"{0}" must have a value of the type {1}, null, or undefined.',b,h);d[c]=a}:function(a){if(a!==R&&null!==a&&k.type(a)!==h)throw n('"{0}" must have a value of the type {1}, null, or undefined.',b,h);d[c]=a}:m?function(a){if(m())throw n('"{0}" cannot be set because it is a read-only field.',b);d[c]=a}:function(a){d[c]=a}},Y=function(a,b,c){return"get"===c?{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:b.set}:"set"===c?{configurable:a.configurable, | |
enumerable:a.enumerable,get:b.get,set:a.set}:a},Ja=function(a,b,c,d,h,m,e,k,n){a.configurable=b;a.enumerable=!0;b=function(){var a=d.apply(c,arguments);return a===m||e&&a===e||a===h?k:a};"get"===n?a.get=b:"set"===n?a.set=b:a.value=b},ta=function(a,b,c,d){if(c[fa])if(c[ea])d[b]=a;else return(c=d[b]||null)||(d[b]=a),c;else d[b]=null;return null},ua=function(a,b,e,d,h,k,n,r,w,t,p,q,f,l){var u=b[a];switch(u[L]){case "field":b={};var g=u[M];l&&u[Qa]?Va(b,g,u[N],l,u[Ra],u[qa]?k:null):Ua(b,!1,g,u[N],t,p, | |
q,f,u[qa]?k:null);r||w?(m.call(c,t,g,b),P?m.call(c,q,g,b):(m.call(c,p,g,b),d[g]=b,h[g]=b),w&&m.call(c,f,g,b)):m.call(c,p,g,b);break;case "method":b={};g=u[M];k=p;r&&"~constructor"===g&&(P?(k=H.call(c,p),m.call(c,k,"__base",{get:function(){var a=p.__base;return a&&a["~constructor"]||null}}),B.call(c,k)):k=n);Ja(b,!1,k,u[N],t,p,q,f);r||w?(m.call(c,t,g,b),a=(a=ta(b,a,u,e))?a:b,P?m.call(c,q,g,a):(m.call(c,p,g,a),d[g]=a,h[g]=b),w&&m.call(c,f,g,a)):m.call(c,p,g,b);break;case "property":n=a.substr(1,3); | |
var g=u[M],v=u[Fa];k=v&&x.call(t,g);l=v&&x.call(p,g);var z=k||l;b={};Ja(b,v&&!z,p,u[N],t,p,q,f,n);!v||z?(v=v&&x.call(f,g),r||w?(m.call(c,t,g,k?Y(b,t[g],n):b),a=(a=ta(b,a,u,e))?a:b,P?(m.call(c,q,g,k?Y(a,q[g],n):a),l&&m.call(c,p,g,p[g])):(m.call(c,p,g,l?Y(a,p[g],n):a),d[g]=z&&x.call(d,g)?Y(a,d[g],n):a,h[g]=z&&x.call(h,g)?Y(b,h[g],n):b),w?m.call(c,f,g,v?Y(a,f[g],n):a):v&&m.call(c,f,g,f[g])):z?(m.call(c,p,g,l?Y(b,p[g],n):b),k&&(m.call(c,t,g,t[g]),P&&m.call(c,q,g,q[g])),v&&m.call(c,f,g,f[g])):m.call(c, | |
p,g,b)):r||w?(m.call(c,t,g,{configurable:!0,value:b}),a=(a=ta(b,a,u,e))?a:b,P?m.call(c,q,g,{configurable:!0,value:a}):(m.call(c,p,g,{configurable:!0,value:a}),d[g]=a,h[g]=b),w&&m.call(c,f,g,{configurable:!0,value:a})):m.call(c,p,g,{configurable:!0,value:b})}},va=function(a,b,k){for(var d in a)if(!x.call(k,d)){var h=a[d];m.call(c,k,d,h);b[d]=h}},k=function(){var a=0,b=null,e=arguments[a++],d="",h=null;if(k.isSimpleObject(e))h=e,e=null;else if(h=arguments[a++],k.isFunction(e)||(k.isClass(e)?(b=e,k.isFunction(h)? | |
(e=h,h=arguments[a++]):e=null):(d=k.asString(e),k.isClass(h)?(b=h,e=arguments[a++]):e=h,k.isFunction(e)?h=arguments[a++]:(h=e,e=null))),!k.isSimpleObject(h))throw ba(null,arguments);if(arguments.length!==a)throw ba(null,arguments);var r=!1,s=!1,x=!1,w=!1,t=!1,p=!1;if(d){for(var q=Z.call(d).split(" ")||[],d=0,f=q.length;d<f;d++){var l=q[d];if("abstract"===l)r=!0;else if("expando"===l)p=t=w=x=!0;else if("expando-private"===l||"private-expando"===l)w=!0;else if("expando-public"===l||"public-expando"=== | |
l)p=!0;else if("expando-prototype"===l||"prototype-expando"===l)t=!0;else if("expando-static"===l||"static-expando"===l)x=!0;else if("sealed"===l)s=!0;else if(l)throw n('"{0}" is not a valid class modifier.',l);}if(arguments.length!==a)throw ba(null,arguments);if(r&&s)throw n("Classes cannot have the abstract and sealed modifiers.");}var u={},g=b?H.call(c,b[oa]):{},d=new V,v=b?H.call(c,b[pa]):{},q={},a={},l=b&&b[oa]||null,z=b&&b[pa]||null,A;for(A in h)"constructor"!==A&&"prototype"!==A&&Ta(u,g,v, | |
q,a,A,h[A],l,z,r,s);if(b){if(b[Da])throw n("Classes cannot inherit from a sealed class.");if(b[Ea])throw n("Classes cannot inherit from a .NET class.");if(b[za]){h=aa.call(c,l)||[];A=aa.call(c,z)||[];d=0;for(f=h.length;d<f;d++)Ia(g,l,h[d]);d=0;for(f=A.length;d<f;d++)Ia(v,z,A[d])}ga=!0;d=new b;ga=!1}e||(e=function(){if(this.__base)return this.__base.apply(this,arguments)});h={};h[da]=!1;h[ea]=!1;h[fa]=!1;h[M]="~constructor";h[L]="method";h[N]=e;B.call(c,h);m.call(c,g,"~constructor",{enumerable:!0, | |
value:h});for(var F in q)e=q[F],"prototype"===e[L]&&m.call(c,d,e[M],{enumerable:!0,value:e[N]});B.call(c,u);B.call(c,g);B.call(c,v);var I=aa.call(c,u)||[],G=aa.call(c,g)||[],D=aa.call(c,v)||[],J=function(a,b,e,f,d,k,h,m,n){if(this===V){var l=null,r=a[0],q=null,s=a[2];P?(l=a[3],q=a[1]):l=a[1];a=0;for(var t=I.length;a<t;a++)ua(I[a],u,null,null,null,h,null,!1,!1,l,r,q,s,n);a=0;for(t=G.length;a<t;a++)ua(G[a],g,d,e,b,h,m,!0,!1,l,r,q,s,n);a=0;for(t=D.length;a<t;a++)ua(D[a],v,k,f,b,h,null,!1,!0,l,r,q,s, | |
n);P&&(B.call(c,l),B.call(c,q),w||B.call(c,r),p||B.call(c,s))}},C=[];F=b;for(var y=1;k.isClass(F);)C.push(F),F=F[Aa];var K=function(){if(!ga){if(r)throw n("Abstract classes cannot be instantiated.");var a=this,b=[],g=!1,e=this instanceof K;e||(ga=!0,a=new K,ga=!1);m.call(c,a,"as",{value:function(c){if(!(k.isClass(c)&&a instanceof c))return null;var d=0;do if(C[d]===c)break;while(++d<y);return b[d][2]}});m.call(c,a,"is",{value:function(b){return b?!!(a instanceof b):!1}});var f=a,d=null,h=null,l=a, | |
q=function(){return g},s={},t={};if(P){h=a;for(p=y-1;0<=p;p--)f=H.call(c,f),h=H.call(c,h),l=H.call(c,l),d=H.call(c,h),m.call(c,d,"__self",{value:a}),m.call(c,l,"__self",{value:a}),m.call(c,d,"__this",{value:l}),v=C[p],m.call(c,d,"__type",{value:v}),m.call(c,l,"__type",{value:v}),p!==y-1&&m.call(c,d,"__base",{value:b[p+1][3]}),b[p]=[d,h,l,f];for(p=0;p<y;p++)(0===p?J:C[p][$]).call(V,b[p],null,null,null,s,t,q,null,null)}else{for(var h=[],u=[],p=0;p<y;p++){var f=H.call(c,a),d={},l=H.call(c,a),w=H.call(c, | |
d),v=[d,f,l];m.call(c,d,"__self",{value:a});m.call(c,l,"__self",{value:a});m.call(c,d,"__this",{value:l});var x={},z={},A={};(0===p?J:C[p][$]).call(V,v,x,z,A,s,t,q,w,null);b.push(v);h.push(w);u.push([x,z,A])}t=s=q=null;for(p=y-1;0<=p;p--){var v=b[p],f=v[1],d=v[0],l=v[2],v=C[p];m.call(c,d,"__type",{value:v});m.call(c,l,"__type",{value:v});p!==y-1?(x=b[p+1][1],m.call(c,d,"__base",{value:x}),w=h[p],m.call(c,w,"__base",{value:x["~constructor"]}),B.call(c,w),x=q,z=s,A=t,w=u[p],q=w[0],s=w[1],t=w[2],va(x, | |
q,f),va(z,s,d),va(A,t,l)):(w=u[p],q=w[0],s=w[1],t=w[2]);B.call(c,f);v[Ba]||B.call(c,d);v[Ca]||B.call(c,l)}}e&&(arguments.length?d["~constructor"].apply(d,arguments):d["~constructor"].call(d));g=!0;return l}},y=C.unshift(K),E;for(E in a)e=a[E],"static"===e[L]&&m.call(c,K,e[M],{enumerable:!0,value:e[N]});E={};E[za]={value:r};E[Aa]={value:b};E[$]={value:s?k.empty():J};E[Oa]={value:x};E[Ba]={value:w};E[Pa]={value:t};E[Ca]={value:p};E[Da]={value:s};E[oa]={value:s?{}:g};E[pa]={value:v};E[Ea]={value:!1}; | |
Ka.call(c,K,E);m.call(c,d,"constructor",{value:K});t||B.call(c,d);m.call(c,K,"prototype",{value:d});K.toString=Sa;x||B.call(c,K);return K};r("toString",function(){return"[object jTypes]"});m.call(c,k,"version",{configurable:!1,enumerable:!0,value:"2.1.1",writable:!1});ia.call(["private","protected","public"],function(a){r(a,function(b,e){var d={};switch(arguments.length){case 1:d[ra]=a;d[ja]=b;break;case 2:b=k.asString(b);d[ra]=b?a+" "+b:a;d[ja]=e;break;default:if(k.debug)throw ba(a,arguments);return null}B.call(c, | |
d);return d})});(function(){var a={};ia.call("Array Boolean Date Function Number RegExp String".split(" "),function(b){var c=b.toLowerCase();a["[object "+b+"]"]=c;r("is"+b,function(a){return k.type(a)===c})});ia.call(["Window","window","Global","global"],function(b){a["[object "+b+"]"]="window"});r("type",function(b){return null===b||b===R?b+"":b===W?"window":x.call(b,$)&&"function"===typeof b[$]?"class":b instanceof V?"instance":a[La.call(b)]||"object"})})();r("isClass",function(a){return a&&"function"=== | |
typeof a[$]});r("isFinite",function(a){return!(!k.isNumber(a)||!isFinite(a))});r("isInfinity",function(a){return k.isNumber(a)&&!isNaN(a)&&!isFinite(a)});r("isInstance",function(a){return a===R||null===a?!1:!!(a instanceof V)});r("isNaN",function(a){return!(!k.isNumber(a)||!isNaN(a))});r("isNegativeInfinity",function(a){return k.isNumber(a)&&!isNaN(a)&&!isFinite(a)&&0>a});r("isNull",function(a){return null===a});r("isPositiveInfinity",function(a){return k.isNumber(a)&&!isNaN(a)&&!isFinite(a)&&0<a}); | |
r("isReferenceType",function(a){a=k.type(a);return"undefined"!==a&&"null"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a});r("isSimpleObject",function(a){return a&&"object"===k.type(a)?wa.call(c,a)===la:!1});r("isUndefined",function(a){return a===R});r("isValueType",function(a){a=k.type(a);return"boolean"===a||"number"===a||"string"===a});r("isWindow",function(a){return a===W?!0:"window"===k.type(a)});r("asArray",function(a){if(null===a||a===R)return[];var b=k.type(a);return"array"===b?a:"boolean"=== | |
b||"number"===b||"string"===b?[]:ma.slice.call(a,0)||[]});r("asBool",function(a){return!!a});r("asFloat",function(a){return parseFloat(a)});r("asInt",function(a){var b=parseInt(a,10);if(!isNaN(b))return b;b=parseFloat(a);return 9007199254740992<b?Infinity:-9007199254740992>b?-Infinity:NaN});r("asString",function(a){var b=k.type(a);return"string"===b?a:"boolean"===b||"number"===b?a+"":""});r("empty",function(){return function(){}});r("format",function(a){if(!k.isString(a)){if(k.debug)throw ba("format", | |
arguments);return""}var b=arguments;return Na.call(a,/\{([0-9]{1,2})\}/g,function(a,c){var e=k.asInt(c)+1;return e>=b.length?a:k.asString(b[e])})});ha("debug",function(){return Ga},function(a){Ga=k.asBool(a)});ha("lazy",function(){return P},function(a){P=k.asBool(a)});if("function"===typeof define&&define.amd)define(function(){return k});else if("undefined"!==typeof module&&module&&module.exports)module.exports=k;else{if(W.$$===R||W.$$===W.jTypes)W.$$=k;W.jTypes=k}})("undefined"!==typeof window?window: | |
{}); | |
var Person = $$(function($fName, $lName, $age) | |
{ | |
this.firstName = $fName; | |
this.lastName = $lName; | |
this._age = $age; | |
}, | |
{ | |
'public readonly firstName': '', | |
'public readonly lastName': '', | |
'protected _age': 0, | |
'public getFullName': function() | |
{ | |
return this.firstName + ' ' + this.lastName; | |
}, | |
'public virtual triggerOneYearOlder': function() | |
{ | |
this._age++; | |
}, | |
'public age': | |
{ | |
'get': function() | |
{ | |
return this._age; | |
}, | |
'set': function($v) | |
{ | |
if ($v > 0) | |
this._age = $v; | |
} | |
} | |
}); | |
var Employee = $$(Person, function($fName, $lName, $age, $salary) | |
{ | |
this.__base($fName, $lName, $age); | |
this._salary = $salary; | |
}, | |
{ | |
'protected _salary': 0, | |
'public override triggerOneYearOlder': function() | |
{ | |
this.__base.triggerOneYearOlder(); | |
this._salary *= 1.03; | |
}, | |
'public salary': | |
{ | |
'get': function() | |
{ | |
return this._salary; | |
} | |
} | |
}); | |
var p = new Person('John', 'Doe', 30); | |
var e = new Employee(p.firstName, p.lastName, p.age, 75000); | |
this.p = p; | |
this.e = e; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment