* Creates a function that performs a mathematical operation on two values. * * @private * @param {Function} operator The function to perform the operation. * @param {number} [defaultValue] The value used for `undefined` arguments. * @returns {Function} Returns the new mathem
(operator, defaultValue)
| 12871 | * @returns {Function} Returns the new mathematical operation function. |
| 12872 | */ |
| 12873 | function createMathOperation(operator, defaultValue) { |
| 12874 | return function(value, other) { |
| 12875 | var result; |
| 12876 | if (value === undefined && other === undefined) { |
| 12877 | return defaultValue; |
| 12878 | } |
| 12879 | if (value !== undefined) { |
| 12880 | result = value; |
| 12881 | } |
| 12882 | if (other !== undefined) { |
| 12883 | if (result === undefined) { |
| 12884 | return other; |
| 12885 | } |
| 12886 | if (typeof value == 'string' || typeof other == 'string') { |
| 12887 | value = baseToString(value); |
| 12888 | other = baseToString(other); |
| 12889 | } else { |
| 12890 | value = baseToNumber(value); |
| 12891 | other = baseToNumber(other); |
| 12892 | } |
| 12893 | result = operator(value, other); |
| 12894 | } |
| 12895 | return result; |
| 12896 | }; |
| 12897 | } |
| 12898 | |
| 12899 | /** |
| 12900 | * Creates a function like `_.over`. |
no test coverage detected