Gathering detailed insights and metrics for @workmate/country-and-currency
Gathering detailed insights and metrics for @workmate/country-and-currency
Gathering detailed insights and metrics for @workmate/country-and-currency
Gathering detailed insights and metrics for @workmate/country-and-currency
npm install @workmate/country-and-currency
Typescript
Module System
Node Version
NPM Version
TypeScript (99.42%)
HTML (0.38%)
JavaScript (0.2%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
68 Commits
5 Branches
1 Contributors
Updated on Dec 04, 2024
Latest Version
1.2.2
Package Id
@workmate/country-and-currency@1.2.2
Unpacked Size
312.66 kB
Size
51.97 kB
File Count
33
NPM Version
10.2.4
Node Version
21.6.1
Published on
Mar 28, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
Add the js script to the head of the html file
1<script src="https://cdn.jsdelivr.net/npm/@workmate/country-and-currency/dist/bundle.js" defer></script>
Then you can access the country and currency instance using
1<script defer> 2 var CountryAndCurrency = CountryAndCurrencyLib.setup() 3</script>
1# using npm 2npm install --save @workmate/country-and-currency 3 4# using yarn 5yarn add @workmate/country-and-currency
Then you can access the country and currency instance using
1import CountryAndCurrency from "@workmate/country-and-currency";
1interface Currency { 2 name: string; 3 code: string; 4 symbol: string; 5} 6 7interface Country { 8 name: string; 9 capital: string; 10 continent: string; 11 flag: string; 12 iso2: string; 13 iso3: string; 14 dail_code: string; 15 latitude: number; 16 longitude: number; 17 currency: { 18 unicode: string; 19 code: string; 20 name: string; 21 symbol: string; 22 }; 23} 24 25interface CountryWithDistance extends Country { 26 distance: number; 27} 28 29interface LocationInterface { 30 long: number; 31 lat: number; 32}
getCurrencies(): Array<Currency>
getCurrencyBy(field: "name" | "code" | "symbol",value: string): Currency | undefined
getCountries(): Array<Country>
getCountriesBy(field: "name" | "capital" | "continent" | "flag" | "iso2" | "iso3" | "dail_code", value: string): Array<Country>
distanceBetweenLocations(firstLocation: LocationInterface, secondLocation: LocationInterface): number
(result in kilometers)countriesWithinRadius(country: Country, radius: number): Array<CountryWithDistance>
(radius in kilometers)topXClosestCountries(country: Country, x: number): Array<CountryWithDistance>
topXFarthestCountries(country: Country, x: number): Array<CountryWithDistance>
distanceOfCountryToOtherCountries(country: Country, order: "asc" | "desc" = "asc"): Array<CountryWithDistance>
1const currencies = CountryAndCurrency.getCurrencies() 2console.log(currencies) 3/* 4Expected result 5[ 6 { 7 name: "Afghan Afghani", 8 code: "AFA", 9 symbol: "؋", 10 }, 11 ... 12] 13*/ 14 15const currency = CountryAndCurrency.getCurrencyBy("code", "AFA") 16console.log(currency) 17/* 18Expected result 19{ 20 name: "Afghan Afghani", 21 code: "AFA", 22 symbol: "؋", 23}, 24*/ 25 26const countries = CountryAndCurrency.getCountries() 27console.log(countries) 28/* 29Expected result 30[ 31 { 32 name: "Mexico", 33 capital: "Mexico City", 34 continent: "NA", 35 flag: "https://upload.wikimedia.org/wikipedia/commons/f/fc/Flag_of_Mexico.svg", 36 iso2: "MX", 37 iso3: "MEX", 38 dail_code: "+52", 39 latitude: 23, 40 longitude: -102, 41 currency: { 42 unicode: "🇲🇽", 43 code: "MXN", 44 name: "Mexican Peso", 45 symbol: "$", 46 }, 47 }, 48 ... 49] 50*/ 51 52const countriesBy = CountryAndCurrency.getCountriesBy("iso3", "MEX") 53// if the field selected (in this case iso3) is unique, the result would be an array of length 0 or 1 54console.log(countriesBy) 55 56/* 57[ 58 { 59 name: "Mexico", 60 capital: "Mexico City", 61 continent: "NA", 62 flag: "https://upload.wikimedia.org/wikipedia/commons/f/fc/Flag_of_Mexico.svg", 63 iso2: "MX", 64 iso3: "MEX", 65 dail_code: "+52", 66 latitude: 23, 67 longitude: -102, 68 currency: { 69 unicode: "🇲🇽", 70 code: "MXN", 71 name: "Mexican Peso", 72 symbol: "$", 73 }, 74 } 75] 76*/ 77 78const firstLocation = { 79 lat: 10, 80 long: 15, 81}; 82 83const secondLocation = { 84 lat: 20, 85 long: -17, 86}; 87 88const distanceBetweenLocations = CountryAndCurrency.distanceBetweenLocations(firstLocation, secondLocation) 89console.log(distanceBetweenLocations); 90/* 91Expected result 923604.3678036992624 // in kilometers 93*/ 94 95const mexico = CountryAndCurrency.getCountriesBy("iso3", "MEX")[0]; 96const countriesWithinRadius = CountryAndCurrency.countriesWithinRadius( 97 mexico, 98 2000 99); 100console.log(countriesWithinRadius); 101/* 102Expected result 103[ 104 { 105 name: 'Guatemala', 106 capital: 'Guatemala City', 107 continent: 'NA', 108 flag: 'https://upload.wikimedia.org/wikipedia/commons/e/ec/Flag_of_Guatemala.svg', 109 iso2: 'GT', 110 iso3: 'GTM', 111 dail_code: '+502', 112 latitude: 15.5, 113 longitude: -90.25, 114 currency: { 115 unicode: '🇬🇹', 116 code: 'GTQ', 117 name: 'Guatemalan Quetzal', 118 symbol: 'Q' 119 }, 120 distance: 1487.7626308065874 121 }, 122 ... 123] 124*/ 125 126 127const mexico = CountryAndCurrency.getCountriesBy("iso3", "MEX")[0]; 128const closestCountries = CountryAndCurrency.topXClosestCountries(mexico, 2); 129console.log(closestCountries); 130/* 131Expected result 132[ 133 { 134 name: 'Guatemala', 135 capital: 'Guatemala City', 136 continent: 'NA', 137 flag: 'https://upload.wikimedia.org/wikipedia/commons/e/ec/Flag_of_Guatemala.svg', 138 iso2: 'GT', 139 iso3: 'GTM', 140 dail_code: '+502', 141 latitude: 15.5, 142 longitude: -90.25, 143 currency: { 144 unicode: '🇬🇹', 145 code: 'GTQ', 146 name: 'Guatemalan Quetzal', 147 symbol: 'Q' 148 }, 149 distance: 1487.7626308065874 150 }, 151 ... 152] 153*/ 154 155 156const mexico = CountryAndCurrency.getCountriesBy("iso3", "MEX")[0]; 157const farthestCountries = CountryAndCurrency.topXFarthestCountries(mexico, 2); 158console.log(farthestCountries); 159 160/* 161Expected result 162[ 163 { 164 name: 'British Indian Ocean Territory', 165 capital: 'Diego Garcia', 166 continent: 'AS', 167 flag: 'https://upload.wikimedia.org/wikipedia/commons/6/6e/Flag_of_the_British_Indian_Ocean_Territory.svg', 168 iso2: 'IO', 169 iso3: 'IOT', 170 dail_code: '+246', 171 latitude: -6, 172 longitude: 71.5, 173 currency: { unicode: '🇮🇴', code: 'USD', name: 'US Dollar', symbol: '$' }, 174 distance: 18000.497060769732 175 }, 176 ... 177] 178*/ 179 180const mexico = CountryAndCurrency.getCountriesBy("iso3", "MEX")[0]; 181const distanceFromOthers = CountryAndCurrency.distanceOfCountryToOtherCountries( 182 mexico, 183 "asc" // from closest to farthest 184); 185console.log(distanceFromOthers); 186/* 187Expected result 188[ 189 { 190 name: 'British Indian Ocean Territory', 191 capital: 'Diego Garcia', 192 continent: 'AS', 193 flag: 'https://upload.wikimedia.org/wikipedia/commons/6/6e/Flag_of_the_British_Indian_Ocean_Territory.svg', 194 iso2: 'IO', 195 iso3: 'IOT', 196 dail_code: '+246', 197 latitude: -6, 198 longitude: 71.5, 199 currency: { unicode: '🇮🇴', code: 'USD', name: 'US Dollar', symbol: '$' }, 200 distance: 18000.497060769732 201 }, 202 ... 203] 204*/
No vulnerabilities found.
No security vulnerabilities found.