@bemedev/basifun
Version:
Basic ts functions
25 lines (22 loc) • 634 B
JavaScript
;
const maxLength = (max, value) => {
return maxLength.normal(max, value);
};
maxLength.checker = (max, value) => value.length < max;
maxLength.low = (max, value) => {
const bool = maxLength.checker(max, value);
return {
bool,
value,
};
};
maxLength.normal = (max, _value) => {
const { bool, value } = maxLength.low(max, _value);
if (!bool)
throw new Error(`"${value}" is greater or equal than ${max}`);
return value;
};
maxLength.strict = maxLength.normal;
maxLength.strictest = maxLength.strict;
exports.maxLength = maxLength;
//# sourceMappingURL=maxLength.cjs.map