currency-in-words
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "currency-in-words", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Handles both indian-system and international-system. A light-weight, fast and efficient lib that converts currency or any numbers to corresponding words", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
299
README.md
@@ -6,2 +6,3 @@ # currency-in-words | ||
### Installation: | ||
@@ -12,3 +13,5 @@ | ||
``` | ||
___ | ||
### Usage: | ||
@@ -20,8 +23,8 @@ | ||
// indian-system | ||
const result = convert('777') | ||
const result = convert('777') // seven hundred seventy seven | ||
// or | ||
const result = convert('777', { format: 'in' }) | ||
const result = convert('777', { format: 'in' }) // seven hundred seventy seven | ||
// international-system | ||
const result = convert('777', { format: 'intl' }) | ||
const result = convert('777', { format: 'intl' }) // seven hundred seventy seven | ||
``` | ||
@@ -41,141 +44,7 @@ | ||
> 2. Decimals are corrected to two places | ||
___ | ||
Adding test-case results just to make your life easier.. | ||
> **Note** | ||
> 1. Commas in the test cases are just for readability, but doesn't support in the input. | ||
### :rocket: Hacks | ||
```javascript | ||
Convert Indian system | ||
✓ returns "NaN" for undefined (1 ms) | ||
✓ returns "NaN" for null | ||
✓ returns "NaN" for an invalid number(a1.01) | ||
✓ returns "NaN" for an invalid number(1.1a) | ||
✓ returns "NaN" for an invalid number(random string) | ||
✓ returns "one" when given the input 1 | ||
✓ returns "nine" when given the input 9 | ||
✓ returns "ten" when given the input 10 | ||
✓ returns "eleven" when given the input 11 | ||
✓ returns "nineteen" when given the input 19 | ||
✓ returns "ninety" when given the input 90 | ||
✓ returns "ninety nine" when given the input 99 | ||
✓ returns "one hundred" when given the input 100 | ||
✓ returns "one hundred nine" when given the input 109 (1 ms) | ||
✓ returns "one hundred ten" when given the input 110 | ||
✓ returns "one hundred eleven" when given the input 111 | ||
✓ returns "one hundred nineteen" when given the input 119 | ||
✓ returns "one hundred ninety" when given the input 190 (1 ms) | ||
✓ returns "one hundred ninety nine" when given the input 199 | ||
✓ returns "one thousand" when given the input 1000 | ||
✓ returns "one thousand one" when given the input 1001 | ||
✓ returns "one thousand ten" when given the input 1010 | ||
✓ returns "one thousand one hundred ten" when given the input 1110 | ||
✓ returns "one thousand one hundred eleven" when given the input 1111 | ||
✓ returns "one thousand one hundred ninety nine" when given the input 1199 | ||
✓ returns "one thousand nine hundred" when given the input 1900 (1 ms) | ||
✓ returns "one thousand nine hundred ninety nine" when given the input 1999 | ||
✓ returns "ten thousand" when given the input 10000 | ||
✓ returns "eleven thousand one hundred nine" when given the input 11109 | ||
✓ returns "eleven thousand one hundred ten" when given the input 11110 | ||
✓ returns "eleven thousand one hundred eleven" when given the input 11111 | ||
✓ returns "eleven thousand one hundred nineteen" when given the input 11119 (2 ms) | ||
✓ returns "eleven thousand one hundred ninety" when given the input 11190 | ||
✓ returns "eleven thousand one hundred ninety nine" when given the input 11199 | ||
✓ returns "one lakh" when given the input 1,00,000 | ||
✓ returns "one lakh eleven thousand one hundred nine" when given the input 1,11,109 | ||
✓ returns "one lakh eleven thousand one hundred ten" when given the input 1,11,110 | ||
✓ returns "one lakh eleven thousand one hundred eleven" when given the input 1,11,111 (1 ms) | ||
✓ returns "one lakh eleven thousand one hundred nineteen" when given the input 1,11,119 | ||
✓ returns "one lakh leven thousand one hundred ninety" when given the input 1,11,190 | ||
✓ returns "one lakh eleven thousand one hundred ninety nine" when given the input 1,11,199 | ||
✓ returns "ten lakh" when given the input 10,00,000 | ||
✓ returns "ten lakh eleven thousand one hundred nine" when given the input 10,11,109 | ||
✓ returns "ten lakh eleven thousand one hundred ten" when given the input 10,11,110 | ||
✓ returns "ten lakh eleven thousand one hundred eleven" when given the input 10,11,111 | ||
✓ returns "ten lakh eleven thousand one hundred nineteen" when given the input 10,11,119 | ||
✓ returns "ten lakh leven thousand one hundred ninety" when given the input 10,11,190 | ||
✓ returns "ten lakh eleven thousand one hundred ninety nine" when given the input 10,11,199 | ||
✓ returns "one crore" when given the input 1,00,00,000 | ||
✓ returns "one crore one lakh eleven thousand one hundred nine" when given the input 1,01,11,109 | ||
✓ returns "one crore one lakh eleven thousand one hundred ten" when given the input 1,01,11,110 | ||
✓ returns "one crore one lakh eleven thousand one hundred eleven" when given the input 1,01,11,111 | ||
✓ returns "oone crore ne lakh eleven thousand one hundred nineteen" when given the input 1,11,119 | ||
✓ returns "one crore one lakh leven thousand one hundred ninety" when given the input 1,11,190 | ||
✓ returns "one crore one lakh eleven thousand one hundred ninety nine" when given the input 1,11,199 | ||
✓ returns "ten crore ten lakh" when given the input 10,00,00,000 | ||
✓ returns "tten crore en lakh eleven thousand one hundred nine" when given the input 10,00,11,109 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred ten" when given the input 10,00,11,110 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred eleven" when given the input 10,00,11,111 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred nineteen" when given the input 10,00,11,119 | ||
✓ returns "ten crore ten lakh leven thousand one hundred ninety" when given the input 10,00,11,190 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred ninety nine" when given the input 10,00,11,199 | ||
✓ returns "five hundred fifty five" when given the input 555 | ||
✓ returns "seventy seven thousand two hundred eighty nine" when given the input 77,289 | ||
✓ returns "seventeen crore ninety nine lakh one hundred" when given the input 17,99,00,100 (1 ms) | ||
✓ returns "ninety nine crore ninety nine lakh ninety nine thousand nine hundred ninety nine" when given the input 99,99,99,999 | ||
✓ returns "one.one" when given the input 1.1 | ||
✓ returns "fifty seven.ninety nine" when given the input 57.99 | ||
✓ returns "ten" when given the input 10.01; ignore x.01 to x.09 | ||
✓ returns "zero" when given the input 0.00 | ||
✓ returns "zero" when given the input 000 | ||
✓ returns "three hundred thirty" when given the input 00330; corrected leading zeros | ||
✓ returns "eighty eight.twenty" when given the input 088.200; corrected leading zeros and two decimal places | ||
✓ returns "zero" when given the input 0.00 | ||
Convert international system | ||
✓ returns "NaN" for undefined (1 ms) | ||
✓ returns "NaN" for null | ||
✓ returns "NaN" for an invalid number(a1.01) | ||
✓ returns "NaN" for an invalid number(1.1a) | ||
✓ returns "NaN" for an invalid number(random string) | ||
✓ returns "one" when given the input 1 | ||
✓ returns "nine" when given the input 9 | ||
✓ returns "ten" when given the input 10 | ||
✓ returns "eleven" when given the input 11 | ||
✓ returns "nineteen" when given the input 19 (1 ms) | ||
✓ returns "ninety" when given the input 90 | ||
✓ returns "ninety nine" when given the input 99 | ||
✓ returns "one hundred" when given the input 100 | ||
✓ returns "one hundred nine" when given the input 109 | ||
✓ returns "one hundred ten" when given the input 110 | ||
✓ returns "one hundred eleven" when given the input 111 | ||
✓ returns "one hundred nineteen" when given the input 119 | ||
✓ returns "one hundred ninety" when given the input 190 | ||
✓ returns "one hundred ninety nine" when given the input 199 (1 ms) | ||
✓ returns "one thousand" when given the input 1,000 | ||
✓ returns "one thousand one" when given the input 1,001 | ||
✓ returns "one thousand eleven" when given the input 1,011 | ||
✓ returns "one thousand one hundred eleven" when given the input 1,111 | ||
✓ returns "ten thousand" when given the input 10,000 | ||
✓ returns "ten thousand one" when given the input 10,001 | ||
✓ returns "ten thousand eleven" when given the input 10,011 | ||
✓ returns "ten thousand one hundred eleven" when given the input 10,111 | ||
✓ returns "eleven thousand one hundred eleven" when given the input 11,111 | ||
✓ returns "one hundred thousand" when given the input 100,000 | ||
✓ returns "one million" when given the input 1,000,000 | ||
✓ returns "one million one" when given the input 1,000,001 | ||
✓ returns "one million eleven" when given the input 1,000,011 | ||
✓ returns "one million one hundred" when given the input 1,000,100 | ||
✓ returns "one million one hundred eleven" when given the input 1,000,111 | ||
✓ returns "one million one thousand" when given the input 1,001,000 | ||
✓ returns "one million" when given the input 1,001,001 | ||
✓ returns "one million one thousand eleven" when given the input 1,001,001 | ||
✓ returns "one million ten thousand one hundred eleven" when given the input 10,010,111 | ||
✓ returns "one million eleven thousand one hundred eleven" when given the input 1,011,111 | ||
✓ returns "one million one hundred thousand" when given the input 1,100,000 (1 ms) | ||
✓ returns "ten million" when given the input 10,011,111 | ||
✓ returns "nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine" when given the input 999,999,999 | ||
✓ returns "ten million" when given the input 10,000,000.99 | ||
✓ returns "ten million.fifty seven" when given the input 10,000,000.57 | ||
✓ returns "zero.ninety nine" when given the input 0.99 | ||
✓ returns "one.one" when given the input 1.1 | ||
✓ returns "fifty seven.ninety nine" when given the input 57.99 | ||
✓ returns "ten" when given the input 10.01; ignore x.01 to x.09 | ||
✓ returns "zero" when given the input 0.00 | ||
✓ returns "zero" when given the input 000 | ||
✓ returns "three hundred thirty" when given the input 00330; corrected leading zeros | ||
✓ returns "eighty eight.twenty" when given the input 088.200; corrected leading zeros and two decimal places | ||
``` | ||
#### :rocket: Hacks | ||
> Some of the features are not implemented for the sake of backward compatability between versions. Hey, but you can always find a way around.. | ||
@@ -188,3 +57,3 @@ | ||
const amount = 0.99 | ||
const convert = convert(`${amount}`) // template-literals will take care of casting it to a number | ||
const result = convert(`${amount}`) // zero.ninety nine | ||
``` | ||
@@ -195,8 +64,7 @@ | ||
```javascript | ||
const regex = /,/g | ||
const amount = '1,000.99' | ||
const replaced = amount.replace(regex, '') | ||
const sanitized = amount.replace(/,/, '') // 1000.99 | ||
``` | ||
For some reason, if you want the decimal places not to be corrected, you can control it from your code | ||
For some reason, if you want the decimal places not to be corrected, control it from your code | ||
@@ -206,3 +74,146 @@ ```javascript | ||
const [dollars, cents] = amount.split('.') | ||
const result = `${convert(dollars)}.${convert(cents)}` | ||
const result = `${convert(dollars)}.${convert(cents)}` // one hundred twenty threee.one hundred twenty three | ||
``` | ||
___ | ||
**Test Case Results** | ||
#### Added few test-case results just to make your life easier.. | ||
> **Note**: Commas in the test cases are just for readability, but doesn't support in the input. | ||
<div style="display:block;padding:20px;max-height:200px;overflow:scroll;background-color: #eee;border: 1px solid #999;"> | ||
<pre> | ||
<code> | ||
Convert Indian system | ||
✓ returns "NaN" for undefined (1 ms) | ||
✓ returns "NaN" for null | ||
✓ returns "NaN" for an invalid number(a1.01) | ||
✓ returns "NaN" for an invalid number(1.1a) | ||
✓ returns "NaN" for an invalid number(random string) | ||
✓ returns "one" when given the input 1 | ||
✓ returns "nine" when given the input 9 | ||
✓ returns "ten" when given the input 10 | ||
✓ returns "eleven" when given the input 11 | ||
✓ returns "nineteen" when given the input 19 | ||
✓ returns "ninety" when given the input 90 | ||
✓ returns "ninety nine" when given the input 99 | ||
✓ returns "one hundred" when given the input 100 | ||
✓ returns "one hundred nine" when given the input 109 (1 ms) | ||
✓ returns "one hundred ten" when given the input 110 | ||
✓ returns "one hundred eleven" when given the input 111 | ||
✓ returns "one hundred nineteen" when given the input 119 | ||
✓ returns "one hundred ninety" when given the input 190 (1 ms) | ||
✓ returns "one hundred ninety nine" when given the input 199 | ||
✓ returns "one thousand" when given the input 1000 | ||
✓ returns "one thousand one" when given the input 1001 | ||
✓ returns "one thousand ten" when given the input 1010 | ||
✓ returns "one thousand one hundred ten" when given the input 1110 | ||
✓ returns "one thousand one hundred eleven" when given the input 1111 | ||
✓ returns "one thousand one hundred ninety nine" when given the input 1199 | ||
✓ returns "one thousand nine hundred" when given the input 1900 (1 ms) | ||
✓ returns "one thousand nine hundred ninety nine" when given the input 1999 | ||
✓ returns "ten thousand" when given the input 10000 | ||
✓ returns "eleven thousand one hundred nine" when given the input 11109 | ||
✓ returns "eleven thousand one hundred ten" when given the input 11110 | ||
✓ returns "eleven thousand one hundred eleven" when given the input 11111 | ||
✓ returns "eleven thousand one hundred nineteen" when given the input 11119 (2 ms) | ||
✓ returns "eleven thousand one hundred ninety" when given the input 11190 | ||
✓ returns "eleven thousand one hundred ninety nine" when given the input 11199 | ||
✓ returns "one lakh" when given the input 1,00,000 | ||
✓ returns "one lakh eleven thousand one hundred nine" when given the input 1,11,109 | ||
✓ returns "one lakh eleven thousand one hundred ten" when given the input 1,11,110 | ||
✓ returns "one lakh eleven thousand one hundred eleven" when given the input 1,11,111 (1 ms) | ||
✓ returns "one lakh eleven thousand one hundred nineteen" when given the input 1,11,119 | ||
✓ returns "one lakh leven thousand one hundred ninety" when given the input 1,11,190 | ||
✓ returns "one lakh eleven thousand one hundred ninety nine" when given the input 1,11,199 | ||
✓ returns "ten lakh" when given the input 10,00,000 | ||
✓ returns "ten lakh eleven thousand one hundred nine" when given the input 10,11,109 | ||
✓ returns "ten lakh eleven thousand one hundred ten" when given the input 10,11,110 | ||
✓ returns "ten lakh eleven thousand one hundred eleven" when given the input 10,11,111 | ||
✓ returns "ten lakh eleven thousand one hundred nineteen" when given the input 10,11,119 | ||
✓ returns "ten lakh leven thousand one hundred ninety" when given the input 10,11,190 | ||
✓ returns "ten lakh eleven thousand one hundred ninety nine" when given the input 10,11,199 | ||
✓ returns "one crore" when given the input 1,00,00,000 | ||
✓ returns "one crore one lakh eleven thousand one hundred nine" when given the input 1,01,11,109 | ||
✓ returns "one crore one lakh eleven thousand one hundred ten" when given the input 1,01,11,110 | ||
✓ returns "one crore one lakh eleven thousand one hundred eleven" when given the input 1,01,11,111 | ||
✓ returns "oone crore ne lakh eleven thousand one hundred nineteen" when given the input 1,11,119 | ||
✓ returns "one crore one lakh leven thousand one hundred ninety" when given the input 1,11,190 | ||
✓ returns "one crore one lakh eleven thousand one hundred ninety nine" when given the input 1,11,199 | ||
✓ returns "ten crore ten lakh" when given the input 10,00,00,000 | ||
✓ returns "tten crore en lakh eleven thousand one hundred nine" when given the input 10,00,11,109 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred ten" when given the input 10,00,11,110 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred eleven" when given the input 10,00,11,111 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred nineteen" when given the input 10,00,11,119 | ||
✓ returns "ten crore ten lakh leven thousand one hundred ninety" when given the input 10,00,11,190 | ||
✓ returns "ten crore ten lakh eleven thousand one hundred ninety nine" when given the input 10,00,11,199 | ||
✓ returns "five hundred fifty five" when given the input 555 | ||
✓ returns "seventy seven thousand two hundred eighty nine" when given the input 77,289 | ||
✓ returns "seventeen crore ninety nine lakh one hundred" when given the input 17,99,00,100 (1 ms) | ||
✓ returns "ninety nine crore ninety nine lakh ninety nine thousand nine hundred ninety nine" when given the input 99,99,99,999 | ||
✓ returns "one.one" when given the input 1.1 | ||
✓ returns "fifty seven.ninety nine" when given the input 57.99 | ||
✓ returns "ten" when given the input 10.01; ignore x.01 to x.09 | ||
✓ returns "zero" when given the input 0.00 | ||
✓ returns "zero" when given the input 000 | ||
✓ returns "three hundred thirty" when given the input 00330; corrected leading zeros | ||
✓ returns "eighty eight.twenty" when given the input 088.200; corrected leading zeros and two decimal places | ||
✓ returns "zero" when given the input 0.00 | ||
Convert international system | ||
✓ returns "NaN" for undefined (1 ms) | ||
✓ returns "NaN" for null | ||
✓ returns "NaN" for an invalid number(a1.01) | ||
✓ returns "NaN" for an invalid number(1.1a) | ||
✓ returns "NaN" for an invalid number(random string) | ||
✓ returns "one" when given the input 1 | ||
✓ returns "nine" when given the input 9 | ||
✓ returns "ten" when given the input 10 | ||
✓ returns "eleven" when given the input 11 | ||
✓ returns "nineteen" when given the input 19 (1 ms) | ||
✓ returns "ninety" when given the input 90 | ||
✓ returns "ninety nine" when given the input 99 | ||
✓ returns "one hundred" when given the input 100 | ||
✓ returns "one hundred nine" when given the input 109 | ||
✓ returns "one hundred ten" when given the input 110 | ||
✓ returns "one hundred eleven" when given the input 111 | ||
✓ returns "one hundred nineteen" when given the input 119 | ||
✓ returns "one hundred ninety" when given the input 190 | ||
✓ returns "one hundred ninety nine" when given the input 199 (1 ms) | ||
✓ returns "one thousand" when given the input 1,000 | ||
✓ returns "one thousand one" when given the input 1,001 | ||
✓ returns "one thousand eleven" when given the input 1,011 | ||
✓ returns "one thousand one hundred eleven" when given the input 1,111 | ||
✓ returns "ten thousand" when given the input 10,000 | ||
✓ returns "ten thousand one" when given the input 10,001 | ||
✓ returns "ten thousand eleven" when given the input 10,011 | ||
✓ returns "ten thousand one hundred eleven" when given the input 10,111 | ||
✓ returns "eleven thousand one hundred eleven" when given the input 11,111 | ||
✓ returns "one hundred thousand" when given the input 100,000 | ||
✓ returns "one million" when given the input 1,000,000 | ||
✓ returns "one million one" when given the input 1,000,001 | ||
✓ returns "one million eleven" when given the input 1,000,011 | ||
✓ returns "one million one hundred" when given the input 1,000,100 | ||
✓ returns "one million one hundred eleven" when given the input 1,000,111 | ||
✓ returns "one million one thousand" when given the input 1,001,000 | ||
✓ returns "one million" when given the input 1,001,001 | ||
✓ returns "one million one thousand eleven" when given the input 1,001,001 | ||
✓ returns "one million ten thousand one hundred eleven" when given the input 10,010,111 | ||
✓ returns "one million eleven thousand one hundred eleven" when given the input 1,011,111 | ||
✓ returns "one million one hundred thousand" when given the input 1,100,000 (1 ms) | ||
✓ returns "ten million" when given the input 10,011,111 | ||
✓ returns "nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine" when given the input 999,999,999 | ||
✓ returns "ten million" when given the input 10,000,000.99 | ||
✓ returns "ten million.fifty seven" when given the input 10,000,000.57 | ||
✓ returns "zero.ninety nine" when given the input 0.99 | ||
✓ returns "one.one" when given the input 1.1 | ||
✓ returns "fifty seven.ninety nine" when given the input 57.99 | ||
✓ returns "ten" when given the input 10.01; ignore x.01 to x.09 | ||
✓ returns "zero" when given the input 0.00 | ||
✓ returns "zero" when given the input 000 | ||
✓ returns "three hundred thirty" when given the input 00330; corrected leading zeros | ||
✓ returns "eighty eight.twenty" when given the input 088.200; corrected leading zeros and two decimal places | ||
</code> | ||
</pre> | ||
</div> |
@@ -1,8 +0,6 @@ | ||
import { convertIntl } from './utils/intl' | ||
import { indian } from './utils/in' | ||
import { handleTens } from './utils/common' | ||
import { convertIntl, indianFormat, handleTens } from './utils' | ||
type standard = 'in' | 'intl' | ||
type language = 'en' | ||
interface params { | ||
interface IConvert { | ||
format?: standard, | ||
@@ -14,14 +12,15 @@ lang?: language | ||
value: string, | ||
{ format, lang }: params = { format: 'in', lang: 'en' } | ||
{ format, lang }: IConvert = { format: 'in', lang: 'en' } | ||
): string { | ||
let result = '' | ||
const regex = /^\d*(\.\d+)?$/ | ||
if (!value || !value.match(regex)) return 'NaN' | ||
if (!value || !value.match(/^\d*(\.\d+)?$/)) return 'NaN' | ||
const [integer, fraction] = value.split('.') | ||
const zeroCorrected = `${parseInt(integer, 10)}` | ||
const zeroCorrected: string = `${parseInt(integer, 10)}` | ||
const twoDecimalPlaces: string = parseInt(fraction, 10) ? `${fraction.substring(0, 2)}` : `` | ||
if (parseInt(fraction) && zeroCorrected === '0') return `zero.${handleTens(fraction.substring(0, 2))}` | ||
if (parseInt(fraction, 10) && zeroCorrected === '0') return `zero.${handleTens(twoDecimalPlaces)}` | ||
if (zeroCorrected === '0') return 'zero' | ||
let result = '' | ||
if (format === 'intl') { | ||
@@ -31,9 +30,9 @@ result = convertIntl(zeroCorrected) | ||
if (fraction && +fraction[0] !== 0) | ||
result = `${result.trim()}.${handleTens(fraction.substring(0, 2))}` | ||
result = `${result.trim()}.${handleTens(twoDecimalPlaces)}` | ||
} else { | ||
const integerResult = (indian[zeroCorrected.length] as Function)(zeroCorrected) | ||
const integerResult = (indianFormat[zeroCorrected.length] as Function)(zeroCorrected) | ||
result = integerResult | ||
if (fraction && +fraction[0] !== 0) // ignore .01 - .09 | ||
result = `${result}.${(indian[fraction.substring(0, 2).length] as Function)(fraction.substring(0, 2))}` // limit to two decimal places.` | ||
result = `${result}.${(indianFormat[twoDecimalPlaces.length] as Function)(twoDecimalPlaces)}` // limit to two decimal places.` | ||
} | ||
@@ -40,0 +39,0 @@ |
import { singleDigit, caseOne, twoDigit } from "../lang/en" | ||
export function isFirstCharZero(key: string): boolean { | ||
return +key[0] === 0 | ||
function isFirstCharZero(value: string): boolean { | ||
return +value[0] === 0 | ||
} | ||
export function isSecondCharZero(key: string): boolean { | ||
return +key[1] === 0 | ||
function isSecondCharZero(value: string): boolean { | ||
return +value[1] === 0 | ||
} | ||
/** | ||
* Pass "key" as string for function argument, but cast to number (+key) when used as Array<string> index | ||
*/ | ||
export function handleOnes(key: string): string { | ||
return singleDigit[+key] | ||
function handleOnes(value: string): string { | ||
return singleDigit[+value] | ||
} | ||
export function handleTeens(key: string): string { | ||
if (+key[0] === 1) | ||
return caseOne[+key.slice(-1)] | ||
function handleTeens(value: string): string { | ||
if (+value[0] === 1) | ||
return caseOne[+value.slice(-1)] | ||
else | ||
return `${twoDigit[+key[0]]} ${singleDigit[+key.slice(-1)]}` | ||
return `${twoDigit[+value[0]]} ${singleDigit[+value.slice(-1)]}` | ||
} | ||
export function handleTens(key: string): string { | ||
if (isFirstCharZero(key)) | ||
return `${singleDigit[+key[1]]}` | ||
if (isSecondCharZero(key)) | ||
return `${twoDigit[+key[0]]}` | ||
return handleTeens(key) | ||
function handleTens(value: string): string { | ||
if (isFirstCharZero(value)) | ||
return `${singleDigit[+value[1]]}` | ||
if (isSecondCharZero(value)) | ||
return `${twoDigit[+value[0]]}` | ||
return handleTeens(value) | ||
} | ||
export { isFirstCharZero, isSecondCharZero, handleOnes, handleTeens, handleTens } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55259
12
802
213