UNPKG

somali-exchange-rates

Version:

πŸ‡ΈπŸ‡΄ Comprehensive Somali Exchange Rates platform with real-time rates, transfer fees, alerts, multi-language support, and advanced financial tools

35 lines (32 loc) β€’ 1.84 kB
type ISO4217 = "SOS" | "USD" | "EUR" | "GBP" | "KES" | "ETB" | "AED" | "SAR" | "TRY" | "CNY"; type RateTable = Record<ISO4217, number>; interface Provider { /** Return a table where keys are currency codes and values are the rate for 1 SOS in that currency. */ fetchRatesSOS(): Promise<RateTable>; name: string; } interface CacheOptions { /** How long to keep cache before a refresh is allowed (ms). Default 6 hours. */ ttlMs?: number; /** Optional path to persist JSON cache (e.g., ~/.sosx/cache.json). If omitted, in-memory only. */ persistPath?: string; } interface GetRateOptions extends CacheOptions { /** Inject a custom provider. Default: exchangerate.host adapter. */ provider?: Provider; /** If true, skip network and use cache/seed. */ offline?: boolean; } /** Load rates (1 SOS in currency X), honoring cache/ttl/offline. */ declare function getRates(options?: GetRateOptions): Promise<RateTable>; /** Get single rate: 1 SOS in target currency. */ declare function getRate(target: ISO4217, options?: GetRateOptions): Promise<number>; /** Convert amount between any two currencies using SOS as pivot. */ declare function convert(amount: number, from: ISO4217, to: ISO4217, options?: GetRateOptions): Promise<number>; /** Format a number in Somali Shillings (Sh.). */ declare function formatSOS(value: number): string; /** Format any ISO currency in Somali locale. */ declare function formatCurrency(value: number, currency: ISO4217): string; /** Convenience helper: get compact string like '100 USD = Sh. 5,700,000' */ declare function quote(from: ISO4217, to: ISO4217, amount?: number, options?: GetRateOptions): Promise<string>; export { type CacheOptions, type GetRateOptions, type ISO4217, type Provider, type RateTable, convert, formatCurrency, formatSOS, getRate, getRates, quote };