UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

29 lines (28 loc) 916 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.sortedIndex = void 0; const baseSortedIndex_1 = __importDefault(require("./.internal/baseSortedIndex")); /** * Uses a binary search to determine the lowest index at which `value` * should be inserted into `array` in order to maintain its sort order. * * @since 5.11.0 * @category Array * @param array The sorted array to inspect. * @param value The value to evaluate. * @returns Returns the index at which `value` should be inserted into `array`. * @example * * ```js * sortedIndex([30, 50], 40) * // => 1 * ``` */ function sortedIndex(array, value) { return (0, baseSortedIndex_1.default)(array, value); } exports.sortedIndex = sortedIndex; exports.default = sortedIndex;