UNPKG
@extra-array/drop-while-right
Version:
latest (2.10.19)
2.10.19
2.10.18
2.10.17
2.10.16
2.10.15
2.10.14
2.10.13
2.10.12
2.10.11
2.10.10
2.10.9
2.10.8
2.10.7
2.10.6
2.10.5
2.10.4
2.10.2
2.10.1
2.10.0
2.9.64
2.9.63
2.9.62
2.9.61
2.9.60
2.9.59
2.9.58
2.9.57
2.9.56
2.9.55
2.9.54
2.9.53
2.9.52
2.9.51
2.9.50
2.9.49
2.9.48
2.9.47
2.9.46
2.9.45
2.9.44
2.9.43
2.9.42
Discards values from right, while a test passes.
github.com/nodef/extra-array
nodef/extra-array
@extra-array/drop-while-right
/
index.mjs
11 lines
(10 loc)
•
263 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
function
scanUntilRight
(
x, ft
) {
for
(
var
i = x.
length
-
1
; i >=
0
; i--)
if
(
ft
(x[i], i, x))
break
;
return
i +
1
; }
function
dropWhileRight
(
x, ft
) {
return
x.
slice
(
0
,
scanUntilRight
(x, ft)); }
export
{ dropWhileRight
as
default
};