VimUnDog4Rp޷ⱘ &jZ LP%p_Pvar end = require("./end")5_ P  next(end(), value)5_Pvar error = require("./error")5_P  next(error(e))5_ P  }, function(e) {5_ P " when(result, function(value) {5_  P  }, function(error) {5_ P  next(error5_ P/5_ P0function Reducible()5_ P0function Reducible() {}5_  P0 5_ P0function Reducible() {}}5_P05_P0accumulate.define()5_'P0(accumulate.define(Reducible, function())5_)P0 +accumulate.define(Reducible, function() {})5_&P0!)accumulate.define(Reducible, function() {5_%P01Aaccumulate.define(Reducible, function(reducible, next, initial) {5_0P07   5_P0B  reducible.reduce()5_P0H5_P0Kvar accumulate = require()5_P0Kvar accumulate = require("")5_P0O#var when = require("eventual/when")5_P0Q"var convert = require("./convert")5_ P0R  5_ P0U function reducible()5_ P0V function reducible() {}5_  P0W   5_! P0Z function reducible() {5_ "! P0\  function reducible(f) {5_!#" P0e  var 5_"$# P0j   5_#%$ P0t  reducible.reduce = reducible5_$&% P0v   5_%'& P0   reducible.reduce = reduce5_&('P0 5_')(P0   5_(*)P0 accumulate()5_)+*P0 var reduce = reducible.reduce5_*,+P0! reducible.reduce(next, initial)5_+-,P0' reducible.reduce(function(), initial)5_,.-P0 * reducible.reduce(function() {}, initial)5_-/.P0 reducible.reduce(function() {5_.0/#P0& return reducible.reduce(function() {5_/10P4function Reducible() {}5_021P4 5_132P4function Reducible() {5_243P4 5_354P4@!// that can be reduced. 5_465)P4W!)// that can be reduced. Most of the time 5_576'P4"=// over other reducible by capturing it in the lexical scope.5_687.P4 "=// over other reducible by capturing it in the lexical scope.5_798;vP4"F// Reducible is a type of the data-structure that represents somethingN// that can be reduced. Most of the time it's used to represent transformation;// over other reducible by capturing it in a lexical scope.function Reducible(reduce) {5_8:9;vP4  5_9;:;vP4#H // Reducible is a type of the data-structure that represents something5_:<;;vP4 $E Reducible is a type of the data-structure that represents somethingKthat can be reduced. Most of the time it's used to represent transformation $N// that can be reduced. Most of the time it's used to represent transformation5_;=< ;vP4 $M that can be reduced. Most of the time it's used to represent transformation8over other reducible by capturing it in a lexical scope. $;// over other reducible by capturing it in a lexical scope.5_<>= ;vP4 %  $5_=?> ;vP4  Reducible &  %5_>@? ;vP4 '$ Reducible has one method `reduce` 5_?A@ ;vP4 '( Reducible has one attributes `reduce` 5_@BA ;vP4 '' Reducible has an attributes `reduce` 5_ACB &;vP4  '& Reducible has an attribute `reduce` 5_BDC;vP4)(5_CED ;vP4 * // captured 5_DFE;vP5 *5_EGF;vP5 * // JS engines optimize 5_FHG ;vP52 +5_GIH ;vP59, var value = new Reducible()5_HJI;vP5<, return new Reducible()5_IKJ;vP5@ value.reduce = reduce5_JmK;vP5@ return value5_KnLm"(vP7?*2 return reducible.reduce(function(state, value) {5_mon(vP7J*: return reducible.reduce(function forward(state, value) {5_npo (vP7N*> var result reducible.reduce(function forward(state, value) {5_oqp (vP7T+ *5_prq )vP7W+ return()5_qsr)vP7`+ return(value, result)5_rts )vP7b+ return(value, state)5_sut)vP7e+ next(value, state)5_tvu )vP7o, +5_uwv *vP7y, reduce()5_vxw*vP7}, reduce(result, function())5_wyx*vP7~, reduce(result, function() {})5_xzy +vP7 reduce(result, function() {5_y{z*vP7 })5_z|{)vP7, +5_{}|*vP7, when()5_|~}vP7, when(result, function)5_}~vP70" }, function onfailure(error) {5_~vP70 })5_vP70 next(error)5_vP70 next(null, value)5_vP7105_vP71var when = require()5_vP71var when = require("")5_vP71var when = require("./when")5_$$/vP7#%%#%1 function reducible(source, f) {: return convert(source, function(source, next, initial) {< var result = f(source, function forward(result, value) { return next(value, result) }, initial), when(result, function ondeliver(value) { next(null, value)" }, function onfailure(error) { next(error) }) })}5_ $$vP7& %5_%%vP7&* // We just inverse order of arguments 5_%%vP7&/ // We actulally inverse order of arguments 5_3%%vP7&3 // We actually just inverse order of arguments 5_ %%vP7&5_&&vP7('5_''vP8(" // when we have a result we disp5_''vP8( // when result we disp5_''vP8!( // when result is reday disp5_''vP8%( // when result is ready disp5_((vP83)F // when result is ready dispatch end of stream and aggregated value.5_ ((vP8:!) }, function onfailure(error) {5_!((vP8? ! next(error)5_!''vP8? ! })5_&&vP8B'* when(result, function ondeliver(value) {next(null, value) ' next(null, value)5_%%vP8C&< when(result, function ondeliver(value) { next(null, value)}, next) & }, next)5_$$vP8F% // I5_$$vP8[%% // If result errors forward 5_PP=%(var accumulate = require("./accumulate")5_"PP@&%$var reduce = require("./accumulate")5_ PPF'%Laccumulate.define(Reducible, function accumulate(reducible, next, initial) {5_PP5_PPF // When result is ready dispatch end of stream and aggregated value.5_PP( // If result errors also forward that.5_PPE when(result, function ondeliver(value) { next(null, value) }, next)5_PP(!@ var result = reducible.reduce(function forward(state, value) {5_:PP!: return reducible.reduce(function forward(state, value) {5_PQ8 // We actually just inverse order of arguments here.5_PQ return next(value, state)5_PQ) }, initial)5_,PT*Hreduce.define(Reducible, function accumulate(reducible, next, initial) {5_(PT+Dreduce.define(Reducible, function reduce(reducible, next, initial) {5_P[ "use strict"; var reduce = require("./reduce")#var when = require("eventual/when")function Reducible(reduce) { /**E Reducible is a type of the data-structure that represents somethingM that can be reduced. Most of the time it's used to represent transformation: over other reducible by capturing it in a lexical scope.F Reducible has an attribute `reduce` pointing to a function that does reduction. **/O // JS engines optimize access to properties that are set in the constructor's // so we set it here. this.reduce = reduce}M// Implementation of `accumulate` for reducible, which just delegates to it's// `reduce` attribute.Mreduce.define(Reducible, function reduceReducible(reducible, next, initial) {( return reducible.reduce(next, initial)})function reducible(reduce) { return new Reducible(reduce)}module.exports = reducible5_'P\%5_P\!&5_P\" 5_  vP\B,& %5_, /vP\U {5_+ .vP\W95_*vP\Z+:1 accumulate(function forward(value, state) {! if (result) return result if (isEnd(value)) {! result = reduced(state) next(end, state) }" else if (isError(value)) {! result = reduced(state) next(error, state) } else {$ state = next(value, state)! if (isReduced(state)) { result = state# next(end, result.value) } } })5_+*vP\]*+ }5_*vP\a+9/ accumulate(function forward(value, state) { if (result) return result if (isEnd(value)) { result = reduced(state) next(end, state) } else if (isError(value)) { result = reduced(state) next(error, state) } else {" state = next(value, state) if (isReduced(state)) { result = state! next(end, result.value) } } })5_**vP\e*,95_ v P\w:- accumulate(function forward(value, state) {5_ v P\: var result5_ v P\5_) v P\(*9 })5_ v P\:95_ v P\,fun5_  v P]:95_ v P]:var end = require()5_ v P]-:var end = require("")5_ v P].; :5_D v P]<<D // If reduce reduction has already being completed just stop the5_ v P]=/ // computation.5_ v P]B; if (isEnd(value)) {5_ v P]D0; if (value)) {5_ v P]T if (value === end) {5_ v P]T result = reduced(state)5_ v P]U next(end, state)5_ v P]U }5_  v P]W7 else if (isError(value)) {5_ v P]Y875_ v P]\8var isError = require()5_ v P]]18var isError = require("")5_ v P]f985_ v P]j9var reduced = require()5_ v P]j29var reduced = require("")5_  v P]}3!9 next(error, state)5_" v P] "9 }else {!#9 else {5_A v P] // `result` holding `reduced8A // If reduce reduction has already being completed just stop!5_ v P]9" // `result` holding `reduced` 5_6 v P]496 // `result` that is last state boxed in `reduced` 5_6 v P]" // trying to dispatch after it96 // `result` that is last state boxed in `reduced`.5_< v P] :< // trying to dispatch after it's closed will just error.5_+ v P^;F // trying to dispatch after it's closed will just be handed back a5_4 v P^;O // trying to dispatch after it's closed or error will just be handed back a5_4 v P^;Q // trying to dispatch after it's closed or errored will just be handed back a5_L v P^ ;R // trying to dispatch after it's closed or error-ed will just be handed back a5_ v P^ < // back a5_  v P^ < // a back a+`reduced` indicating that no further items !<2 // `reduced` indicating that no further items 5_ v P^  ;4 // a `reduced` indicating that no further items 5_ v P^# ;: // a `reduced` state indicating that no further items 5_ v P^$ ;; // a `reduced` `state indicating that no further items 5_< v P^%5!;< // a `reduced` `state` indicating that no further items 5_! v P^0!#= !#<5_" v P^:!#= // If value is an errors5_" v P^;!#= // If value is an error5_" v P^;!#= // If value is an `error5_"# v P^U!#=C // If value is an `error` which also includes `end` of stream, 5_". v P^Y!#=H // If value is an `error` (that also also includes `end` of stream, 5_"C v P^[!$=C // If value is an `error` (that also includes `end` of stream, 5_"M v P^h!#>M // If value is an `error` (that also includes `end` of stream) no further5_"J v P^n!#>J // If value is an `error` (that also includes `end` of stream), update5_# v P^q"$> // items ar5_  v P^}? >5_0 v P^6?3 reducible.reduce(function forward(value, state) {5_  v P^? var state5_/  v P^7.0? }, initial)5_$  v P^#%? // last state 5_$ v P^#%? // last `state 5_#H v P^"$?H // If value is an `error` (that also includes `end` of stream), save5_$ v P^#&? // last `state` int5_% v P^$'@ // subsequent5_%I v P^$&AI // subsequent attempts of calling this function will just be handed a5_& v P^8%& // last `5_%M v P^9$'@M // subsequent attempts of calling this function will just be handed that.5_* v P_)-A } else {5_+ v P_*,C 5_+  v P_!*,C // If 5_+ v P_/*,C // Otherwise `state` is 5_+  v P_0*,C // Otherwise new `state` is 5_& v P_YD C5_  v P_\D try {}5_ v P_]DB // If reduce reduction has already being completed just return5_ v P_^ DH // `result` that is last state boxed in `reduced`. That way anything5_  v P_`!DK // trying to dispatch after it's closed or error-ed will just be handed5_! v P_a "DI // a `reduced` `state` indicating last value and no intent of getting5_" v P_b!#D // more values.5_# v P_c"$D if (result) return result5_$ v P_d#%DL // If value is an `error` (that also includes `end` of stream), box last5_% v P_e$&DF // last `state` with `reduced` and store it to result, so that any5_& v P_f%'DM // subsequent attempts of calling this function will just be handed that,5_' v P_g&(D2 // again indicating no intent of being called.5_( v P_h')D if (isError(value)) {5_ ) v P_k(*D result = reduced(state)5_  ( v P_q')D if (isError(value)) {5_   ))*vP_z(*D result = reduced(state) next(value, state)5_   )))vP_z()5_   )))vP_}() }5_  )))vP_(*A@ // Otherwise new `state` is accumulated `by` dispatching to 5_ *))vP_)+A else {5_*))vP_)* else {5_/))vP_.0@ }5_/ ))vP_.0@ } catch ()5_/))vP_.0@ } catch (errors)5_/))vP_.0@ } catch (error)5_/))vP_.1@ } catch (error) {}5_/))vP_/2B /1A5_0))vP_/1C% result = reduced(state)5_0))vP_/1C result = reduced(state)5_0))vP_/1C result = reduced(errors)5_1))vP_02C next(value, state)5_1))vP_02C next(errors, state)5_1))vP_02C next(error, state)5_0))vP_/1C result = reduced(error)5_1))vP_:02C next(error, result)5_(%))vP_;')C% if (isError(value)) throw error5_ /$'3v3P`.2C } catch (error) {5_! 0$'3v3P`24H4 // again indicating no intent of being called./4E 5_ "!1$'3v3P`02HH // last `state` with `reduced` and store it to result, so that any5_!#"0$'3v3P`/1HL // If value is an `error` (that also includes `end` of stream), box last5_"$#0$'3v3P`"/1HP // If value is thrown `error` (that also includes `end` of stream), box last5_#%$0$'3v3P`$/1H@ // If `error` (that also includes `end` of stream), box last5_$&%0$'3v3P`)/3HJ // If `error` is thrown (that also includes `end` of stream), box last5_%'&1$'3v3P`502J //5_&('2$'3v3P`602J // .(that also includes `end` of stream), box last13J5 // (that also includes `end` of stream), box last5_')(00$'3v3P`</1I0 // If `error` is thrown that may few things:5_(*)1$'3v3P`B02I5 // (that also includes `end` of stream), box last5_)+*1!$'3v3P`J02IO // 1. Last value dispatched (that also includes `end` of stream), box last5_*,+1O$'3v3P`X03Ii // 1. Last value dispatched was indicator of an error (that also includes `end` of stream), box last5_+-,2$'3v3P``13J" // `end` of stream), box last5_,.-2$'3v3P`i13J% // `end` of stream), box last5_-/.2$'3v3P`l15J% // `end` of stream). box last5_.0/2 $'3v3P`o24M // 24L5_/103-$'3v3P`24M8 // 2. `next` handler provided has thrown exception 5_0213 $'3v3P`24M7 // 2. `next` handler provided has threw exception 5_1323,$'3v3P`24M@ // 2. Provided `next` handler provided has threw exception 5_2433'$'3v3P`24M7 // 2. Provided `next` handler has threw exception 5_3543($'3v3P`24M3 // 2. Provided `next` handler threw exception 5_46536$'3v3P`24M6 // 2. Provided `next` handler threw an exception 5_57636$'3v3P`24M6 // 2. Provided `next` handler threw an exception.5_6874$'3v3P`34 //5_7984$'3v3P`34 // box last5_8:93$'3v3P`35K5_9;:4$'3v3P`46M //46L5_:<;5$'3v3P`46M // When this happens 5_;=<5)$'3v3P`46M6 // When this happens stream is eithr finished or 5_<>=57$'3v3P`47M7 // When this happens stream is either finished or 5_=?>6$'3v3Pa 57N // no new items should 5_>@?6($'3v3Pa57N( // no new items should get through.5_?A@7$'3v3Pa57N2 // no new items should get through. There for?last `state` with `reduced` and store it to result, so that any68NF // last `state` with `reduced` and store it to result, so that any5_@BA5$'3v3Pa46MK // When this happens stream is either finished or error-ed, either way5_ACB5$'3v3Pa46MJ //aWhen this happens stream is either finished or error-ed, either way5_BDC6$'3v3Pa 57Mr // no new items should get through. There for last `state` with `reduced` and store it to result, so that any5_CED6q$'3v3Pa!57Mq // no new items should get through. There for last `state` with `reduced` and store it to result, so that any5_DFE6C$'3v3Pa'58Mr // no new items should get through. There for last `state` with `reduced` and store it to result, so that anyb5_EGF6L$'3v3Pa.57NL // no new items should get through. There for last `state` is boxed into5_FHG7 $'3v3Pa468N5 // `reduced` and store it to result, so that anyb5_GIH7 $'3v3Pa868N4 // `reduced` and store as a result, so that anyb5_HJI7($'3v3Pa:68N5 // `reduced` and store as a `result, so that anyb5_IKJ7K$'3v3PaF68NK // `reduced` and store as a `result` of this accumulation. so that anyb5_JLK8 $'3v3PaL68NB // `reduced` and store as a `result` of this accumulation. AnyFsubsequent attempts of calling this function will just be handed that,79NO // subsequent attempts of calling this function will just be handed that,5_KML7N$'3v3PaN69M // `reduced` and store as a `result` of this accumulation. Any subsequent attempts of calling this function will just be handed that,5_LNM8$'3v3PaQ79NB // attempts of calling this function will just be handed that,5_MON8-$'3v3PaX79NB // attempts to provide this function will just be handed that,5_NPO8$'3v3PaZ79N0 // attempts to provide just be handed that,5_OQP88$'3v3Pa^79N8 // attempts of providing values just be handed that,5_PRQ8J$'3v3Pal7:NJ // attempts of providing values will just get it in return, hopefully 5_QSR9$'3v3Pao8:O // closing5_RTS9$'3v3Paw8:O // closing 5_SUT4$'3v3Pa|34 //5_TVU3$'3v3Pa~35N5_UWV0$'3v3Pa02O5_VXW:$'3v3Pa9;P // closing all the 5_WYX;$'3v3Pa:;4 // again indicating no intent of being called.5_XZY:$'3v3Pa9;O // closing source to close.5_Y[Z:$'3v3Pa9;O' // causing closing source to close.5_Z\[:$'3v3Pa9;O( // causing closing sourcbe to close.5_[]\:$'3v3Pa9;O' // causing closing source to close.5_\^]:$'3v3Pa9;O // causing source to close.5_]_^:$'3v3Pa9;O% // causing source of value close.5_^`_:,$'3v3Pa<9;O, // causing source of value to get close.5__a`+$'3v3Pa*,O if (isReduced(state)) {5_`ba,$'3v3Pa+, result = state5_acb,$'3v3Pa+, next(end, result.value)5_bdc,$'3v3Pa+, }5_ced$N$'3v3Pa#&LN // If value is an `error` (that also includes `end` of stream), box last5_dfe&$(3v3Pa%&H // last `state` with `reduced` and store it to result, so that any5_egf&$'3v3Pa%&O // subsequent attempts of calling this function will just be handed that,5_fhg&$&3v3Pa%&4 // again indicating no intent of being called.5_gih&$&3v3Pa&(J5_hji(B$&3v3Pb '*KB // Otherwise new `state` is accumulated `by` dispatching to 5_ikj*$&3v3Pb$)+L state = next(value, state)5_jlk*$&3v3Pb&=)+L state = next(state)5_kml)$&3v3Pb_>(*L // actual 5_lnm*$&3v3Pbj*,M *,L5_mon$&3v3PbnNM5_npo%'3v3PbrNvar isReduced = require()5_oqp%'3v3Pbr?Nvar isReduced = require("")5_prq%'3v3Pbw@N var isError = require("./error")5_qsr, %'3v3Pb+-N // 5_rts+%'3v3Pb+-N5_sut-%'3v3Pb,.O // If state is 5_tvu=%'3v3Pb=?P =?O5_uwv>%'3v3PbA=> return result5_vxw.%'3v3PbB.1P .0O5_wyx-A%'3v3Pb,/QA // If new `state` is boxed in `reduced` than we should stop5_xzy-<%'3v3Pb,.RL // If new `state` is boxed in `reduced` than we should stop forwarding5_y{z-8%'3v3Pb,.RH // If new `state` is boxed in `reduced` than souce stop forwarding5_z|{-:%'3v3Pb,.RI // If new `state` is boxed in `reduced` than source stop forwarding5_{}|-H%'3v3Pb,.RS // If new `state` is boxed in `reduced` than source should be stop forwarding5_|~}-L%'3v3Pb,/RV // If new `state` is boxed in `reduced` than source should be stopped forwarding5_}~.%'3v3Pb-/S // forwarding5_~.%'3v3Pb-/S // and nom 5_/ %'3v3Pb-/S // and no more .0S // any more 5_.%'3v3PbC-/R // and no more 5_.3%'3v3Pc%D-/R9 // and no more values should be forwarded to state.5_.;%'3v3Pc(-/R; // and no more values should be forwarded to a state.5_.D%'3v3Pc-E-0RD // and no more values should be forwarded to a `next` handler.5_0-%'3v3PcQF/1S- if (isReduced(state)) throw state.value5_/%'3v3PcYG.0S8 // that we throw and let `catch` block do the job.5_/>%'3v3Pc`H.0S> // that we throw `end` and let `catch` block do the job.5_2%'3v3Pcf24S5_3%'3v3Pcg235_1%'3v3Pch13T13S5_$%'3v3Pcp$&T5_3&(3v3Pcr24U // If code got that far 5_3F&(3v3Pc25UO // If code got that far then `new` state is just returned back, notifiing5_4&(3v3Pc35V // notifiing5_4&(3v3Pc35V // notifying5_4&(3v3PcI35V // notifying con5_4&(3v3Pc35V! // notifying consumer about5_4 &(3v3Pc35V // to consumer about5_4&(3v3PcJ35V // to a consumer about5_3#&(3v3Pc24VE // If code got that far then `new` state is just returned back,5_3O&(3v3Pc25Vb // If code got that far then nothing special happened and `new` state is just returned back,5_5 &(3v3PcK35W // just returned back,to a consumer.46W // to a consumer.5_G&(3v3PcFG5_G&(3v3PcFG@ var result = reducible.reduce(function forward(state, value) {5_G&(3v3PcFG8 // We actually just inverse order of arguments here.5_G&(3v3PcFG return next(value, state)5_G&(3v3PcFG }, initial)5_G&(3v3PcFG5_G&(3v3PcFGF // When result is ready dispatch end of stream and aggregated value.5_G&(3v3PcFG( // If result errors also forward that.5_G&(3v3PcLFGE when(result, function ondeliver(value) { next(null, value) }, next)5_F&(3v3PcMEGM })5_ &(3v3PcN M5_F (*3v3PdNFHP FHO5_!(*3v3Pd&P! // reducer of the result is not5_1(*3v3Pd0PO // State is intentionally accumulated in the outer variable, that way even ifP1 // reducer of the result is not playing nicely 5_2(*3v3PdUPA // matter if consumer is broken we still forward intended state5_>(*3v3PdWPD // matter if consumer is broken we still accumulate intended state5_;(*3v3PdYP; // matter if consumer is broken we still accumulate state5_!(*3v3Pd_PA // matter if consumer is broken we still accumulate state accar5_C(*3v3PdfPO // matter if consumer is broken and passes in we still accumulate state accar5_A(*3v3PdjPA // matter if consumer is broken and passes in wrong state accar5_)+3v3PdOQ // 5_F )+3v3PdFHR FHQ5_G )+3v3PdFHR try {}5_H)+3v3PdFHR try {next(error, state)GIR next(error, state)5_G)+3v3PdFHQ try { next(error, state)5_G)+3v3PdGIR GIQ5_H )+3v3PdGIR catch ()5_H)+3v3PdGIR catch (error)5_H)+3v3PdGIR catch (exception)5_H)+3v3PdGIR catch (exception) {}5_G )+3v3PdFHR try { next(error, state) }5_G )+3v3PdFHR try { next(error, state)5_H)+3v3PdGH( catch (exception) { console.error}5_F)+3v3PdPFIR FHQ5_)+3v3PdQS5_TVPe!T "use strict";(var accumulate = require("./accumulate")#var when = require("eventual/when")var end = require("./end")#var isError = require("./is-error")'var isReduced = require("./is-reduced")"var reduced = require("./reduced")function Reducible(reduce) { /**E Reducible is a type of the data-structure that represents somethingM that can be reduced. Most of the time it's used to represent transformation: over other reducible by capturing it in a lexical scope.F Reducible has an attribute `reduce` pointing to a function that does reduction. **/O // JS engines optimize access to properties that are set in the constructor's // so we set it here. this.reduce = reduce}M// Implementation of `accumulate` for reducible, which just delegates to it's// `reduce` attribute.Laccumulate.define(Reducible, function accumulate(reducible, next, initial) { var resultJ // State is intentionally accumulated in the outer variable, that way noL // matter if consumer is broken and passes in wrong accumulated state back2 // this reducible will still behave as intended. var state = initial, reducible.reduce(function forward(value) { try {D // If reduce reduction has already being completed just returnJ // `result` that is last state boxed in `reduced`. That way anythingM // trying to dispatch after it's closed or error-ed will just be handedK // a `reduced` `state` indicating last value and no intent of getting // more values. if (result) return resultL // If value is an `error` (that also includes `end` of stream) we just< // throw and let `catch` block do the rest of the job.% if (isError(value)) throw valueM // Otherwise new `state` is accumulated `by` forwarding a `value` to an // actual `next` handler. state = next(state, state)K // If new `state` is boxed in `reduced` than source should be stoppedJ // and no more values should be forwarded to a `next` handler. To doJ // that we throw `end` and let `catch` block do the rest of the job.% if (isReduced(state)) throw endN // If code got that far then nothing special happened and `new` state is+ // just returned back, to a consumer. return state }0 // If `error` is thrown that may few things: //N // 1. Last value dispatched was indicator of an error (that also includes // `end` of stream). M // 2. Provided `next` handler threw an exception causing stream failure. //J // When this happens stream is either finished or error-ed, either wayL // no new items should get through. There for last `state` is boxed withM // `reduced` and store as a `result` of this accumulation. Any subsequentI // attempts of providing values will just get it in return, hopefully- // causing source of value to get closed. catch (error) { result = reduced(state)L // Maybe we should console.error exceptions if such arise when calling& // `next` in the following line. next(error, state) return result } }, null)})function reducible(reduce) { return new Reducible(reduce)}module.exports = reducible5_TVPe@ "use strict"; var reduce = require("./reduce")#var when = require("eventual/when")function Reducible(reduce) { /**E Reducible is a type of the data-structure that represents somethingM that can be reduced. Most of the time it's used to represent transformation: over other reducible by capturing it in a lexical scope.F Reducible has an attribute `reduce` pointing to a function that does reduction. **/O // JS engines optimize access to properties that are set in the constructor's // so we set it here. this.reduce = reduce}M// Implementation of `accumulate` for reducible, which just delegates to it's// `reduce` attribute.Mreduce.define(Reducible, function reduceReducible(reducible, next, initial) {( return reducible.reduce(next, initial)})function reducible(reduce) { return new Reducible(reduce)}module.exports = reducible5_%VPeLU "use strict";$(var accumulate = require("./accumulate")#var when = require("eventual/when")function Reducible(reduce) { /**E Reducible is a type of the data-structure that represents somethingM that can be reduced. Most of the time it's used to represent transformation: over other reducible by capturing it in a lexical scope.F Reducible has an attribute `reduce` pointing to a function that does reduction. **/O // JS engines optimize access to properties that are set in the constructor's // so we set it here. this.reduce = reduce}M// Implementation of `accumulate` for reducible, which just delegates to it's// `reduce` attribute.Laccumulate.define(Reducible, function accumulate(reducible, next, initial) {@ var result = reducible.reduce(function forward(state, value) {8 // We actually just inverse order of arguments here. return next(value, state) }, initial)F // When result is ready dispatch end of stream and aggregated value.( // If result errors also forward that.E when(result, function ondeliver(value) { next(null, value) }, next)})function reducible(reduce) { return new Reducible(reduce)}module.exports = reducible5_UUVVPeNRTU5_RUUVPmSRTURTT5_0VVVPn T/1U state = next(state, state)5_0VVVPn U/1U! state = next(values, state)5_!&VVVP@!#V !#U5_"WWVPCV!#V console.log()5_"WWVPKW!#V console.log(value)5_"""vPU!#V console.log(">>>>", value)5_"""vPUX!" 5_0""vP[Y13W 03V 02U5_2""vP]]13W console.log(">>>>", value)5_2""vP12' console.log(">>>>", value, state)5_2""vPb125_! ""vP!#V !#U5_"##vPc!#V console.log()5_"##vP/d!" console.log(value)5_, ""vP1i+-U% if (isError(value)) throw value5_>UUVPo=? // `end` of stream). 5_FUUVP%FHV FHU5_G VVVP%FHV if ()5_GVVVP%FHV if (isReduced)5_GVVVP%FHV if (isReduced())5_GVVVP%FHV if (isReduced(state))5_GVVVP%FIV if (isReduced(state)) {}5_HWWVP%GJW result = state}5_IXXVP%HJX }5_HXXVP%HJY HJX5_JYYVP%IKY }5_JYYVP%IKY } else {}5_KYYVP%JLY result = reduced(state)5_KYYVP%pKMZ KMY5_5VVVP%46U if (isReduced(state)) {$ state = state.valuethrow end5_5UUVP$46U: if (isReduced(state)) state = state.value, throw end5_5VVVP% 46U if (isReduced(state)) {& state = state.value, throw end5_6WWVP%57V state = state.value throw end5_7XXVP%l78W 79X }5_5YYVP%>56X 57Y console.log()5_6YYVP%B57Y console.log("")5_6YYVP%Dm57Y console.log("!!!!")5_5UUVP$46U; if (isReduced(state)) (state = state.value, throw end5_5;UUVP$k46U< if (isReduced(state)) (state = state.value, throw end)5_5$UUVP$46U; if (isReduced(state)) state = (state.value, throw end5_50UUVP$46U< if (isReduced(state)) state = state.value && throw end5_M ""vP3hLNU }, initial)5_!)""vP̸ "U3 reducible.reduce(function forward(value, state) {5_M ""vP̽fLNU }, initial)5_,""vP,+-U. if (isError(value) || value) throw value5_>""vP_=? // `end` of stream).5_ !!vP!5_ )!!vP!T3 reducible.reduce(function forward(value, state) {5_L !!vPaKMT }, initial)5_2""vP|\135_2""vP|[135_  "vP\'%* var result = reducible.reduce(, initial)"! var result = reducible.reduce({ var result1 accumulate(function forward(value, state) {! if (result) return result if (isEnd(value)) {! result = reduced(state) next(end, state) }" else if (isError(value)) {! result = reduced(state) next(error, state) } else {$ state = next(value, state)! if (isReduced(state)) { result = state# next(end, result.value) } } }) }, initial)5_ "vP\865_PP!function Reducible(method) {5_ " v P-#& "use strict";"var convert = require("./convert")#var when = require("eventual/when")function reducible(source, f) {: return convert(source, function(source, next, initial) {< var result = f(source, function forward(result, value) { return next(value, result) }, initial), when(result, function ondeliver(value) { next(null, value)" }, function onfailure(error) { next(error) }) })}module.exports = reducible5_KMmLvP5N)*5_LNMvP5O reducible.type = Reducible5_MONvP5V 5_NPO!!vP5W! " /** **?5_OQP!!vP5]# **/5_PRQ##vP5^# * $F Takes `reduce` function and returns a data structure that represents reducible with a given reduce`5_QSR ##vP5}%1 reducible with a given `reduce` implementation.5_RTS2##vP5%( return reducible.reduce(next, initial)5_SjT""vP55_TkUj""vP6$. return reducible.reduce(function(), initial)5_jlk$""vP6$1 return reducible.reduce(function() {}, initial)5_kl&##vP6$& return reducible.reduce(function() { }, initial)5_TVjU""vP5$. var result = reducible.reduce(next, initial)5_UWV ##vP5$ % when()5_VXW##vP5% when(result, )5_WYX##vP5% reduce(result, )5_XZY##vP5% reduce(result, function())5_Y[Z##vP5% reduce(result, function() {})5_Z\[$$vP5% reduce(result, function() { })5_[]\$$vP5&$ reduce(result, function() { next()5_\^]#$$vP5&( reduce(result, function() { next(null)5_]_^##vP5&})&+ reduce(result, function() { next(null) })5_^`_'##vP5%- reduce(result, function() { next(null, ) })5__a`##vP5%2 reduce(result, function(value) { next(null, ) })5_`ba.##vP5%7 reduce(result, function(value) { next(null, value) })5_acb$$vP6 %&var reduce = require()5_bdc$$vP6 &var reduce = require("")5_ced$$vP6& var reduce = require("./reduce")5_dfe %%vP6'& ' r5_egf$$vP6*5_fhg##vP6*5_gih##vP6,%) returns reducible.reduce(next, initial)5_hi ##vP6/%( return reducible.reduce(next, initial)5_ P next(null, value) > when(result, function ondeliver(value) { next(null, value)5