Added mathematics filter operators power and log (#5080)

This commit is contained in:
saqimtiaz
2020-11-20 14:00:20 +00:00
committed by GitHub
parent fd14e94610
commit 89541edcff
5 changed files with 66 additions and 0 deletions
+14
View File
@@ -91,6 +91,20 @@ exports.exponential = makeNumericBinaryOperator(
function(a,b) {return Number.prototype.toExponential.call(a,Math.min(Math.max(b,0),100));}
);
exports.power = makeNumericBinaryOperator(
function(a,b) {return Math.pow(a,b);}
);
exports.log = makeNumericBinaryOperator(
function(a,b) {
if(b) {
return Math.log(a)/Math.log(b);
} else {
return Math.log(a);
}
}
);
exports.sum = makeNumericReducingOperator(
function(accumulator,value) {return accumulator + value},
0 // Initial value