react-application-core
Version:
A react-based application core for the business applications.
52 lines • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StackUtils = exports.truncateStack = exports.findStackItemEntityIndexBySection = void 0;
var R = require("ramda");
var select_1 = require("./select");
/**
* @stable [19.12.2019]
* @param {string} currentSection
* @param {IReduxStackEntity} stackEntity
* @returns {number}
*/
exports.findStackItemEntityIndexBySection = function (currentSection, stackEntity) {
return R.findIndex(function (entry) { return entry.section === currentSection; }, stackEntity.stack);
};
/**
* @stable [19.12.2019]
* @param {IReduxStackEntity} stackEntity
* @param {string} section
* @returns {IReduxStackItemEntity[]}
*/
exports.truncateStack = function (stackEntity, section) {
return stackEntity
.stack
.slice(0, exports.findStackItemEntityIndexBySection(section, stackEntity) + 1);
};
/**
* @stable [21.05.2020]
* @param {IReduxStackEntity} entity
* @returns {boolean}
*/
var doesStackEntityContainChildren = function (entity) {
return (select_1.Selectors.stack(entity) || []).length > 1;
};
/**
* @stable [21.05.2020]
* @param {IReduxStackHolderEntity} entity
* @returns {boolean}
*/
var doesHolderStackEntityContainChildren = function (entity) {
return doesStackEntityContainChildren(select_1.Selectors.stack(entity));
};
/**
* @stable [21.05.2020]
*/
var StackUtils = /** @class */ (function () {
function StackUtils() {
}
StackUtils.doesHolderStackEntityContainChildren = doesHolderStackEntityContainChildren; /* @stable [21.05.2020] */
return StackUtils;
}());
exports.StackUtils = StackUtils;
//# sourceMappingURL=stack.js.map