Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.sortedindex

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.sortedindex - npm Package Compare versions

Comparing version 4.0.3 to 4.1.0

71

index.js

@@ -9,6 +9,6 @@ /**

*/
var baseSortedIndexBy = require('lodash._basesortedindexby');
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295,
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;

@@ -29,2 +29,6 @@

/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeFloor = Math.floor,
nativeMin = Math.min;
/**

@@ -64,2 +68,55 @@ * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which

/**
* The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
* which invokes `iteratee` for `value` and each element of `array` to compute
* their sort ranking. The iteratee is invoked with one argument; (value).
*
* @private
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @param {Function} iteratee The iteratee invoked per element.
* @param {boolean} [retHighest] Specify returning the highest qualified index.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
*/
function baseSortedIndexBy(array, value, iteratee, retHighest) {
value = iteratee(value);
var low = 0,
high = array ? array.length : 0,
valIsNaN = value !== value,
valIsNull = value === null,
valIsSymbol = isSymbol(value),
valIsUndefined = value === undefined;
while (low < high) {
var mid = nativeFloor((low + high) / 2),
computed = iteratee(array[mid]),
othIsDefined = computed !== undefined,
othIsNull = computed === null,
othIsReflexive = computed === computed,
othIsSymbol = isSymbol(computed);
if (valIsNaN) {
var setLow = retHighest || othIsReflexive;
} else if (valIsUndefined) {
setLow = othIsReflexive && (retHighest || othIsDefined);
} else if (valIsNull) {
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
} else if (valIsSymbol) {
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
} else if (othIsNull || othIsSymbol) {
setLow = false;
} else {
setLow = retHighest ? (computed <= value) : (computed < value);
}
if (setLow) {
low = mid + 1;
} else {
high = mid;
}
}
return nativeMin(high, MAX_ARRAY_INDEX);
}
/**
* Uses a binary search to determine the lowest index at which `value`

@@ -80,5 +137,2 @@ * should be inserted into `array` in order to maintain its sort order.

* // => 1
*
* _.sortedIndex([4, 5], 4);
* // => 0
*/

@@ -125,4 +179,3 @@ function sortedIndex(array, value) {

* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified,
* else `false`.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example

@@ -142,3 +195,3 @@ *

/**
* This method returns the first argument given to it.
* This method returns the first argument it receives.
*

@@ -153,5 +206,5 @@ * @static

*
* var object = { 'user': 'fred' };
* var object = { 'a': 1 };
*
* _.identity(object) === object;
* console.log(_.identity(object) === object);
* // => true

@@ -158,0 +211,0 @@ */

7

package.json
{
"name": "lodash.sortedindex",
"version": "4.0.3",
"version": "4.1.0",
"description": "The lodash method `_.sortedIndex` exported as a module.",

@@ -16,6 +16,3 @@ "homepage": "https://lodash.com/",

"repository": "lodash/lodash",
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" },
"dependencies": {
"lodash._basesortedindexby": "~4.0.0"
}
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }
}

@@ -1,2 +0,2 @@

# lodash.sortedindex v4.0.3
# lodash.sortedindex v4.1.0

@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.sortedIndex` exported as a [Node.js](https://nodejs.org/) module.

See the [documentation](https://lodash.com/docs#sortedIndex) or [package source](https://github.com/lodash/lodash/blob/4.0.3-npm-packages/lodash.sortedindex) for more details.
See the [documentation](https://lodash.com/docs#sortedIndex) or [package source](https://github.com/lodash/lodash/blob/4.1.0-npm-packages/lodash.sortedindex) for more details.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc