UNPKG

digit-to-words-nepali

Version:

A comprehensive TypeScript library for converting numbers to words in English and Nepali languages. Supports numbers up to 10^39 (Adanta Singhar), currency formatting, decimal handling with individual digit pronunciation, and BigInt. Zero dependencies, fu

30 lines (29 loc) 926 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConverterFactory = void 0; /** * ConverterFactory * Singleton factory for creating and reusing converter instances. * Ensures only one instance per converter class for performance. */ class ConverterFactory { /** * Get or create an instance of a converter. * @param className The class name of the converter * @param creator Factory function to create a new instance if needed */ static getInstance(className, creator) { if (!this.instances.has(className)) { this.instances.set(className, creator()); } return this.instances.get(className); } /** * Clear all cached instances (useful for testing) */ static clearInstances() { this.instances.clear(); } } exports.ConverterFactory = ConverterFactory; ConverterFactory.instances = new Map();