n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
68 lines (67 loc) • 2.84 kB
TypeScript
/**
* English (Bangladesh) language converter
*
* CLDR: en-BD | English as used in Bangladesh
*
* Key features:
* - Indian numbering system (thousand, lakh, crore, arab, kharab)
* - 3-2-2 grouping pattern (last 3 digits, then groups of 2)
* - British-style "and" after hundreds
* - Bangladeshi Taka currency (BDT)
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
/**
* Converts a numeric value to English words using Indian numbering.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The number in English words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCardinal(42) // 'forty-two'
* toCardinal(100000) // 'one lakh'
* toCardinal(10000000) // 'one crore'
* toCardinal(1234567) // 'twelve lakh thirty-four thousand five hundred and sixty-seven'
*/
declare function toCardinal(value: number | string | bigint): string;
/**
* Converts a numeric value to English ordinal words using Indian numbering.
* @param {number | string | bigint} value - The numeric value to convert (must be a positive integer)
* @returns {string} The number as ordinal words
* @throws {TypeError} If value is not a valid numeric type
* @throws {RangeError} If value is negative, zero, or has a decimal part
* @example
* toOrdinal(1) // 'first'
* toOrdinal(100000) // 'one lakhth'
* toOrdinal(100001) // 'one lakh first'
*/
declare function toOrdinal(value: number | string | bigint): string;
export type CurrencyOptions = {
/**
* - Use "and" between taka and paise
*/
and?: boolean;
};
/**
* @typedef {object} CurrencyOptions
* @property {boolean} [and] - Use "and" between taka and paise
*/
/** @type {Required<CurrencyOptions>} */
export declare const currencyDefaults: Required<CurrencyOptions>;
/**
* Converts a numeric value to Bangladeshi English currency words.
* @param {number | string | bigint} value - The currency amount to convert
* @param {CurrencyOptions} [options] - Optional configuration
* @returns {string} The amount in Bangladeshi English currency words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCurrency(42.50) // 'forty-two taka and fifty paise'
* toCurrency(100000) // 'one lakh taka'
* toCurrency(1) // 'one taka'
* toCurrency(0.50) // 'fifty paise'
* toCurrency(42.50, { and: false }) // 'forty-two taka fifty paise'
*/
declare function toCurrency(value: number | string | bigint, options?: CurrencyOptions): string;
export { toCardinal, toOrdinal, toCurrency };