Simplify inRange

This commit is contained in:
Siarhei
2018-09-03 10:27:11 +04:00
parent 1c0c9e2f46
commit 8573bb024a
2 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
const inRange = (n, start, end = null) => {
if (end && start > end) end = [start, (start = end)][0];
if (end && start > end) [end, start] = [start, end];
return end == null ? n >= 0 && n < start : n >= start && n < end;
};
module.exports = inRange;