@geekagency/redux-action-types
Version:
Action Types lib for redux (or anything)
54 lines (44 loc) • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.expandPrefix = exports.expandSuffix = exports.hold = exports.expand = exports.expandActionType = exports.groupAs = exports.combineActionTypes = exports.actionTypeValue = exports.actionType = exports.makeNamespaceEnhancer = void 0;
var c = _interopRequireWildcard(require("@geekagency/composite-js"));
var z = _interopRequireWildcard(require("@geekagency/composite-js/Combinator"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
var makeNamespaceEnhancer = c.curry(function (app, reducer, name) {
return "".concat(app, "/").concat(reducer, "/").concat(name);
});
exports.makeNamespaceEnhancer = makeNamespaceEnhancer;
var actionType = function actionType(key) {
return function (enhance) {
return z.asScalarPropWithDefaultValue(key)(key)(enhance);
};
};
exports.actionType = actionType;
var actionTypeValue = function actionTypeValue(key) {
return function (value) {
return function (enhance) {
return z.asScalarPropWithDefaultValue(key)(value)(enhance);
};
};
};
exports.actionTypeValue = actionTypeValue;
var combineActionTypes = z.combineObject;
exports.combineActionTypes = combineActionTypes;
var groupAs = z.makeCombineGroup(combineActionTypes);
exports.groupAs = groupAs;
var expandActionType = z.makeExpander(actionType); // Transformer -> Array -> String -> [String]
exports.expandActionType = expandActionType;
var expand = expandActionType;
exports.expand = expand;
var hold = z.makeFreezeEnhancer(combineActionTypes);
exports.hold = hold;
var expandSuffix = expand(function (t, s) {
return "".concat(t, "_").concat(s);
});
exports.expandSuffix = expandSuffix;
var expandPrefix = expand(function (t, s) {
return "".concat(s, "_").concat(t);
});
exports.expandPrefix = expandPrefix;