mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
Math them all.
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeMax = Math.max
|
||||
const nativeMin = Math.min
|
||||
|
||||
/**
|
||||
* The base implementation of `inRange` which doesn't coerce arguments.
|
||||
*
|
||||
@@ -12,7 +8,7 @@ const nativeMin = Math.min
|
||||
* @returns {boolean} Returns `true` if `number` is in the range, else `false`.
|
||||
*/
|
||||
function baseInRange(number, start, end) {
|
||||
return number >= nativeMin(start, end) && number < nativeMax(start, end)
|
||||
return number >= Math.min(start, end) && number < Math.max(start, end)
|
||||
}
|
||||
|
||||
export default baseInRange
|
||||
|
||||
@@ -4,9 +4,6 @@ import arrayIncludesWith from './arrayIncludesWith.js'
|
||||
import arrayMap from './arrayMap.js'
|
||||
import cacheHas from './cacheHas.js'
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeMin = Math.min
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `intersection` that accepts an
|
||||
* array of arrays to inspect.
|
||||
@@ -33,7 +30,7 @@ function baseIntersection(arrays, iteratee, comparator) {
|
||||
if (othIndex && iteratee) {
|
||||
array = arrayMap(array, (value) => iteratee(value))
|
||||
}
|
||||
maxLength = nativeMin(array.length, maxLength)
|
||||
maxLength = Math.min(array.length, maxLength)
|
||||
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
|
||||
? new SetCache(othIndex && array)
|
||||
: undefined
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeCeil = Math.ceil
|
||||
const nativeMax = Math.max
|
||||
|
||||
/**
|
||||
* The base implementation of `range` and `rangeRight` which doesn't
|
||||
* coerce arguments.
|
||||
@@ -15,7 +11,7 @@ const nativeMax = Math.max
|
||||
*/
|
||||
function baseRange(start, end, step, fromRight) {
|
||||
let index = -1
|
||||
let length = nativeMax(nativeCeil((end - start) / (step || 1)), 0)
|
||||
let length = Math.max(Math.ceil((end - start) / (step || 1)), 0)
|
||||
const result = new Array(length)
|
||||
|
||||
while (length--) {
|
||||
|
||||
@@ -4,9 +4,6 @@ import isSymbol from '../isSymbol.js'
|
||||
const MAX_ARRAY_LENGTH = 4294967295
|
||||
const MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeFloor = Math.floor, nativeMin = Math.min
|
||||
|
||||
/**
|
||||
* The base implementation of `sortedIndexBy` and `sortedLastIndexBy`
|
||||
* which invokes `iteratee` for `value` and each element of `array` to compute
|
||||
@@ -32,7 +29,7 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
||||
|
||||
while (low < high) {
|
||||
let setLow
|
||||
const mid = nativeFloor((low + high) / 2)
|
||||
const mid = Math.floor((low + high) / 2)
|
||||
const computed = iteratee(array[mid])
|
||||
const othIsDefined = computed !== undefined
|
||||
const othIsNull = computed === null
|
||||
@@ -58,7 +55,7 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
||||
high = mid
|
||||
}
|
||||
}
|
||||
return nativeMin(high, MAX_ARRAY_INDEX)
|
||||
return Math.min(high, MAX_ARRAY_INDEX)
|
||||
}
|
||||
|
||||
export default baseSortedIndexBy
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeMax = Math.max
|
||||
|
||||
/**
|
||||
* Creates an array that is the composition of partially applied arguments,
|
||||
* placeholders, and provided arguments into a single array of arguments.
|
||||
@@ -19,7 +16,7 @@ function composeArgs(args, partials, holders, isCurried) {
|
||||
|
||||
let argsIndex = -1
|
||||
let leftIndex = -1
|
||||
let rangeLength = nativeMax(argsLength - holdersLength, 0)
|
||||
let rangeLength = Math.max(argsLength - holdersLength, 0)
|
||||
|
||||
const result = new Array(leftLength + rangeLength)
|
||||
const isUncurried = !isCurried
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeMax = Math.max
|
||||
|
||||
/**
|
||||
* This function is like `composeArgs` except that the arguments composition
|
||||
* is tailored for `partialRight`.
|
||||
@@ -20,7 +17,7 @@ function composeArgsRight(args, partials, holders, isCurried) {
|
||||
const argsLength = args.length
|
||||
const holdersLength = holders.length
|
||||
const rightLength = partials.length
|
||||
const rangeLength = nativeMax(argsLength - holdersLength, 0)
|
||||
const rangeLength = Math.max(argsLength - holdersLength, 0)
|
||||
const result = new Array(rangeLength + rightLength)
|
||||
const isUncurried = !isCurried
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ import hasUnicode from './hasUnicode.js'
|
||||
import stringSize from './stringSize.js'
|
||||
import stringToArray from './stringToArray.js'
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeCeil = Math.ceil
|
||||
|
||||
/**
|
||||
* Creates the padding for `string` based on `length`. The `chars` string
|
||||
* is truncated if the number of characters exceeds `length`.
|
||||
@@ -24,7 +21,7 @@ function createPadding(length, chars) {
|
||||
if (charsLength < 2) {
|
||||
return charsLength ? baseRepeat(chars, length) : chars
|
||||
}
|
||||
const result = baseRepeat(chars, nativeCeil(length / stringSize(chars)))
|
||||
const result = baseRepeat(chars, Math.ceil(length / stringSize(chars)))
|
||||
return hasUnicode(chars)
|
||||
? castSlice(stringToArray(result), 0, length).join('')
|
||||
: result.slice(0, length)
|
||||
|
||||
@@ -13,9 +13,6 @@ const WRAP_CURRY_FLAG = 8
|
||||
const WRAP_ARY_FLAG = 128
|
||||
const WRAP_REARG_FLAG = 256
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeMin = Math.min
|
||||
|
||||
/**
|
||||
* Merges the function metadata of `source` into `data`.
|
||||
*
|
||||
@@ -76,7 +73,7 @@ function mergeData(data, source) {
|
||||
}
|
||||
// Use source `ary` if it's smaller.
|
||||
if (srcBitmask & WRAP_ARY_FLAG) {
|
||||
data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8])
|
||||
data[8] = data[8] == null ? source[8] : Math.min(data[8], source[8])
|
||||
}
|
||||
// Use source `arity` if one is not provided.
|
||||
if (data[9] == null) {
|
||||
|
||||
Reference in New Issue
Block a user