@@ -2,7 +2,7 @@ import isNumber from "../is/number.js";
22import clamp from "../math/clamp.js" ;
33import 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