goog.format
Functions
fileSize( bytes, opt_decimals ) → string
string
insertWordBreaks( str, opt_maxlen ) → string
string
Inserts word breaks into an HTML string at a given interval.
This method is as aggressive as possible, using a full table of Unicode characters where it is legal to insert word breaks; however, this table comes at a 2.5k pre-gzip (~1k post-gzip) size cost. Consider using insertWordBreaksBasic to minimize the size impact.
warning Deprecated | Prefer wrapping with CSS word-wrap: break-word. |
---|
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
insertWordBreaksBasic( str, opt_maxlen ) → string
string
Inserts word breaks into an HTML string at a given interval.
This method is less aggressive than insertWordBreaks, only inserting breaks next to punctuation and between Latin or Cyrillic characters. However, this is good enough for the common case of URLs. It also works for all Latin and Cyrillic languages, plus CJK has no need for word breaks. When this method is used, goog.i18n.GraphemeBreak may be dead code eliminated.
warning Deprecated | Prefer wrapping with CSS word-wrap: break-word. |
---|
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
isConvertableScaledNumber( val ) → boolean
boolean
Checks whether string value containing scaling units (K, M, G, T, P, m, u, n) can be converted to a number.
Where there is a decimal, there must be a digit to the left of the decimal point.
Negative numbers are valid.
Examples: 0, 1, 1.0, 10.4K, 2.3M, -0.3P, 1.2m
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
numBytesToString( val, opt_decimals, opt_suffix, opt_useSeparator ) → string
string
Converts number of bytes to string representation. Binary conversion. Default is to return the additional 'B' suffix only for scales greater than 1K, e.g. '10.5KB' to minimize confusion with counts that are scaled by powers of 1000. Otherwise, suffix is empty string.
Parameters |
| ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
numericValueToString( val, opt_decimals ) → string
string
stringToNumBytes( stringValue ) → number
number
stringToNumericValue( stringValue ) → number
number
Properties
WORD_BREAK_HTML → string
string
Constant for the WBR replacement used by insertWordBreaks. Safari requires <wbr></wbr>, Opera needs the entity, though this will give a visible hyphen at breaks. IE8 uses a zero width space. Other browsers just use <wbr>.