All files / src/model event-util.ts

100% Statements 11/11
50% Branches 1/2
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20        5x 3x 6x 6x     3x 3x 3x     3x 3x 3x 3x  
'use strict';
 
import { Event } from './event';
 
export const eventMerge = (events: Array<Event>) => {
    const eventTypes = events.map((event) => {
        const eventType = event.payload.eventType || event.eventType;
        return eventType;
    });
 
    const reduce = (result: any, entry: any): any => {
        entry.eventType = undefined;
        return { ...result, ...entry };
    };
 
    const history = (events.reduceRight(reduce) as any);
    delete history.eventType;
    history.eventTypes = eventTypes;
    return history;
};