fox-slack-block-builder
Version:
Maintainable code for interactive Slack messages, modals, home tabs, and workflow steps. A must-have for the Slack Block Kit framework.
30 lines (29 loc) • 997 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.conditionals = exports.omitIfFalsy = exports.setIfFalsy = exports.omitIfTruthy = exports.setIfTruthy = void 0;
const falsyValues = [undefined, null, false];
const falsy = (value) => falsyValues.includes(value);
const truthy = (value) => !falsyValues.includes(value);
function setIfTruthy(condition, toSet) {
return truthy(condition) ? toSet : undefined;
}
exports.setIfTruthy = setIfTruthy;
function omitIfTruthy(condition, toOmit) {
return truthy(condition) ? undefined : toOmit;
}
exports.omitIfTruthy = omitIfTruthy;
function setIfFalsy(condition, toSet) {
return falsy(condition) ? toSet : undefined;
}
exports.setIfFalsy = setIfFalsy;
function omitIfFalsy(condition, toOmit) {
return falsy(condition) ? undefined : toOmit;
}
exports.omitIfFalsy = omitIfFalsy;
const conditionals = {
setIfTruthy,
omitIfTruthy,
setIfFalsy,
omitIfFalsy,
};
exports.conditionals = conditionals;
;