Skip to content

Commit f3dc2a2

Browse files
Fix range/split recursion and make clamp calls consistent
1 parent c31632d commit f3dc2a2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

date/clamp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default ([min, max]) => dateStringOrDate => {
1+
export default (min, max) => dateStringOrDate => {
22
const date = new Date(dateStringOrDate);
33
const clamped = new Date(
44
Math.min(max.valueOf(), Math.max(min.valueOf(), date.valueOf()))

range/split.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import isNumber from "../is/number.js";
22
import clamp from "../math/clamp.js";
33
import empty from "./empty.js";
44

5-
export default (used, sourceRange = [-Infinity, Infinity]) => range => {
5+
const split = (used, sourceRange = [-Infinity, Infinity]) => range => {
66
if (empty(range) || !range.every(isNumber)) {
77
return [];
88
}
@@ -19,20 +19,22 @@ export default (used, sourceRange = [-Infinity, Infinity]) => range => {
1919
}
2020

2121
const [sourceMin, sourceMax] = sourceRange;
22-
const clampToSourceRange = clamp(sourceRange);
22+
const clampToSourceRange = clamp(...sourceRange);
2323

2424
const freeLeft = [sourceMin, usedMin].map(clampToSourceRange);
2525
const freeRight = [usedMax, sourceMax].map(clampToSourceRange);
2626

27-
const clampLeft = clamp(freeLeft);
27+
const clampLeft = clamp(...freeLeft);
2828
const clampedLeft = range.map(clampLeft);
2929

3030
const lefts = split(xs, sourceRange)(clampedLeft);
3131

32-
const clampRight = clamp(freeRight);
32+
const clampRight = clamp(...freeRight);
3333
const clampedRight = range.map(clampRight);
3434

3535
const rights = split(xs, sourceRange)(clampedRight);
3636

3737
return [...lefts, ...rights].filter(range => !empty(range));
3838
};
39+
40+
export default split;

0 commit comments

Comments
 (0)