VimUnDo9U0^ے0Z3ɲwݘB[9accumulate.define(Event, function(event, next, initial) {: 0Px9e_10?P>? }5_021?P>? return void(0)5_132?P>? }5_243?P>? })5_354>P=?A var instance = new Event()5_465> P=?A returns new Event()5_576?P?AA5_687?P?AC?AB5_798APACDACC5_8:9CPBCsignal.type = Signal5_9;:CPBC5_:<; P  Bfunction Event() {} B}5_;=<5PA8watchers.define(Event, function signalWatchers(signal) {5_<>=&PA2watchers.define(Event, function signalWatchers() {5_=?>.PA1watchers.define(Event, function eventWatchers() {5_>@?P A" var watchers = signal[observers]5_?A@P A" var watchers = signal[observers]5_@BA/PA;watch.define(Event, function watchSignal(signal, watcher) {5_ACB(P A:watch.define(Event, function watchSignal(event, watcher) {5_BDC!P "A, if (!watchers) signal[observers] = watcher5_CED%'P  $&AH else if (watchers !== watcher) signal[observers] = [watchers, watcher]5_DFE P!B !A5_EGF P#!B switch ()5_FHG P%!B switch (typeof())5_GIH P'!B switch (typeof(watcher))5_HJI P("B switch (typeof(watcher)) {}5_IKJ!P) ! }5_JLK P* "C  "B5_KML! P, "C case: ""5_LNM!P. "C case: "undefined"5_MON P1 "C5_NPO!P3 !5_OQP"P5!"I // Optimize the case of one watcher. Don't need the extra array object.5_PRQ"P7!#B+ if (!watchers) event[observers] = watcher5_QSR! P= "B case: "undefined":5_RTS"P>"$C "$B5_SUT# PD"$C case ""5_TVU#PF"$C case "function"5_UWV#PH#%D #%C5_VXW$ PU#%D if ()5_WYX$P[#%D if (watchers !== watcher)5_XZY$&P_#%D' if (watchers !== watcher) event[]5_Y[Z$0Pa#%D0 if (watchers !== watcher) event[observers]5_Z\[$4Pc#%D5 if (watchers !== watcher) event[observers] = []5_[]\$DPi$&E $&D5_\^]"Pl"$F "$E5_]_^#Po"$F return void()5_^`_%Pp%'G %'F5__a`&Pr%'G return5_`ba& Ps%'G return5_acb&Pu%'G return void()5_bfc&Pu&(H &(G5_cgdf' P')I ')H5_fhg( P')I if ()5_gih(P')I if (watchers.indexOf())5_hji(#P')I$ if (watchers.indexOf(watcher))5_ikj((P')I( if (watchers.indexOf(watcher) < 0)5_jlk(7P')I8 if (watchers.indexOf(watcher) < 0) watchers.push()5_kml(?P')I@ if (watchers.indexOf(watcher) < 0) watchers.push(watchers)5_lnm(=P(*J (*I5_mon)P(*J return void()5_npo)P)+K )+J5_oqp+P*+5_prq+P*+- else if (typeof(watchers) !== "function") {5_qsr+P*+= if (watchers.indexOf(watcher) < 0) watchers.push(watcher)5_rts+P*+ }5_sut+P*+G else if (watchers !== watcher) event[observers] = [watchers, watcher]5_tvu+P *+ return void(0)5_uwv PF E5_vxw PF switch ()5_wyxPF switch (typeof())5_xzyPF switch (typeof(watchers))5_y{zPF switch (typeof(watchers)) {}5_z|{PF7 return typeof(watchers) === "function" ? [watchers] :5_{}|PF" case "function" ? [watchers] :5_|~}PF# case "function": ? [watchers] :5_}~!PF! case "function": [watchers] :5_~PH G5_ PH case ""5_PH case "undefined"5_PI H5_PI default: watchers()5_PI default: watchers.slice()5_PI case "undefined": []5_PI case "function": [watchers]5_ PI default: watchers.slice(0)5_!PJ I5_P5_ P0 typeof(watchers) === "undefined" ? [] :5_ P watchers.slice(0)5_5"#vP59H 57G5_7"#vP79K 79J5_8 "#vP79K void5_8 "#vP79K void()5_8"#vP79K void(0)5_8"#vP!68K case "undefined":return void(0)79K return void(0)5_7"#vP"79J5_777$vP%7:L 79K5_877$vP'79M$ case "undefined": return void(0)5_577$vP557M5_988$vP>9;O 9;N5_;88$vPF:;5_;88$vPF:;5_;88$vPF:;5_;88$vPF:;* // Otherwise see the type of `watchers`.5_;88$vPF:; var type = typeof(watchers)5_;88$vPG:;K // If it's either function (different from given `watcher` or `undefined`5_;88$vPG:; // just escape.5_;88$vPG:;A if (type === "function" || type === "undefined") return void(0)5_;88$vPH:;E // Otherwise remove a `watcher` from the `watchers` of this signal.5_;88$vPI:<F' var index = watchers.indexOf(watcher)5_<88$vPK;=F+ if (index >= 0) watchers.splice(index, 1)5_=88$vPM<>F8 if (watchers.length === 0) signal[observers] = void(0)5_>88$vPY=?F return void(0)5_>88$vP[>@G >@F5_/,88$vPf.0G?unwatch.define(Event, function unwatchSignal(signal, watcher) {5_/288$vPi.0G>unwatch.define(Event, function unwatchEvent(signal, watcher) {5_088$vPl/1G" var watchers = signal[observers]5_3 88$vPo24G signal[observers] = void(0)5_='88$vPt<>G< if (watchers.length === 0) signal[observers] = void(0)5_@88$vPAC emit.define@CH@BG5_B 88$vPACI emit.define()5_B&88$vPACI(emit.define(Event, function emitEvent())5_B388$vPACI4emit.define(Event, function emitEvent(event, value))5_B588$vPADI7emit.define(Event, function emitEvent(event, value) {})5_B88$vPBDK BDJ5_C 88$vPBDK switch ()5_C88$vPBDK switch (typeof())5_B00!vPBEL BDK5_D00!vPCD5_D00!vPCEL switch (typeof(wa))5_D00!vPCFL switch (typeof(watchers)) {}5_D00!vPDFN DFM5_E 00!vPDFN case ""5_E00!vPDFN case "function"5_E00!vPDFN case "undefined"5_E"00!vPDFN# case "undefined": return void()5_E$00!vPDFN$ case "undefined": return void(0)5_E!00!vPEGO EGN5_F 00!vPEGO case ""5_F00!vPFH try EHO case "function"5_G 00!vPFIP try {}5_G00!vPFG try {5_G00!vPFG }5_F00!vPFHP FHO5_G00!vP FHP watchers()5_G00!vP GIQ GIP5_H00!vPGIQ return ture5_H00!vPHJR HJQ5_I 00!vPHKR case: ""5_I 00!vPIKT IKS5_J00!vP#IKT watchers5_J00!vP+JMU JLT5_L 00!vP<LNW LNV5_M 00!vP>LNW while ()5_M00!vPBLNW while (index < count)5_M00!vPBLOW while (index < count) {}5_M00!vPCMOY MOX5_N00!vPIMOY watchers5_N00!vPIMOY watchers[]5_N00!vPLMOY watchers[index]5_N00!vPLMOY watchers[index]()5_N00!vPNNPZ NPY5_E00!vPgDGZ" case "undefined": return false5_#00!vP#%\ #%[5_$ 11!vP#%\ try {}5_%11!vP$&\ event[observers] = watcher5_%11!vP%'] %'\5_&22!vP%& } catch 5_$11!vP#$ try {5_$00!vP#%[" event[observers] = watcher5_00!vP [function Event() {}5_11!vP \5_ 22!vP 5_ 11!vP \function Event() {} \}5_ vP 5_vP [ Z5_  vP [// Event is a type5_  vP [3// data structure representing a time-varying value5_   vP [9// Event data structure representing a time-varying value5_  vP [// manually in an imperatively by calling `emit(event, value)`5_ "  vP{ ]?// manually in an imperative style calling `emit(event, value)`5_ +  vP ]J// `Event` type has internal property where it's listeners are stored. For5_ B  vP ]G// `Event` type has internal property of it's listeners are stored. For5_ <  vP ]generated unique name and define it as non-enumerable property ^L// now we use generated unique name and define it as non-enumerable property5_     vP ]J// property generated unique name and define it as non-enumerable property5_  (  vP ]F// property has a unique name and define it as non-enumerable property5_  8  vP ]P// property has a unique name and is intentionally it as non-enumerable property5_ O  vP ]O// property has a unique name and is intentionally made non-enumerable property5_ H  vP ]H// property has a unique name and is intentionally made non-enumerable (5_   vP ]K// but in a future once engines will implement private names we'll just use5_  vP ]D// a future once engines will implement private names we'll just use5_D  vP ]D// a future when engines will implement private names we'll just use5_(  vP ]9// a future when engines will implement private names we'5_*  vP ]*// a future it will be a private names we'5_'  vP ]'// a future it will be a private names 5_   vP ]&// a future it will be a private namesChttp://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects]L// that: http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects5_&  vP ]j// a future it will be a private names http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects]// \5_G  vP // that it]G// http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects)5_)  vP ^)// that it's behavior can not be tempred.5_  vP&^5_  vP,_K// Function returns array of watchers for the given value returned array is5_#  vP3_c// `Event` type implements Function returns array of watchers for the given value returned array is5_  vP5`_5_   vP>// of ita// `5_!   vP^c// of it's watchers.5_ "!@  vPfcL// Type implements `Watchable` abstraction for registration / unregistration5_!#"  vPicM// Type implements `Watchable` abstraction for registration / un-registration5_"$#  vPlcT// Type implements subset `Watchable` abstraction for registration / un-registration5_#%$8  vPncW// Type implements subset of `Watchable` abstraction for registration / un-registration5_$&%M  vPrc\// Type implements subset of `Watchable` abstraction to allow registration / un-registration5_%'&  vPud// and un-registration5_&('#  vPd#// and un-registration of watchers 5_')(H  vPeH// and un-registration of watchers that would wish to be notified on new5_(*)  vPe// value5_)+*   vPe // new value5_*,+  vP// 5_+-,  vP5_,.-  vP\// `Event` type implements ` returns array of watchers for the given value returned array is5_-/.  vP3// just a copy so that it can not be tempered with.5_.0/  vP6watchers.define(Event, function eventWatchers(event) {5_/10  vP! var watchers = event[observers]5_021  vP switch (typeof(watchers)) {5_132  vP& case "function": return [watchers]5_243  vP case "undefined": return []5_354  vP% default: return watchers.slice(0)5_465  vP }5_576  vP})5_687  vPY// new value are dispatched.5_798N  vPYN// new value are dispatched. Type intentionally does not implements `watchers`5_8:9  vPZ7// method so that event dispatch could not be emulated 5_9;:D  vPZD// method so that inconsistent event dispatch could not be emulated 5_:<;  vPZ5_;=<  vP[5_<>=   vP[5_=?>  vP \H// Function `watch` can be used to subscribe to a new values for a given5_>@?$  vP \`// `Event` type implements Function `watch` can be used to subscribe to a new values for a given5_?A@1  vP \W// `Event` type implements `watch` can be used to subscribe to a new values for a given5_@BAG  vP \c// `Event` type implements `watch` as a primary mechanism for subscribe to a new values for a given5_ACBG  vP  \f// `Event` type implements `watch` as a primary mechanism for subscribeing to a new values for a given5_BDCO  vP !\e// `Event` type implements `watch` as a primary mechanism for subscribing to a new values for a given5_CED   vP!]// new values for a given5_DFE   vP!]// new values of the 5_EGF   vP!] // new dispatched values of the 5_FHG!  vP( ! // `signal`5_GIH /  vP)!\/// new dispatched values of the given instance.5_HJI"   vPE"$] "$\5_IKJ#  vPL"# // Dispatch 5_JLK"  vPM"$] "$\5_KML#=  vP{"%]= // Event type optimizes for a case with a single `watcher` 5_LNM$  vP#%^ // most common case. 5_MON$!  vP#%^* // most common case. There for dispatch 5_NPO$2  vP#%^2 // most common case. There for `value` dispatch 5_OQP$+  vP#%^+ // most common case. There for `watcher` 5_PRQ$   vP#%^5 // most common case. There for `watcher` is stored 5_QSR$8  vP#&^8 // most common case. In such case `watcher` is stored 5_RTS$$%vP#%_H // most common case. In such case `watcher` is stored directly without // creation of an array.5_SUT$$$0vP#%^ // most common case. 5_TVU%$$0vP%(_ %'^5_UWV&$$0vP%'`5 In such case `watcher` is stored directly without5_VXW& $$0vP%'`8 // In such case `watcher` is stored directly without5_WYX&$$0vP%'`8 // If such case `watcher` is stored directly without5_XZY'$$0vP&(` // creation of an array.5_Y[Z*$$0vP*,a *,`5_Z\[+$$$0vP *,a6 // If type is a `function` then event already hase5_[]\+*$$0vP!*,a7 // If type is a `function` then `event already hase5_\^]+8$$0vP"*,a8 // If type is a `function` then `event` already hase5_]_^+:$$0vP&*,aA // If type is a `function` then `event` already has a watcher5_^`_+B$$0vP&*.aB // If type is a `function` then `event` already has a `watcher5__a`-$$0vPJ,.c // pre-existing watcher is 5_`ba-($$0vPV,/c( // pre-existing watcher is this one.5_acb1$$0vP13e 13d5_bdc2'$$0vP13e9 // Otherwise it's an array and new watcher is pushed 5_ced2-$$0vP13e8 // Otherwise it's an array and a `watcher is pushed 5_dfe29$$0vP14e9 // Otherwise it's an array and a `watcher` is pushed 5_egf8$$0vP.8;g8:f5_fhg: $$0vPe :>i// :<h5_gih<B<J<IvIP;=M// `Event` type implements `unwatch` function that can be used to unsubscribe5_hji<B<J<IvIP;=kK// `Event` type implements `unwatch` function that can be used to subscribe5_ikj><J<IvIP!=>5_jlk=<J<IvIP<>j,// from the new values of the given `event`.5_kml=%<J<IvIP"<>j8// a `watcher` from the new values of the given `event`.5_lnm@<J<IvIP?AjB // Optimize the case of one watcher and set `observers` to void.5_mon@<J<IvIP?AjD // Optimize the a case of one watcher and set `observers` to void.5_npo@/<J<IvIP?AjD // Optimize for a case of one watcher and set `observers` to void.5_oqp@B<J<IvIP?AjJ // Optimize for a case of where it's only `watcher` `observers` to void.5_prq@<J<IvIP?AjF // Optimize for a case of where it's only `watcher` and set to void.5_qsr@<J<IvIP?AjC // Optimize for a case where it's only `watcher` and set to void.5_rts@#<J<IvIP?AjB // Optimize for a case when it's only `watcher` and set to void.5_sut@E<J<IvIP #?AjE // Optimize for a case when it's an only `watcher` and set to void.5_tvuE<J<IvIP$DFj5_uwvL<J<IvIP"KMj; if (watchers.length === 0) event[observers] = void(0)5_vxwL;<J<IvIP(KMj; if (watchers.length === 1) event[observers] = void(0)5_wyxL=<J<IvIP+KMj> if (watchers.length === 1) event[observers] = watchers[]5_xzyE<J<IvIP.DE& // Otherwise go with a default path.5_y{zD<J<IvIP.DFi5_z|{E<J<IvIP/EGj5_{}|G<J<IvIP1GIl GIk5_|~}H <J<IvIP7GIl // If event has 5_}~H<J<IvIP8GIl // If `event has 5_~H<J<IvIP9GIl // If `event` has 5_I"<J<IvIPEIKm IKl5_J#<J<IvIPNIKm# // If `event` has only watcher 5_J<J<IvIPSIKm5 // If `event` has only watcher that is different 5_J<J<IvIPVIKm3 // If `event` has an watcher that is different 5_J.<J<IvIPYIKm8 // If `event` has an only watcher that is different 5_J0<J<IvIP[ILm0 // If `event` has an only watcher different 5_K <J<IvIPuJLn // since case of it being 5_K$<J<IvIPvJLn$ // since other case of it being 5_K<<J<IvIP%JLn< // since other case was handled in `if` clause already).5_L"<J<IvIPLNo LNn5_M<J<IvIPLNo // Otherwise 5_M&<J<IvIPLNo0 // Otherwise `event` has multiple watchers, 5_M/<J<IvIPLNo1 // Otherwise `event` has multiple `watchers, 5_M2<J<IvIP&LOo2 // Otherwise `event` has multiple `watchers`, 5_Q.<J<IvIPQSq QSp5_R'<J<IvIP/QSq' // If only single watcher is left5_R2<J<IvIPIQSq: // If only single watcher is left set it as watchers5_RD<J<IvIPKQTqD // If only single watcher is left set it as internal `watchers5_RN<J<IvIPVQSrN // If only single watcher is left set it as internal `watchers` property5_S<J<IvIPWRTr // so that dispatch 5_RO<J<IvIP[QSrO // If only single watcher is left set it as internal `watchers` property,5_S<J<IvIP\(RTr // to opti5_X MvNPX^sXZr5_Y  MvNPXZw // ### watch5_Y MvNPXZw // ## Emit5_Y MvNPXZw // ## mmit5_[! MvNPZ\wN// `Event` type implements `watch` as a primary mechanism for subscribing to a5_[I MvNPZ\wM// `Event` type implements `emit` as a primary mechanism for subscribing to a5_[M MvNPZ\wM// `Event` type implements `emit` as a primary mechanism for dispatching to a5_\ MvNP[]wM// new dispatched values of the given instance. `watcher` must be a function.5_\  MvNP[]w?// values of the given instance. `watcher` must be a function.5_\> MvNP[]w>// values of the given `event`. `watcher` must be a function.5_\, MvNP[]w4// values of the given `event`. All of the watchers5_\5 MvNP[^w5// values of the given `event`. All of the `watchers5_] MvNP\^x// be invoked 5_^ MvNP]^5_] MvNP\^w// be invoked in FIFO order 5_]: MvNP\_w:// be invoked in FIFO order. Function returns `false` if 5_^ MvNP]_x// `watchers`5_^3 MvNP\^xF// be invoked in FIFO order. Function returns `false` if event has no.]_x4// `watchers` to indicate that dispatch has failed.5_] MvNP\^w// be invoked in FIFO order. .5_]" MvNP"\^w+// be invoked in FIFO order. Any watchers 5_]0 MvNP$\_w0// be invoked in FIFO order. Any new `watchers 5_^ MvNP7)]_x// call will not be invoked 5_^/ MvNPF_a// otherwise, although it]ax/// call will not be invoked until next `emit`.5_`  MvNP{_az4// otherwise, although it's not guaranteed and may 5_`M MvNP*_bzM// otherwise, although this implementation detail is not guaranteed and may 5_c MvNPce| ce{5_d MvNPcd // Emi5_c MvNPce{5_d MvNPcd5_d MvNPdf| df{5_e MvNPdf| // If no wa5_g MvNPgi} gi|5_h  MvNPgi}! // If it's only one `watcher`5_h MvNPgi}' // If event it's only one `watcher`5_h MvNPgi}& // If event has only one `watcher`5_h" MvNPgi}" // If event has only `watcher`5_k MvNPkm}5_l MvNPkm~5_lC MvNPkm~K // Otherwise slice array of watchers (this will guarantee that unwatch 5_lL MvNPkn~L // Otherwise slice array of watchers (this will guarantee that `unwatch 5_m1 MvNP#ln1 // and `watch` calls in side effect will not 5_mA MvNP.loA // and `watch` calls in side effect to the dispatch will not 5_mF MvNP8lnF // and `watch` calls in side effect to the dispatch will not cause5_n MvNPHmo //5_n MvNPOmo // dispatch order).5_n MvNP^+mo // dispatch order). 5_n8 MvNPjmo8 // dispatch order) and invoke each one with a value.5_nC MvNPpmoC // dispatch order) and invoke each one with a value. `true` is 5_nJ MvNPwmpP // dispatch order) and invoke each one with a value. Return `true` as result5_o  MvNPy,np // result5_|  MvNP~| |~5_} MvNP} * }5_~ MvNP} Function creates new event5_~ MvNP} Function creates new `event5_~ MvNP} Function creates new `event`5_~ MvNP-} Function creates new `Event`5_ MvNP.~ on it.5_ MvNP var e = event 5_ MvNP 5_ MvNP emit 5_ MvNP watch(e, consolel.log)5_+ MvNP+ watch(e, consolel.log.bind(console, "=>")5_ MvNP emit(5_ MvNP 5_ MvNP 5_ MvNP5_  MvNP emit(e, 0)5_  MvNP 5_ MvNP 5_ MvNP  unwatch 5_ MvNP5_ MvNP unwatch(e, 5_ MvNP05_Y  MvNPXZ // ## emit5_[  MvNP1Z\L// `Event` type implements `emit` as a primary mechanism for dispatching new5_^- MvNP]_N// call will not be invoked until next `emit`. Note at this point `emit` will5_^H MvNP2]_N// call will not be invoked until next `send`. Note at this point `emit` will5_b MvNP3ac5emit.define(Event, function emitEvent(event, value) {5_b  MvNP!4ac5send.define(Event, function emitEvent(event, value) {5_~K MvNP$}O Function creates new `Event` that can be `watched` for a new values `emit`-ed5_ MvNP'~J on it. Also `emit` function can be used on returned instance to emit new5_F MvNP)5~J on it. Also `send` function can be used on returned instance to emit new5_ MvNP, emit(e, 0)5_ MvNP/ emit(e, 1) // => 15_ MvNP26 emit(e, 2) // => 25_ MvNP7var emit = require("./emit")5_ MvNP:var send = require("./emit")5_ / MvNP<7 B// manually in an imperative style by calling `emit(event, value)`5_ MvNPƵ8,var watchers = require("watchable/watchers")5_MvNP&var watch = require("watchable/watch")5_ MvNP9*var unwatch = require("watchable/unwatch")5_MvNP:5Object.defineProperties(Event.prototype, observers, {5_b MvNPǬbd bd5_cMvNPǰ;bd console.log()5_'MvNPZ<&( case "undefined":5_$MvNPj=#% switch (typeof(watcher)) {5_FMvNPo>EG switch (typeof(watcher)) {5_cPu@bc console.log(watchers)5_P 5_Pvar accumulate = require()5_Pvar accumulate = require("")5_zPP{}accumulate.definez}z|5_|PV{}accumulate.define()5_|#PX{}$accumulate.define(Event, function())5_|%PXA{~'accumulate.define(Event, function() {})5_|"Ps{}%accumulate.define(Event, function() {5_|0Pׯ|~ |~5_}P׳|~ watch()5_}P׵|~ watch(event, function())5_}P׶| watch(event, function() {})5_}P׸|~ watch(event, function() {5_ | P|~ |~5_  ~P~ ~5_    P~ next()5_   P~ next(value, state)5_    P 5_  P if ()5_ P if (isReduced())5_~P} watch(event, function(value) {5_P if (isReduced(state))5_"P# if (isReduced(state)) unwatch()5_|*Pخ| |~5_Pد5_Pش~= if (isOpen(signal)) throw Error("Signal is being consumed")5_Pظ~< if (isOpen(event)) throw Error("Signal is being consumed")5_Pغ~1 if (isClosed(signal)) return next(end, initial)5_Pؽ~0 if (isEnded(signal)) return next(end, initial)5_P 5_ P else event[]5_P else event[accumulator]5_-P95_P; else event[accumulator] = next5_P=5_P> event[accumulator] = next5_ PP event[watchers] = next5_! PU event[observers] = next5_ "!!PW! event[observers] = { next: next5_!#"Pِ signal[accumulator] = next5_"$#Pّ signal[state] = initial5_#%$Pّ5_$&%Pّ var state = initial5_%'&Pْ( watch(event, function watcher(value) {5_&('Pْ state = next(value, state)5_')(Pْ1 if (isReduced(state)) unwatch(event, watcher)5_(+)Pٓ })5_),*+"7vP3 event[observers] = { next: next, state: initial }5_+-,"7vP 5_,.-"7vP~/ if (isEnded(event)) return next(end, initial)5_-/. "7vP~' if (event)) return next(end, initial)5_.0/"7vP~* if (event.end) return next(end, initial)5_/10""7vP5_021"7vPC5_132j"7vPik watchers(value)5_243j"7vPik watchers.next(value)5_354j'"7vP.ik( watchers.next(value, watchers.end)5_465j"7vP1ik* watchers.next(value, watchers.state)5_576j"7vP:ik; watchers.state = watchers.next(value, watchers.state)5_687j"7vP?jl jl5_798k "7vP@jl if ()5_8:9k"7vPDjl if (state === end)5_9;:k"7vPPjl if (state === accumulated)5_:<;k"7vPTjl if (isReduced())5_;=<k"7vPVjl if (isReduced(state))5_<>=k""7vPejl# if (isReduced(state)) event[]5_=?>k,"7vPgjl, if (isReduced(state)) event[observers]5_>@?k4"7vPijl5 if (isReduced(state)) event[observers] = void()5_?A@k4"7vPkkm km5_@BAl"7vPokl 5_ACBk"7vPpkm km5_BDCl"7vPukl return vo5_CEDi"7vPژhj case "function":5_DFEc"7vPښce ce5_EGFd"7vPڜce if ()5_FHGd"7vPڡce if (watchers === "")5_GIHd"7vPڢce if (watchers === void())5_HJId"7vPڤce if (watchers === void(0))5_IKJd"7vPڥce if (watchers === void(0)) {}5_JLKe"7vPڦde switch (typeof(watchers)) {5_KMLf"7vPکef case "undefined":5_LNMf"7vPڪeg return false5_MONf"7vPڬfi fh5_NPOh "7vPڰgi else if 5_OQPh"7vPڳgi if ()5_PRQh"7vPڶgi if ()5_QTRh "7vPڹgi if (isA)5_RUSTh"7vPھgi if (isArray())5_TVUh"7vPgi if (watchers.next)5_UWVh"7vPgi if (watchers.next) {}5_VXWj"7vPij case "function":5_WYXj"7vPik6 var state = watchers.next(value, watchers.state)5_XZYk"7vPjl6 if (isReduced(state)) event[observers] = void(0)5_Y[Zk("7vPkm km5_Z\[l"7vPkl5_[]\l"7vPkm return true5_\^]l"7vPln ln5_]_^m"7vPmo mo5_^`_n"7vPmo if ()5__a`n"7vPmp if (watchers)5_`ban"7vPmn 5_acbs"7vPrs default:5_bdcsszvPr{! watchers = watchers.slice() var index = 0! var count = watchers.length while (index < count) { watchers[index](value) index = index + 1 } return true5_cedoozvPn{ L // Otherwise slice array of watchers (this will guarantee that `unwatch`K // and `watch` calls in side effect to the dispatch will not break FIFOI // dispatch order) and invoke each one with a value. Return `true` as // result. watchers = watchers.slice() var index = 0 var count = watchers.length while (index < count) { watchers[index](value) index = index + 1 } return true5_dfe{ozvPz{ }5_egfvozvP'vx vx5_fhgwo{vP-vx var watcher = watchers[]5_gihwo{vP.wy wy5_hjiyo|vP5xz watchers[index](value)5_ikjyo|vP^xz watcher.next(value)5_jlkjo|vPkDik4 var state = watchers.next(value, watchers.state)5_kmlyo|vPrxz# var state = watcher.next(value)5_lnmy2o|vPxxz3 var state = watcher.state = watcher.next(value)5_monyo|vPۊy{5_npogo}vPێgi5_oqp{p~vP۔z{5_prq{p}vP۔z{ index = index + 15_qsrzp|vPەz| z|5_rts{p}vPۗz| if ()5_sut{p}vPۙz| if (isReduced())5_tvu{p}vPۛz| if (isReduced(state))5_uwvtp}vPst watchers = watchers.slice()5_vxwzp|vPy{+ if (isReduced(state)) watchers.splice()5_wyxzp|vPy|. if (isReduced(state)) {} watchers.splice()5_xzy{p}vPz| } watchers.splice()5_y{z{p}vPz| watchers.splice()5_z|{{p}vPz| watchers.splice()5_{}|{p}vP{} {}5_|~}{p~vP{} {}5_}~|pvP{| watcher.5_~{p~vPz| watchers.splice()5_|p~vP{} }5_| p~vP{~ } else {}5_|pvP|~ |~5_xpvPwx index = index + 15_ypvPxz if (isReduced(state)) {5_zpvPxz if (isReduced(state))watchers.splice(index, 1)y{ watchers.splice(index, 1)5_zp~vPy{ } else {5_z p~vPy{ else {5_{p~vPy{ else index = index + 1z| index = index + 15_{p}vPz{ }5_p|vP"5_q}vP(var isReduced = require()5_q}vP(var isReduced = require("")5_-vP.  5_ -vP0 .var isReduced = require("reducers/is-reduced")5_&-vP4E (var end = require("reducers/is-reduced")5_<<YvPP;=/;=// ### unwatch//M// `Event` type implements `unwatch` function that can be used to unsubscribe9// a `watcher` from the new values for the given `event`.=unwatch.define(Event, function unwatchEvent(event, watcher) {! var watchers = event[observers]5 // Optimize for a case when it's an only `watcher`. if (watchers === watcher) { event[observers] = void(0) return void(0) } switch (typeof(watchers)) {+ // If `event` has no `watchers` ignore.$ case "undefined": return void(0)N // If `event` has an only watcher different from given one (it's differentC // since other case was handled in `if` clause already) ignore.# case "function": return void(0)K // Otherwise `event` has multiple `watchers`, if given `watcher` is one3 // of them remove it from the `watchers` array. default:+ var index = watchers.indexOf(watcher)/ if (index >= 0) watchers.splice(index, 1)N // If only single watcher is left set it as internal `watchers` propertyL // to optimize a dispatch by avoiding slicing arrays and enumerations.? if (watchers.length === 1) event[observers] = watchers[0] return void(0) }})5_<<<vPPF;</5_;vP[Gq // ## send%// ## Watchable//J// Type implements subset of `Watchable` abstraction to allow registrationI// and un-registration of watchers that would wish to be notified on onceN// new value are dispatched. Type intentionally does not implements `watchers`D// method so that inconsistent event dispatch could not be emulated. // ### watch//N// `Event` type implements `watch` as a primary mechanism for subscribing to aM// new dispatched values of the given instance. `watcher` must be a function.9watch.define(Event, function watchEvent(event, watcher) {! var watchers = event[observers]K // Event type optimizes for a case with a single `watcher` case as it's a // most common case. switch (typeof(watchers)) {G // If there is no watchers yet `watcher` is stored directly without // creation of an array. case "undefined": event[observers] = watcher return void(0)L // If type is a `function` then `event` already has a `watcher`, in suchF // case array of pre-existing and a new watcher is created, unlessI // pre-existing watcher is this one (in such case do nothing to avoid/ // double notifications of a same watcher). case "function":F if (watchers !== watcher) event[observers] = [watchers, watcher] return void(0)L // Otherwise it's an array and a `watcher` is pushed into it was already // in it. default:? if (watchers.indexOf(watcher) < 0) watchers.push(watcher) return void(0) }}) // ## send5_vPprq5_ vPtrvar ended = ""5_vPxrvar ended = "ended@"5_vP}sr5_0vP܃u3Object.defineProperty(Event.prototype, observers, {5_vP܊IuH value: void(0), enumerable: false, configurable: false, writable: true5_vP( v u5_ vP+ vvar hub = require()5_ vP+J vvar hub = require("")5_ vP1 w v5_ vP9K y x5_vPݲ-{!z y5_8 !*vP8: 8:5_9!*vP8: if ()5_9!*vP8: if (value === end)5_9!*vP8; if (value === end) {}5_9!*vP9D 9;5_:!*vP9; while (consumers.length) {5_;!*vP:< var count = consumers.length5_;!*vP:<" var count = consumers.length5_<!*vP;= var index = 05_=!*vP<> while (index < count) {5_>!*vP=?% var consumer = consumers[index]5_>!*vP=?' var consumer = consumers[index]5_>!*vP=?& var watcher = consumers[index]5_?!*vP>@( consumer.next(end, consumer.state)5_9!*vP9; 9;5_:!*vP 9; if ()5_:!*vP9; if (watcher === void())5_:!*vP9; if (watcher === void(0))5_9!*vP9; 9;5_: !*vP9; event[]5_:!*vP9; event[ended]5_:::vP&9; event[ended] = true5_:::vP'9: 5_:::vP*9; if (watcher === void(0)) 5_:::vP,9; if (watcher === void()) 5_:::vP09; if (watcher === void(0)) 5_:!::vP29;! if (watcher === void(0)) true5_:::vP59; if (watcher === void(0))5_:"::vP@9;" if (watchers && watchers.next)5_:$::vP@9<% if (watchers && watchers.next) {}5_:::vPA:< :<5_;::vPD:; event[ended] = true5_:::vPE:< :<5_;::vPO:< watchers.next()5_9::vPQ9; 9;5_:;;vPS9; if ()5_:;;vPU9; if (watchers)5_:;;vPZ9; if (watchers === void())5_:;;vP[9; if (watchers === void(0))5_:;;vP\9< if (watchers === void(0)) {}5_:<<vP\:< :<5_; ==vPe:< event[]5_;==vPh:< event[ended]5_;==vPj;= ;=5_=>>vPn=?5_@??vPt?A watchers.next()5_@&??vP|@B @B5_A ??vP~@B event[]5_A??vPހ@B event[end]5_A??vPނ@B event[ended]5_???vPޗ?A ?A5_@ ??vPޙ?A event[]5_@??vPޜ?@ event[ended]5_B??vPBD5_???vP?A ?A5_@ ??vP?A event[]5_@??vP?A event[ended]5_B??vPAB event[ended] = true5_???vP ?A ?A5_???vP>@$ if (watchers && watchers.next) {5_???vP?A ?A5_@ ??vP ?A while ()5_@??vP%?A while (event[])5_@ ??vP(?A while (event[observers])5_???vP:>? if (watchers.next) {5_???vP:>?) while (watchers = event[observers])5_???vP:>?! var watcher = watchers.next5_???vP;>? event[ended] = true5_???vP;>?( watchers.next(end, watchers.state)5_???vP;>? }5_???vP<>?5_???vPF>@ while (watchers.length) {5_???vPK>@ while (event[]) {5_? ??vPS>@ while (event[observers]) {5_? ??vPW>@) while (watchers = event[observers]) {5_?(??vPZ>@* while ((watchers = event[observers]) {5_@??vPi?A! var count = watchers.length5_@!??vPn?A1 var count = watchers.next = watchers.length5_@1??vPq?A1 var count = watchers.next ? watchers.length5_@"??vPu?A4 var count = watchers.next ? watchers.length : 5_@8??vPw?A8 var count = watchers.next ? 1 : watchers.length : 5_C%??vPߑBD% var watcher = watchers[index]5_DCC v PߜCE* consumer.next(end, consumer.state)5_D"CC v PߡCE) watcher.next(end, consumer.state)5_ECC v PߦDF index = index + 15_FCC v PߧEG }5_ FCC v PߵFH FH5_  G CC v P߷FH if ()5_   GCC v P߼FH if (watchers.length)5_  HCC v P߾FH if (watchers.length) consumers.splice(0, count)GI consumers.splice(0, count)5_  G4CC v PGI GI5_HCC v PGI else event[]5_HCC v PGI else event[observers]5_H#CC v PGI$ else event[observers] = void()5_G$CC v PFH5 if (watchers.length) consumers.splice(0, count)5_ICC v PHJ }5_ICC v PIL IK5_ICC v PIK IK5_J CC v PIK event[]5_JCC v PIK event[observers]5_JCC v PIK event[observers] = void()5_=CC v P(>@ if =@ =?5_?EE v P*>@ if ()5_?EE v P->@ if (watchers)5_?EE v P/>@ if (watchers = event[])5_?$EE v P1>@$ if (watchers = event[observers])5_#?&EE v P2>A' if (watchers = event[observers]) {}5_$#?FF v Pe>?& if (watchers = event[observers]) {5_#%$?EE v Pe>? }5_$&%?DD v Pf>?5_%'&MCC v PmMO5_&('OCC v P|NO if (watchers === void(0)) {5_')(OCC v P|NO. // If there are no watchers return `false`5_(*)OCC v P}NO return false5_)+*OCC v P}NO }5_*,+ICC v PIK IK5_+-,J CC v PIK event[]5_,.-JCC v PIK event[ended]5_-/.OCC v PNO5_.0/HCC v PIK if HK HJ5_/10J CC v PIK if ()5_021JCC v PIK if (watchers.length)5_132J!CC v PIK" if (watchers.length) event[]5_243J+CC v PIK+ if (watchers.length) event[observers]5_354JCC v PIK2 if (watchers.length) event[observers] = void5_465J8CC v PIK8 if (watchers.length === 0) event[observers] = void5_576J9CC v PIK: if (watchers.length === 0) event[observers] = void()5_687UCC v PTV4 if (isReduced(state)) event[observers] = void(0)UW UW5_798\ CC v P5\^5_8:9]CC v P7\] //5_9;:bCC v Ppad3 if (isReduced(state)) watchers.splice(index, 1)5_:<;cCC v Pqce ce5_;=<dCC v Pudf df5_<>=f CC v Pzeh else index = index + 15_=?>gCC v P|fi index = index + 15_>@?gCC v Pgi gi5_?E@aCC v P`bB var state = watcher.state = watcher.next(value, watcher.state)5_@FAE  +v P!! function drain(consumers) { while (consumers.length) { var count = consumers.length var index = 0 while (index < count) {% var consumer = consumers[index]( consumer.next(end, consumer.state) index = index + 1 } consumers.splice(0, count) }}5_EGFCC_ v PBKy BD return true } if (watchers.next) {> // If event has only `watcher` invoke it and return `true`E var state = watchers.state = watchers.next(value, watchers.state)4 if (isReduced(state)) event[observers] = void(0) return true }J // Otherwise slice array of watchers (this will guarantee that `unwatch`I // and `watch` calls in side effect to the dispatch will not break FIFOG // dispatch order) and invoke each one with a value. Return `true` as // result. var index = 0 var count = watchers.length while (index < count) {! var watcher = watchers[index]2 var state = watcher.next(value, watcher.state) if (isReduced(state)) { watchers.splice(index, 1) count = count - 1 } else { index = index + 1 watcher.state = state } } return true5_FHGJCCv PIJ5_GIH,CCv P+,! var watchers = event[observers]5_HJI,BBv P+, if (value === end) {5_IKJ,AAv P+, if (watchers === void(0)) {5_JLK,@@v P+, event[ended] = true5_KML,??v P+, return false5_LNM,>>v P+, }5_MON,==v P+,5_NPO,<<v P+,+ while ((watchers = event[observers])) {5_OQP,;;v P+,5 var count = watchers.next ? 1 : watchers.length5_PRQ,::v P+, var index = 05_QSR,99v P+, while (index < count) {5_RTS,88v P+,0 var watcher = watchers[index] || watcher5_SUT,77v P+,( watcher.next(end, watcher.state)5_TVU,66v P+, index = index + 15_UWV,55v P+, }5_VXW,44v P+,4 if (watchers.length) watchers.splice(0, count)5_WYX,33v P+,% else event[observers] = void(0)5_XZY,22v P+,5_Y[Z,11v P+,; if (watchers.length === 0) event[observers] = void(0)5_Z\[,00v P+, }5_[]\,//v P+, event[ended] = true5_\^],..v P+, event[observers] = void(0)5_]_^,--v P+,5_^`_, ,,v P+-h: // Signals may only be reduced by one consumer function.5__a`.,,v P-.= if (isOpen(signal)) throw Error("Signal is being consumed")5_`ba.,,v P-/g1 if (isClosed(signal)) return next(end, initial)5_acb. ,,v P-/g( if (signal)) return next(end, initial)5_bdc. ,,v P-/g) if (signal[]) return next(end, initial)5_ced55OvP4;M46g: // Signals may only be reduced by one consumer function.J // Other data types built on top of signal may allow for more consumers.0 if (event.end) return next(event.end, initial). var watcher = { next: next, state: initial }! var watchers = event[observers]K // Event type optimizes for a case with a single `watcher` case as it's a // most common case. switch (typeof(watchers)) {G // If there is no watchers yet `watcher` is stored directly without // creation of an array. case "undefined": event[observers] = watcher return void(0)L // If type is a `function` then `event` already has a `watcher`, in suchF // case array of pre-existing and a new watcher is created, unlessI // pre-existing watcher is this one (in such case do nothing to avoid/ // double notifications of a same watcher). case "function":F if (watchers !== watcher) event[observers] = [watchers, watcher] return void(0)L // Otherwise it's an array and a `watcher` is pushed into it was already // in it. default:? if (watchers.indexOf(watcher) < 0) watchers.push(watcher) return void(0) }5_dfe7 55vP68R. if (signal[ended]) return next(end, initial)5_egf855vP79R signal[accumulator] = next5_fhg855vP79R event[accumulator] = next5_gih955vP8:R signal[state] = initial5_hki:55vPL9: return signal5_iljk. 55vPj-/Q. if (signal[ended]) return next(end, initial)5_kml..55vPr-/Q/ if (signal[ended]) return throw(end, initial)5_lnm.#55vPt-/Q% if (signal[ended]) return throw("")5_mon.,55vPy-/Q4 if (signal[ended]) return throw("Event was ended")5_npo. 55vP-/Q3 if (signal[ended]) return throw("Event is ended")5_oqp/55vP.0Q signal[accumulator] = next5_prq/55vP.0Q event[accumulator] = next5_qsr055vP/1Q signal[state] = initial5_rts.55vP.0Q5_sut. ..22P-/R2 if (event[ended]) return throw("Event is ended")5_tvu...22P-/R8 if (event[ended]) return throw Error("Event is ended")5_uwv...22P.0S .0R5_vxw/..22P.0S result5_wyx/..22P.0S result = 5_xzy/..22P.0S var result = 5_y{z/..22P.0S var result = event[]5_z|{/..22P.0S var result = event[reducer]5_{}|/..22P.0S var result = event[reducer]()5_|~}/+..22P.0S- var result = event[reducer](value, event[])5_}~/1..22P/1T /1S5_~0..22P/1T if ()5_0..22P/1T if (isReduced())5_0..22P/1T if (isReduced(result))5_0..22P/2T if (isReduced(result)) {}5_0..22P02V 02U5_1 ..22P02V event[]5_1..22P02V event[reducer]5_1..22P02V event[reducer] = event[]5_1!..22P02V! event[reducer] = event[state]5_1)..22P02V* event[reducer] = event[state] = void()5_1)..22P13W 13V5_2 ..22P13W event[]5_2..22P13W event[ended]5_2..22P12 event[ended] 5_1..22P/1V if (isReduced(result)) {'event[reducer] = event[state] = void(0)02V+ event[reducer] = event[state] = void(0)5_0..22P02U5_-J..22P<-/ if ,/VJ // Other data types built on top of signal may allow for more consumers.5_.//22P?-/W if ()5_. //22PJ-/W if (event[])5_-//22PQ-/X // -/W5_.0022PU-. var 5_.//22PZ-/W if (event[reducer])5_.//22P]-/W if (event[reducer] === void())5_.//22P^-/W! if (event[reducer] === void(9))5_.!//22Pb-/W! if (event[reducer] === void(0))5_.//22Pl-." if (event[reducer] === void(0)) 5_...22Pm.0W .0V5_/..22Pr.0W var next = event[]5_/..22Pt/1X /1W5_0..22Pv/1X if ()5_0 ..22Pw/1X if (next)5_0 ..22P}/1X if (next) 5_0 ..22P}/2X if (next) {}5_0..22P02Z 02Y5_1..22P02Z var result = next()5_1#..22P02Z% var result = next(value, event[])5_1'..22P13[ 13Z5_2..22P13[ if ()5_2..22P13[ if (isReduced())5_2..22P13[ if (isReduced(result))5_2!..22P13[" if (isReduced(result)) event[]5_2)..22P13[) if (isReduced(result)) event[reducer]5_22..22P13[3 if (isReduced(result)) event[reducer] = event[]5_28..22P13[8 if (isReduced(result)) event[reducer] = event[state]5_2@..22P13[A if (isReduced(result)) event[reducer] = event[state] = void()5_2@..22P24\ 24[5_3..22P24\ else event[]5_3..22P24\ else event[state]5_5..22P452 var result = event[reducer](value, event[state])5_5..22P45@ if (isReduced(result)) event[reducer] = event[state] = void(0)5_5..22P455_5..22P45 }5_5..22P455_5..22P45 event[reducer] = next5_5..22P45 event[state] = initial5_5..22P45 return signal5_ ..22PUT5_//22Pk5_ ..22PT'var observers = "watchers@" + module.id5_%vPUT5_%vP5_%vPU%var reducer = "watchers@" + module.id5_ %vPU"var reducer = "state@" + module.id5_vP#V!U5_/vPX3Object.defineProperty(Event.prototype, observers, {5_,vPX/Object.defineProperty(Event.prototype, ended, {5_vPXF value: false, enumerable: false, configurable: false, writable: true5_vPMXG value: void(), enumerable: false, configurable: false, writable: true5_vP'var watch = require("watchables/watch")5_vPN+var unwatch = require("watchables/unwatch")5_vP!var hub = require("reducers/hub")5_vP5_vPvar dispatch = hub.dispatch5_vPOvar drain = hub.drain5_IIIvPHJR, watch(e, consolel.log.bind(console, "=>"))5_KIIvPJLR send(e, 1) // => 15_I,IIvPHJR- reduce(e, consolel.log.bind(console, "=>"))5_IIIvPHKR reduce(e, function()5_JIIvPIKS5_JIIvPIKS})5_EEMvPDNS  var e = event() send(e, 0) reduce(e, function() { }) send(e, 1) // => 1 send(e, 2) // => 25_IEMvPIKT IKS5_IENvPHJT reduce(e, function() {5_KENvPJLT })5_JENvPIKT console.log("=>", 5_J&ENvPJLU JLT5_IEOvPHJU( reduce(e, function(index, value) {5_KEOvPJLU return index + 5_NEOvP MOU send(e, 1) // => 15_OEOvP NPU send(e, 2) // => 25_NEOvPMOU send(e, 1) // => 0 15_NEOvPMOU send(e, "a") // => 0 15_OEOvPNPU send(e, 2) // => 0 25_OEOvPQNPU send(e, "b") // => 0 25_,EOvP,.V ,.U5_-FPvP,.V if ()5_-FPvP,.V if (value === ended)5_-FPvP,.V if (value === end)5_-FPvP,.V if (value === end) event[]5_-!FPvP,.V! if (value === end) event[ended]5_1--vP502VB if (isReduced(result)) event[reducer] = event[state] = void(0)5_1,--vP8R03VS if (isReduced(result) || value === end) event[reducer] = event[state] = void(0)5_9--vP69;X // 9;W5_:--vP89;X if ()5_: --vP;9;X if (event[])5_:--vP=9;X if (event[reducer])5_:--vPH9;X if (event[reducer]) 5_:)--vPK9;X= if (event[reducer]) throw Error("Signal is being consumed")5_::--vPMS9;X< if (event[reducer]) throw Error("Event is being consumed")5_--vP!YX5_..vP%Yvar reduced = require()5_..vP%TYvar reduced = require("")5_-1..vP9Z,.Y1 if (event[ended]) throw Error("Event is ended")5_...vP.0Z .0Y5_/ ..vP.0Z else if ()5_/..vP.0Z else if (isError())5_/..vP.0Z else if (isError(value))5_/!..vP.0Z" else if (isError(value)) event[]5_/'..vP.0Z' else if (isError(value)) event[ended]5_...vP-/Z( if (value === end) event[ended] = true5_...vP -/Z5 if (value === end || isError()) event[ended] = true5_. ..vP -/Z7 if (value === end || isError("")) event[ended] = true5_/..vP./. else if (isError(value)) event[ended] = true5_2*..vP13Y+ if (isReduced(result) || value === end)5_2..vP13Y if (isReduced(result) || [])5_2#..vP13Y% if (isReduced(result) || event[])5_.'..vP$\.0Y5_..vPE[Z5_ //vPI[ var isError()5_//vPL[var isError = require()5_ //vPM`[var isError = require("")5_  =//vPA<>[; if (event[reducer]) throw Error("Event is being reduced")5_   =//vPE<>[< if (event[reducer]) return Error("Event is being reduced")5_   =A//vPGa<>[A if (event[reducer]) return next(Error("Event is being reduced")5_   =8//vPPb<>[K if (event[reducer]) return next(Error("Event is being reduced"), initial)5_  ==(=AvAP<>[M if (event[reducer]) return next(Error("Event is already reduced"), initial)5_ ==(=AvAP!<>[X if (event[reducer] || event[]) return next(Error("Event is already reduced"), initial)5_=&=(=AvAP$<?[] if (event[reducer] || event[ended]) return next(Error("Event is already reduced"), initial)5_?=(=AvAP%c>?- if (event[ended]) return next(end, initial)5_Px[/var accumulate = require("reducers/accumulate")5_Px[+var reduce = require("reducers/accumulate")5_*vPx[,var reduce = require("reducible/accumulate")5_!vPx"[.var isReduced = require("reducers/is-reduced")5_vPx$[*var isError = require("reducers/is-error")5_vPx'[)var reduced = require("reducers/reduced")5_vPx)d [!var end = require("reducers/end")5_: vPx8e9;[9accumulate.define(Event, function(event, next, initial) {5_ =//vP<>[: if (event[reducer]) next(Error("Event is being reduced")5_=://vP^<>[D if (event[reducer]) next(Error("Event is being reduced"), initial)5_4..vP835Z'event[reducer] = event[state] = void(0)25ZR if (isReduced(result) || event[ended]) event[reducer] = event[state] = void(0)5_ ..vPY!var result = "ended@" + module.id5_..vPYY"var result = "result@" + module.id5_-..vP,.Y% if (event[result]) return reduced()5_--vPW5_ikj..55vP[-/Q% if (signal[ended]) return reduced()5_@BEAPCC v POQ } else {}5_ACBP RkvPOQ } else {5_BDCRRkvPQl if (watchers.next) {@ // If event has only `watcher` invoke it and return `true`G var state = watchers.state = watchers.next(value, watchers.state)6 if (isReduced(state)) event[observers] = void(0) return true }L // Otherwise slice array of watchers (this will guarantee that `unwatch`K // and `watch` calls in side effect to the dispatch will not break FIFOI // dispatch order) and invoke each one with a value. Return `true` as // result. var index = 0 var count = watchers.length while (index < count) {# var watcher = watchers[index]4 var state = watcher.next(value, watcher.state) if (isReduced(state)) {! watchers.splice(index, 1) count = count - 1 } else { index = index + 1 watcher.state = state } } return true5_CDkRkvPkl km }5_ #?FF v P4>@% if (watcher = event[observers]) {5_! ?"FF v P8>@ if (watcher.next) {5_ "!?FF v P;>@ if (watcher.length) {5_!"?FF v PF>@ if (watchers.length) {5_   GCC v PFH3 if (watchers.next) consumers.splice(0, count)5_  GCC v PFH if (watchers.next) consumers.splice(0, count)5_9>>vPް8:5_9==vPް8:5_9<<vPޱ8:5_9;;vPޱ8:5_9::vPޱ8:5_999vPޱ8:5_999vPޱ8:5_999vPޱ8:5_999vP޲8:5_999vP޲8:5_9 99vP޶8:) while (watchers && watchers.length) {5_)4vPQ)*y )+z if ()5_*vPW)+z if (value === end)5_*vP\)+z if (value === end) drain()5_*vP݋)+z# if (value === end) drain(event[])5_*!vPݍ)+z, if (value === end) drain(event[observers])5_*)vPݏ*+z *,{ else dispatch()5_+vPݓ*,{ else dispatch(event[])5_+vPݔ*,{! else dispatch(event[observers])5_RTSh"7vPںgi if (isArray(wa))5_)+*:::vPٟ9Y9;z5_l. MvNPVkmI // Otherwise slice array of watchers to will guarantee that `unwatch`5_R<J<IvIP QS5_R<J<IvIP 'QS5_   vPX ]Q// of values. that can be dispatched imperatively by calling `emit(event, value)`5_vP [5_vP 5_vP 5_ vP Y//  Zfunction Event() {}5_ vP ZJ// `Event` type has internal property where it's listeners are stored. For5_cefd& P{&'H5_de#P}#$I5