|
- import getHundredName from './getHundredName'
- import NAMES from './names.json'
- import getBaseHundredUnit from './getBaseHundredUnit'
-
- interface GetThousandName {
- (hundreds: number, tens: number, ones: number): string,
- }
-
- const getThousandName: GetThousandName = (hundreds, tens, ones) => {
- if (hundreds === 0) {
- return getHundredName(tens, ones)
- }
-
- if (tens === 0 && ones === 0) {
- return getBaseHundredUnit(hundreds)
- }
-
- if (tens === 0) {
- return [
- getBaseHundredUnit(hundreds),
- NAMES.and,
- NAMES.base.units[ones],
- ]
- .join(' ')
- }
-
- return [
- getBaseHundredUnit(hundreds),
- getHundredName(tens, ones),
- ]
- .join(' ')
- }
-
- export default getThousandName
|