Comparing version 0.0.4 to 0.0.5
/** | ||
* qi-events 0.0.4 | ||
* qi-events 0.0.5 | ||
* http://drkibitz.github.io/qi-events/ | ||
* Copyright (c) 2013 Dr. Kibitz, http://drkibitz.com | ||
* A no nonsense event API (BASED ON Backbone.Events). | ||
* built: Sun Sep 08 2013 10:38:44 GMT-0700 (PDT) | ||
* built: Sun Jan 26 2014 23:44:53 GMT-0800 (PST) | ||
* | ||
@@ -14,2 +14,2 @@ * Backbone.js 0.9.10 | ||
*/ | ||
!function(a,b){"use strict";function c(a,b,c,d,e){var g,h,i;if(!c)return!0;if("string"==typeof c){if(f.test(c))for(g=c.split(f),h=0,i=g.length;i>h;h++)b.call(a,g[h],d,e);return!0}if(Array.isArray(c))for(h=0,i=c.length;i>h;h++)b.call(a,c[h],d,e);else for(var j in c)b.call(a,j,c[j],d)}function d(a,b,c){var d,e=-1,f=a.length,g=b[c],h=b[c+1],i=b[c+2];switch(b.length-c){case 0:for(;++e<f;)(d=a[e]).callback.call(d.context);return;case 1:for(;++e<f;)(d=a[e]).callback.call(d.context,g);return;case 2:for(;++e<f;)(d=a[e]).callback.call(d.context,g,h);return;case 3:for(;++e<f;)(d=a[e]).callback.call(d.context,g,h,i);return;default:for(b=c?Array.prototype.slice.call(b,c):b;++e<f;)(d=a[e]).callback.apply(d.context,b)}}function e(){}b["true"]=a;var f=/\s+/;e.ALL="all";var g=e.prototype;g.mixin=function(a){return a.on=g.on,a.once=g.once,a.off=g.off,a.trigger=g.trigger,a},g.on=function h(a,b,d){return c(this,h,a,b,d)&&b?(this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push({callback:b,context:d||this}),this):this},g.once=function i(a,b,d){if(!c(this,i,a,b,d)||!b)return this;var e,f=this,g=function(){e||(e=!0,f.off(a,g),b.apply(this,arguments))};return g._callback=b,this.on(a,g,d)},g.off=function j(a,b,d){var e,f,g,h,i,k,l,m;if(!this._events||!c(this,j,a,b,d))return this;if(!a&&!b&&!d)return this._events=null,this;for(h=a?[a]:Object.keys(this._events),i=0,k=h.length;k>i;i++)if(a=h[i],g=this._events[a]){if(this._events[a]=e=[],b||d)for(l=0,m=g.length;m>l;l++)f=g[l],(b&&b!==f.callback&&b!==f.callback._callback||d&&d!==f.context)&&e.push(f);e.length||(this._events[a]=null)}return this},g.trigger=function(a){var b,c=this._events;return c?(b=c[e.ALL],c[a]&&d(c[a],arguments,1),b&&d(b,arguments,0),this):this},a=module.exports=new e,a.Events=e}({},function(){return this}()); | ||
!function(t,e){"use strict";function n(t,e,n,r,s){var c,l,a;if(!n)return!0;if("string"==typeof n){if(i.test(n))for(c=n.split(i),l=0,a=c.length;a>l;l++)e.call(t,c[l],r,s);return!0}if(Array.isArray(n))for(l=0,a=n.length;a>l;l++)e.call(t,n[l],r,s);else for(var o in n)e.call(t,o,n[o],r)}function r(t,e,n){var r,s=-1,i=t.length,c=e[n],l=e[n+1],a=e[n+2];switch(e.length-n){case 0:for(;++s<i;)(r=t[s]).callback.call(r.context);return;case 1:for(;++s<i;)(r=t[s]).callback.call(r.context,c);return;case 2:for(;++s<i;)(r=t[s]).callback.call(r.context,c,l);return;case 3:for(;++s<i;)(r=t[s]).callback.call(r.context,c,l,a);return;default:for(e=n?Array.prototype.slice.call(e,n):e;++s<i;)(r=t[s]).callback.apply(r.context,e)}}function s(){}var i=/\s+/;s.ALL="all";var c=s.prototype;c.mixin=function(t){return t.on=c.on,t.once=c.once,t.off=c.off,t.trigger=c.trigger,t},c.on=function l(t,e,r){return n(this,l,t,e,r)&&e?(this._events||(this._events={}),this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,context:r||this}),this):this},c.once=function a(t,e,r){if(!n(this,a,t,e,r)||!e)return this;var s,i=this,c=function(){s||(s=!0,i.off(t,c),e.apply(this,arguments))};return c._callback=e,this.on(t,c,r)},c.off=function o(t,e,r){var s,i,c,l,a,f,h,u;if(!this._events||!n(this,o,t,e,r))return this;if(!t&&!e&&!r)return this._events=null,this;for(l=t?[t]:Object.keys(this._events),a=0,f=l.length;f>a;a++)if(t=l[a],c=this._events[t]){if(this._events[t]=s=[],e||r)for(h=0,u=c.length;u>h;h++)i=c[h],(e&&e!==i.callback&&e!==i.callback._callback||r&&r!==i.context)&&s.push(i);s.length||(this._events[t]=null)}return this},c.trigger=function(t){var e,n=this._events;return n?(e=n[s.ALL],n[t]&&r(n[t],arguments,1),e&&r(e,arguments,0),this):this},e=t.exports=new s,e.Events=s}(module,exports); |
@@ -6,8 +6,9 @@ { | ||
"devDependencies": { | ||
"mocha": "*", | ||
"grunt": "0.4.x", | ||
"grunt-contrib-jshint": "0.6.x", | ||
"grunt-jsdoc": "0.4.x", | ||
"grunt-simple-mocha": "0.4.x", | ||
"grunt-contrib-uglify": "~0.2.4" | ||
"gulp": "~3.5.0", | ||
"gulp-jshint": "~1.3.4", | ||
"gulp-mocha": "~0.4.1", | ||
"gulp-uglify": "~0.2.0", | ||
"gulp-util": "*", | ||
"map-stream": "~0.1.0", | ||
"mocha": "*" | ||
}, | ||
@@ -29,5 +30,5 @@ "description": "A no nonsense event API (BASED ON Backbone.Events).", | ||
"scripts": { | ||
"test": "grunt" | ||
"test": "grunt test" | ||
}, | ||
"version": "0.0.4" | ||
"version": "0.0.5" | ||
} |
[![Build Status](https://travis-ci.org/drkibitz/qi-events.png?branch=master)](https://travis-ci.org/drkibitz/qi-events) | ||
[![Coverage Status](https://coveralls.io/repos/drkibitz/qi-events/badge.png)](https://coveralls.io/r/drkibitz/qi-events) | ||
[![NPM version](https://badge.fury.io/js/qi-events.png)](http://badge.fury.io/js/qi-events) | ||
[![devDependency Status](https://david-dm.org/drkibitz/qi-events/dev-status.png)](https://david-dm.org/drkibitz/qi-events#info=devDependencies) | ||
@@ -20,4 +22,4 @@ # Qi Events | ||
require('qi-events').mixin({}); | ||
.on('myevent', console.log, console) | ||
.trigger('myevent', 'something', 'something', 'darkside'); | ||
.on('myevent', console.log, console) | ||
.trigger('myevent', 'something', 'something', 'darkside'); | ||
@@ -45,4 +47,4 @@ // > something something darkside | ||
1. Added mixin method to replace Backbone mixin functionality | ||
2. Underscore was only used for slice, just using the native method | ||
1. Added mixin method to replace Backbone mixin functionality | ||
2. Underscore was only used for slice, just using the native method | ||
@@ -53,13 +55,17 @@ 5. Completely removed listenTo(), listenToOnce(), and stopListening() methods | ||
1. This is a micro optimization and allows better obfuscation | ||
1. This is a micro optimization and allows better obfuscation | ||
8. trigger() no longer calls eventsApi(), this is a very rare (and mostly unnecessary) use case that can be avoided | ||
1. Optimization is important when triggering, but convenience is important when adding and removing | ||
1. Optimization is important when triggering, but convenience is important when adding and removing | ||
9. With trigger not using eventsApi(), it allowed further optimizations on eventsApi() and trigger() | ||
1. Removed ctx property from _events[name] object, just use context property instead | ||
2. Fixed lint errors in the process | ||
1. Removed ctx property from _events[name] object, just use context property instead | ||
2. Fixed lint errors in the process | ||
10. Added aStart argument to triggerEvents() as a logical slice removing slice call for most cases | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/drkibitz/qi-events/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5772
69
7