PageRenderTime 23ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/lodash/sortedIndexBy.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 33 lines | 6 code | 2 blank | 25 comment | 0 complexity | a8ce87b2d628d16f6a579769d78d6c62 MD5 | raw file
 1var baseIteratee = require('./_baseIteratee'),
 2    baseSortedIndexBy = require('./_baseSortedIndexBy');
 3
 4/**
 5 * This method is like `_.sortedIndex` except that it accepts `iteratee`
 6 * which is invoked for `value` and each element of `array` to compute their
 7 * sort ranking. The iteratee is invoked with one argument: (value).
 8 *
 9 * @static
10 * @memberOf _
11 * @since 4.0.0
12 * @category Array
13 * @param {Array} array The sorted array to inspect.
14 * @param {*} value The value to evaluate.
15 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16 * @returns {number} Returns the index at which `value` should be inserted
17 *  into `array`.
18 * @example
19 *
20 * var objects = [{ 'x': 4 }, { 'x': 5 }];
21 *
22 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
23 * // => 0
24 *
25 * // The `_.property` iteratee shorthand.
26 * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
27 * // => 0
28 */
29function sortedIndexBy(array, value, iteratee) {
30  return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
31}
32
33module.exports = sortedIndexBy;