Remove baseClamp.

This commit is contained in:
John-David Dalton
2017-03-11 21:44:14 -08:00
parent fa8c607742
commit 3b302b822c
6 changed files with 45 additions and 38 deletions

View File

@@ -1,4 +1,3 @@
import baseClamp from './.internal/baseClamp.js'
import toInteger from './toInteger.js'
/** Used as references for the maximum length and index of an array. */
@@ -30,7 +29,17 @@ const MAX_ARRAY_LENGTH = 4294967295
* // => 3
*/
function toLength(value) {
return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0
if (!value) {
return 0
}
value = toInteger(value)
if (value < 0) {
return 0
}
if (value > MAX_ARRAY_LENGTH) {
return MAX_ARRAY_LENGTH
}
return value
}
export default toLength