-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmon.min.js
6 lines (6 loc) · 2.59 KB
/
cmon.min.js
1
2
3
4
5
6
/*!
* cmon 0.6.0+201311090640
* https://github.com/ryanve/cmon
* MIT License 2013 Ryan Van Etten
*/
!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c.call(a):(a[b]=c=c.call(a),a.require||c.claim("require",c.require,a),a.provide||c.claim("provide",c.provide,a),c.provide(b,c))}(this,"cmon",function(){function a(a,b){if(null==a)throw new TypeError("@require");return"function"==typeof b?j(a,b):(null!=m[a]?m:null!=l[a]?l:k)[a]}function b(a,c){if(null==a)throw new TypeError("@provide");return m[a]=c,b.emit(a),c}function c(d,e){return"function"==typeof d?void d.call(l,c):2==arguments.length?b(d,e):a(d)}function d(a,b,c){if(null==a)throw new TypeError("@claim");return c=c||l,n[a]=c[a],c[a]=b}function e(a,b,c){if(null==a)throw new TypeError("@unclaim");return c=c||l,(null==b||b===c[a])&&(c[a]=o.call(n,a)?n[a]:void 0),b}function f(c){return e("provide",b),e("require",a),c&&null!=this.id&&e(this.id,this),"function"==typeof c&&c.call(l,this),this}function g(b,c,d){b=[].concat(b),c=c||a;for(var e,f=0,g=b.length;g>f;)if(e=c.call(d,b[f++]),null!=e)return e}function h(a,b,c){a=[].concat(a),b=b||g;for(var d=[],e=0,f=a.length;f>e;e++)null==b.call(c,a[e])&&d.push(a[e]);return d.length?d:!1}function i(a,b,c){a=[].concat(a),b=b||g;for(var d=[],e=0,f=a.length;f>e;e++)d[e]=b.call(c,a[e]);return d}function j(a,c,d){function e(){(j||f||!h(a))&&(j||b.off(g,e),c.apply(l,i(a)))}if(null==a)throw new TypeError("@able");var f="number"==typeof d,g=h(a),j=!g;return null==c||(j?e():(b.on(g,e),f&&setTimeout(e,d))),j}var k="undefined"!=typeof window&&window||"undefined"!=typeof global&&global,l=this||k,m={},n={},o=n.hasOwnProperty;return function(a,b,c,d){function e(a,b){for(var c=0,d=a&&a.length;d>c&&!1!==a[c++].call(b););return c}function f(a,b){for(var c=a.length;c--;)b===a[c]&&a.splice(c,1);return a}return a.emit=function(a){return d.call(c,a)?e(c[a],b):0},a.trigger=function(b){var c,d=0,e=a.emit;if("object"!=typeof b)e(b);else for(c=b.length;c>d;)e(b[d++])},a.on=function(a,b){if(null==a||"function"!=typeof b)throw new TypeError("@on");a=[].concat(a);for(var e=0,f=0,g=a.length;g>f;f++)e+=(c[a[f]]=d.call(c,a[f])&&c[a[f]]||[]).push(b);return e},a.off=function(a,b){a=[].concat(a);for(var e,g=0,h=0,i=a.length;i>h;)d.call(c,e=a[h++])&&null!=e&&(void 0===b?c[e]=b:c[e]&&(g+=f(c[e],b).length));return g},a.one=function(b,c){function d(){return a.off(b,d),c.apply(this,arguments)}return a.on(b,d)},a.done=function(b,c){var d;return a.on(b,d="function"==typeof c?function(){var e=c.apply(this,arguments);return!0===e&&a.off(b,d),e}:d)},a}(b,l,{},o),c.able=j,c.provide=b,c.require=a,c.claim=d,c.unclaim=e,c.noConflict=f,c});