lodash.toarray
Advanced tools
Comparing version 3.0.0 to 3.0.1
42
index.js
/** | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* lodash 3.0.1 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
@@ -14,5 +14,4 @@ * Available under MIT license <https://lodash.com/license> | ||
/** | ||
* Used as the maximum length of an array-like value. | ||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) | ||
* for more details. | ||
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
*/ | ||
@@ -22,4 +21,31 @@ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; | ||
/** | ||
* The base implementation of `_.property` without support for deep paths. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
} | ||
/** | ||
* Gets the "length" property value of `object`. | ||
* | ||
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) | ||
* in Safari on iOS 8.1 ARM64. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {*} Returns the "length" value. | ||
*/ | ||
var getLength = baseProperty('length'); | ||
/** | ||
* Checks if `value` is a valid array-like length. | ||
* | ||
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). | ||
* | ||
* @private | ||
@@ -43,7 +69,9 @@ * @param {*} value The value to check. | ||
* | ||
* (function() { return _.toArray(arguments).slice(1); })(1, 2, 3); | ||
* (function() { | ||
* return _.toArray(arguments).slice(1); | ||
* }(1, 2, 3)); | ||
* // => [2, 3] | ||
*/ | ||
function toArray(value) { | ||
var length = value ? value.length : 0; | ||
var length = value ? getLength(value) : 0; | ||
if (!isLength(length)) { | ||
@@ -50,0 +78,0 @@ return values(value); |
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
@@ -4,0 +4,0 @@ |
{ | ||
"name": "lodash.toarray", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "The modern build of lodash’s `_.toArray` as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.toarray v3.0.0 | ||
# lodash.toarray v3.0.1 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.toArray` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#toArray) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.toarray) for more details. | ||
See the [documentation](https://lodash.com/docs#toArray) or [package source](https://github.com/lodash/lodash/blob/3.0.1-npm-packages/lodash.toarray) for more details. |
5746
105