fun/array/index-on
Given an array, fun/array/index-on will return a new function, which when given a predicate function will return the index of the first item in the array to match the predicate.
Syntax
index = indexOn(arr)(predicate)
Parameters
arrThe array to search through.predicateA predicate function to shortcut the search once an item has been found. The function should take one parameter:itemThe iterated item. The predicate function should returntrueifitemmatches the predicate.
Examples
var a = [ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
var q = indexOn(a)
q(function(x) { return x === 1 }) // 5