UNPKG

countries-ts

Version:

A powerful TypeScript library with 60+ functions for country data - search, validate, format, compare, and more. Zero dependencies.

109 lines (82 loc) 3.24 kB
# Upgrade Summary - countries-ts v2.0.0 ## Overview The countries-ts library has been significantly enhanced from 7 functions to over 60 functions while maintaining complete backward compatibility. All existing functions continue to work exactly as before. ## Key Enhancements ### 🔍 Advanced Search Capabilities - **Fuzzy search** across multiple fields - **Field-specific search** (search only in capitals, currencies, etc.) - **Advanced filtering** with regions, currencies, languages, population, and area filters ### 📊 Data Analysis & Statistics - Get statistics by region, currency, and language - Compare countries by various attributes - Export data as CSV or JSON - Sort countries by any field ### ✅ Validation & Formatting - Validate country codes, currency codes, and phone codes - Format country names and phone numbers - Batch validation for multiple codes at once ### 🌍 Geographic Features - Region name mapping and statistics - Flag URLs in multiple sizes - Capital city queries - Neighboring countries by region ### 💱 Enhanced Currency & Language Support - Get all unique currencies and languages - Detailed information including which countries use them - Search by currency symbol - Multi-language filtering ### 🚀 Performance & Developer Experience - Zero dependencies - lightweight and fast - Full TypeScript support with detailed interfaces - Tree-shakeable exports - Comprehensive documentation ## Migration Guide No migration needed! All existing functions work exactly as before: ```typescript // These all work exactly as in v1.x getByCode('US') getByCurrency('EUR') getByLanguage('en') // ... etc ``` ## New Capabilities Examples ```typescript // Search with fuzzy matching searchCountries('united'); // Returns US, UK, UAE, etc. // Advanced search with filters searchCountriesAdvanced('island', { regions: ['OC'], currencies: ['AUD', 'NZD'] }); // Batch operations getByMultipleCodes(['US', 'CA', 'MX']); validateCountryCodes(['US', 'XX', 'CA']); // Validates multiple at once // Data analysis getRegionStats(); // Countries per region getCurrencyDetails('EUR'); // All info about Euro // Formatting and validation formatCountryName('US'); // "United States of America (US)" isValidCountryCode('XX'); // false // Export capabilities exportCountriesToCSV(); // Full CSV export ``` ## Future-Ready The Country interface has been extended with optional fields for future enhancements: - `timezone` - Timezone information - `coordinates` - Geographic coordinates - `area` - Country area - `population` - Population data - `borderCountries` - Neighboring countries - `nativeName` - Native language names - `subregion` - Subregional classification These fields are ready for data enrichment without breaking changes. ## Documentation - **README.md** - Comprehensive guide with examples - **API.md** - Complete API reference - **CHANGELOG.md** - Detailed change history - **TypeScript definitions** - Full type support ## Testing All new functions are thoroughly tested. Run `npm test` to verify everything works correctly. ## Support - Report issues: https://github.com/esmat-nawahda/countries/issues - Full documentation: https://github.com/esmat-nawahda/countries#readme