Move zeroPad function to BaseTypes and add tests for it
This commit is contained in:
@@ -295,7 +295,25 @@ OpenLayers.Number = {
|
||||
str = integer + dsep + rem;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: zeroPad
|
||||
* Create a zero padded string optionally with a radix for casting numbers.
|
||||
*
|
||||
* Parameters:
|
||||
* num - {Number} The number to be zero padded.
|
||||
* len - {Number} The length of the string to be returned.
|
||||
* radix - {Number} An integer between 2 and 36 specifying the base to use
|
||||
* for representing numeric values.
|
||||
*/
|
||||
zeroPad: function(num, len, radix) {
|
||||
var str = num.toString(radix || 10);
|
||||
while (str.length < len) {
|
||||
str = "0" + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user