* 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} Re
(operator, defaultValue)
| 15849 | * @returns {Function} Returns the new mathematical operation function. |
| 15850 | */ |
| 15851 | function createMathOperation(operator, defaultValue) { |
| 15852 | return function(value, other) { |
| 15853 | var result; |
| 15854 | if (value === undefined && other === undefined) { |
| 15855 | return defaultValue; |
| 15856 | } |
| 15857 | if (value !== undefined) { |
| 15858 | result = value; |
| 15859 | } |
| 15860 | if (other !== undefined) { |
| 15861 | if (result === undefined) { |
| 15862 | return other; |
| 15863 | } |
| 15864 | if (typeof value == 'string' || typeof other == 'string') { |
| 15865 | value = baseToString(value); |
| 15866 | other = baseToString(other); |
| 15867 | } else { |
| 15868 | value = baseToNumber(value); |
| 15869 | other = baseToNumber(other); |
| 15870 | } |
| 15871 | result = operator(value, other); |
| 15872 | } |
| 15873 | return result; |
| 15874 | }; |
| 15875 | } |
| 15876 | |
| 15877 | /** |
| 15878 | * Creates a function like `_.over`. |
no test coverage detected