Coerce drop and dropRight n param using toInteger (#4412)

* Coerce dropRight n param using toInteger

* Coerce drop n param using toInteger
This commit is contained in:
Luiz Américo
2019-08-16 19:52:06 -03:00
committed by John-David Dalton
parent a965836cf3
commit 37cd5dc97a
4 changed files with 5 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
import slice from './slice.js'
import toInteger from './toInteger.js'
/**
* Creates a slice of `array` with `n` elements dropped from the beginning.
@@ -25,7 +26,7 @@ import slice from './slice.js'
function drop(array, n=1) {
const length = array == null ? 0 : array.length
return length
? slice(array, n < 0 ? 0 : n, length)
? slice(array, n < 0 ? 0 : toInteger(n), length)
: []
}