1 var baseToNumber = require('./_baseToNumber'),
2 baseToString = require('./_baseToString');
5 * Creates a function that performs a mathematical operation on two values.
8 * @param {Function} operator The function to perform the operation.
9 * @param {number} [defaultValue] The value used for `undefined` arguments.
10 * @returns {Function} Returns the new mathematical operation function.
12 function createMathOperation(operator, defaultValue) {
13 return function(value, other) {
15 if (value === undefined && other === undefined) {
18 if (value !== undefined) {
21 if (other !== undefined) {
22 if (result === undefined) {
25 if (typeof value == 'string' || typeof other == 'string') {
26 value = baseToString(value);
27 other = baseToString(other);
29 value = baseToNumber(value);
30 other = baseToNumber(other);
32 result = operator(value, other);
38 module.exports = createMathOperation;