mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Avoid more coercion.
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -5454,7 +5454,7 @@
|
||||
var func = Math[methodName];
|
||||
return function(number, precision) {
|
||||
number = toNumber(number);
|
||||
precision = nativeMin(toInteger(precision), 292);
|
||||
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
|
||||
if (precision) {
|
||||
// Shift with exponential notation to avoid floating-point issues.
|
||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||
@@ -10852,7 +10852,7 @@
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
|
||||
start = start == null ? 0 : nativeMax(toInteger(start), 0);
|
||||
return baseRest(function(args) {
|
||||
var array = args[start],
|
||||
otherArgs = castSlice(args, 0, start);
|
||||
@@ -12542,7 +12542,9 @@
|
||||
* // => 3
|
||||
*/
|
||||
function toSafeInteger(value) {
|
||||
return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
|
||||
return value
|
||||
? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
|
||||
: (value === 0 ? value : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -14631,7 +14633,7 @@
|
||||
*/
|
||||
function startsWith(string, target, position) {
|
||||
string = toString(string);
|
||||
position = position === undefined
|
||||
position = position == null
|
||||
? 0
|
||||
: baseClamp(toInteger(position), 0, string.length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user