sortedIndexBy
arrayThis method is like sortedIndex except that it accepts iteratee which is invoked for value and each element of array to compute their sort ranking.
Signature
sortedIndexBy<T, U>(array: T[], value: T, iteratee: (value: T) => U): numberParameters
| Name | Type | Description |
|---|---|---|
array | T[] | The sorted array to inspect |
value | T | The value to evaluate |
iteratee | (value: T) => U | The iteratee invoked per element |
Returns
number - Returns the index at which value should be inserted into array
Examples
With iteratee
import { sortedIndexBy } from 'dashlite'
const objects = [{ x: 4 }, { x: 5 }]
const result = sortedIndexBy(objects, { x: 4 }, (o) => o.x)
console.log(result)Output:
0Available since version 1.0.0