generaltranslation
Version:
A language toolkit for AI developers
27 lines (26 loc) • 1.03 kB
TypeScript
import { ConstructorType, CustomIntlConstructors } from './types';
/**
* Cache for Intl and custom format instances to avoid repeated instantiation
* Uses a two-level structure: constructor name -> cache key -> instance
*/
declare class IntlCache {
private cache;
constructor();
/**
* Generates a consistent cache key from locales and options
* Handles all LocalesArgument types (string, Locale, array, undefined)
*/
private _generateKey;
/**
* Gets a cached Intl instance or creates a new one if not found
* @param constructor The name of the Intl constructor to use
* @param args Constructor arguments (locales, options)
* @returns Cached or newly created Intl instance
*/
get<K extends keyof CustomIntlConstructors>(constructor: K, ...args: ConstructorParameters<CustomIntlConstructors[K]>): InstanceType<ConstructorType<K>>;
}
/**
* Global instance of the Intl cache for use throughout the application
*/
export declare const intlCache: IntlCache;
export {};