mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
Rebuild dist.
This commit is contained in:
273
dist/lodash.compat.js
vendored
273
dist/lodash.compat.js
vendored
@@ -25,7 +25,7 @@
|
||||
PARTIAL_RIGHT_FLAG = 64;
|
||||
|
||||
/** Used as the property name for wrapper metadata */
|
||||
var EXPANDO = '__lodash@' + VERSION + '__';
|
||||
var EXPANDO = '__lodash_' + VERSION.replace(/[-.]/g, '_') + '__';
|
||||
|
||||
/** Used as the TypeError message for "Functions" methods */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -40,6 +40,9 @@
|
||||
*/
|
||||
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
||||
|
||||
/** Used as the internal argument placeholder */
|
||||
var PLACEHOLDER = '__lodash_placeholder__';
|
||||
|
||||
/** Used to generate unique IDs */
|
||||
var idCounter = 0;
|
||||
|
||||
@@ -129,7 +132,7 @@
|
||||
];
|
||||
|
||||
/** Used to make template sourceURLs easier to identify */
|
||||
var templateCounter = 0;
|
||||
var templateCounter = -1;
|
||||
|
||||
/** `Object#toString` result references */
|
||||
var argsClass = '[object Arguments]',
|
||||
@@ -426,7 +429,7 @@
|
||||
* @returns {number} Returns the sort order indicator for `object`.
|
||||
*/
|
||||
function compareAscending(object, other) {
|
||||
return baseCompareAscending(object.criteria, other.criteria) || object.index - other.index;
|
||||
return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,7 +664,6 @@
|
||||
bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
|
||||
ceil = Math.ceil,
|
||||
clearTimeout = context.clearTimeout,
|
||||
Float64Array = isNative(Float64Array = context.Float64Array) && Float64Array,
|
||||
floor = Math.floor,
|
||||
getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
||||
hasOwnProperty = objectProto.hasOwnProperty,
|
||||
@@ -670,8 +672,19 @@
|
||||
Set = isNative(Set = context.Set) && Set,
|
||||
setTimeout = context.setTimeout,
|
||||
splice = arrayProto.splice,
|
||||
Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array,
|
||||
unshift = arrayProto.unshift;
|
||||
Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array;
|
||||
|
||||
/** Used to clone array buffers */
|
||||
var Float64Array = (function() {
|
||||
// Safari 5 errors when using an array buffer to initialize a typed array
|
||||
// where the array buffer's `byteLength` is not a multiple of the typed
|
||||
// array's `BYTES_PER_ELEMENT`
|
||||
try {
|
||||
var func = isNative(func = context.Float64Array) && func,
|
||||
result = new func(new ArrayBuffer(10), 0, 1) && func;
|
||||
} catch(e) { }
|
||||
return result;
|
||||
}());
|
||||
|
||||
/** Used to set metadata on functions */
|
||||
var defineProperty = (function() {
|
||||
@@ -698,7 +711,7 @@
|
||||
nativeRandom = Math.random;
|
||||
|
||||
/** Used as the size, in bytes, of each Float64Array element */
|
||||
var FLOAT64_BYTES_PER_ELEMENT = Float64Array && Float64Array.BYTES_PER_ELEMENT;
|
||||
var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
|
||||
|
||||
/** Used to lookup a built-in constructor by [[Class]] */
|
||||
var ctorByClass = {};
|
||||
@@ -988,8 +1001,7 @@
|
||||
* @type boolean
|
||||
*/
|
||||
try {
|
||||
support.nonEnumArgs = !(argsKey == '1' && hasOwnProperty.call(arguments, argsKey) &&
|
||||
propertyIsEnumerable.call(arguments, argsKey));
|
||||
support.nonEnumArgs = !(hasOwnProperty.call(arguments, 1) && propertyIsEnumerable.call(arguments, 1));
|
||||
} catch(e) {
|
||||
support.nonEnumArgs = true;
|
||||
}
|
||||
@@ -1058,26 +1070,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Appends placeholder indexes to `array` adding `offset` to each appended index.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array of placeholder indexes to append to.
|
||||
* @param {Array} indexes The array of placeholder indexes to append.
|
||||
* @param {number} offset The placeholder offset.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function appendHolders(array, indexes, offset) {
|
||||
var length = array.length,
|
||||
index = indexes.length;
|
||||
|
||||
array.length += index;
|
||||
while (index--) {
|
||||
array[length + index] = indexes[index] + offset;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `_.forEach` for arrays without support for
|
||||
* callback shorthands or `this` binding.
|
||||
@@ -1589,7 +1581,7 @@
|
||||
}
|
||||
if (isCurry || isCurryRight) {
|
||||
var placeholder = wrapper.placeholder,
|
||||
newPartialHolders = getHolders(args, placeholder);
|
||||
newPartialHolders = replaceHolders(args, placeholder);
|
||||
|
||||
length -= newPartialHolders.length;
|
||||
|
||||
@@ -1700,7 +1692,7 @@
|
||||
iterable = toIterable(collection);
|
||||
|
||||
while (++index < length) {
|
||||
if (iterator(iterable[index], index, collection) === false) {
|
||||
if (iterator(iterable[index], index, iterable) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1723,7 +1715,7 @@
|
||||
}
|
||||
var iterable = toIterable(collection);
|
||||
while (length--) {
|
||||
if (iterator(iterable[length], length, collection) === false) {
|
||||
if (iterator(iterable[length], length, iterable) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1809,7 +1801,7 @@
|
||||
function baseFlatten(array, isDeep, isStrict, fromIndex) {
|
||||
var index = (fromIndex || 0) - 1,
|
||||
length = array.length,
|
||||
resIndex = 0,
|
||||
resIndex = -1,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
@@ -1826,10 +1818,10 @@
|
||||
|
||||
result.length += valLength;
|
||||
while (++valIndex < valLength) {
|
||||
result[resIndex++] = value[valIndex];
|
||||
result[++resIndex] = value[valIndex];
|
||||
}
|
||||
} else if (!isStrict) {
|
||||
result[resIndex++] = value;
|
||||
result[++resIndex] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -2407,11 +2399,19 @@
|
||||
high = array ? array.length : low;
|
||||
|
||||
value = iterator(value);
|
||||
var hintNum = typeof value == 'number' ||
|
||||
(value != null && isFunction(value.valueOf) && typeof value.valueOf() == 'number');
|
||||
|
||||
while (low < high) {
|
||||
var mid = (low + high) >>> 1,
|
||||
computed = iterator(array[mid]);
|
||||
computed = iterator(array[mid]),
|
||||
setLow = retHighest ? computed <= value : computed < value;
|
||||
|
||||
if (retHighest ? computed <= value : computed < value) {
|
||||
if (hintNum && typeof computed != 'undefined') {
|
||||
computed = +computed;
|
||||
setLow = computed != computed || setLow;
|
||||
}
|
||||
if (setLow) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
high = mid;
|
||||
@@ -2821,29 +2821,21 @@
|
||||
}
|
||||
// append partial left arguments
|
||||
if (isPartial) {
|
||||
var partialHolders = data[5],
|
||||
funcPartialArgs = funcData[4];
|
||||
|
||||
var funcPartialArgs = funcData[4];
|
||||
if (funcPartialArgs) {
|
||||
appendHolders(funcData[5], partialHolders, funcPartialArgs.length);
|
||||
push.apply(funcPartialArgs, partialArgs);
|
||||
} else {
|
||||
funcData[4] = partialArgs;
|
||||
funcData[5] = partialHolders;
|
||||
funcPartialArgs = composeArgs(funcPartialArgs, funcData[5], partialArgs);
|
||||
}
|
||||
funcData[4] = funcPartialArgs || partialArgs;
|
||||
funcData[5] = funcPartialArgs ? replaceHolders(funcPartialArgs, PLACEHOLDER) : data[5];
|
||||
}
|
||||
// prepend partial right arguments
|
||||
if (isPartialRight) {
|
||||
var partialRightHolders = data[7],
|
||||
funcPartialRightArgs = funcData[6];
|
||||
|
||||
var funcPartialRightArgs = funcData[6];
|
||||
if (funcPartialRightArgs) {
|
||||
appendHolders(funcData[7], partialRightHolders, funcPartialRightArgs.length);
|
||||
unshift.apply(funcPartialRightArgs, partialRightArgs);
|
||||
} else {
|
||||
funcData[6] = partialRightArgs;
|
||||
funcData[7] = partialRightHolders;
|
||||
funcPartialRightArgs = composeArgsRight(funcPartialRightArgs, funcData[7], partialRightArgs);
|
||||
}
|
||||
funcData[6] = funcPartialRightArgs || partialRightArgs;
|
||||
funcData[7] = funcPartialRightArgs ? replaceHolders(funcPartialRightArgs, PLACEHOLDER) : data[7];
|
||||
}
|
||||
// merge flags
|
||||
funcData[1] |= bitmask;
|
||||
@@ -2871,26 +2863,6 @@
|
||||
return arguments.length ? result(func, thisArg, argCount) : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the indexes of all placeholder elements in `array`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @returns {Array} Returns the new array of placeholder indexes.
|
||||
*/
|
||||
function getHolders(array, placeholder) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === placeholder) {
|
||||
result.push(index);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
||||
* customized this function returns the custom method, otherwise it returns
|
||||
@@ -2974,6 +2946,29 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all `placeholder` elements in `array` with an internal placeholder
|
||||
* and returns an array of their indexes.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to modify.
|
||||
* @param {*} placeholder The placeholder to replace.
|
||||
* @returns {Array} Returns the new array of placeholder indexes.
|
||||
*/
|
||||
function replaceHolders(array, placeholder) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === placeholder) {
|
||||
array[index] = PLACEHOLDER;
|
||||
result.push(index);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets wrapper metadata on a given function.
|
||||
*
|
||||
@@ -3088,20 +3083,39 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `collection` to an array if it is not an array-like value.
|
||||
* Converts `value` to an array-like object if it is not one.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object|string} collection The collection to process.
|
||||
* @returns {Array} Returns the iterable object.
|
||||
* @param {*} value The value to process.
|
||||
* @returns {Array|Object} Returns the array-like object.
|
||||
*/
|
||||
function toIterable(collection) {
|
||||
var length = collection ? collection.length : 0;
|
||||
if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) {
|
||||
return values(collection);
|
||||
} else if (support.unindexedChars && isString(collection)) {
|
||||
return collection.split('');
|
||||
function toIterable(value) {
|
||||
if (value == null) {
|
||||
return [];
|
||||
}
|
||||
return collection || [];
|
||||
var length = value.length;
|
||||
if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) {
|
||||
return values(value);
|
||||
}
|
||||
value = toObject(value);
|
||||
if (support.unindexedChars && isString(value)) {
|
||||
var index = -1;
|
||||
while (++index < length) {
|
||||
value[index] = value.charAt(index);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `value` to an object if it is not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {Object} Returns the object.
|
||||
*/
|
||||
function toObject(value) {
|
||||
return isObject(value) ? value : Object(value);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -3154,13 +3168,13 @@
|
||||
function compact(array) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0,
|
||||
resIndex = 0,
|
||||
resIndex = -1,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (value) {
|
||||
result[resIndex++] = value;
|
||||
result[++resIndex] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -3275,7 +3289,7 @@
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|string} [predicate=identity] The function called
|
||||
* per element.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
@@ -3324,6 +3338,7 @@
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|string} [predicate=identity] The function called
|
||||
* per element.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
@@ -3863,21 +3878,17 @@
|
||||
|
||||
start = start == null ? 0 : (+start || 0);
|
||||
if (start < 0) {
|
||||
start = nativeMax(length + start, 0);
|
||||
} else if (start > length) {
|
||||
start = length;
|
||||
start = -start > length ? 0 : (length + start);
|
||||
}
|
||||
end = typeof end == 'undefined' ? length : (+end || 0);
|
||||
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
||||
if (end < 0) {
|
||||
end = nativeMax(length + end, 0);
|
||||
} else if (end > length) {
|
||||
end = length;
|
||||
end += length;
|
||||
}
|
||||
length = start > end ? 0 : (end - start);
|
||||
|
||||
var result = Array(length);
|
||||
while (++index < length) {
|
||||
result[index] = array[start + index];
|
||||
result[index] = array[index + start];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -4039,6 +4050,7 @@
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|string} [predicate=identity] The function called
|
||||
* per element.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
@@ -4087,6 +4099,7 @@
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|string} [predicate=identity] The function called
|
||||
* per element.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
@@ -4575,7 +4588,7 @@
|
||||
* // => { '3': 2, '5': 1 }
|
||||
*/
|
||||
var countBy = createAggregator(function(result, value, key) {
|
||||
(hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
|
||||
hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -4628,7 +4641,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over elements of `collection` returning an array of all elements
|
||||
* Iterates over elements of `collection`, returning an array of all elements
|
||||
* the predicate returns truthy for. The predicate is bound to `thisArg` and
|
||||
* invoked with three arguments; (value, index|key, collection).
|
||||
*
|
||||
@@ -4919,7 +4932,7 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* Invokes the method named by `methodName` on each element in the collection
|
||||
* Invokes the method named by `methodName` on each element in the collection,
|
||||
* returning an array of the results of each invoked method. Additional arguments
|
||||
* is provided to each invoked method. If `methodName` is a function it is
|
||||
* invoked for, and `this` bound to, each element in the collection.
|
||||
@@ -5346,10 +5359,9 @@
|
||||
* // => [3, 1]
|
||||
*/
|
||||
function sample(collection, n, guard) {
|
||||
collection = toIterable(collection);
|
||||
|
||||
var length = collection.length;
|
||||
if (n == null || guard) {
|
||||
collection = toIterable(collection);
|
||||
var length = collection.length;
|
||||
return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;
|
||||
}
|
||||
var result = shuffle(collection);
|
||||
@@ -5563,8 +5575,13 @@
|
||||
* // => [2, 3, 4]
|
||||
*/
|
||||
function toArray(collection) {
|
||||
var iterable = toIterable(collection);
|
||||
return iterable === collection ? slice(collection) : iterable;
|
||||
var length = collection ? collection.length : 0;
|
||||
if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) {
|
||||
return (support.unindexedChars && isString(collection))
|
||||
? collection.split('')
|
||||
: slice(collection);
|
||||
}
|
||||
return values(collection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5695,7 +5712,7 @@
|
||||
return createWrapper([func, BIND_FLAG, null, thisArg]);
|
||||
}
|
||||
var args = slice(arguments, 2),
|
||||
partialHolders = getHolders(args, bind.placeholder);
|
||||
partialHolders = replaceHolders(args, bind.placeholder);
|
||||
|
||||
return basePartial(func, BIND_FLAG | PARTIAL_FLAG, args, partialHolders, thisArg);
|
||||
}
|
||||
@@ -5773,7 +5790,7 @@
|
||||
var data = [key, BIND_FLAG | BIND_KEY_FLAG, null, object];
|
||||
if (arguments.length > 2) {
|
||||
var args = slice(arguments, 2);
|
||||
data.push(args, getHolders(args, bindKey.placeholder));
|
||||
data.push(args, replaceHolders(args, bindKey.placeholder));
|
||||
}
|
||||
return createWrapper(data);
|
||||
}
|
||||
@@ -6248,7 +6265,7 @@
|
||||
*/
|
||||
function partial(func) {
|
||||
var args = slice(arguments, 1),
|
||||
partialHolders = getHolders(args, partial.placeholder);
|
||||
partialHolders = replaceHolders(args, partial.placeholder);
|
||||
|
||||
return basePartial(func, PARTIAL_FLAG, args, partialHolders);
|
||||
}
|
||||
@@ -6286,7 +6303,7 @@
|
||||
*/
|
||||
function partialRight(func) {
|
||||
var args = slice(arguments, 1),
|
||||
partialHolders = getHolders(args, partialRight.placeholder);
|
||||
partialHolders = replaceHolders(args, partialRight.placeholder);
|
||||
|
||||
return basePartial(func, PARTIAL_RIGHT_FLAG, args, partialHolders);
|
||||
}
|
||||
@@ -6565,7 +6582,6 @@
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
|
||||
* @returns {Object} Returns the destination object.
|
||||
* @example
|
||||
*
|
||||
@@ -7395,7 +7411,7 @@
|
||||
* // => ['x', 'y'] (property order is not guaranteed across environments)
|
||||
*/
|
||||
var keys = !nativeKeys ? shimKeys : function(object) {
|
||||
object = Object(object);
|
||||
object = toObject(object);
|
||||
|
||||
var Ctor = object.constructor,
|
||||
length = object.length;
|
||||
@@ -7432,7 +7448,7 @@
|
||||
if (object == null) {
|
||||
return [];
|
||||
}
|
||||
object = Object(object);
|
||||
object = toObject(object);
|
||||
|
||||
var length = object.length;
|
||||
length = (typeof length == 'number' && length > 0 &&
|
||||
@@ -7616,7 +7632,7 @@
|
||||
return basePick(object, negate(getCallback(predicate, thisArg, 3)));
|
||||
}
|
||||
var omitProps = baseFlatten(arguments, false, false, 1);
|
||||
return basePick(Object(object), baseDifference(keysIn(object), arrayMap(omitProps, String)));
|
||||
return basePick(toObject(object), baseDifference(keysIn(object), arrayMap(omitProps, String)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7677,7 +7693,7 @@
|
||||
if (object == null) {
|
||||
return {};
|
||||
}
|
||||
return basePick(Object(object),
|
||||
return basePick(toObject(object),
|
||||
typeof predicate == 'function'
|
||||
? getCallback(predicate, thisArg, 3)
|
||||
: baseFlatten(arguments, false, false, 1)
|
||||
@@ -8257,7 +8273,7 @@
|
||||
|
||||
// use a sourceURL for easier debugging
|
||||
// http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
||||
var sourceURL = options.sourceURL || ('/lodash/template/source[' + (templateCounter++) + ']');
|
||||
var sourceURL = options.sourceURL || ('/lodash/template/source[' + (++templateCounter) + ']');
|
||||
sourceURL = sourceURL ? ('\n/*\n//# sourceURL=' + sourceURL + '\n*/') : '';
|
||||
|
||||
string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
||||
@@ -8842,19 +8858,27 @@
|
||||
* @category Utility
|
||||
* @param {string} value The value to parse.
|
||||
* @param {number} [radix] The radix to interpret `value` by.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {number} Returns the converted integer.
|
||||
* @example
|
||||
*
|
||||
* _.parseInt('08');
|
||||
* // => 8
|
||||
*/
|
||||
var parseInt = nativeParseInt(whitespace + '08') == 8 ? nativeParseInt : function(value, radix) {
|
||||
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and
|
||||
// Chrome fails to trim leading <BOM> whitespace characters.
|
||||
// See https://code.google.com/p/v8/issues/detail?id=3109
|
||||
value = trim(value);
|
||||
return nativeParseInt(value, +radix || (reHexPrefix.test(value) ? 16 : 10));
|
||||
};
|
||||
function parseInt(value, radix, guard) {
|
||||
return nativeParseInt(value, guard ? 0 : radix);
|
||||
}
|
||||
// fallback for environments with pre-ES5 implementations
|
||||
if (nativeParseInt(whitespace + '08') != 8) {
|
||||
parseInt = function(value, radix, guard) {
|
||||
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and
|
||||
// Chrome fails to trim leading <BOM> whitespace characters.
|
||||
// See https://code.google.com/p/v8/issues/detail?id=3109
|
||||
value = trim(value);
|
||||
radix = guard ? 0 : +radix;
|
||||
return nativeParseInt(value, radix || (reHexPrefix.test(value) ? 16 : 10));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a "_.pluck" style function which returns the `key` value of a
|
||||
@@ -8914,6 +8938,11 @@
|
||||
* // => a floating-point number between 1.2 and 5.2
|
||||
*/
|
||||
function random(min, max, floating) {
|
||||
// enables use as a callback for functions like `_.map`
|
||||
var type = typeof max;
|
||||
if ((type == 'number' || type == 'string') && floating && floating[max] === min) {
|
||||
max = floating = null;
|
||||
}
|
||||
var noMin = min == null,
|
||||
noMax = max == null;
|
||||
|
||||
@@ -8979,6 +9008,12 @@
|
||||
*/
|
||||
function range(start, end, step) {
|
||||
start = +start || 0;
|
||||
|
||||
// enables use as a callback for functions like `_.map`
|
||||
var type = typeof end;
|
||||
if ((type == 'number' || type == 'string') && step && step[end] === start) {
|
||||
end = step = null;
|
||||
}
|
||||
step = step == null ? 1 : (+step || 0);
|
||||
|
||||
if (end == null) {
|
||||
|
||||
Reference in New Issue
Block a user