maths: add pad function

This commit is contained in:
jean-emmanuel 2018-02-16 23:19:19 +01:00
parent 9f81e0b9cb
commit 1c53aea10e
2 changed files with 11 additions and 2 deletions

View file

@ -76,6 +76,14 @@ module.exports = {
})
math.import({
unpack: function(a) { return Array.isArray(a) ? a.toString() : a },
pad: function(x, padding) {
var str = String(x),
[int, dec] = str.split('.')
while (int.length < padding) {
int = '0' + int
}
return dec ? int + '.' + dec : int
},
// basic relationnal to keep alphabetical string comparison (v4 change)
equal: function (a, b) { return a == b },
unequal: function (a, b) { return a != b },