<commit_before>"use strict";
var redux_actions_1 = require("redux-actions");
;
/**
 * Фабрика action creator'ов и reducer'ов, хранящая в себе типы текущей ветки store и Payload action'а.
 * @template TState store's current brunch type.
 * @template TPayload action's payload type.
 */
var GuardedFactory = (function () {
    function GuardedFactory(type) {
        this._type = type;
        this._actionCreator = redux_actions_1.createAction(this._type.toString());
    }
    Object.defineProperty(GuardedFactory.prototype, "type", {
        get: function () {
            return this._type.toString();
        },
        enumerable: true,
        configurable: true
    });
    /**
     * Создает action creator.
     * @param payload payload для action'а.
     */
    GuardedFactory.prototype.createAction = function (payload) {
        return this._actionCreator(payload);
    };
    /**
     * Создает reducer, привязанный к конкретному GuardedActionType.
     * @param reducer reducer.
     */
    GuardedFactory.prototype.createReducer = function (reducer, initialState) {
        var _this = this;
        var actionReducer = function (state, action) {
            if (is(action, _this._type))
                return reducer(state, action);
            return state || initialState;
        };
        return new GuardedReducer(this._type, actionReducer);
    };
    return GuardedFactory;
}());
exports.GuardedFactory = GuardedFactory;
var GuardedReducer = (function () {
    function GuardedReducer(type, reducer) {
        this._type = (type || "").toString();
        this._reducer = reducer;
    }
    Object.defineProperty(GuardedReducer.prototype, "reducer", {
        get: function () {
            return this._reducer;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GuardedReducer.prototype, "type", {
        get: function () {
            return this._type;
        },
        enumerable: true,
        configurable: true
    });
    return GuardedReducer;
}());
/**
* Склеивает набор reducer'ов для работы с одной веткой state'а
* (в отличие от combine, где каждый reducer работает со своим поддеревом).
*
* Можно добиться такой неприятной ситуации, когда defaultReducer среагирует на action, на который уже среагировал
* один из actionReducer'ов. Запретить такую регистрацию не представляется возможным.
* @param initialState state по-умолчанию.
* @param actionReducers массив reducer'ов с GuardedActionType'ом.
* @param defaultReducer reducer по-умолчанию.
*/
var joinReducers = function (initialState, actionReducers, defaultReducer) {
    var actionReducerMap = {};
    for (var _i = 0, actionReducers_1 = actionReducers; _i < actionReducers_1.length; _i++) {
        var actionReducer = actionReducers_1[_i];
        if (actionReducerMap[actionReducer.type] != null)
            throw new Error("reducer \u0441 \u0442\u0438\u043F\u043E\u043C \"" + actionReducer.type + "\" \u0443\u0436\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0438\u0440\u043E\u0432\u0430\u043D");
        actionReducerMap[actionReducer.type] = actionReducer.reducer;
    }
    var reducer = function (currentState, action) {
        var actionReducer = actionReducerMap[action.type];
        var actualState = currentState || initialState;
        if (actionReducer != null)
            actualState = actionReducer(actualState, action);
        if (defaultReducer != null)
            actualState = defaultReducer(actualState, action);
        return actualState;
    };
    return reducer;
};
exports.joinReducers = joinReducers;
/**
 * Проверяет, имеет ли указанный FSA (Flux Standard Action) требуемый тип.
 * @param action action, который нужно проверить.
 * @param type требуемый тип action'а.
 * @template TPayload тип полезной нагрузки action'а.
 */
var is = function (action, type) { return action.type === type; };
/**
 * Создает фабрику action-creator'ов и reducer-creator'ов.
 * @param type тип action'а.
 * @template TPayload тип полезной нагрузки action'а.
 */
var createFactory = function (type) { return new GuardedFactory(type); };
exports.createFactory = createFactory;<commit_msg>Build ts<commit_after>"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var redux_actions_1 = require("redux-actions");
;
/**
 * Action creator's and reducer's factory. It contains current store brunch's type and action payload's type.
 * @template TState store's current brunch type.
 * @template TPayload action's payload type.
 */
var GuardedFactory = (function () {
    function GuardedFactory(type) {
        this._type = type;
        this._actionCreator = redux_actions_1.createAction(this._type.toString());
    }
    Object.defineProperty(GuardedFactory.prototype, "type", {
        get: function () {
            return this._type.toString();
        },
        enumerable: true,
        configurable: true
    });
    /**
     * Creates an action creator.
     * @param payload payload for an action.
     */
    GuardedFactory.prototype.createAction = function (payload) {
        return this._actionCreator(payload);
    };
    /**
     * Creates a reducer, bounded to concrete GuardedActionType.
     * @param reducer reducer.
     */
    GuardedFactory.prototype.createReducer = function (reducer, initialState) {
        var _this = this;
        var actionReducer = function (state, action) {
            if (is(action, _this._type))
                return reducer(state, action);
            return state || initialState;
        };
        return new GuardedReducer(this._type, actionReducer);
    };
    return GuardedFactory;
}());
exports.GuardedFactory = GuardedFactory;
var GuardedReducer = (function () {
    function GuardedReducer(type, reducer) {
        this._type = (type).toString();
        this._reducer = reducer;
    }
    Object.defineProperty(GuardedReducer.prototype, "reducer", {
        get: function () {
            return this._reducer;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GuardedReducer.prototype, "type", {
        get: function () {
            return this._type;
        },
        enumerable: true,
        configurable: true
    });
    return GuardedReducer;
}());
/**
* Join a set of reducers that work with same state's branch
* (unlike combine where each reducer work with different branches).
*
* You can register a defaultReducer that will be triggered even if an action
* was already processed. Please avoid such registrations.
* @param initialState initial state.
* @param actionReducers a set of reducers with GuardedActionType.
* @param defaultReducer default reducer.
*/
var joinReducers = function (initialState, actionReducers, defaultReducer) {
    var actionReducerMap = {};
    for (var _i = 0, actionReducers_1 = actionReducers; _i < actionReducers_1.length; _i++) {
        var actionReducer = actionReducers_1[_i];
        if (actionReducerMap[actionReducer.type] != null)
            throw new Error("Reducer with type \"" + actionReducer.type + "\" had already been registered.");
        actionReducerMap[actionReducer.type] = actionReducer.reducer;
    }
    var reducer = function (currentState, action) {
        if (currentState === void 0) { currentState = initialState; }
        var actionReducer = actionReducerMap[action.type];
        var nextState = currentState;
        if (actionReducer != null)
            nextState = actionReducer(nextState, action);
        if (defaultReducer != null)
            nextState = defaultReducer(nextState, action);
        return nextState;
    };
    return reducer;
};
exports.joinReducers = joinReducers;
/**
 * Check that FSA (Flux Standard Action) has required type.
 * @param action action to check.
 * @param type required action type.
 * @template TPayload action's payload type.
 */
var is = function (action, type) { return action.type === type; };
/**
 * Create action creator's and action reducer's factory.
 * @param type action's type.
 * @template TPayload action's payload type.
 */
var createFactory = function (type) { return new GuardedFactory(type); };
exports.createFactory = createFactory;
{'fraction_non_alphanumeric': 0.10761893114834291, 'fraction_numerical': 0.012229423994129877, 'mean_word_length': 3.056547619047619, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1621482', 'n_tokens_mistral': 2540, 'n_tokens_neox': 2469, 'n_words': 636}