From 63ea557b064b7f5fc9660432f3ff7d886e832044 Mon Sep 17 00:00:00 2001 From: tjcrowder Date: Thu, 10 Sep 2009 16:51:36 +0100 Subject: [PATCH] doc: Merged and updated old docs for Number#toPaddedString. --- src/lang/number.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/lang/number.js b/src/lang/number.js index ea7da0d..643d1e9 100644 --- a/src/lang/number.js +++ b/src/lang/number.js @@ -73,10 +73,30 @@ Object.extend(Number.prototype, (function() { /** * Number#toPaddedString(length[, radix]) -> String + * - length (Number): The minimum length for the resulting string. + * - radix (Number): An optional radix for the string representation, + * defaults to 10 (decimal). * - * Converts the number into a string padded with 0s so that the string's length - * is at least equal to `length`. - * Takes an optional `radix` argument which specifies the base to use for conversion. + * Returns a string representation of the number padded with leading 0s so + * that the string's length is at least equal to `length`. Takes an optional + * `radix` argument which specifies the base to use for conversion. + * + * ### Examples + * + * (13).toPaddedString(4); + * // -> "0013" + * + * (13).toPaddedString(2); + * // -> "13" + * + * (13).toPaddedString(1); + * // -> "13" + * + * (13).toPaddedString(4, 16) + * // -> "000d" + * + * (13).toPaddedString(4, 2); + * // -> "1101" **/ function toPaddedString(length, radix) { var string = this.toString(radix || 10);