forked from ryanve/cmon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmon.min.js
6 lines (6 loc) · 2.46 KB
/
cmon.min.js
1
2
3
4
5
6
/*!
* cmon 0.5.2+201309031951
* 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),c.id=b,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){if(null==a)throw new TypeError("@require");return(m.call(k,a)?k:j)[a]}function b(a,c){if(null==a)throw new TypeError("@provide");return k[a]=c,b.trigger(a),c}function c(d,e){return"function"!=typeof d?2==arguments.length?b.call(j,d,e):a.call(j,d):(d.call(j,c),void 0)}function d(a,b,c){if(null==a)throw new TypeError("@claim");return c=c||j,l[a]=c[a],c[a]=b}function e(a,b,c){if(null==a)throw new TypeError("@unclaim");return c=c||j,(null==b||b===c[a])&&(c[a]=m.call(l,a)?l[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(j,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}var j=this||window,k={},l={},m=l.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););}function f(a,b){for(var c=a.length;c--;)b===a[c]&&a.splice(c,1);return a}return a.trigger=function(a){a="object"==typeof a?a:[a];for(var f=0,g=a.length;g>f;f++)d.call(c,a[f])&&e(c[a[f]],b)},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,j,{},m),c.able=function(a,c,d){function e(){(k||f||!h(a))&&(k||b.off(g,e),c.apply(j,i(a)))}if(null==a)throw new TypeError("@able");var f="number"==typeof d,g=h(a),k=!g;return null==c||(k?e():(b.on(g,e),f&&setTimeout(e,d))),k},c.provide=b,c.require=a,c.claim=d,c.unclaim=e,c.noConflict=f,c});