Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
country-list-spanish
Advanced tools
Changelog
[0.3.2] - 2023-03-08
Readme
Get the country name in Spanish for any ISO 3166-1 alpha-2 country code, and vice versa.
The full list of 263 country names and codes in this package is composed as follows:
As with any other node package:
npm install country-list-spanish
The package exports four functions:
Arguments: 1, string
, an ISO 3166-1 alpha-2 code.
Returns: string
, a country name in Spanish.
If the code parameter is left empty or it's not in the list, returns undefined
.
const { getCountry } = require("country-list-spanish");
console.log(getCountry("PM")); // logs 'San Pedro y Miquelón'
console.log(getCountry("IC")); // logs 'Islas Canarias'
console.log(getCountry("NJ")); // logs undefined
Arguments: 1, string
, a country name in Spanish.
Returns: string
, an ISO 3166-1 alpha-2 code.
If the country parameter is left empty or it's not in the list, returns undefined
.
const { getCode } = require("country-list-spanish");
console.log(getCode("San Pedro y Miquelón")); // logs 'PM'
console.log(getCode("Islas Canarias")); // logs 'IC'
console.log(getCode("País de Nunca Jamás")); // logs undefined
Arguments: 0 or 1, object
, a config object (see table below and examples).
Returns: array
(default) or object
, with all the countries in the list.
By default, the function returns an array with all 249 official country names in it.
If { object: true }
is passed as config, the function returns an object of code-country (key-value) pairs.
If { extended: true }
is passed, the exceptionally reserved codes are included in the response.
const { getCountries } = require("country-list-spanish");
console.log(getCountries()); // logs [ "Andorra", "Emiratos Árabes Unidos", ... ], an array of length 249
console.log(getCountries({ object: true, extended: true })); // logs { AD: "Andorra", AE: "Emiratos Árabes Unidos", ... }, an object with 263 key-value pairs
Arguments: 0 or 1, object
, a config object (see below).
Returns: array
(default) or object
, with all the codes in the list.
By default, the function returns an array with all 249 official codes in it.
If {object: true}
is passed as config, the function returns an object of country-code (key-value) pairs.
If {extended: true}
is passed, the exceptionally reserved codes are included in the response.
const { getCodes } = require("country-list-spanish");
console.log(getCodes()); // logs [ "AD", "AE", ... ], an array of length 249
console.log(getCodes({ object: true })); // logs { Andorra: "AD", Emiratos Árabes Unidos: "AE", ... }, an object with 249 key-value pairs
param | type | default | feature |
---|---|---|---|
object | boolean | false | Return an array or an object |
extended | boolean | false | Include the 14 reserved/extra codes or not |
FAQs
Get the country name in Spanish for any ISO 3166 country code, and vice versa
The npm package country-list-spanish receives a total of 1,163 weekly downloads. As such, country-list-spanish popularity was classified as popular.
We found that country-list-spanish demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.