Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

to-words

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-words - npm Package Compare versions

Comparing version 3.7.0 to 4.0.0

__tests__/en-IE.test.ts

2

__tests__/ee-EE.test.ts

@@ -145,3 +145,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Ainult Null Eurot Ja Üheksakümmend Seitse Senti`],
[0.999, `Ainult Üks Eurot`],
[0.999, `Ainult Üks Euro`],
[37.06, `Ainult Kolmkümmend Seitse Eurot Ja Kuus Senti`],

@@ -148,0 +148,0 @@ [37.068, `Ainult Kolmkümmend Seitse Eurot Ja Seitse Senti`],

@@ -157,3 +157,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Dirhams And Ninety Seven Fils Only`],
[0.999, `One Dirhams Only`],
[0.999, `One Dirham Only`],
[37.06, `Thirty Seven Dirhams And Six Fils Only`],

@@ -160,0 +160,0 @@ [37.068, `Thirty Seven Dirhams And Seven Fils Only`],

@@ -152,2 +152,3 @@ import { cloneDeep } from 'lodash';

[0.0, `Zero Pounds Only`],
[0.01, `Zero Pounds And One Penny Only`],
[0.04, `Zero Pounds And Four Pence Only`],

@@ -158,3 +159,3 @@ [0.0468, `Zero Pounds And Five Pence Only`],

[0.973, `Zero Pounds And Ninety Seven Pence Only`],
[0.999, `One Pounds Only`],
[0.999, `One Pound Only`],
[37.06, `Thirty Seven Pounds And Six Pence Only`],

@@ -201,3 +202,3 @@ [37.068, `Thirty Seven Pounds And Seven Pence Only`],

} else {
row[1] = (row[1] as string).replace(new RegExp(` And [\\w ]+ Pence`), '');
row[1] = (row[1] as string).replace(new RegExp(` And [\\w ]+ (Pence|Penny)`), '');
}

@@ -204,0 +205,0 @@ });

@@ -157,3 +157,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Cedis And Ninety Seven Pesewas Only`],
[0.999, `One Cedis Only`],
[0.999, `One Cedi Only`],
[37.06, `Thirty Seven Cedis And Six Pesewas Only`],

@@ -160,0 +160,0 @@ [37.068, `Thirty Seven Cedis And Seven Pesewas Only`],

@@ -146,2 +146,3 @@ import { cloneDeep } from 'lodash';

[0.0, `Zero Rupees Only`],
[0.01, `Zero Rupees And One Paisa Only`],
[0.04, `Zero Rupees And Four Paise Only`],

@@ -152,3 +153,3 @@ [0.0468, `Zero Rupees And Five Paise Only`],

[0.973, `Zero Rupees And Ninety Seven Paise Only`],
[0.999, `One Rupees Only`],
[0.999, `One Rupee Only`],
[37.06, `Thirty Seven Rupees And Six Paise Only`],

@@ -195,3 +196,3 @@ [37.068, `Thirty Seven Rupees And Seven Paise Only`],

} else {
row[1] = (row[1] as string).replace(new RegExp(` And [\\w ]+ Paise`), '');
row[1] = (row[1] as string).replace(new RegExp(` And [\\w ]+ (Paise|Paisa)`), '');
}

@@ -217,3 +218,3 @@ });

}
row[1] = (row[1] as string).replace(new RegExp(` And [\\w ]+ Paise`), '');
row[1] = (row[1] as string).replace(new RegExp(` And [\\w ]+ (Paise|Paisa)`), '');
});

@@ -220,0 +221,0 @@

@@ -157,3 +157,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Kyats And Ninety Seven Pyas Only`],
[0.999, `One Kyats Only`],
[0.999, `One Kyat Only`],
[37.06, `Thirty Seven Kyats And Six Pyas Only`],

@@ -160,0 +160,0 @@ [37.068, `Thirty Seven Kyats And Seven Pyas Only`],

