src/lib/reducers.js
/**
 * Wrap a reducer that works on a metric's value.
 */
Wrap a reducer that works on a metric's value.
Wrap a reducer that works on a metric ' s value .
function metric(reducer) {
  return {
    init: () => {
      return Map({ value: reducer.init() });
    },
    step: (res, event) => {
      return res
        .update('value', acc => reducer.step(acc, event.get('value')))
        .merge(selectKeys(event, ['name', 'tags']));
    },
    result: res => {
      return res.update('value', acc => reducer.result(acc));
    },
    merge: (res1, res2) => {
      return res1.update('value', acc => reducer.merge(acc, res2.get('value')));
    },
  };
}
function metric ( reducer ) { return { init : ( ) => { return Map ( { value : reducer . init ( ) } ) ; } , step : ( res , event ) => { return res . update ( 'value' , acc => reducer . step ( acc , event . get ( 'value' ) ) ) . merge ( selectKeys ( event , [ 'name' , 'tags' ] ) ) ; } , result : res => { return res . update ( 'value' , acc => reducer . result ( acc ) ) ; } , merge : ( res1 , res2 ) => { return res1 . update ( 'value' , acc => reducer . merge ( acc , res2 . get ( 'value' ) ) ) ; } , } ; }
Wrap a reducer that works on a metric's value.
Wrap a reducer that works on a metric ' s value .