(d: Numbers)
| 55 | } |
| 56 | |
| 57 | function extractNumbers(d: Numbers): RawNumberData { |
| 58 | const nu = |
| 59 | d.defaultNumberingSystem === 'latn' |
| 60 | ? ['latn'] |
| 61 | : [d.defaultNumberingSystem, 'latn'] |
| 62 | return { |
| 63 | nu, |
| 64 | symbols: nu.reduce((all: Record<string, SymbolsData>, ns) => { |
| 65 | const rangeSign = d[ |
| 66 | `miscPatterns-numberSystem-${ns}` as 'miscPatterns-numberSystem-latn' |
| 67 | ].range |
| 68 | .match(/[^{}01]/)! |
| 69 | .at(0) as string |
| 70 | |
| 71 | all[ns] = { |
| 72 | ...d[`symbols-numberSystem-${ns}` as 'symbols-numberSystem-latn'], |
| 73 | rangeSign, |
| 74 | } |
| 75 | return all |
| 76 | }, {}), |
| 77 | percent: nu.reduce((all: RawNumberData['percent'], ns) => { |
| 78 | all[ns] = |
| 79 | d[ |
| 80 | `percentFormats-numberSystem-${ns}` as 'percentFormats-numberSystem-latn' |
| 81 | ].standard |
| 82 | return all |
| 83 | }, {}), |
| 84 | decimal: nu.reduce((all: RawNumberData['decimal'], ns) => { |
| 85 | const decimalData = |
| 86 | d[ |
| 87 | `decimalFormats-numberSystem-${ns}` as 'decimalFormats-numberSystem-latn' |
| 88 | ] |
| 89 | const longData = decimalData.long.decimalFormat |
| 90 | const shortData = decimalData.short.decimalFormat |
| 91 | |
| 92 | invariant( |
| 93 | decimalData.standard.includes('.'), |
| 94 | `Decimal pattern does not contain decimal point: ${decimalData.standard}` |
| 95 | ) |
| 96 | |
| 97 | all[ns] = { |
| 98 | standard: decimalData.standard, |
| 99 | long: reduceNumCount(longData), |
| 100 | short: reduceNumCount(shortData), |
| 101 | } |
| 102 | return all |
| 103 | }, {}), |
| 104 | currency: nu.reduce((all: RawNumberData['currency'], ns) => { |
| 105 | const { |
| 106 | currencySpacing, |
| 107 | standard, |
| 108 | accounting, |
| 109 | 'unitPattern-count-other': unitPattern, |
| 110 | short, |
| 111 | } = d[ |
| 112 | `currencyFormats-numberSystem-${ns}` as 'currencyFormats-numberSystem-latn' |
| 113 | ] |
| 114 | all[ns] = { |
no test coverage detected