@@ -151,3 +151,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Rupees And Ninety Seven Cents Only`],
[0.999, `One Rupees Only`],
[0.999, `One Rupee Only`],
[37.06, `Thirty Seven Rupees And Six Cents Only`],

@@ -154,0 +154,0 @@ [37.068, `Thirty Seven Rupees And Seven Cents Only`],

@@ -151,3 +151,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Rupees And Ninety Seven Paisa Only`],
[0.999, `One Rupees Only`],
[0.999, `One Rupee Only`],
[37.06, `Thirty Seven Rupees And Six Paisa Only`],

@@ -154,0 +154,0 @@ [37.068, `Thirty Seven Rupees And Seven Paisa Only`],

@@ -157,3 +157,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Pesos And Ninety Seven Cents Only`],
[0.999, `One Pesos Only`],
[0.999, `One Peso Only`],
[37.06, `Thirty Seven Pesos And Six Cents Only`],

@@ -160,0 +160,0 @@ [37.068, `Thirty Seven Pesos And Seven Cents Only`],

@@ -157,3 +157,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Dollars And Ninety Seven Cents Only`],
[0.999, `One Dollars Only`],
[0.999, `One Dollar Only`],
[37.06, `Thirty Seven Dollars And Six Cents Only`],

@@ -245,3 +245,3 @@ [37.068, `Thirty Seven Dollars And Seven Cents Only`],

[0.973, `Zero Euros And Ninety Seven Eurocents Only`],
[0.999, `One Euros Only`],
[0.999, `One Euro Only`],
[37.06, `Thirty Seven Euros And Six Eurocents Only`],

@@ -256,2 +256,3 @@ [37.068, `Thirty Seven Euros And Seven Eurocents Only`],

plural: 'Euros',
singular: 'Euro',
symbol: '€',

@@ -261,2 +262,3 @@ fractionalUnit: {

plural: 'Eurocents',
singular: 'Eurocent',
symbol: '¢',

@@ -263,0 +265,0 @@ },

@@ -137,3 +137,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zéro Euros Et Nonante-Sept Centimes`],
[0.999, `Un Euros`],
[0.999, `Un Euro`],
[37.06, `Trente-Sept Euros Et Six Centimes`],

@@ -140,0 +140,0 @@ [37.068, `Trente-Sept Euros Et Sept Centimes`],

@@ -140,3 +140,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zéro Euros Et Quatre-Vingt-Dix-Sept Centimes`],
[0.999, `Un Euros`],
[0.999, `Un Euro`],
[37.06, `Trente-Sept Euros Et Six Centimes`],

@@ -143,0 +143,0 @@ [37.068, `Trente-Sept Euros Et Sept Centimes`],

@@ -127,3 +127,3 @@ import { cloneDeep } from 'lodash';

[0.973, 'શૂન્ય રૂપિયા અને સત્તાણું પૈસા'],
[0.999, 'એક રૂપિયા'],
[0.999, 'એક રૂપિયો'],
[37.06, 'સાડત્રીસ રૂપિયા અને છ પૈસા'],

@@ -130,0 +130,0 @@ [37.068, 'સાડત્રીસ રૂપિયા અને સાત પૈસા'],

@@ -131,3 +131,3 @@ import { cloneDeep } from 'lodash';

[0.973, 'शून्य रुपये और सत्तानवे पैसे'],
[0.999, 'एक रुपये'],
[0.999, 'एक रुपया'],
[37.06, 'सैंतीस रुपये और छह पैसे'],

@@ -134,0 +134,0 @@ [37.068, 'सैंतीस रुपये और सात पैसे'],

@@ -130,3 +130,3 @@ import { cloneDeep } from 'lodash';

[0.973, 'शून्य रुपये आणि सत्त्याण्णव पैसे'],
[0.999, 'एक रुपये'],
[0.999, 'एक रुपया'],
[37.06, 'सदतीस रुपये आणि सहा पैसे'],

@@ -133,0 +133,0 @@ [37.068, 'सदतीस रुपये आणि सात पैसे'],

