|
- import { GetKiloName } from '../../NumberSystem'
- import NAMES from './names.json'
- import getKiloCombiningPrefix from './base/kilo/combiningPrefix'
-
- const capitalizeFirstLetter = (word: string) => word.slice(0, 1).toUpperCase() + word.slice(1)
-
- const getLongKiloName: GetKiloName = (thousandPower) => {
- if (thousandPower === 0) {
- return ''
- }
- if (thousandPower === 1) {
- return capitalizeFirstLetter(NAMES.thousand)
- }
- const kilo = thousandPower
- const kiloHundreds = Math.floor(kilo / 2 / 100)
- const kiloTens = Math.floor((kilo / 2 / 10) % 10)
- const kiloOnes = Math.floor((kilo / 2) % 10)
- const kiloCombiningPrefix = getKiloCombiningPrefix(kiloHundreds, kiloTens, kiloOnes)
-
- return capitalizeFirstLetter(
- thousandPower % 2 === 0 ? kiloCombiningPrefix + NAMES.kiloEvenSuffix : kiloCombiningPrefix + NAMES.kiloOddSuffix,
- )
- }
-
- export default getLongKiloName
|