Get the name of a number, even if it's stupidly big.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

29 lines
700 B

  1. import NAMES from './names.json'
  2. interface GetBaseHundredUnit {
  3. (hundreds: number): string
  4. }
  5. const getBaseHundredUnit: GetBaseHundredUnit = hundreds => {
  6. let hundredsUnit = NAMES.base.units[hundreds]
  7. const hundredsSuffix = NAMES.hundred
  8. const unitLastCharacter = hundredsUnit.slice(-1)
  9. switch (unitLastCharacter) {
  10. case 't':
  11. case 'm':
  12. return hundredsUnit + 'nar' + hundredsSuffix.slice(1)
  13. case 'a':
  14. if (hundredsUnit.startsWith('i')) {
  15. hundredsUnit = hundredsUnit.slice(1)
  16. }
  17. return hundredsUnit + 'n' + hundredsSuffix
  18. case 'o':
  19. default:
  20. break
  21. }
  22. return hundredsUnit + 'ng' + hundredsSuffix
  23. }
  24. export default getBaseHundredUnit