@@ -159,3 +159,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Nul Surinaamse dollars En Zevenennegentig Centen`],
[0.999, `Een Surinaamse dollars`],
[0.999, `Een Surinaamse dollar`],
[37.06, `Zevenendertig Surinaamse dollars En Zes Centen`],

@@ -162,0 +162,0 @@ [37.068, `Zevenendertig Surinaamse dollars En Zeven Centen`],

@@ -157,3 +157,3 @@ import { cloneDeep } from 'lodash';

[0.973, `Zero Reais E Noventa E Sete Centavos`],
[0.999, `Um Reais`],
[0.999, `Um Real`],
[37.06, `Trinta E Sete Reais E Seis Centavos`],

@@ -160,0 +160,0 @@ [37.068, `Trinta E Sete Reais E Sete Centavos`],

@@ -5,2 +5,4 @@ # Changelog

## [4.0.0](https://github.com/mastermunj/to-words/compare/v3.7.0...v4.0.0) (2023-12-21)
## [3.7.0](https://github.com/mastermunj/to-words/compare/v3.6.1...v3.7.0) (2023-11-28)

@@ -7,0 +9,0 @@

@@ -9,5 +9,7 @@ "use strict";

plural: 'Eurot',
singular: 'Euro',
symbol: '€',
fractionalUnit: {
name: 'Sent',
singular: 'Sent',
plural: 'Senti',

@@ -14,0 +16,0 @@ symbol: '¢',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Dirhams',
singular: 'Dirham',
symbol: '',
fractionalUnit: {
name: 'Fil',
singular: 'Fil',
plural: 'Fils',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Taka',
singular: 'Taka',
symbol: '৳',
fractionalUnit: {
name: 'Poysha',
singular: 'Poysha',
plural: 'Poysha',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,2 +9,3 @@ "use strict";

plural: 'Pounds',
singular: 'Pound',
symbol: '£',

@@ -14,2 +15,3 @@ fractionalUnit: {

plural: 'Pence',
singular: 'Penny',
symbol: '',

@@ -16,0 +18,0 @@ },

@@ -9,5 +9,7 @@ "use strict";

plural: 'Cedis',
singular: 'Cedi',
symbol: 'GH¢',
fractionalUnit: {
name: 'Pesewa',
singular: 'Pesewa',
plural: 'Pesewas',

@@ -14,0 +16,0 @@ symbol: 'Gp',

@@ -9,2 +9,3 @@ "use strict";

plural: 'Rupees',
singular: 'Rupee',
symbol: '₹',

@@ -14,2 +15,3 @@ fractionalUnit: {

plural: 'Paise',
singular: 'Paisa',
symbol: '',

@@ -16,0 +18,0 @@ },

@@ -9,5 +9,7 @@ "use strict";

plural: 'Kyats',
singular: 'Kyat',
symbol: 'K',
fractionalUnit: {
name: 'Pya',
singular: 'Pya',
plural: 'Pyas',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Rupees',
singular: 'Rupee',
symbol: 'Rs',
fractionalUnit: {
name: 'Cent',
singular: 'Cent',
plural: 'Cents',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Naira',
singular: 'Naira',
symbol: '₦',
fractionalUnit: {
name: 'Kobo',
singular: 'Kobo',
plural: 'Kobo',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Rupees',
singular: 'Rupee',
symbol: '₹',
fractionalUnit: {
name: 'Paisa',
singular: 'Paisa',
plural: 'Paisa',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Pesos',
singular: 'Peso',
symbol: '₱',
fractionalUnit: {
name: 'Cent',
singular: 'Cent',
plural: 'Cents',

@@ -14,0 +16,0 @@ symbol: '¢',

@@ -9,2 +9,3 @@ "use strict";

plural: 'Dollars',
singular: 'Dollar',
symbol: '$',

@@ -14,2 +15,3 @@ fractionalUnit: {

plural: 'Cents',
singular: 'Cent',
symbol: '¢',

@@ -16,0 +18,0 @@ },

@@ -9,5 +9,7 @@ "use strict";

plural: '',
singular: '',
symbol: 'تومان',
fractionalUnit: {
name: '',
singular: 'ریال',
plural: 'تومان',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Euros',
singular: 'Euro',
symbol: '€',
fractionalUnit: {
name: 'Centime',
singular: 'Centime',
plural: 'Centimes',

@@ -14,0 +16,0 @@ symbol: 'Cts',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Euros',
singular: 'Euro',
symbol: '€',
fractionalUnit: {
name: 'Centime',
singular: 'Centime',
plural: 'Centimes',

@@ -14,0 +16,0 @@ symbol: 'Cts',

@@ -9,5 +9,7 @@ "use strict";

plural: 'રૂપિયા',
singular: 'રૂપિયો',
symbol: '₹',
fractionalUnit: {
name: 'પૈસા',
singular: 'પૈસા',
plural: 'પૈસા',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'रुपये',
singular: 'रुपया',
symbol: '₹',
fractionalUnit: {
name: 'पैसा',
singular: 'पैसा',
plural: 'पैसे',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'रुपये',
singular: 'रुपया',
symbol: '₹',
fractionalUnit: {
name: 'पैसा',
singular: 'पैसा',
plural: 'पैसे',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Surinaamse dollars',
singular: 'Surinaamse dollar',
symbol: 'SRD',
fractionalUnit: {
name: 'Cent',
singular: 'Cent',
plural: 'Centen',

@@ -14,0 +16,0 @@ symbol: 'SRD',

@@ -9,5 +9,7 @@ "use strict";

plural: 'Reais',
singular: 'Real',
symbol: 'R$',
fractionalUnit: {
name: 'Centavo',
singular: 'Centavo',
plural: 'Centavos',

@@ -14,0 +16,0 @@ symbol: '',

@@ -9,5 +9,7 @@ "use strict";

plural: '',
singular: '',
symbol: '₺',
fractionalUnit: {
name: '',
singular: 'lira',
plural: 'lira',

@@ -14,0 +16,0 @@ symbol: '',

@@ -10,2 +10,3 @@ "use strict";

const en_GH_1 = __importDefault(require("./locales/en-GH"));
const en_IE_1 = __importDefault(require("./locales/en-IE"));
const en_IN_1 = __importDefault(require("./locales/en-IN"));

@@ -56,2 +57,4 @@ const en_MM_1 = __importDefault(require("./locales/en-MM"));

return en_GH_1.default;
case 'en-IE':
return en_IE_1.default;
case 'en-IN':

@@ -172,3 +175,8 @@ return en_IN_1.default;

let words = [...this.convertInternal(Number(split[0]))];
if (currencyOptions.plural) {
// Determine if the main currency should be in singular form
// e.g. 1 Dollar Only instead of 1 Dollars Only
if (Number(split[0]) === 1 && currencyOptions.singular) {
words.push(currencyOptions.name);
}
else if (currencyOptions.plural) {
words.push(currencyOptions.plural);

@@ -187,3 +195,4 @@ }

}
wordsWithDecimal.push(...this.convertInternal(Number(split[1]) * (!locale.config.decimalLengthWordMapping ? Math.pow(10, 2 - split[1].length) : 1)));
const decimalPart = Number(split[1]) * (!locale.config.decimalLengthWordMapping ? Math.pow(10, 2 - split[1].length) : 1);
wordsWithDecimal.push(...this.convertInternal(decimalPart));
const decimalLengthWord = (_d = (_c = locale.config) === null || _c === void 0 ? void 0 : _c.decimalLengthWordMapping) === null || _d === void 0 ? void 0 : _d[split[1].length];

@@ -193,3 +202,10 @@ if (decimalLengthWord === null || decimalLengthWord === void 0 ? void 0 : decimalLengthWord.length) {

}
wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);
// Determine if the fractional unit should be in singular form
// e.g. 1 Dollar and 1 Cent Only instead of 1 Dollar and 1 Cents Only
if (decimalPart === 1 && currencyOptions.fractionalUnit.singular) {
wordsWithDecimal.push(currencyOptions.fractionalUnit.singular);
}
else {
wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);
}
}

@@ -196,0 +212,0 @@ else if (locale.config.decimalLengthWordMapping && words.length) {

@@ -5,5 +5,7 @@ export interface CurrencyOptions {

symbol: string;
singular?: string;
fractionalUnit: {
name: string;
plural: string;
singular?: string;
symbol: string;

@@ -10,0 +12,0 @@ };

{
"name": "to-words",
"version": "3.7.0",
"version": "4.0.0",
"description": "Converts numbers (including decimal points) into words & currency.",

@@ -46,19 +46,19 @@ "keywords": [

"@commitlint/config-conventional": "^18.4.3",
"@types/jest": "^29.5.10",
"@types/jest": "^29.5.11",
"@types/lodash": "^4.14.202",
"@types/node": "^20.10.0",
"@types/node": "^20.10.5",
"@types/source-map-support": "^0.5.10",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-prettier": "^5.1.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lint-staged": "^15.1.0",
"lint-staged": "^15.2.0",
"lodash": "^4.17.21",
"prettier": "^3.1.0",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",

@@ -69,3 +69,3 @@ "sort-package-json": "^1.57.0",

"ts-jest": "^29.1.1",
"typescript": "^5.3.2"
"typescript": "^5.3.3"
},

@@ -72,0 +72,0 @@ "engines": {

@@ -112,2 +112,3 @@ # Number to Words

| Ghana | English | en-GH |
| Ireland | English | en-IE |
| India | English | en-IN (default) |

@@ -114,0 +115,0 @@ | Myanmar | English | en-MM |

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Eurot',
singular: 'Euro',
symbol: '€',
fractionalUnit: {
name: 'Sent',
singular: 'Sent',
plural: 'Senti',

@@ -13,0 +15,0 @@ symbol: '¢',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Dirhams',
singular: 'Dirham',
symbol: '',
fractionalUnit: {
name: 'Fil',
singular: 'Fil',
plural: 'Fils',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Taka',
singular: 'Taka',
symbol: '৳',
fractionalUnit: {
name: 'Poysha',
singular: 'Poysha',
plural: 'Poysha',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,2 +8,3 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Pounds',
singular: 'Pound',
symbol: '£',

@@ -13,2 +14,3 @@ fractionalUnit: {

plural: 'Pence',
singular: 'Penny',
symbol: '',

@@ -15,0 +17,0 @@ },

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Cedis',
singular: 'Cedi',
symbol: 'GH¢',
fractionalUnit: {
name: 'Pesewa',
singular: 'Pesewa',
plural: 'Pesewas',

@@ -13,0 +15,0 @@ symbol: 'Gp',

@@ -8,2 +8,3 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Rupees',
singular: 'Rupee',
symbol: '₹',

@@ -13,2 +14,3 @@ fractionalUnit: {

plural: 'Paise',
singular: 'Paisa',
symbol: '',

@@ -15,0 +17,0 @@ },

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Kyats',
singular: 'Kyat',
symbol: 'K',
fractionalUnit: {
name: 'Pya',
singular: 'Pya',
plural: 'Pyas',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Rupees',
singular: 'Rupee',
symbol: 'Rs',
fractionalUnit: {
name: 'Cent',
singular: 'Cent',
plural: 'Cents',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Naira',
singular: 'Naira',
symbol: '₦',
fractionalUnit: {
name: 'Kobo',
singular: 'Kobo',
plural: 'Kobo',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Rupees',
singular: 'Rupee',
symbol: '₹',
fractionalUnit: {
name: 'Paisa',
singular: 'Paisa',
plural: 'Paisa',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Pesos',
singular: 'Peso',
symbol: '₱',
fractionalUnit: {
name: 'Cent',
singular: 'Cent',
plural: 'Cents',

@@ -13,0 +15,0 @@ symbol: '¢',

@@ -8,2 +8,3 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Dollars',
singular: 'Dollar',
symbol: '$',

@@ -13,2 +14,3 @@ fractionalUnit: {

plural: 'Cents',
singular: 'Cent',
symbol: '¢',

@@ -15,0 +17,0 @@ },

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: '',
singular: '',
symbol: 'تومان',
fractionalUnit: {
name: '',
singular: 'ریال',
plural: 'تومان',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Euros',
singular: 'Euro',
symbol: '€',
fractionalUnit: {
name: 'Centime',
singular: 'Centime',
plural: 'Centimes',

@@ -13,0 +15,0 @@ symbol: 'Cts',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Euros',
singular: 'Euro',
symbol: '€',
fractionalUnit: {
name: 'Centime',
singular: 'Centime',
plural: 'Centimes',

@@ -13,0 +15,0 @@ symbol: 'Cts',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'રૂપિયા',
singular: 'રૂપિયો',
symbol: '₹',
fractionalUnit: {
name: 'પૈસા',
singular: 'પૈસા',
plural: 'પૈસા',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'रुपये',
singular: 'रुपया',
symbol: '₹',
fractionalUnit: {
name: 'पैसा',
singular: 'पैसा',
plural: 'पैसे',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'रुपये',
singular: 'रुपया',
symbol: '₹',
fractionalUnit: {
name: 'पैसा',
singular: 'पैसा',
plural: 'पैसे',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Surinaamse dollars',
singular: 'Surinaamse dollar',
symbol: 'SRD',
fractionalUnit: {
name: 'Cent',
singular: 'Cent',
plural: 'Centen',

@@ -13,0 +15,0 @@ symbol: 'SRD',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: 'Reais',
singular: 'Real',
symbol: 'R$',
fractionalUnit: {
name: 'Centavo',
singular: 'Centavo',
plural: 'Centavos',

@@ -13,0 +15,0 @@ symbol: '',

@@ -8,5 +8,7 @@ import { LocaleConfig, LocaleInterface } from '../types';

plural: '',
singular: '',
symbol: '₺',
fractionalUnit: {
name: '',
singular: 'lira',
plural: 'lira',

@@ -13,0 +15,0 @@ symbol: '',

@@ -5,2 +5,3 @@ import { ConstructorOf, ConverterOptions, LocaleInterface, NumberWordMap, ToWordsOptions } from './types';

import enGh from './locales/en-GH';
import enIe from './locales/en-IE';
import enIn from './locales/en-IN';

@@ -57,2 +58,4 @@ import enMm from './locales/en-MM';

return enGh;
case 'en-IE':
return enIe;
case 'en-IN':

@@ -181,3 +184,8 @@ return enIn;

let words = [...this.convertInternal(Number(split[0]))];
if (currencyOptions.plural) {
// Determine if the main currency should be in singular form
// e.g. 1 Dollar Only instead of 1 Dollars Only
if (Number(split[0]) === 1 && currencyOptions.singular) {
words.push(currencyOptions.name);
} else if (currencyOptions.plural) {
words.push(currencyOptions.plural);

@@ -199,7 +207,5 @@ }

}
wordsWithDecimal.push(
...this.convertInternal(
Number(split[1]) * (!locale.config.decimalLengthWordMapping ? Math.pow(10, 2 - split[1].length) : 1),
),
);
const decimalPart =
Number(split[1]) * (!locale.config.decimalLengthWordMapping ? Math.pow(10, 2 - split[1].length) : 1);
wordsWithDecimal.push(...this.convertInternal(decimalPart));
const decimalLengthWord = locale.config?.decimalLengthWordMapping?.[split[1].length];

@@ -209,3 +215,9 @@ if (decimalLengthWord?.length) {

}
wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);
// Determine if the fractional unit should be in singular form
// e.g. 1 Dollar and 1 Cent Only instead of 1 Dollar and 1 Cents Only
if (decimalPart === 1 && currencyOptions.fractionalUnit.singular) {
wordsWithDecimal.push(currencyOptions.fractionalUnit.singular);
} else {
wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);
}
} else if (locale.config.decimalLengthWordMapping && words.length) {

@@ -212,0 +224,0 @@ wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);

@@ -5,5 +5,7 @@ export interface CurrencyOptions {

symbol: string;
singular?: string;
fractionalUnit: {
name: string;
plural: string;
singular?: string;
symbol: string;

@@ -10,0 +12,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc