indexof-property
Compiles an optimized indexof function for a known property.
//let's search for the 'name' propertyvar indexOf = 'name' var list = name: 'foo' data: 5 name: 'bar' data: 10 name: 'beep' data: 0 name: 'foobar' data: -5 name: 'beep' data: 20 // prints 2console // prints -1console // prints 4console
The function compiles with bracket notation to support unusual property names, e.g. "border-radius"
.
Usage
require('indexof-property')(property)
Compiles a new function that searches for the specified property
name. The new function has the signature:
i = indexOf(array, value[, start])
Which searches for the first strictly equal match to value
and returns that index, or -1 if none was found. The start
index defaults to zero if unspecified.
License
MIT, see LICENSE.md for details.