MCPcopy Index your code
hub / github.com/deployd/deployd / createMathOperation

Function createMathOperation

test-app/public/sinon.js:15851–15875  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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`.

Callers 1

sinon.jsFile · 0.85

Calls 2

baseToStringFunction · 0.85
baseToNumberFunction · 0.85

Tested by

no test coverage detected