UNPKG

currency-in-words

Version:

A light-weight, fast and efficient lib that converts currency or any numbers to corresponding words

132 lines 3.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIndianPlaceValues = exports.getInternationalPlaceValues = void 0; var globalConfig_1 = require("../lib/globalConfig"); var lang = (0, globalConfig_1.getGlobalConfig)().lang; /** * Placeholder values for international numbering systems. */ var internationalMap = { de: { hundred: 'hundert', thousand: 'tausend', million: 'million', billion: 'milliarde', trillion: 'billion', and: 'und', }, en: { hundred: 'hundred', thousand: 'thousand', million: 'million', billion: 'billion', trillion: 'trillion', and: 'and', }, es: { hundred: 'centenar', thousand: 'mil', million: 'millón', billion: 'mil millones', trillion: 'billón', and: 'y', }, fr: { hundred: 'cent', thousand: 'mille', million: 'million', billion: 'milliard', trillion: 'billion', and: 'et', }, it: { hundred: 'centinaio', thousand: 'mille', million: 'milioni', billion: 'miliardi', trillion: 'trilioni', and: 'e', }, nl: { hundred: 'honderd', thousand: 'duizend', million: 'miljoen', billion: 'miljard', trillion: 'biljoen', and: 'en', }, pt: { hundred: 'centenas', thousand: 'mil', million: 'milhão', billion: 'bilhão', trillion: 'trilhão', and: 'e', }, }; /** * Placeholder values for the Indian numbering system. */ var indianMap = { hi: { hundred: 'सौ', thousand: 'हज़ार', lakh: 'लाख', crore: 'करोड़', and: 'और', }, en: { hundred: 'hundred', thousand: 'thousand', lakh: 'lakh', crore: 'crore', and: 'and' } }; /** * Retrieves the international place values for the current language. * Throws an error if the language is not supported for international place values. * * @returns The international place values for the current language. * @throws Error if the language is not supported. */ var getInternationalPlaceValues = function () { // Check if the current language is not a valid international language if (!(lang in internationalMap)) { throw new Error("Unsupported language for international place values: ".concat(lang)); } // Cast `lang` to `InternationalLangTypes` to ensure type safety var internationalLang = lang; // Return the international place values return { hundred: internationalMap[internationalLang]['hundred'], thousand: internationalMap[internationalLang]['thousand'], million: internationalMap[internationalLang]['million'], billion: internationalMap[internationalLang]['billion'], trillion: internationalMap[internationalLang]['trillion'], and: internationalMap[internationalLang]['and'], }; }; exports.getInternationalPlaceValues = getInternationalPlaceValues; /** * Retrieves the Indian place values for the specified language. * Throws an error if the language is not supported for Indian place values. * * @returns The Indian place values for the specified language. * @throws Error if the language is not supported. */ var getIndianPlaceValues = function () { if (!(lang in indianMap)) { throw new Error("Unsupported language for Indian place values: ".concat(lang)); } var indianLang = lang; return { hundred: indianMap[indianLang]['hundred'], thousand: indianMap[indianLang]['thousand'], lakh: indianMap[indianLang]['lakh'], crore: indianMap[indianLang]['crore'], and: indianMap[indianLang]['and'] }; }; exports.getIndianPlaceValues = getIndianPlaceValues; //# sourceMappingURL=placeholders.js.map