mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Bump to v4.7.0.
This commit is contained in:
19
subtract.js
19
subtract.js
@@ -1,8 +1,11 @@
|
||||
import createMathOperation from './_createMathOperation';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -12,18 +15,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;
|
||||
});
|
||||
|
||||
export default subtract;
|
||||
|
||||
Reference in New Issue
Block a user