Browse files

Fixing subscribeOnce not having options.

  • Loading branch information...
1 parent d629ce8 commit 6c8cb8737c1a1c5f0dcd518dc064242b59066b6e @iros iros committed Nov 14, 2012
View
18 dist/miso.events.0.0.1.js
@@ -76,14 +76,24 @@
* Params:
* name - name of event
* callback - The callback to trigger
+ * options - optional arguments
+ * priority - allows rearranging of existing callbacks based on priority
+ * context - allows attaching diff context to callback
+ * token - allows callback identification by token.
*/
- subscribeOnce : function(name, callback) {
+ subscribeOnce : function(name, callback, options) {
this._events = this._events || {};
- var token = _.uniqueId('t');
+ options = options || {};
+ var self = this;
+
+ if (typeof options.token === "undefined") {
+ options.token = _.uniqueId('t');
+ }
+
return this.subscribe(name, function() {
- this.unsubscribe(name, { token : token });
+ self.unsubscribe(name, { token : options.token });
callback.apply(this, arguments);
- }, this, token);
+ }, options);
},
/**
View
18 dist/miso.events.deps.0.0.1.js
@@ -4252,14 +4252,24 @@
* Params:
* name - name of event
* callback - The callback to trigger
+ * options - optional arguments
+ * priority - allows rearranging of existing callbacks based on priority
+ * context - allows attaching diff context to callback
+ * token - allows callback identification by token.
*/
- subscribeOnce : function(name, callback) {
+ subscribeOnce : function(name, callback, options) {
this._events = this._events || {};
- var token = _.uniqueId('t');
+ options = options || {};
+ var self = this;
+
+ if (typeof options.token === "undefined") {
+ options.token = _.uniqueId('t');
+ }
+
return this.subscribe(name, function() {
- this.unsubscribe(name, { token : token });
+ self.unsubscribe(name, { token : options.token });
callback.apply(this, arguments);
- }, this, token);
+ }, options);
},
/**
View
2 dist/miso.events.deps.min.0.0.1.js
@@ -5,4 +5,4 @@
* Dual Licensed: MIT, GPL
* https://github.com/misoproject/events/blob/master/LICENSE-MIT
*/
-(function(e,t){function lt(e){if(e&&e.__wrapped__)return e;if(!(this instanceof lt))return new lt(e);this.__wrapped__=e}function vt(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||a),s=i?{}:e;if(i){var o=t-1;while(++o<r){var u=e[o]+"";(k.call(s,u)?s[u]:s[u]=[]).push(e[o])}}return function(e){if(i){var n=e+"";return k.call(s,n)&&Mn(s[n],e)>-1}return Mn(s,e,t)>-1}}function mt(e,n){var r=e.index,i=n.index;e=e.criteria,n=n.criteria;if(e!==n){if(e>n||e===t)return 1;if(e<n||n===t)return-1}return r<i?-1:1}function gt(e,t,n){function o(){var u=arguments,a=i?this:t;r||(e=t[s]),n.length&&(u=u.length?n.concat(O.call(u)):n);if(this instanceof o){St.prototype=e.prototype,a=new St;var f=e.apply(a,u);return f&&at[typeof f]?f:a}return e.apply(a,u)}var r=Wt(e),i=!n,s=e;return i&&(n=t),o}function yt(e,n){return e?typeof e!="function"?function(t){return t[e]}:n!==t?function(t,r,i){return e.call(n,t,r,i)}:e:ir}function bt(){var e={arrayLoop:"",bottom:"",hasDontEnumBug:K,isKeysFast:st,objectLoop:"",noArgsEnum:Y,noCharByIndex:tt,shadowed:E,top:"",useHas:!0};for(var t,n=0;t=arguments[n];n++)for(var r in t)e[r]=t[r];var i=e.args;e.firstArg=/^[^,]+/.exec(i)[0];var s=Function("createCallback, hasOwnProperty, isArguments, objectTypes, nativeKeys, propertyIsEnumerable, stringClass, toString","return function("+i+") {\n"+ct(e)+"\n}");return s(yt,k,Tt,at,B,A,J,M)}function wt(e){return"\\"+ft[e]}function Et(e){return At[e]}function St(){}function xt(e){return Ot[e]}function Tt(e){return M.call(e)==q}function kt(e){var t=!1;if(!e||typeof e!="object"||Tt(e))return t;var n=e.constructor;return(!nt||typeof e.toString=="function"||typeof (e+"")!="string")&&(!Wt(n)||n instanceof n)?Q?(Nt(e,function(e,n,r){return t=!k.call(r,n),!1}),t===!1):(Nt(e,function(e,n){t=n}),t===!1||k.call(e,t)):t}function Lt(e){var t=[];return Ct(e,function(e,n){t.push(n)}),t}function Mt(e,t,n,r,i){if(e==null)return e;n&&(t=!1);var s=at[typeof e];if(s){var o=M.call(e);if(!ut[o]||Z&&Tt(e))return e;var u=o==R;s=u||(o==V?Kt(e):s)}if(!s||!t)return s?u?O.call(e):Dt({},e):e;var a=e.constructor;switch(o){case U:case z:return new a(+e);case X:case J:return new a(e);case $:return a(e.source,v.exec(e))}r||(r=[]),i||(i=[]);var f=r.length;while(f--)if(r[f]==e)return i[f];var l=u?a(e.length):{};return r.push(e),i.push(l),(u?cn:Ct)(e,function(e,n){l[n]=Mt(e,t,null,r,i)}),l}function Pt(e){var t=[];return Nt(e,function(e,n){Wt(e)&&t.push(n)}),t.sort()}function Ht(e,t){return e?k.call(e,t):!1}function Bt(e){var t={};return Ct(e,function(e,n){t[e]=n}),t}function Ft(e){return e===!0||e===!1||M.call(e)==U}function It(e){return M.call(e)==z}function qt(e){return e?e.nodeType===1:!1}function Rt(e){var t=!0;if(!e)return t;var n=M.call(e),r=e.length;return n==R||n==J||n==q||Z&&Tt(e)||n==V&&typeof r=="number"&&Wt(e.splice)?!r:(Ct(e,function(){return t=!1}),t)}function Ut(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;var i=M.call(e);if(i!=M.call(t))return!1;switch(i){case U:case z:return+e==+t;case X:return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case $:case J:return e==t+""}var s=i==R||i==q;if(Z&&!s&&(s=Tt(e))&&!Tt(t))return!1;if(!s){if(e.__wrapped__||t.__wrapped__)return Ut(e.__wrapped__||e,t.__wrapped__||t);if(i!=V||nt&&(typeof e.toString!="function"&&typeof (e+"")=="string"||typeof t.toString!="function"&&typeof (t+"")=="string"))return!1;var o=e.constructor,u=t.constructor;if(o!=u&&!(Wt(o)&&o instanceof o&&Wt(u)&&u instanceof u))return!1}n||(n=[]),r||(r=[]);var a=n.length;while(a--)if(n[a]==e)return r[a]==t;var f=-1,l=!0,c=0;n.push(e),r.push(t);if(s){c=e.length,l=c==t.length;if(l)while(c--)if(!(l=Ut(e[c],t[c],n,r)))break;return l}for(var h in e)if(k.call(e,h)){c++;if(!k.call(t,h)||!Ut(e[h],t[h],n,r))return!1}for(h in t)if(k.call(t,h)&&!(c--))return!1;if(K)while(++f<7){h=E[f];if(k.call(e,h)&&(!k.call(t,h)||!Ut(e[h],t[h],n,r)))return!1}return!0}function zt(e){return P(e)&&!H(parseFloat(e))}function Wt(e){return typeof e=="function"}function Xt(e){return e?at[typeof e]:!1}function Vt(e){return M.call(e)==X&&e!=+e}function $t(e){return e===null}function Jt(e){return M.call(e)==X}function Qt(e){return M.call(e)==$}function Gt(e){return M.call(e)==J}function Yt(e){return e===t}function en(e,t,n){var r=arguments,i=0,s=2,o=r[3],a=r[4];n!==u&&(o=[],a=[],s=r.length);while(++i<s)Ct(r[i],function(t,n){var r,i,s;if(t&&((i=jt(t))||Kt(t))){var f=o.length;while(f--){r=o[f]==t;if(r)break}r?e[n]=a[f]:(o.push(t),a.push(s=(s=e[n],i)?jt(s)?s:[]:Kt(s)?s:{}),e[n]=en(s,t,u,o,a))}else t!=null&&(e[n]=t)});return e}function tn(e,t,n){var r=typeof t=="function",s={};if(r)t=yt(t,n);else var o=T.apply(i,arguments);return Nt(e,function(e,n,i){if(r?!t(e,n,i):Mn(o,n,1)<0)s[n]=e}),s}function nn(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t}function rn(e,t,n){var r={};if(typeof t!="function"){var s=0,o=T.apply(i,arguments),u=o.length;while(++s<u){var a=o[s];a in e&&(r[a]=e[a])}}else t=yt(t,n),Nt(e,function(e,n,i){t(e,n,i)&&(r[n]=e)});return r}function sn(e){var t=[];return Ct(e,function(e){t.push(e)}),t}function on(e,t){var n=e?e.length:0;return typeof n=="number"?(M.call(e)==J?e.indexOf(t):Mn(e,t))>-1:xn(e,function(e){return e===t})}function un(e,t,n){var r={};return t=yt(t,n),cn(e,function(e,n,i){n=t(e,n,i),k.call(r,n)?r[n]++:r[n]=1}),r}function an(e,t,n){var r=!0;return t=yt(t,n),cn(e,function(e,n,i){return r=!!t(e,n,i)}),r}function fn(e,t,n){var r=[];return t=yt(t,n),cn(e,function(e,n,i){t(e,n,i)&&r.push(e)}),r}function ln(e,t,n){var r;return t=yt(t,n),xn(e,function(e,n,i){return t(e,n,i)&&(r=e,!0)}),r}function hn(e,t,n){var r={};return t=yt(t,n),cn(e,function(e,n,i){n=t(e,n,i),(k.call(r,n)?r[n]:r[n]=[]).push(e)}),r}function pn(e,t){var n=O.call(arguments,2),r=typeof t=="function",i=[];return cn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i}function dn(e,t,n){var r=-1,i=e?e.length:0,s=Array(typeof i=="number"?i:0);t=yt(t,n);if(jt(e))while(++r<i)s[r]=t(e[r],r,e);else cn(e,function(e,n,i){s[++r]=t(e,n,i)});return s}function vn(e,t,n){var r=-Infinity,i=-1,s=e?e.length:0,o=r;if(t||typeof s!="number")t=yt(t,n),cn(e,function(e,n,i){var s=t(e,n,i);s>r&&(r=s,o=e)});else while(++i<s)e[i]>o&&(o=e[i]);return o}function mn(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||typeof s!="number")t=yt(t,n),cn(e,function(e,n,i){var s=t(e,n,i);s<r&&(r=s,o=e)});else while(++i<s)e[i]<o&&(o=e[i]);return o}function gn(e,t){var n=[];return cn(e,function(e){n.push(e[t])}),n}function yn(e,t,n,r){var i=arguments.length<3;return t=yt(t,r),cn(e,function(e,r,s){n=i?(i=!1,e):t(n,e,r,s)}),n}function bn(e,t,n,r){var i=e,s=e?e.length:0,o=arguments.length<3;if(typeof s!="number"){var u=Zt(e);s=u.length}else tt&&M.call(e)==J&&(i=e.split(""));return cn(e,function(e,a,f){a=u?u[--s]:--s,n=o?(o=!1,i[a]):t.call(r,n,i[a],a,f)}),n}function wn(e,t,n){return t=yt(t,n),fn(e,function(e,n,r){return!t(e,n,r)})}function En(e){var t=-1,n=Array(e?e.length:0);return cn(e,function(e){var r=N(I()*(++t+1));n[t]=n[r],n[r]=e}),n}function Sn(e){var t=e?e.length:0;return typeof t=="number"?t:Zt(e).length}function xn(e,t,n){var r;return t=yt(t,n),cn(e,function(e,n,i){return!(r=t(e,n,i))}),!!r}function Tn(e,t,n){var r=[];t=yt(t,n),cn(e,function(e,n,i){r.push({criteria:t(e,n,i),index:n,value:e})});var i=r.length;r.sort(mt);while(i--)r[i]=r[i].value;return r}function Nn(e){return e&&typeof e.length=="number"?(et?M.call(e)==J:typeof e=="string")?e.split(""):O.call(e):sn(e)}function Cn(e,t){var n=[];return Nt(t,function(e,t){n.push(t)}),fn(e,function(e){var r=n.length;while(r--){var i=e[n[r]]===t[n[r]];if(!i)break}return!!i})}function kn(e){var t=-1,n=e?e.length:0,r=[];while(++t<n){var i=e[t];i&&r.push(i)}return r}function Ln(e){var t=-1,n=e?e.length:0,r=T.apply(i,arguments),s=vt(r,n),o=[];while(++t<n){var u=e[t];s(u)||o.push(u)}return o}function An(e,t,n){if(e)return t==null||n?e[0]:O.call(e,0,t)}function On(e,t){var n=-1,r=e?e.length:0,i=[];while(++n<r){var s=e[n];jt(s)?L.apply(i,t?s:On(s)):i.push(s)}return i}function Mn(e,t,n){var r=-1,i=e?e.length:0;if(typeof n=="number")r=(n<0?j(0,i+n):n||0)-1;else if(n)return r=In(e,t),e[r]===t?r:-1;while(++r<i)if(e[r]===t)return r;return-1}function _n(e,t,n){return e?O.call(e,0,-(t==null||n?1:t)):[]}function Dn(e){var t=arguments,n=t.length,r={},i=[];return cn(e,function(e){if(Mn(i,e)<0){var s=n;while(--s)if(!(r[s]||(r[s]=vt(t[s])))(e))return;i.push(e)}}),i}function Pn(e,t,n){if(e){var r=e.length;return t==null||n?e[r-1]:O.call(e,-t||r)}}function Hn(e,t,n){var r=e?e.length:0;typeof n=="number"&&(r=(n<0?j(0,r+n):F(n,r-1))+1);while(r--)if(e[r]===t)return r;return-1}function Bn(e,t){var n=-1,r=e?e.length:0,i={};while(++n<r){var s=e[n];t?i[s]=t[n]:i[s[0]]=s[1]}return i}function jn(e,t,n){e=+e||0,n=+n||1,t==null&&(t=e,e=0);var r=-1,i=j(0,x((t-e)/n)),s=Array(i);while(++r<i)s[r]=e,e+=n;return s}function Fn(e,t,n){return e?O.call(e,t==null||n?1:t):[]}function In(e,t,n,r){var i=0,s=e?e.length:i;n=n?yt(n,r):ir,t=n(t);while(i<s){var o=i+s>>>1;n(e[o])<t?i=o+1:s=o}return i}function qn(){return Rn(T.apply(i,arguments))}function Rn(e,t,n,r){var i=-1,s=e?e.length:0,o=[],u=o;typeof t=="function"&&(r=n,n=t,t=!1),n&&(u=[],n=yt(n,r));while(++i<s){var a=e[i],f=n?n(a,i,e):a;if(t?!i||u[u.length-1]!==f:Mn(u,f)<0)n&&u.push(f),o.push(a)}return o}function Un(e){var t=-1,n=e?e.length:0,r=vt(arguments,1,20),i=[];while(++t<n){var s=e[t];r(s)||i.push(s)}return i}function zn(e){var t=-1,n=e?vn(gn(arguments,"length")):0,r=Array(n);while(++t<n)r[t]=gn(arguments,t);return r}function Wn(e,t){return e<1?t():function(){if(--e<1)return t.apply(this,arguments)}}function Xn(e,t){return it||_&&arguments.length>2?_.call.apply(_,arguments):gt(e,t,O.call(arguments,2))}function Vn(e){var t=arguments,n=t.length>1?0:(t=Pt(e),-1),r=t.length;while(++n<r){var i=t[n];e[i]=Xn(e[i],e)}return e}function $n(){var e=arguments;return function(){var t=arguments,n=e.length;while(n--)t=[e[n].apply(this,t)];return t[0]}}function Jn(e,t,n){function u(){o=null,n||(i=e.apply(s,r))}var r,i,s,o;return function(){var a=n&&!o;return r=arguments,s=this,clearTimeout(o),o=setTimeout(u,t),a&&(i=e.apply(s,r)),i}}function Kn(e,n){var r=O.call(arguments,2);return setTimeout(function(){e.apply(t,r)},n)}function Qn(e){var n=O.call(arguments,1);return setTimeout(function(){e.apply(t,n)},1)}function Gn(e,t){return gt(t,e,O.call(arguments,2))}function Yn(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return k.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}}function Zn(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}}function er(e){return gt(e,O.call(arguments,1))}function tr(e,t){function u(){o=new Date,s=null,r=e.apply(i,n)}var n,r,i,s,o=0;return function(){var a=new Date,f=t-(a-o);return n=arguments,i=this,f<=0?(clearTimeout(s),o=a,r=e.apply(i,n)):s||(s=setTimeout(u,f)),r}}function nr(e,t){return function(){var n=[e];return L.apply(n,arguments),t.apply(this,n)}}function rr(e){return e==null?"":(e+"").replace(b,Et)}function ir(e){return e}function sr(e){cn(Pt(e),function(t){var n=lt[t]=e[t];lt.prototype[t]=function(){var e=[this.__wrapped__];L.apply(e,arguments);var t=n.apply(lt,e);return this.__chain__&&(t=new lt(t),t.__chain__=!0),t}})}function or(){return e._=f,this}function ur(e,t){return e==null&&t==null&&(t=1),e=+e||0,t==null&&(t=e,e=0),e+N(I()*((+t||0)-e+1))}function ar(e,t){var n=e?e[t]:null;return Wt(n)?e[t]():n}function fr(e,t,n){e||(e=""),n||(n={});var r,i,s=0,o=lt.templateSettings,u="__p += '",a=n.variable||o.variable,f=a,c=RegExp((n.escape||o.escape||y).source+"|"+(n.interpolate||o.interpolate||y).source+"|"+(n.evaluate||o.evaluate||y).source+"|$","g");e.replace(c,function(t,n,i,o,a){u+=e.slice(s,a).replace(w,wt),u+=n?"' +\n__e("+n+") +\n'":o?"';\n"+o+";\n__p += '":i?"' +\n((__t = ("+i+")) == null ? '' : __t) +\n'":"",r||(r=o||l.test(n||i)),s=a+t.length}),u+="';\n";if(!f){a="obj";if(r)u="with ("+a+") {\n"+u+"\n}\n";else{var v=RegExp("(\\(\\s*)"+a+"\\."+a+"\\b","g");u=u.replace(m,"$&"+a+".").replace(v,"$1__d")}}u=(r?u.replace(h,""):u).replace(p,"$1").replace(d,"$1;"),u="function("+a+") {\n"+(f?"":a+" || ("+a+" = {});\n")+"var __t, __p = '', __e = _.escape"+(r?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":(f?"":", __d = "+a+"."+a+" || "+a)+";\n")+u+"return __p\n}";var g=ot?"\n//@ sourceURL="+(n.sourceURL||"/lodash/template/source["+S++ +"]"):"";try{i=Function("_","return "+u+g)(lt)}catch(b){throw b.source=u,b}return t?i(t):(i.source=u,i)}function lr(e,t,n){e=+e||0;var r=-1,i=Array(e);while(++r<e)i[r]=t.call(n,r);return i}function cr(e){return e==null?"":(e+"").replace(c,xt)}function hr(e){var t=o++;return e?e+t:t}function pr(e){return e=new lt(e),e.__chain__=!0,e}function dr(e,t){return t(e),e}function vr(){return this.__chain__=!0,this}function mr(){return this.__wrapped__}var n=typeof exports=="object"&&exports,r=typeof global=="object"&&global;r.global===r&&(e=r);var i=[],s={},o=0,u={},a=30,f=e._,l=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,c=/&(?:amp|lt|gt|quot|#x27);/g,h=/\b__p \+= '';/g,p=/\b(__p \+=) '' \+/g,d=/(__e\(.*?\)|\b__t\)) \+\n'';/g,v=/\w*$/,m=/(?:__e|__t = )\(\s*(?![\d\s"']|this\.)/g,g=RegExp("^"+(s.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),y=/($^)/,b=/[&<>"']/g,w=/['\n\r\t\u2028\u2029\\]/g,E=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],S=0,x=Math.ceil,T=i.concat,N=Math.floor,C=g.test(C=Object.getPrototypeOf)&&C,k=s.hasOwnProperty,L=i.push,A=s.propertyIsEnumerable,O=i.slice,M=s.toString,_=g.test(_=O.bind)&&_,D=g.test(D=Array.isArray)&&D,P=e.isFinite,H=e.isNaN,B=g.test(B=Object.keys)&&B,j=Math.max,F=Math.min,I=Math.random,q="[object Arguments]",R="[object Array]",U="[object Boolean]",z="[object Date]",W="[object Function]",X="[object Number]",V="[object Object]",$="[object RegExp]",J="[object String]",K,Q,G=(G={0:1,length:1},i.splice.call(G,0,1),G[0]),Y=!0;(function(){function t(){this.x=1}var e=[];t.prototype={valueOf:1,y:1};for(var n in new t)e.push(n);for(n in arguments)Y=!n;K=!/valueOf/.test(e),Q=e[0]!="x"})(1);var Z=!Tt(arguments),et=O.call("x")[0]!="x",tt="x"[0]+Object("x")[0]!="xx";try{var nt=({toString:0}+"",M.call(e.document||0)==V)}catch(rt){}var it=_&&/\n|Opera/.test(_+M.call(e.opera)),st=B&&/^.+$|true/.test(B+!!e.attachEvent);try{var ot=(Function("//@")(),!e.attachEvent)}catch(rt){}var ut={};ut[q]=ut[W]=!1,ut[R]=ut[U]=ut[z]=ut[X]=ut[V]=ut[$]=ut[J]=!0;var at={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};lt.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var ct=fr("<% if (obj.useStrict) { %>'use strict';\n<% } %>var index, value, iteratee = <%= firstArg %>, result = <%= firstArg %>;\nif (!<%= firstArg %>) return result;\n<%= top %>;\n<% if (arrayLoop) { %>var length = iteratee.length; index = -1;\nif (typeof length == 'number') { <% if (noCharByIndex) { %>\n if (toString.call(iteratee) == stringClass) {\n iteratee = iteratee.split('')\n } <% } %>\n while (++index < length) {\n value = iteratee[index];\n <%= arrayLoop %>\n }\n}\nelse { <% } else if (noArgsEnum) { %>\n var length = iteratee.length; index = -1;\n if (length && isArguments(iteratee)) {\n while (++index < length) {\n value = iteratee[index += ''];\n <%= objectLoop %>\n }\n } else { <% } %> <% if (!hasDontEnumBug) { %>\n var skipProto = typeof iteratee == 'function' && \n propertyIsEnumerable.call(iteratee, 'prototype');\n <% } %> <% if (isKeysFast && useHas) { %>\n var ownIndex = -1,\n ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n <% if (!hasDontEnumBug) { %>if (!(skipProto && index == 'prototype')) {\n <% } %> value = iteratee[index];\n <%= objectLoop %>\n <% if (!hasDontEnumBug) { %>}\n<% } %> } <% } else { %>\n for (index in iteratee) {<% if (!hasDontEnumBug || useHas) { %>\n if (<% if (!hasDontEnumBug) { %>!(skipProto && index == 'prototype')<% } if (!hasDontEnumBug && useHas) { %> && <% } if (useHas) { %>hasOwnProperty.call(iteratee, index)<% } %>) { <% } %>\n value = iteratee[index];\n <%= objectLoop %>; <% if (!hasDontEnumBug || useHas) { %>\n }<% } %>\n } <% } %> <% if (hasDontEnumBug) { %>\n\n var ctor = iteratee.constructor;\n <% for (var k = 0; k < 7; k++) { %>\n index = '<%= shadowed[k] %>';\n if (<% if (shadowed[k] == 'constructor') { %>!(ctor && ctor.prototype === iteratee) && <% } %>hasOwnProperty.call(iteratee, index)) {\n value = iteratee[index];\n <%= objectLoop %>\n } <% } %> <% } %> <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n<%= bottom %>;\nreturn result"),ht={args:"collection, callback, thisArg",top:"callback = createCallback(callback, thisArg)",arrayLoop:"if (callback(value, index, collection) === false) return result",objectLoop:"if (callback(value, index, collection) === false) return result"},pt={useHas:!1,args:"object",top:"for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",objectLoop:"result[index] = value",bottom:" }\n}"},dt={arrayLoop:null};Z&&(Tt=function(e){return e?k.call(e,"callee"):!1});var Nt=bt(ht,dt,{useHas:!1}),Ct=bt(ht,dt),At={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},Ot=Bt(At),_t=bt(pt,{objectLoop:"if (result[index] == null) "+pt.objectLoop}),Dt=bt(pt),jt=D||function(e){return M.call(e)==R};Wt(/x/)&&(Wt=function(e){return M.call(e)==W});var Kt=C?function(e){if(!e||typeof e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=C(t))&&C(n);return n?e==n||C(e)==n&&!Tt(e):kt(e)}:kt,Zt=B?function(e){var t=typeof e;return t=="function"&&A.call(e,"prototype")?Lt(e):e&&at[t]?B(e):[]}:Lt,cn=bt(ht);lt.VERSION="0.9.1",lt.after=Wn,lt.bind=Xn,lt.bindAll=Vn,lt.chain=pr,lt.clone=Mt,lt.compact=kn,lt.compose=$n,lt.contains=on,lt.countBy=un,lt.debounce=Jn,lt.defaults=_t,lt.defer=Qn,lt.delay=Kn,lt.difference=Ln,lt.escape=rr,lt.every=an,lt.extend=Dt,lt.filter=fn,lt.find=ln,lt.first=An,lt.flatten=On,lt.forEach=cn,lt.forIn=Nt,lt.forOwn=Ct,lt.functions=Pt,lt.groupBy=hn,lt.has=Ht,lt.identity=ir,lt.indexOf=Mn,lt.initial=_n,lt.intersection=Dn,lt.invert=Bt,lt.invoke=pn,lt.isArguments=Tt,lt.isArray=jt,lt.isBoolean=Ft,lt.isDate=It,lt.isElement=qt,lt.isEmpty=Rt,lt.isEqual=Ut,lt.isFinite=zt,lt.isFunction=Wt,lt.isNaN=Vt,lt.isNull=$t,lt.isNumber=Jt,lt.isObject=Xt,lt.isPlainObject=Kt,lt.isRegExp=Qt,lt.isString=Gt,lt.isUndefined=Yt,lt.keys=Zt,lt.last=Pn,lt.lastIndexOf=Hn,lt.lateBind=Gn,lt.map=dn,lt.max=vn,lt.memoize=Yn,lt.merge=en,lt.min=mn,lt.mixin=sr,lt.noConflict=or,lt.object=Bn,lt.omit=tn,lt.once=Zn,lt.pairs=nn,lt.partial=er,lt.pick=rn,lt.pluck=gn,lt.random=ur,lt.range=jn,lt.reduce=yn,lt.reduceRight=bn,lt.reject=wn,lt.rest=Fn,lt.result=ar,lt.shuffle=En,lt.size=Sn,lt.some=xn,lt.sortBy=Tn,lt.sortedIndex=In,lt.tap=dr,lt.template=fr,lt.throttle=tr,lt.times=lr,lt.toArray=Nn,lt.unescape=cr,lt.union=qn,lt.uniq=Rn,lt.uniqueId=hr,lt.values=sn,lt.where=Cn,lt.without=Un,lt.wrap=nr,lt.zip=zn,lt.all=an,lt.any=xn,lt.collect=dn,lt.detect=ln,lt.drop=Fn,lt.each=cn,lt.foldl=yn,lt.foldr=bn,lt.head=An,lt.include=on,lt.inject=yn,lt.methods=Pt,lt.select=fn,lt.tail=Fn,lt.take=An,lt.unique=Rn,lt._iteratorTemplate=ct,sr(lt),lt.prototype.chain=vr,lt.prototype.value=mr,cn(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];lt.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),G&&e.length===0&&delete e[0],this.__chain__&&(e=new lt(e),e.__chain__=!0),e}}),cn(["concat","join","slice"],function(e){var t=i[e];lt.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(e,arguments);return this.__chain__&&(n=new lt(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=lt,define(function(){return lt})):n?typeof module=="object"&&module&&module.exports==n?(module.exports=lt)._=lt:n._=lt:e._=lt})(this),function(e,t){var n=e.Miso=e.Miso||{};n.Events={publish:function(e){var n=t.toArray(arguments);return n.shift(),this._events&&this._events[e]&&t.each(this._events[e],function(e){e.callback.apply(e.context||this,n)},this),this},subscribe:function(e,n,r){r=r||{},this._events=this._events||{},this._events[e]=this._events[e]||[];var i={callback:n,priority:r.priority||0,token:r.token||t.uniqueId("t"),context:r.context||this},s;return t.each(this._events[e],function(e,n){if(!t.isUndefined(s))return;e.priority<=i.priority&&(s=n)}),this._events[e].splice(s,0,i),i.token},subscribeOnce:function(e,n){this._events=this._events||{};var r=t.uniqueId("t");return this.subscribe(e,function(){this.unsubscribe(e,{token:r}),n.apply(this,arguments)},this,r)},unsubscribe:function(e,n){return t.isUndefined(this._events[e])?this:(t.isFunction(n)?this._events[e]=t.reject(this._events[e],function(e){return e.callback===n}):t.isString(n)?this._events[e]=t.reject(this._events[e],function(e){return e.token===n}):this._events[e]=[],this)}}}(this,_);
+(function(e,t){function lt(e){if(e&&e.__wrapped__)return e;if(!(this instanceof lt))return new lt(e);this.__wrapped__=e}function vt(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||a),s=i?{}:e;if(i){var o=t-1;while(++o<r){var u=e[o]+"";(k.call(s,u)?s[u]:s[u]=[]).push(e[o])}}return function(e){if(i){var n=e+"";return k.call(s,n)&&Mn(s[n],e)>-1}return Mn(s,e,t)>-1}}function mt(e,n){var r=e.index,i=n.index;e=e.criteria,n=n.criteria;if(e!==n){if(e>n||e===t)return 1;if(e<n||n===t)return-1}return r<i?-1:1}function gt(e,t,n){function o(){var u=arguments,a=i?this:t;r||(e=t[s]),n.length&&(u=u.length?n.concat(O.call(u)):n);if(this instanceof o){St.prototype=e.prototype,a=new St;var f=e.apply(a,u);return f&&at[typeof f]?f:a}return e.apply(a,u)}var r=Wt(e),i=!n,s=e;return i&&(n=t),o}function yt(e,n){return e?typeof e!="function"?function(t){return t[e]}:n!==t?function(t,r,i){return e.call(n,t,r,i)}:e:ir}function bt(){var e={arrayLoop:"",bottom:"",hasDontEnumBug:K,isKeysFast:st,objectLoop:"",noArgsEnum:Y,noCharByIndex:tt,shadowed:E,top:"",useHas:!0};for(var t,n=0;t=arguments[n];n++)for(var r in t)e[r]=t[r];var i=e.args;e.firstArg=/^[^,]+/.exec(i)[0];var s=Function("createCallback, hasOwnProperty, isArguments, objectTypes, nativeKeys, propertyIsEnumerable, stringClass, toString","return function("+i+") {\n"+ct(e)+"\n}");return s(yt,k,Tt,at,B,A,J,M)}function wt(e){return"\\"+ft[e]}function Et(e){return At[e]}function St(){}function xt(e){return Ot[e]}function Tt(e){return M.call(e)==q}function kt(e){var t=!1;if(!e||typeof e!="object"||Tt(e))return t;var n=e.constructor;return(!nt||typeof e.toString=="function"||typeof (e+"")!="string")&&(!Wt(n)||n instanceof n)?Q?(Nt(e,function(e,n,r){return t=!k.call(r,n),!1}),t===!1):(Nt(e,function(e,n){t=n}),t===!1||k.call(e,t)):t}function Lt(e){var t=[];return Ct(e,function(e,n){t.push(n)}),t}function Mt(e,t,n,r,i){if(e==null)return e;n&&(t=!1);var s=at[typeof e];if(s){var o=M.call(e);if(!ut[o]||Z&&Tt(e))return e;var u=o==R;s=u||(o==V?Kt(e):s)}if(!s||!t)return s?u?O.call(e):Dt({},e):e;var a=e.constructor;switch(o){case U:case z:return new a(+e);case X:case J:return new a(e);case $:return a(e.source,v.exec(e))}r||(r=[]),i||(i=[]);var f=r.length;while(f--)if(r[f]==e)return i[f];var l=u?a(e.length):{};return r.push(e),i.push(l),(u?cn:Ct)(e,function(e,n){l[n]=Mt(e,t,null,r,i)}),l}function Pt(e){var t=[];return Nt(e,function(e,n){Wt(e)&&t.push(n)}),t.sort()}function Ht(e,t){return e?k.call(e,t):!1}function Bt(e){var t={};return Ct(e,function(e,n){t[e]=n}),t}function Ft(e){return e===!0||e===!1||M.call(e)==U}function It(e){return M.call(e)==z}function qt(e){return e?e.nodeType===1:!1}function Rt(e){var t=!0;if(!e)return t;var n=M.call(e),r=e.length;return n==R||n==J||n==q||Z&&Tt(e)||n==V&&typeof r=="number"&&Wt(e.splice)?!r:(Ct(e,function(){return t=!1}),t)}function Ut(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;var i=M.call(e);if(i!=M.call(t))return!1;switch(i){case U:case z:return+e==+t;case X:return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case $:case J:return e==t+""}var s=i==R||i==q;if(Z&&!s&&(s=Tt(e))&&!Tt(t))return!1;if(!s){if(e.__wrapped__||t.__wrapped__)return Ut(e.__wrapped__||e,t.__wrapped__||t);if(i!=V||nt&&(typeof e.toString!="function"&&typeof (e+"")=="string"||typeof t.toString!="function"&&typeof (t+"")=="string"))return!1;var o=e.constructor,u=t.constructor;if(o!=u&&!(Wt(o)&&o instanceof o&&Wt(u)&&u instanceof u))return!1}n||(n=[]),r||(r=[]);var a=n.length;while(a--)if(n[a]==e)return r[a]==t;var f=-1,l=!0,c=0;n.push(e),r.push(t);if(s){c=e.length,l=c==t.length;if(l)while(c--)if(!(l=Ut(e[c],t[c],n,r)))break;return l}for(var h in e)if(k.call(e,h)){c++;if(!k.call(t,h)||!Ut(e[h],t[h],n,r))return!1}for(h in t)if(k.call(t,h)&&!(c--))return!1;if(K)while(++f<7){h=E[f];if(k.call(e,h)&&(!k.call(t,h)||!Ut(e[h],t[h],n,r)))return!1}return!0}function zt(e){return P(e)&&!H(parseFloat(e))}function Wt(e){return typeof e=="function"}function Xt(e){return e?at[typeof e]:!1}function Vt(e){return M.call(e)==X&&e!=+e}function $t(e){return e===null}function Jt(e){return M.call(e)==X}function Qt(e){return M.call(e)==$}function Gt(e){return M.call(e)==J}function Yt(e){return e===t}function en(e,t,n){var r=arguments,i=0,s=2,o=r[3],a=r[4];n!==u&&(o=[],a=[],s=r.length);while(++i<s)Ct(r[i],function(t,n){var r,i,s;if(t&&((i=jt(t))||Kt(t))){var f=o.length;while(f--){r=o[f]==t;if(r)break}r?e[n]=a[f]:(o.push(t),a.push(s=(s=e[n],i)?jt(s)?s:[]:Kt(s)?s:{}),e[n]=en(s,t,u,o,a))}else t!=null&&(e[n]=t)});return e}function tn(e,t,n){var r=typeof t=="function",s={};if(r)t=yt(t,n);else var o=T.apply(i,arguments);return Nt(e,function(e,n,i){if(r?!t(e,n,i):Mn(o,n,1)<0)s[n]=e}),s}function nn(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t}function rn(e,t,n){var r={};if(typeof t!="function"){var s=0,o=T.apply(i,arguments),u=o.length;while(++s<u){var a=o[s];a in e&&(r[a]=e[a])}}else t=yt(t,n),Nt(e,function(e,n,i){t(e,n,i)&&(r[n]=e)});return r}function sn(e){var t=[];return Ct(e,function(e){t.push(e)}),t}function on(e,t){var n=e?e.length:0;return typeof n=="number"?(M.call(e)==J?e.indexOf(t):Mn(e,t))>-1:xn(e,function(e){return e===t})}function un(e,t,n){var r={};return t=yt(t,n),cn(e,function(e,n,i){n=t(e,n,i),k.call(r,n)?r[n]++:r[n]=1}),r}function an(e,t,n){var r=!0;return t=yt(t,n),cn(e,function(e,n,i){return r=!!t(e,n,i)}),r}function fn(e,t,n){var r=[];return t=yt(t,n),cn(e,function(e,n,i){t(e,n,i)&&r.push(e)}),r}function ln(e,t,n){var r;return t=yt(t,n),xn(e,function(e,n,i){return t(e,n,i)&&(r=e,!0)}),r}function hn(e,t,n){var r={};return t=yt(t,n),cn(e,function(e,n,i){n=t(e,n,i),(k.call(r,n)?r[n]:r[n]=[]).push(e)}),r}function pn(e,t){var n=O.call(arguments,2),r=typeof t=="function",i=[];return cn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i}function dn(e,t,n){var r=-1,i=e?e.length:0,s=Array(typeof i=="number"?i:0);t=yt(t,n);if(jt(e))while(++r<i)s[r]=t(e[r],r,e);else cn(e,function(e,n,i){s[++r]=t(e,n,i)});return s}function vn(e,t,n){var r=-Infinity,i=-1,s=e?e.length:0,o=r;if(t||typeof s!="number")t=yt(t,n),cn(e,function(e,n,i){var s=t(e,n,i);s>r&&(r=s,o=e)});else while(++i<s)e[i]>o&&(o=e[i]);return o}function mn(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||typeof s!="number")t=yt(t,n),cn(e,function(e,n,i){var s=t(e,n,i);s<r&&(r=s,o=e)});else while(++i<s)e[i]<o&&(o=e[i]);return o}function gn(e,t){var n=[];return cn(e,function(e){n.push(e[t])}),n}function yn(e,t,n,r){var i=arguments.length<3;return t=yt(t,r),cn(e,function(e,r,s){n=i?(i=!1,e):t(n,e,r,s)}),n}function bn(e,t,n,r){var i=e,s=e?e.length:0,o=arguments.length<3;if(typeof s!="number"){var u=Zt(e);s=u.length}else tt&&M.call(e)==J&&(i=e.split(""));return cn(e,function(e,a,f){a=u?u[--s]:--s,n=o?(o=!1,i[a]):t.call(r,n,i[a],a,f)}),n}function wn(e,t,n){return t=yt(t,n),fn(e,function(e,n,r){return!t(e,n,r)})}function En(e){var t=-1,n=Array(e?e.length:0);return cn(e,function(e){var r=N(I()*(++t+1));n[t]=n[r],n[r]=e}),n}function Sn(e){var t=e?e.length:0;return typeof t=="number"?t:Zt(e).length}function xn(e,t,n){var r;return t=yt(t,n),cn(e,function(e,n,i){return!(r=t(e,n,i))}),!!r}function Tn(e,t,n){var r=[];t=yt(t,n),cn(e,function(e,n,i){r.push({criteria:t(e,n,i),index:n,value:e})});var i=r.length;r.sort(mt);while(i--)r[i]=r[i].value;return r}function Nn(e){return e&&typeof e.length=="number"?(et?M.call(e)==J:typeof e=="string")?e.split(""):O.call(e):sn(e)}function Cn(e,t){var n=[];return Nt(t,function(e,t){n.push(t)}),fn(e,function(e){var r=n.length;while(r--){var i=e[n[r]]===t[n[r]];if(!i)break}return!!i})}function kn(e){var t=-1,n=e?e.length:0,r=[];while(++t<n){var i=e[t];i&&r.push(i)}return r}function Ln(e){var t=-1,n=e?e.length:0,r=T.apply(i,arguments),s=vt(r,n),o=[];while(++t<n){var u=e[t];s(u)||o.push(u)}return o}function An(e,t,n){if(e)return t==null||n?e[0]:O.call(e,0,t)}function On(e,t){var n=-1,r=e?e.length:0,i=[];while(++n<r){var s=e[n];jt(s)?L.apply(i,t?s:On(s)):i.push(s)}return i}function Mn(e,t,n){var r=-1,i=e?e.length:0;if(typeof n=="number")r=(n<0?j(0,i+n):n||0)-1;else if(n)return r=In(e,t),e[r]===t?r:-1;while(++r<i)if(e[r]===t)return r;return-1}function _n(e,t,n){return e?O.call(e,0,-(t==null||n?1:t)):[]}function Dn(e){var t=arguments,n=t.length,r={},i=[];return cn(e,function(e){if(Mn(i,e)<0){var s=n;while(--s)if(!(r[s]||(r[s]=vt(t[s])))(e))return;i.push(e)}}),i}function Pn(e,t,n){if(e){var r=e.length;return t==null||n?e[r-1]:O.call(e,-t||r)}}function Hn(e,t,n){var r=e?e.length:0;typeof n=="number"&&(r=(n<0?j(0,r+n):F(n,r-1))+1);while(r--)if(e[r]===t)return r;return-1}function Bn(e,t){var n=-1,r=e?e.length:0,i={};while(++n<r){var s=e[n];t?i[s]=t[n]:i[s[0]]=s[1]}return i}function jn(e,t,n){e=+e||0,n=+n||1,t==null&&(t=e,e=0);var r=-1,i=j(0,x((t-e)/n)),s=Array(i);while(++r<i)s[r]=e,e+=n;return s}function Fn(e,t,n){return e?O.call(e,t==null||n?1:t):[]}function In(e,t,n,r){var i=0,s=e?e.length:i;n=n?yt(n,r):ir,t=n(t);while(i<s){var o=i+s>>>1;n(e[o])<t?i=o+1:s=o}return i}function qn(){return Rn(T.apply(i,arguments))}function Rn(e,t,n,r){var i=-1,s=e?e.length:0,o=[],u=o;typeof t=="function"&&(r=n,n=t,t=!1),n&&(u=[],n=yt(n,r));while(++i<s){var a=e[i],f=n?n(a,i,e):a;if(t?!i||u[u.length-1]!==f:Mn(u,f)<0)n&&u.push(f),o.push(a)}return o}function Un(e){var t=-1,n=e?e.length:0,r=vt(arguments,1,20),i=[];while(++t<n){var s=e[t];r(s)||i.push(s)}return i}function zn(e){var t=-1,n=e?vn(gn(arguments,"length")):0,r=Array(n);while(++t<n)r[t]=gn(arguments,t);return r}function Wn(e,t){return e<1?t():function(){if(--e<1)return t.apply(this,arguments)}}function Xn(e,t){return it||_&&arguments.length>2?_.call.apply(_,arguments):gt(e,t,O.call(arguments,2))}function Vn(e){var t=arguments,n=t.length>1?0:(t=Pt(e),-1),r=t.length;while(++n<r){var i=t[n];e[i]=Xn(e[i],e)}return e}function $n(){var e=arguments;return function(){var t=arguments,n=e.length;while(n--)t=[e[n].apply(this,t)];return t[0]}}function Jn(e,t,n){function u(){o=null,n||(i=e.apply(s,r))}var r,i,s,o;return function(){var a=n&&!o;return r=arguments,s=this,clearTimeout(o),o=setTimeout(u,t),a&&(i=e.apply(s,r)),i}}function Kn(e,n){var r=O.call(arguments,2);return setTimeout(function(){e.apply(t,r)},n)}function Qn(e){var n=O.call(arguments,1);return setTimeout(function(){e.apply(t,n)},1)}function Gn(e,t){return gt(t,e,O.call(arguments,2))}function Yn(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return k.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}}function Zn(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}}function er(e){return gt(e,O.call(arguments,1))}function tr(e,t){function u(){o=new Date,s=null,r=e.apply(i,n)}var n,r,i,s,o=0;return function(){var a=new Date,f=t-(a-o);return n=arguments,i=this,f<=0?(clearTimeout(s),o=a,r=e.apply(i,n)):s||(s=setTimeout(u,f)),r}}function nr(e,t){return function(){var n=[e];return L.apply(n,arguments),t.apply(this,n)}}function rr(e){return e==null?"":(e+"").replace(b,Et)}function ir(e){return e}function sr(e){cn(Pt(e),function(t){var n=lt[t]=e[t];lt.prototype[t]=function(){var e=[this.__wrapped__];L.apply(e,arguments);var t=n.apply(lt,e);return this.__chain__&&(t=new lt(t),t.__chain__=!0),t}})}function or(){return e._=f,this}function ur(e,t){return e==null&&t==null&&(t=1),e=+e||0,t==null&&(t=e,e=0),e+N(I()*((+t||0)-e+1))}function ar(e,t){var n=e?e[t]:null;return Wt(n)?e[t]():n}function fr(e,t,n){e||(e=""),n||(n={});var r,i,s=0,o=lt.templateSettings,u="__p += '",a=n.variable||o.variable,f=a,c=RegExp((n.escape||o.escape||y).source+"|"+(n.interpolate||o.interpolate||y).source+"|"+(n.evaluate||o.evaluate||y).source+"|$","g");e.replace(c,function(t,n,i,o,a){u+=e.slice(s,a).replace(w,wt),u+=n?"' +\n__e("+n+") +\n'":o?"';\n"+o+";\n__p += '":i?"' +\n((__t = ("+i+")) == null ? '' : __t) +\n'":"",r||(r=o||l.test(n||i)),s=a+t.length}),u+="';\n";if(!f){a="obj";if(r)u="with ("+a+") {\n"+u+"\n}\n";else{var v=RegExp("(\\(\\s*)"+a+"\\."+a+"\\b","g");u=u.replace(m,"$&"+a+".").replace(v,"$1__d")}}u=(r?u.replace(h,""):u).replace(p,"$1").replace(d,"$1;"),u="function("+a+") {\n"+(f?"":a+" || ("+a+" = {});\n")+"var __t, __p = '', __e = _.escape"+(r?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":(f?"":", __d = "+a+"."+a+" || "+a)+";\n")+u+"return __p\n}";var g=ot?"\n//@ sourceURL="+(n.sourceURL||"/lodash/template/source["+S++ +"]"):"";try{i=Function("_","return "+u+g)(lt)}catch(b){throw b.source=u,b}return t?i(t):(i.source=u,i)}function lr(e,t,n){e=+e||0;var r=-1,i=Array(e);while(++r<e)i[r]=t.call(n,r);return i}function cr(e){return e==null?"":(e+"").replace(c,xt)}function hr(e){var t=o++;return e?e+t:t}function pr(e){return e=new lt(e),e.__chain__=!0,e}function dr(e,t){return t(e),e}function vr(){return this.__chain__=!0,this}function mr(){return this.__wrapped__}var n=typeof exports=="object"&&exports,r=typeof global=="object"&&global;r.global===r&&(e=r);var i=[],s={},o=0,u={},a=30,f=e._,l=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,c=/&(?:amp|lt|gt|quot|#x27);/g,h=/\b__p \+= '';/g,p=/\b(__p \+=) '' \+/g,d=/(__e\(.*?\)|\b__t\)) \+\n'';/g,v=/\w*$/,m=/(?:__e|__t = )\(\s*(?![\d\s"']|this\.)/g,g=RegExp("^"+(s.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),y=/($^)/,b=/[&<>"']/g,w=/['\n\r\t\u2028\u2029\\]/g,E=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],S=0,x=Math.ceil,T=i.concat,N=Math.floor,C=g.test(C=Object.getPrototypeOf)&&C,k=s.hasOwnProperty,L=i.push,A=s.propertyIsEnumerable,O=i.slice,M=s.toString,_=g.test(_=O.bind)&&_,D=g.test(D=Array.isArray)&&D,P=e.isFinite,H=e.isNaN,B=g.test(B=Object.keys)&&B,j=Math.max,F=Math.min,I=Math.random,q="[object Arguments]",R="[object Array]",U="[object Boolean]",z="[object Date]",W="[object Function]",X="[object Number]",V="[object Object]",$="[object RegExp]",J="[object String]",K,Q,G=(G={0:1,length:1},i.splice.call(G,0,1),G[0]),Y=!0;(function(){function t(){this.x=1}var e=[];t.prototype={valueOf:1,y:1};for(var n in new t)e.push(n);for(n in arguments)Y=!n;K=!/valueOf/.test(e),Q=e[0]!="x"})(1);var Z=!Tt(arguments),et=O.call("x")[0]!="x",tt="x"[0]+Object("x")[0]!="xx";try{var nt=({toString:0}+"",M.call(e.document||0)==V)}catch(rt){}var it=_&&/\n|Opera/.test(_+M.call(e.opera)),st=B&&/^.+$|true/.test(B+!!e.attachEvent);try{var ot=(Function("//@")(),!e.attachEvent)}catch(rt){}var ut={};ut[q]=ut[W]=!1,ut[R]=ut[U]=ut[z]=ut[X]=ut[V]=ut[$]=ut[J]=!0;var at={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};lt.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var ct=fr("<% if (obj.useStrict) { %>'use strict';\n<% } %>var index, value, iteratee = <%= firstArg %>, result = <%= firstArg %>;\nif (!<%= firstArg %>) return result;\n<%= top %>;\n<% if (arrayLoop) { %>var length = iteratee.length; index = -1;\nif (typeof length == 'number') { <% if (noCharByIndex) { %>\n if (toString.call(iteratee) == stringClass) {\n iteratee = iteratee.split('')\n } <% } %>\n while (++index < length) {\n value = iteratee[index];\n <%= arrayLoop %>\n }\n}\nelse { <% } else if (noArgsEnum) { %>\n var length = iteratee.length; index = -1;\n if (length && isArguments(iteratee)) {\n while (++index < length) {\n value = iteratee[index += ''];\n <%= objectLoop %>\n }\n } else { <% } %> <% if (!hasDontEnumBug) { %>\n var skipProto = typeof iteratee == 'function' && \n propertyIsEnumerable.call(iteratee, 'prototype');\n <% } %> <% if (isKeysFast && useHas) { %>\n var ownIndex = -1,\n ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n <% if (!hasDontEnumBug) { %>if (!(skipProto && index == 'prototype')) {\n <% } %> value = iteratee[index];\n <%= objectLoop %>\n <% if (!hasDontEnumBug) { %>}\n<% } %> } <% } else { %>\n for (index in iteratee) {<% if (!hasDontEnumBug || useHas) { %>\n if (<% if (!hasDontEnumBug) { %>!(skipProto && index == 'prototype')<% } if (!hasDontEnumBug && useHas) { %> && <% } if (useHas) { %>hasOwnProperty.call(iteratee, index)<% } %>) { <% } %>\n value = iteratee[index];\n <%= objectLoop %>; <% if (!hasDontEnumBug || useHas) { %>\n }<% } %>\n } <% } %> <% if (hasDontEnumBug) { %>\n\n var ctor = iteratee.constructor;\n <% for (var k = 0; k < 7; k++) { %>\n index = '<%= shadowed[k] %>';\n if (<% if (shadowed[k] == 'constructor') { %>!(ctor && ctor.prototype === iteratee) && <% } %>hasOwnProperty.call(iteratee, index)) {\n value = iteratee[index];\n <%= objectLoop %>\n } <% } %> <% } %> <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n<%= bottom %>;\nreturn result"),ht={args:"collection, callback, thisArg",top:"callback = createCallback(callback, thisArg)",arrayLoop:"if (callback(value, index, collection) === false) return result",objectLoop:"if (callback(value, index, collection) === false) return result"},pt={useHas:!1,args:"object",top:"for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",objectLoop:"result[index] = value",bottom:" }\n}"},dt={arrayLoop:null};Z&&(Tt=function(e){return e?k.call(e,"callee"):!1});var Nt=bt(ht,dt,{useHas:!1}),Ct=bt(ht,dt),At={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},Ot=Bt(At),_t=bt(pt,{objectLoop:"if (result[index] == null) "+pt.objectLoop}),Dt=bt(pt),jt=D||function(e){return M.call(e)==R};Wt(/x/)&&(Wt=function(e){return M.call(e)==W});var Kt=C?function(e){if(!e||typeof e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=C(t))&&C(n);return n?e==n||C(e)==n&&!Tt(e):kt(e)}:kt,Zt=B?function(e){var t=typeof e;return t=="function"&&A.call(e,"prototype")?Lt(e):e&&at[t]?B(e):[]}:Lt,cn=bt(ht);lt.VERSION="0.9.1",lt.after=Wn,lt.bind=Xn,lt.bindAll=Vn,lt.chain=pr,lt.clone=Mt,lt.compact=kn,lt.compose=$n,lt.contains=on,lt.countBy=un,lt.debounce=Jn,lt.defaults=_t,lt.defer=Qn,lt.delay=Kn,lt.difference=Ln,lt.escape=rr,lt.every=an,lt.extend=Dt,lt.filter=fn,lt.find=ln,lt.first=An,lt.flatten=On,lt.forEach=cn,lt.forIn=Nt,lt.forOwn=Ct,lt.functions=Pt,lt.groupBy=hn,lt.has=Ht,lt.identity=ir,lt.indexOf=Mn,lt.initial=_n,lt.intersection=Dn,lt.invert=Bt,lt.invoke=pn,lt.isArguments=Tt,lt.isArray=jt,lt.isBoolean=Ft,lt.isDate=It,lt.isElement=qt,lt.isEmpty=Rt,lt.isEqual=Ut,lt.isFinite=zt,lt.isFunction=Wt,lt.isNaN=Vt,lt.isNull=$t,lt.isNumber=Jt,lt.isObject=Xt,lt.isPlainObject=Kt,lt.isRegExp=Qt,lt.isString=Gt,lt.isUndefined=Yt,lt.keys=Zt,lt.last=Pn,lt.lastIndexOf=Hn,lt.lateBind=Gn,lt.map=dn,lt.max=vn,lt.memoize=Yn,lt.merge=en,lt.min=mn,lt.mixin=sr,lt.noConflict=or,lt.object=Bn,lt.omit=tn,lt.once=Zn,lt.pairs=nn,lt.partial=er,lt.pick=rn,lt.pluck=gn,lt.random=ur,lt.range=jn,lt.reduce=yn,lt.reduceRight=bn,lt.reject=wn,lt.rest=Fn,lt.result=ar,lt.shuffle=En,lt.size=Sn,lt.some=xn,lt.sortBy=Tn,lt.sortedIndex=In,lt.tap=dr,lt.template=fr,lt.throttle=tr,lt.times=lr,lt.toArray=Nn,lt.unescape=cr,lt.union=qn,lt.uniq=Rn,lt.uniqueId=hr,lt.values=sn,lt.where=Cn,lt.without=Un,lt.wrap=nr,lt.zip=zn,lt.all=an,lt.any=xn,lt.collect=dn,lt.detect=ln,lt.drop=Fn,lt.each=cn,lt.foldl=yn,lt.foldr=bn,lt.head=An,lt.include=on,lt.inject=yn,lt.methods=Pt,lt.select=fn,lt.tail=Fn,lt.take=An,lt.unique=Rn,lt._iteratorTemplate=ct,sr(lt),lt.prototype.chain=vr,lt.prototype.value=mr,cn(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];lt.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),G&&e.length===0&&delete e[0],this.__chain__&&(e=new lt(e),e.__chain__=!0),e}}),cn(["concat","join","slice"],function(e){var t=i[e];lt.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(e,arguments);return this.__chain__&&(n=new lt(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=lt,define(function(){return lt})):n?typeof module=="object"&&module&&module.exports==n?(module.exports=lt)._=lt:n._=lt:e._=lt})(this),function(e,t){var n=e.Miso=e.Miso||{};n.Events={publish:function(e){var n=t.toArray(arguments);return n.shift(),this._events&&this._events[e]&&t.each(this._events[e],function(e){e.callback.apply(e.context||this,n)},this),this},subscribe:function(e,n,r){r=r||{},this._events=this._events||{},this._events[e]=this._events[e]||[];var i={callback:n,priority:r.priority||0,token:r.token||t.uniqueId("t"),context:r.context||this},s;return t.each(this._events[e],function(e,n){if(!t.isUndefined(s))return;e.priority<=i.priority&&(s=n)}),this._events[e].splice(s,0,i),i.token},subscribeOnce:function(e,n,r){this._events=this._events||{},r=r||{};var i=this;return typeof r.token=="undefined"&&(r.token=t.uniqueId("t")),this.subscribe(e,function(){i.unsubscribe(e,{token:r.token}),n.apply(this,arguments)},r)},unsubscribe:function(e,n){return t.isUndefined(this._events[e])?this:(t.isFunction(n)?this._events[e]=t.reject(this._events[e],function(e){return e.callback===n}):t.isString(n)?this._events[e]=t.reject(this._events[e],function(e){return e.token===n}):this._events[e]=[],this)}}}(this,_);
View
2 dist/miso.events.min.0.0.1.js
@@ -5,4 +5,4 @@
* Dual Licensed: MIT, GPL
* https://github.com/misoproject/events/blob/master/LICENSE-MIT
*/
-(function(e,t){var n=e.Miso=e.Miso||{};n.Events={publish:function(e){var n=t.toArray(arguments);return n.shift(),this._events&&this._events[e]&&t.each(this._events[e],function(e){e.callback.apply(e.context||this,n)},this),this},subscribe:function(e,n,r){r=r||{},this._events=this._events||{},this._events[e]=this._events[e]||[];var i={callback:n,priority:r.priority||0,token:r.token||t.uniqueId("t"),context:r.context||this},s;return t.each(this._events[e],function(e,n){if(!t.isUndefined(s))return;e.priority<=i.priority&&(s=n)}),this._events[e].splice(s,0,i),i.token},subscribeOnce:function(e,n){this._events=this._events||{};var r=t.uniqueId("t");return this.subscribe(e,function(){this.unsubscribe(e,{token:r}),n.apply(this,arguments)},this,r)},unsubscribe:function(e,n){return t.isUndefined(this._events[e])?this:(t.isFunction(n)?this._events[e]=t.reject(this._events[e],function(e){return e.callback===n}):t.isString(n)?this._events[e]=t.reject(this._events[e],function(e){return e.token===n}):this._events[e]=[],this)}}})(this,_);
+(function(e,t){var n=e.Miso=e.Miso||{};n.Events={publish:function(e){var n=t.toArray(arguments);return n.shift(),this._events&&this._events[e]&&t.each(this._events[e],function(e){e.callback.apply(e.context||this,n)},this),this},subscribe:function(e,n,r){r=r||{},this._events=this._events||{},this._events[e]=this._events[e]||[];var i={callback:n,priority:r.priority||0,token:r.token||t.uniqueId("t"),context:r.context||this},s;return t.each(this._events[e],function(e,n){if(!t.isUndefined(s))return;e.priority<=i.priority&&(s=n)}),this._events[e].splice(s,0,i),i.token},subscribeOnce:function(e,n,r){this._events=this._events||{},r=r||{};var i=this;return typeof r.token=="undefined"&&(r.token=t.uniqueId("t")),this.subscribe(e,function(){i.unsubscribe(e,{token:r.token}),n.apply(this,arguments)},r)},unsubscribe:function(e,n){return t.isUndefined(this._events[e])?this:(t.isFunction(n)?this._events[e]=t.reject(this._events[e],function(e){return e.callback===n}):t.isString(n)?this._events[e]=t.reject(this._events[e],function(e){return e.token===n}):this._events[e]=[],this)}}})(this,_);
View
18 dist/node/miso.events.0.0.1.js
@@ -78,14 +78,24 @@ var _ = require("lodash");
* Params:
* name - name of event
* callback - The callback to trigger
+ * options - optional arguments
+ * priority - allows rearranging of existing callbacks based on priority
+ * context - allows attaching diff context to callback
+ * token - allows callback identification by token.
*/
- subscribeOnce : function(name, callback) {
+ subscribeOnce : function(name, callback, options) {
this._events = this._events || {};
- var token = _.uniqueId('t');
+ options = options || {};
+ var self = this;
+
+ if (typeof options.token === "undefined") {
+ options.token = _.uniqueId('t');
+ }
+
return this.subscribe(name, function() {
- this.unsubscribe(name, { token : token });
+ self.unsubscribe(name, { token : options.token });
callback.apply(this, arguments);
- }, this, token);
+ }, options);
},
/**
View
18 src/events.js
@@ -68,14 +68,24 @@
* Params:
* name - name of event
* callback - The callback to trigger
+ * options - optional arguments
+ * priority - allows rearranging of existing callbacks based on priority
+ * context - allows attaching diff context to callback
+ * token - allows callback identification by token.
*/
- subscribeOnce : function(name, callback) {
+ subscribeOnce : function(name, callback, options) {
this._events = this._events || {};
- var token = _.uniqueId('t');
+ options = options || {};
+ var self = this;
+
+ if (typeof options.token === "undefined") {
+ options.token = _.uniqueId('t');
+ }
+
return this.subscribe(name, function() {
- this.unsubscribe(name, { token : token });
+ self.unsubscribe(name, { token : options.token });
callback.apply(this, arguments);
- }, this, token);
+ }, options);
},
/**
View
15 test/unit/events.js
@@ -44,6 +44,21 @@ test("subscribeOnce", 1, function() {
app.publish('test');
});
+test("subscribeOnce With Options", 1, function() {
+ var app = _.extend({}, Miso.Events);
+
+ var context = { counter : 0 };
+
+ function tester() {
+ this.counter++;
+ }
+
+ app.subscribeOnce('test', tester, { context: context });
+ app.publish('test');
+ app.publish('test');
+ ok(context.counter === 1);
+});
+
test("priority", function() {
var app = _.extend({}, Miso.Events);
var output = [];

0 comments on commit 6c8cb87

Please sign in to comment.