typedash
Version:
modern, type-safe collection of utility functions
20 lines (18 loc) • 572 B
JavaScript
;
// src/functions/inRange/inRange.ts
function inRange(value, range, options) {
const [start, end] = range;
const { inclusive = "start" } = options ?? {};
if (start > end) {
throw new RangeError(`Invalid range: [${start},${end}]`);
}
return {
true: () => value >= start && value <= end,
false: () => value > start && value < end,
start: () => value >= start && value < end,
end: () => value > start && value <= end
}[inclusive]();
}
exports.inRange = inRange;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.cjs.map