lodash.map
Advanced tools
Comparing version 3.1.0 to 3.1.1
56
index.js
/** | ||
* lodash 3.1.0 (Custom Build) <https://lodash.com/> | ||
* lodash 3.1.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.8.2 <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 | ||
@@ -16,2 +16,8 @@ * Available under MIT license <https://lodash.com/license> | ||
/** | ||
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
*/ | ||
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; | ||
/** | ||
* The base implementation of `_.map` without support for callback shorthands | ||
@@ -26,5 +32,8 @@ * and `this` binding. | ||
function baseMap(collection, iteratee) { | ||
var result = []; | ||
var index = -1, | ||
length = getLength(collection), | ||
result = isLength(length) ? Array(length) : []; | ||
baseEach(collection, function(value, key, collection) { | ||
result.push(iteratee(value, key, collection)); | ||
result[++index] = iteratee(value, key, collection); | ||
}); | ||
@@ -35,2 +44,40 @@ return result; | ||
/** | ||
* 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 | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`. | ||
*/ | ||
function isLength(value) { | ||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | ||
} | ||
/** | ||
* Creates an array of values by running each element in `collection` through | ||
@@ -67,3 +114,2 @@ * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three | ||
* per iteration. | ||
* create a `_.property` or `_.matches` style callback respectively. | ||
* @param {*} [thisArg] The `this` binding of `iteratee`. | ||
@@ -70,0 +116,0 @@ * @returns {Array} Returns the new mapped array. |
{ | ||
"name": "lodash.map", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "The modern build of lodash’s `_.map` as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.map v3.1.0 | ||
# lodash.map v3.1.1 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.map` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#map) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.map) for more details. | ||
See the [documentation](https://lodash.com/docs#map) or [package source](https://github.com/lodash/lodash/blob/3.1.1-npm-packages/lodash.map) for more details. |
7551
132