Files
less.js/lib/less/functions/math.js
Matthew Dean 42fd7dca20 Release v3.5.0 beta (#3230)
* Lint cleanup of quotes
* v3.5.0-beta
2018-06-24 20:14:33 -07:00

30 lines
714 B
JavaScript

var functionRegistry = require('./function-registry'),
mathHelper = require('./math-helper.js');
var mathFunctions = {
// name, unit
ceil: null,
floor: null,
sqrt: null,
abs: null,
tan: '',
sin: '',
cos: '',
atan: 'rad',
asin: 'rad',
acos: 'rad'
};
for (var f in mathFunctions) {
if (mathFunctions.hasOwnProperty(f)) {
mathFunctions[f] = mathHelper._math.bind(null, Math[f], mathFunctions[f]);
}
}
mathFunctions.round = function (n, f) {
var fraction = typeof f === 'undefined' ? 0 : f.value;
return mathHelper._math(function(num) { return num.toFixed(fraction); }, null, n);
};
functionRegistry.addMultiple(mathFunctions);