lodash.sortbyorder
Advanced tools
Comparing version 3.4.1 to 3.4.2
41
index.js
/** | ||
* lodash 3.4.1 (Custom Build) <https://lodash.com/> | ||
* lodash 3.4.2 (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,6 +16,13 @@ * Available under MIT license <https://lodash.com/license> | ||
* This method is like `_.sortByAll` except that it allows specifying the | ||
* sort orders of the property names to sort by. A truthy value in `orders` | ||
* will sort the corresponding property name in ascending order while a | ||
* falsey value will sort it in descending order. | ||
* sort orders of the iteratees to sort by. A truthy value in `orders` will | ||
* sort the corresponding property name in ascending order while a falsey | ||
* value will sort it in descending order. | ||
* | ||
* If a property name is provided for an iteratee the created `_.property` | ||
* style callback returns the property value of the given element. | ||
* | ||
* If an object is provided for an iteratee the created `_.matches` style | ||
* callback returns `true` for elements that have the properties of the given | ||
* object, else `false`. | ||
* | ||
* @static | ||
@@ -25,4 +32,4 @@ * @memberOf _ | ||
* @param {Array|Object|string} collection The collection to iterate over. | ||
* @param {string[]} props The property names to sort by. | ||
* @param {boolean[]} orders The sort orders of `props`. | ||
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. | ||
* @param {boolean[]} orders The sort orders of `iteratees`. | ||
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. | ||
@@ -33,6 +40,6 @@ * @returns {Array} Returns the new sorted array. | ||
* var users = [ | ||
* { 'user': 'barney', 'age': 26 }, | ||
* { 'user': 'fred', 'age': 40 }, | ||
* { 'user': 'barney', 'age': 36 }, | ||
* { 'user': 'fred', 'age': 30 } | ||
* { 'user': 'fred', 'age': 48 }, | ||
* { 'user': 'barney', 'age': 34 }, | ||
* { 'user': 'fred', 'age': 42 }, | ||
* { 'user': 'barney', 'age': 36 } | ||
* ]; | ||
@@ -42,13 +49,13 @@ * | ||
* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values); | ||
* // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]] | ||
* // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] | ||
*/ | ||
function sortByOrder(collection, props, orders, guard) { | ||
function sortByOrder(collection, iteratees, orders, guard) { | ||
if (collection == null) { | ||
return []; | ||
} | ||
if (guard && isIterateeCall(props, orders, guard)) { | ||
if (guard && isIterateeCall(iteratees, orders, guard)) { | ||
orders = null; | ||
} | ||
if (!isArray(props)) { | ||
props = props == null ? [] : [props]; | ||
if (!isArray(iteratees)) { | ||
iteratees = iteratees == null ? [] : [iteratees]; | ||
} | ||
@@ -58,5 +65,5 @@ if (!isArray(orders)) { | ||
} | ||
return baseSortByOrder(collection, props, orders); | ||
return baseSortByOrder(collection, iteratees, orders); | ||
} | ||
module.exports = sortByOrder; |
{ | ||
"name": "lodash.sortbyorder", | ||
"version": "3.4.1", | ||
"version": "3.4.2", | ||
"description": "The modern build of lodash’s `_.sortByOrder` as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.sortbyorder v3.4.1 | ||
# lodash.sortbyorder v3.4.2 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.sortByOrder` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#sortByOrder) or [package source](https://github.com/lodash/lodash/blob/3.4.1-npm-packages/lodash.sortbyorder) for more details. | ||
See the [documentation](https://lodash.com/docs#sortByOrder) or [package source](https://github.com/lodash/lodash/blob/3.4.2-npm-packages/lodash.sortbyorder) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5360
62