UNPKG
imma
Version:
latest (0.0.1)
0.0.1
A collection of functions for dealing with native arrays and objects immutably
imma
/
lib
/
array
/
findLastEntry.js
10 lines
(9 loc)
•
295 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
'use strict'
const
findLastEntry =
module
.
exports
=
(
array, fn
) =>
{
for
(
let
index = array.
length
-
1
; index >=
0
; index--) {
// Skip sparse entries
if
(!(index
in
array))
continue
const
value = array[index]
if
(
fn
(value, index, array))
return
[ index, value ] } }