summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/lodash/internal/createSortedIndex.js
blob: 86c78520c9bc7359c2667693fba13109cc1412ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var baseCallback = require('./baseCallback'),
    binaryIndex = require('./binaryIndex'),
    binaryIndexBy = require('./binaryIndexBy');

/**
 * Creates a `_.sortedIndex` or `_.sortedLastIndex` function.
 *
 * @private
 * @param {boolean} [retHighest] Specify returning the highest qualified index.
 * @returns {Function} Returns the new index function.
 */
function createSortedIndex(retHighest) {
  return function(array, value, iteratee, thisArg) {
    return iteratee == null
      ? binaryIndex(array, value, retHighest)
      : binaryIndexBy(array, value, baseCallback(iteratee, thisArg, 1), retHighest);
  };
}

module.exports = createSortedIndex;