lodash.slice
Advanced tools
Comparing version 4.0.5 to 4.0.6
102
index.js
/** | ||
* lodash 4.0.5 (Custom Build) <https://lodash.com/> | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -40,16 +40,2 @@ * Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
/** | ||
* Checks if `value` is a valid array-like index. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. | ||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`. | ||
*/ | ||
function isIndex(value, length) { | ||
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; | ||
length = length == null ? MAX_SAFE_INTEGER : length; | ||
return value > -1 && value % 1 == 0 && value < length; | ||
} | ||
/** Used for built-in method references. */ | ||
@@ -59,3 +45,4 @@ var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -70,3 +57,3 @@ */ | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new function. | ||
* @returns {Function} Returns the new accessor function. | ||
*/ | ||
@@ -93,2 +80,17 @@ function baseProperty(key) { | ||
/** | ||
* Checks if `value` is a valid array-like index. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. | ||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`. | ||
*/ | ||
function isIndex(value, length) { | ||
length = length == null ? MAX_SAFE_INTEGER : length; | ||
return !!length && | ||
(typeof value == 'number' || reIsUint.test(value)) && | ||
(value > -1 && value % 1 == 0 && value < length); | ||
} | ||
/** | ||
* Checks if the given arguments are from an iteratee call. | ||
@@ -273,4 +275,5 @@ * | ||
/** | ||
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | ||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* Checks if `value` is the | ||
* [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) | ||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
@@ -354,2 +357,37 @@ * @static | ||
/** | ||
* Converts `value` to a finite number. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.12.0 | ||
* @category Lang | ||
* @param {*} value The value to convert. | ||
* @returns {number} Returns the converted number. | ||
* @example | ||
* | ||
* _.toFinite(3.2); | ||
* // => 3.2 | ||
* | ||
* _.toFinite(Number.MIN_VALUE); | ||
* // => 5e-324 | ||
* | ||
* _.toFinite(Infinity); | ||
* // => 1.7976931348623157e+308 | ||
* | ||
* _.toFinite('3.2'); | ||
* // => 3.2 | ||
*/ | ||
function toFinite(value) { | ||
if (!value) { | ||
return value === 0 ? value : 0; | ||
} | ||
value = toNumber(value); | ||
if (value === INFINITY || value === -INFINITY) { | ||
var sign = (value < 0 ? -1 : 1); | ||
return sign * MAX_INTEGER; | ||
} | ||
return value === value ? value : 0; | ||
} | ||
/** | ||
* Converts `value` to an integer. | ||
@@ -368,3 +406,3 @@ * | ||
* | ||
* _.toInteger(3); | ||
* _.toInteger(3.2); | ||
* // => 3 | ||
@@ -378,16 +416,10 @@ * | ||
* | ||
* _.toInteger('3'); | ||
* _.toInteger('3.2'); | ||
* // => 3 | ||
*/ | ||
function toInteger(value) { | ||
if (!value) { | ||
return value === 0 ? value : 0; | ||
} | ||
value = toNumber(value); | ||
if (value === INFINITY || value === -INFINITY) { | ||
var sign = (value < 0 ? -1 : 1); | ||
return sign * MAX_INTEGER; | ||
} | ||
var remainder = value % 1; | ||
return value === value ? (remainder ? value - remainder : value) : 0; | ||
var result = toFinite(value), | ||
remainder = result % 1; | ||
return result === result ? (remainder ? result - remainder : result) : 0; | ||
} | ||
@@ -406,4 +438,4 @@ | ||
* | ||
* _.toNumber(3); | ||
* // => 3 | ||
* _.toNumber(3.2); | ||
* // => 3.2 | ||
* | ||
@@ -416,4 +448,4 @@ * _.toNumber(Number.MIN_VALUE); | ||
* | ||
* _.toNumber('3'); | ||
* // => 3 | ||
* _.toNumber('3.2'); | ||
* // => 3.2 | ||
*/ | ||
@@ -420,0 +452,0 @@ function toNumber(value) { |
{ | ||
"name": "lodash.slice", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"description": "The lodash method `_.slice` exported as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.slice v4.0.5 | ||
# lodash.slice v4.0.6 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.slice` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#slice) or [package source](https://github.com/lodash/lodash/blob/4.0.5-npm-packages/lodash.slice) for more details. | ||
See the [documentation](https://lodash.com/docs#slice) or [package source](https://github.com/lodash/lodash/blob/4.0.6-npm-packages/lodash.slice) for more details. |
14564
436