maths: add pad function
This commit is contained in:
parent
9f81e0b9cb
commit
1c53aea10e
2 changed files with 11 additions and 2 deletions
|
|
@ -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 },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue