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

lodash.max

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.max - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

107

index.js
/**
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
* lodash 3.1.0 (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.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors

@@ -10,5 +10,82 @@ * Available under MIT license <https://lodash.com/license>

var arrayMax = require('lodash._arraymax'),
createExtremum = require('lodash._createextremum');
baseCallback = require('lodash._basecallback'),
baseEach = require('lodash._baseeach'),
isIterateeCall = require('lodash._isiterateecall'),
toIterable = require('lodash._toiterable'),
isArray = require('lodash.isarray'),
isString = require('lodash.isstring');
/**
* Used by `_.max` and `_.min` as the default callback for string values.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the code unit of the first character of the string.
*/
function charAtCallback(string) {
return string.charCodeAt(0);
}
/** Used as references for `-Infinity` and `Infinity`. */
var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,
POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
/**
* Creates a `_.max` or `_.min` function.
*
* @private
* @param {Function} arrayFunc The function to get the extremum value from an array.
* @param {boolean} [isMin] Specify returning the minimum, instead of the maximum,
* extremum value.
* @returns {Function} Returns the new extremum function.
*/
function createExtremum(arrayFunc, isMin) {
return function(collection, iteratee, thisArg) {
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
iteratee = null;
}
var noIteratee = iteratee == null;
iteratee = noIteratee ? iteratee : baseCallback(iteratee, thisArg, 3);
if (noIteratee) {
var isArr = isArray(collection);
if (!isArr && isString(collection)) {
iteratee = charAtCallback;
} else {
return arrayFunc(isArr ? collection : toIterable(collection));
}
}
return extremumBy(collection, iteratee, isMin);
};
}
/**
* Gets the extremum value of `collection` invoking `iteratee` for each value
* in `collection` to generate the criterion by which the value is ranked.
* The `iteratee` is invoked with three arguments: (value, index, collection).
*
* @private
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {boolean} [isMin] Specify returning the minimum, instead of the
* maximum, extremum value.
* @returns {*} Returns the extremum value.
*/
function extremumBy(collection, iteratee, isMin) {
var exValue = isMin ? POSITIVE_INFINITY : NEGATIVE_INFINITY,
computed = exValue,
result = computed;
baseEach(collection, function(value, index, collection) {
var current = iteratee(value, index, collection);
if ((isMin ? (current < computed) : (current > computed)) ||
(current === exValue && current === result)) {
computed = current;
result = value;
}
});
return result;
}
/**
* Gets the maximum value of `collection`. If `collection` is empty or falsey

@@ -18,8 +95,12 @@ * `-Infinity` is returned. If an iteratee function is provided it is invoked

* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
* arguments; (value, index, collection).
* arguments: (value, index, 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.
*
* If an object is provided for `predicate` the created "_.matches" style
* If a value is also provided for `thisArg` the created `_.matchesProperty`
* style callback returns `true` for elements that have a matching property
* value, else `false`.
*
* If an object is provided for `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given

@@ -30,7 +111,5 @@ * object, else `false`.

* @memberOf _
* @category Collection
* @category Math
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
* If a property name or object is provided it is used to create a "_.property"
* or "_.matches" style callback respectively.
* @param {*} [thisArg] The `this` binding of `iteratee`.

@@ -51,8 +130,10 @@ * @returns {*} Returns the maximum value.

*
* _.max(users, function(chr) { return chr.age; });
* // => { 'user': 'fred', 'age': 40 };
* _.max(users, function(chr) {
* return chr.age;
* });
* // => { 'user': 'fred', 'age': 40 }
*
* // using the "_.property" callback shorthand
* // using the `_.property` callback shorthand
* _.max(users, 'age');
* // => { 'user': 'fred', 'age': 40 };
* // => { 'user': 'fred', 'age': 40 }
*/

@@ -59,0 +140,0 @@ var max = createExtremum(arrayMax);

2

LICENSE.txt
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.max",
"version": "3.0.0",
"version": "3.1.0",
"description": "The modern build of lodash’s `_.max` as a module.",

@@ -21,4 +21,9 @@ "homepage": "https://lodash.com/",

"lodash._arraymax": "^3.0.0",
"lodash._createextremum": "^3.0.0"
"lodash._basecallback": "^3.0.0",
"lodash._baseeach": "^3.0.0",
"lodash._isiterateecall": "^3.0.0",
"lodash._toiterable": "^3.0.0",
"lodash.isarray": "^3.0.0",
"lodash.isstring": "^3.0.0"
}
}

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

# lodash.max v3.0.0
# lodash.max v3.1.0

@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.max` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module.

See the [documentation](https://lodash.com/docs#max) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.max) for more details.
See the [documentation](https://lodash.com/docs#max) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.max) for more details.
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