Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / array / sortedIndex.js
1 var createSortedIndex = require('../internal/createSortedIndex');
2
3 /**
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).
9  *
10  * If a property name is provided for `iteratee` the created `_.property`
11  * style callback returns the property value of the given element.
12  *
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`.
16  *
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`.
20  *
21  * @static
22  * @memberOf _
23  * @category Array
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
27  *  per iteration.
28  * @param {*} [thisArg] The `this` binding of `iteratee`.
29  * @returns {number} Returns the index at which `value` should be inserted
30  *  into `array`.
31  * @example
32  *
33  * _.sortedIndex([30, 50], 40);
34  * // => 1
35  *
36  * _.sortedIndex([4, 4, 5, 5], 5);
37  * // => 2
38  *
39  * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };
40  *
41  * // using an iteratee function
42  * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) {
43  *   return this.data[word];
44  * }, dict);
45  * // => 1
46  *
47  * // using the `_.property` callback shorthand
48  * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
49  * // => 1
50  */
51 var sortedIndex = createSortedIndex();
52
53 module.exports = sortedIndex;