Socket
Socket
Sign inDemoInstall

country-list-spanish

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    country-list-spanish

Get the country name in Spanish for any ISO 3166 country code, and vice versa


Version published
Weekly downloads
1.5K
decreased by-47.66%
Maintainers
1
Install size
24.4 kB
Created
Weekly downloads
 

Changelog

Source

[0.3.2] - 2023-03-08

Fixed

  • Fixed MK name.

Readme

Source

Country List, in Spanish

What is this?

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:

Installation

As with any other node package:

npm install country-list-spanish

Usage

The package exports four functions:

getCountry(code)

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.

Example
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

getCode(country)

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.

Example
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

getCountries(config)

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.

Example
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

getCodes(config)

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

Config object

paramtypedefaultfeature
objectbooleanfalseReturn an array or an object
extendedbooleanfalseInclude the 14 reserved/extra codes or not

Keywords

FAQs

Last updated on 08 Mar 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc