Get the name of a number, even if it's stupidly big.
You can not select more than 25 topics
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.
|
- import NAMES from './names.json'
-
- interface GetBaseTenUnit {
- (tens: number): string
- }
-
- const getBaseTenUnit: GetBaseTenUnit = (tens) => {
- let tenUnit = NAMES.base.units[tens]
- const tenSuffix = NAMES.ten
- const unitLastCharacter = tenUnit.slice(-1)
- switch (unitLastCharacter) {
- case 't':
- case 'm':
- return tenUnit + 'na' + tenSuffix
- case 'o':
- tenUnit = tenUnit.slice(0, -1) + 'u'
- break
- case 'a':
- if (tenUnit.startsWith('i')) {
- tenUnit = tenUnit.slice(1)
- }
- break
- default:
- break
- }
-
- return tenUnit + 'm' + tenSuffix
- }
-
- export default getBaseTenUnit
|