import { HistoricalOrderStore , Order } from './types' ; import { reviveOrder } from './OrderImpl' ; import { ChronoDB , TimeSeries } from '@bitr/chronodb' ; import { EventEmitter } from 'events' ; class EmittableHistoricalOrderStore extends EventEmitter implements HistoricalOrderStore { private readonly timeSeries : TimeSeries < Order > ; constructor ( chronoDB ) { super ( ) ; this . timeSeries = chronoDB . getTimeSeries < Order > ( 'HistoricalOrder' , order => reviveOrder ( order ) ) ; } get ( key ) { return this . timeSeries . get ( key ) ; } getAll ( ) { return this . timeSeries . getAll ( ) ; } put ( value ) { this . emit ( 'change' ) ; return this . timeSeries . put ( value ) ; } del ( key ) { this . emit ( 'change' ) ; return this . timeSeries . del ( key ) ; } delAll ( ) { this . emit ( 'change' ) ; return this . timeSeries . delAll ( ) ; } } export const getHistoricalOrderStore = ( chronoDB ) : HistoricalOrderStore => new EmittableHistoricalOrderStore ( chronoDB ) ;