datatype-number-debug.js revision b9436848b51ee2b4f04b9217e74172c5a05ce276
/**
* The DataType utility provides a set of utility functions to operate on native
* JavaScript data types.
*
* @module datatype
*/
/**
* Number submodule.
*
* @class DataType.Number
* @static
*/
Number = {
/**
* Returns string name.
*
* @method toString
* @return {String} String representation for this object.
*/
toString: function() {
return "DataType.Number";
},
/**
* Converts data to type Number.
*
* @method parse
* @param data {String | Number | Boolean} Data to convert. The following
* values return as null: null, undefined, NaN, "".
* @return {Number} A number, or null.
* @static
*/
return number;
}
else {
return null;
}
},
/**
* Takes a Number and formats to string for display to user.
*
* @method format
* @param data {Number} Number.
* @param config {Object} (Optional) Optional configuration values:
* <dl>
* <dt>prefix {String}</dd>
* <dd>String prepended before each number, like a currency designator "$"</dd>
* <dt>decimalPlaces {Number}</dd>
* <dd>Number of decimal places to round.</dd>
* <dt>decimalSeparator {String}</dd>
* <dd>Decimal separator</dd>
* <dt>thousandsSeparator {String}</dd>
* <dd>Thousands separator</dd>
* <dt>suffix {String}</dd>
* <dd>String appended after each number, like " items" (note the space)</dd>
* </dl>
* @return {String} Formatted number for display. Note, the following values
* return as "": null, undefined, NaN, "".
*/
// Decimal precision
// Round to the correct decimal place
}
// Decimal separator
if(decSep !== "."){
}
// Add the thousands separator
if(thouSep) {
// Find the dot or where it would be
// Start with the dot and everything to the right
// Working left, every third time add a separator, every time add a digit
}
count++;
}
}
// Prepend prefix
// Append suffix
return output;
}
// Still not a Number, just return unaltered
else {
return data;
}
}
};
Y.namespace("DataType").Number = Number;