1 var createSortedIndex = require('../internal/createSortedIndex');
4 * Uses a binary search to determine the lowest index at which `value` should
5 * be inserted into `array` in order to maintain its sort order. If an iteratee
6 * function is provided it's invoked for `value` and each element of `array`
7 * to compute their sort ranking. The iteratee is bound to `thisArg` and
8 * invoked with one argument; (value).
10 * If a property name is provided for `iteratee` the created `_.property`
11 * style callback returns the property value of the given element.
13 * If a value is also provided for `thisArg` the created `_.matchesProperty`
14 * style callback returns `true` for elements that have a matching property
15 * value, else `false`.
17 * If an object is provided for `iteratee` the created `_.matches` style
18 * callback returns `true` for elements that have the properties of the given
19 * object, else `false`.
24 * @param {Array} array The sorted array to inspect.
25 * @param {*} value The value to evaluate.
26 * @param {Function|Object|string} [iteratee=_.identity] The function invoked
28 * @param {*} [thisArg] The `this` binding of `iteratee`.
29 * @returns {number} Returns the index at which `value` should be inserted
33 * _.sortedIndex([30, 50], 40);
36 * _.sortedIndex([4, 4, 5, 5], 5);
39 * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };
41 * // using an iteratee function
42 * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) {
43 * return this.data[word];
47 * // using the `_.property` callback shorthand
48 * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
51 var sortedIndex = createSortedIndex();
53 module.exports = sortedIndex;