all files / redux/modules/counter/ counter.ts

100% Statements 17/17
100% Branches 7/7
100% Functions 3/3
100% Lines 16/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41            17× 17×               13×                        
"use strict";
/** Action Types */
exports.INCREMENT = 'INCREMENT';
exports.DECREMENT = 'DECREMENT';
/** Counter: Initial State */
var initialState = {
    count: 0,
};
/** Reducer: CounterReducer */
function counterReducer(state, action) {
    if (state === void 0) { state = initialState; }
    switch (action.type) {
        case exports.INCREMENT:
            return {
                count: state.count + 1,
            };
        case exports.DECREMENT:
            return {
                count: ((state.count - 1 > 0) ? state.count - 1 : 0),
            };
        default:
            return state;
    }
}
exports.counterReducer = counterReducer;
/** Action Creator: Increments the Counter */
function increment() {
    return {
        type: exports.INCREMENT,
    };
}
exports.increment = increment;
/** Action Creator: Decrements the Counter */
function decrement() {
    return {
        type: exports.DECREMENT,
    };
}
exports.decrement = decrement;