import * as _ from 'highland' ; import { Store , Middleware , StreamAction } from '../types' ; private param { Store } store return { Function } export const createConsumerCreator = ( store ) => createConsumer ( store ) ; private param { Store } store return { Function } export const createConsumer = ( store ) => ( middleware ) => ( err , item , push , next ) : void => { if ( err ) { push ( err ) ; next ( ) ; } else if ( item === _ . nil ) { push ( null , _ . nil ) ; } else { try { middleware ( store ) ( ( nextItem ) => { if ( nextItem ) { push ( null , nextItem ) ; } else { push ( null , item ) ; } next ( ) ; } ) ( < StreamAction > item ) ; } catch ( err ) { push ( err ) ; next ( ) ; } } } ;