mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Bump to v4.0.2.
This commit is contained in:
@@ -1,17 +1,41 @@
|
||||
/**
|
||||
* lodash 4.0.1 (Custom Build) <https://lodash.com/>
|
||||
* lodash 4.0.2 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||
* Released under MIT license <https://lodash.com/license>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Available under MIT license <https://lodash.com/license>
|
||||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a function that performs a mathematical operation on two values.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} operator The function to perform the operation.
|
||||
* @returns {Function} Returns the new mathematical operation function.
|
||||
*/
|
||||
function createMathOperation(operator) {
|
||||
return function(value, other) {
|
||||
var result;
|
||||
if (value === undefined && other === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (value !== undefined) {
|
||||
result = value;
|
||||
}
|
||||
if (other !== undefined) {
|
||||
result = result === undefined ? other : operator(result, other);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract two numbers.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Math
|
||||
* @param {number} minuend The first number in a subtraction.
|
||||
* @param {number} subtrahend The second number in a subtraction.
|
||||
@@ -21,18 +45,8 @@
|
||||
* _.subtract(6, 4);
|
||||
* // => 2
|
||||
*/
|
||||
function subtract(minuend, subtrahend) {
|
||||
var result;
|
||||
if (minuend === undefined && subtrahend === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (minuend !== undefined) {
|
||||
result = minuend;
|
||||
}
|
||||
if (subtrahend !== undefined) {
|
||||
result = result === undefined ? subtrahend : (result - subtrahend);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var subtract = createMathOperation(function(minuend, subtrahend) {
|
||||
return minuend - subtrahend;
|
||||
});
|
||||
|
||||
module.exports = subtract;
|
||||
|
||||
Reference in New Issue
Block a user