lodash.sortby
Advanced tools
Comparing version 3.1.0 to 3.1.1
79
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 | ||
@@ -31,5 +31,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-number.max_safe_integer) | ||
* 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. | ||
*/ | ||
@@ -39,7 +38,50 @@ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; | ||
/** | ||
* The base implementation of `_.map` without support for callback shorthands | ||
* and `this` binding. | ||
* | ||
* @private | ||
* @param {Array|Object|string} collection The collection to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Array} Returns the new mapped array. | ||
*/ | ||
function baseMap(collection, iteratee) { | ||
var index = -1, | ||
length = getLength(collection), | ||
result = isLength(length) ? Array(length) : []; | ||
baseEach(collection, function(value, key, collection) { | ||
result[++index] = iteratee(value, key, collection); | ||
}); | ||
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 ES `ToLength`. See the | ||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) | ||
* for more details. | ||
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). | ||
* | ||
@@ -58,6 +100,6 @@ * @private | ||
* a stable sort, that is, it preserves the original sort order of equal elements. | ||
* The `iteratee` is bound to `thisArg` and invoked with three arguments; | ||
* The `iteratee` is bound to `thisArg` and invoked with three arguments: | ||
* (value, index|key, collection). | ||
* | ||
* If a property name is provided for `predicate` the created `_.property` | ||
* If a property name is provided for `iteratee` the created `_.property` | ||
* style callback returns the property value of the given element. | ||
@@ -69,3 +111,3 @@ * | ||
* | ||
* If an object is provided for `predicate` the created `_.matches` style | ||
* If an object is provided for `iteratee` the created `_.matches` style | ||
* callback returns `true` for elements that have the properties of the given | ||
@@ -78,5 +120,4 @@ * object, else `false`. | ||
* @param {Array|Object|string} collection The collection to iterate over. | ||
* @param {Array|Function|Object|string} [iteratee=_.identity] The function | ||
* invoked per iteration. If a property name or an object is provided it is | ||
* used to create a `_.property` or `_.matches` style callback respectively. | ||
* @param {Function|Object|string} [iteratee=_.identity] The function invoked | ||
* per iteration. | ||
* @param {*} [thisArg] The `this` binding of `iteratee`. | ||
@@ -110,12 +151,10 @@ * @returns {Array} Returns the new sorted array. | ||
} | ||
var index = -1, | ||
length = collection.length, | ||
result = isLength(length) ? Array(length) : []; | ||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { | ||
iteratee = null; | ||
} | ||
var index = -1; | ||
iteratee = baseCallback(iteratee, thisArg, 3); | ||
baseEach(collection, function(value, key, collection) { | ||
result[++index] = { 'criteria': iteratee(value, key, collection), 'index': index, 'value': value }; | ||
var result = baseMap(collection, function(value, key, collection) { | ||
return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value }; | ||
}); | ||
@@ -122,0 +161,0 @@ return baseSortBy(result, compareAscending); |
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.sortby", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "The modern build of lodash’s `_.sortBy` as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.sortby v3.1.0 | ||
# lodash.sortby v3.1.1 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.sortBy` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#sortBy) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.sortby) for more details. | ||
See the [documentation](https://lodash.com/docs#sortBy) or [package source](https://github.com/lodash/lodash/blob/3.1.1-npm-packages/lodash.sortby) for more details. |
8227
148