New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lodash.sortby

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.sortby - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

40

index.js
/**
* Lo-Dash 2.3.0 (Custom Build) <http://lodash.com/>
* Lo-Dash 2.4.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm/`

@@ -12,3 +12,7 @@ * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>

forEach = require('lodash.foreach'),
getArray = require('lodash._getarray'),
getObject = require('lodash._getobject'),
isArray = require('lodash.isarray'),
map = require('lodash.map'),
releaseArray = require('lodash._releasearray'),
releaseObject = require('lodash._releaseobject');

@@ -26,2 +30,5 @@

*
* If an array of property names is provided for `callback` the collection
* will be sorted by each property value.
*
* If an object is provided for `callback` the created "_.where" style callback

@@ -35,3 +42,3 @@ * will return `true` for elements that have the properties of the given object,

* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [callback=identity] The function called
* @param {Array|Function|Object|string} [callback=identity] The function called
* per iteration. If a property name or object is provided it will be used

@@ -49,15 +56,33 @@ * to create a "_.pluck" or "_.where" style callback, respectively.

*
* var characters = [
* { 'name': 'barney', 'age': 36 },
* { 'name': 'fred', 'age': 40 },
* { 'name': 'barney', 'age': 26 },
* { 'name': 'fred', 'age': 30 }
* ];
*
* // using "_.pluck" callback shorthand
* _.sortBy(['banana', 'strawberry', 'apple'], 'length');
* // => ['apple', 'banana', 'strawberry']
* _.map(_.sortBy(characters, 'age'), _.values);
* // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
*
* // sorting by multiple properties
* _.map(_.sortBy(characters, ['name', 'age']), _.values);
* // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
*/
function sortBy(collection, callback, thisArg) {
var index = -1,
isArr = isArray(callback),
length = collection ? collection.length : 0,
result = Array(typeof length == 'number' ? length : 0);
callback = createCallback(callback, thisArg, 3);
if (!isArr) {
callback = createCallback(callback, thisArg, 3);
}
forEach(collection, function(value, key, collection) {
var object = result[++index] = getObject();
object.criteria = callback(value, key, collection);
if (isArr) {
object.criteria = map(callback, function(key) { return value[key]; });
} else {
(object.criteria = getArray())[0] = callback(value, key, collection);
}
object.index = index;

@@ -72,2 +97,5 @@ object.value = value;

result[length] = object.value;
if (!isArr) {
releaseArray(object.criteria);
}
releaseObject(object);

@@ -74,0 +102,0 @@ }

18

package.json
{
"name": "lodash.sortby",
"version": "2.3.0",
"version": "2.4.0",
"description": "The Lo-Dash function `_.sortBy` as a Node.js module generated by lodash-cli.",

@@ -18,8 +18,12 @@ "homepage": "http://lodash.com/custom-builds",

"dependencies": {
"lodash._compareascending": "~2.3.0",
"lodash.createcallback": "~2.3.0",
"lodash.foreach": "~2.3.0",
"lodash._getobject": "~2.3.0",
"lodash._releaseobject": "~2.3.0"
"lodash._compareascending": "~2.4.0",
"lodash.createcallback": "~2.4.0",
"lodash.foreach": "~2.4.0",
"lodash._getarray": "~2.4.0",
"lodash._getobject": "~2.4.0",
"lodash.isarray": "~2.4.0",
"lodash.map": "~2.4.0",
"lodash._releasearray": "~2.4.0",
"lodash._releaseobject": "~2.4.0"
}
}
}

@@ -1,2 +0,2 @@

# lodash.sortby v2.3.0
# lodash.sortby v2.4.0

@@ -3,0 +3,0 @@ The [Lo-Dash](http://lodash.com/) function [`_.sortBy`](http://lodash.com/docs#sortBy) as a [Node.js](http://nodejs.org/) module generated by [lodash-cli](https://npmjs.org/package/lodash-cli).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc