/
aok.min.js
6 lines (6 loc) · 2.44 KB
/
aok.min.js
1
2
3
4
5
6
/*!
* aok 1.7.3+201312170458
* https://github.com/ryanve/aok
* MIT License 2013 Ryan Van Etten
*/
!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c():a[b]=c()}(this,"aok",function(){function a(a){"object"==typeof a&&a?o(this,a):arguments.length&&(this.test=a),this.init()}function b(b){return arguments.length?new a(b):new a}function c(a,b){for(var d=0,e=c.precise,f=e?l.now():+new Date;d++<a;)b.call(this);return(e?l.now():+new Date)-f}var d=b.prototype=a.prototype,e=this,f={},g=f.hasOwnProperty,h=f.toString,i="undefined"!=typeof window&&window,j="undefined"!=typeof console&&console,k=i&&"alert"in i,l=i.performance,m=0,n=function(a,b){return g.call(a,b)},o=function(a,b){for(var c in b)n(b,c)&&(a[c]=b[c]);return a},p=function(a){return o(function(){a.apply(this,arguments)},a)};return o(b,b.console=function(a,b,c,d){function e(e,f,g){var h=b&&"function"==typeof b[e]?function(){b[e].apply(b,arguments)}:g?g:c?function(){h.force&&d.alert(e+": "+[].join.call(arguments," "))}:function(){};h.force=!!f,a[e]=h}return e("log"),e("trace"),e("info",1),e("warn",1),e("error",1),e("clear",0,function(){}),e("assert",1,function(b,c){b||a.warn(c)}),a}({},j,k,i)),d.express=b.express=p(b.log),d.pass="Pass",d.fail="Fail",d.init=function(){if(this===e)throw new Error("@this");return n(this,"id")||(this.id=++m),n(this,"test")&&this.run(),this},d.run=function(){if(this===e)throw new Error("@this");return this.test=!!b.result(this,"test"),this.handler()},d.cull=function(a){return this[this[null==a?"test":a]?"pass":"fail"]},d.handler=function(){var a=this.cull();return"function"==typeof a?a.call(this):this.express("#"+this.id+": "+this.explain(a)),this},d.explain=b.explain=function(a){return a=arguments.length?a:this,a===Object(a)?h.call(a):""+a},b.result=function(a,b,c){return c||b===c?(b=a,a=this):"function"==typeof b?b:b=a[b],"function"==typeof b?b.call(a):b},b.pass=function(a,b,c,d){if("number"==typeof b)return a?1:0;for(var e=a.length,f=0,g=0;e>f&&(!b.call(c,a[f],f++,a)||++g!==d););return g},b.fail=function(a,b,c,d){if("number"==typeof b)return a?0:1;for(var e=a.length,f=0,g=0;e>f&&(b.call(c,a[f],f++,a)||++g!==d););return g},c.precise=!!l&&"now"in l,b.perform=c,b.race=function(a,c){c=[].concat(c);for(var d=b.perform,e=c.length,f=0;e>f;)c[f]=d.call(this,a,c[f++]);return c},b.can=function(a){return function(){try{("string"==typeof a?this[a]:a).apply(this,arguments)}catch(b){return!1}return!0}},b.id=function(a){return document.getElementById(a)||!1},b});