(str: string)
| 49 | const CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/ |
| 50 | |
| 51 | function parseSignificantPrecision(str: string): ExtendedNumberFormatOptions { |
| 52 | const result: ExtendedNumberFormatOptions = {} |
| 53 | if (str[str.length - 1] === 'r') { |
| 54 | result.roundingPriority = 'morePrecision' |
| 55 | } else if (str[str.length - 1] === 's') { |
| 56 | result.roundingPriority = 'lessPrecision' |
| 57 | } |
| 58 | str.replace( |
| 59 | SIGNIFICANT_PRECISION_REGEX, |
| 60 | function (_: string, g1: string, g2: string | number) { |
| 61 | // @@@ case |
| 62 | if (typeof g2 !== 'string') { |
| 63 | result.minimumSignificantDigits = g1.length |
| 64 | result.maximumSignificantDigits = g1.length |
| 65 | } |
| 66 | // @@@+ case |
| 67 | else if (g2 === '+') { |
| 68 | result.minimumSignificantDigits = g1.length |
| 69 | } |
| 70 | // .### case |
| 71 | else if (g1[0] === '#') { |
| 72 | result.maximumSignificantDigits = g1.length |
| 73 | } |
| 74 | // .@@## or .@@@ case |
| 75 | else { |
| 76 | result.minimumSignificantDigits = g1.length |
| 77 | result.maximumSignificantDigits = |
| 78 | g1.length + (typeof g2 === 'string' ? g2.length : 0) |
| 79 | } |
| 80 | return '' |
| 81 | } |
| 82 | ) |
| 83 | return result |
| 84 | } |
| 85 | |
| 86 | function parseSign(str: string): ExtendedNumberFormatOptions | undefined { |
| 87 | switch (str) { |
no outgoing calls
no test coverage detected