Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
iso-3166-2
Advanced tools
The iso-3166-2 npm package provides utilities for working with ISO 3166-2 codes, which are used to define the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1.
Get country subdivisions
This feature allows you to retrieve the subdivisions of a given country using its ISO 3166-1 alpha-2 code. In this example, it retrieves the subdivisions of the United States.
const iso3166 = require('iso-3166-2');
const subdivisions = iso3166.subdivision('US');
console.log(subdivisions);
Get subdivision name
This feature allows you to get the name of a specific subdivision by providing the country code and the subdivision code. In this example, it retrieves the name of the subdivision 'CA' in the United States.
const iso3166 = require('iso-3166-2');
const subdivisionName = iso3166.subdivision('US', 'CA');
console.log(subdivisionName);
Get country name
This feature allows you to get the name of a country by providing its ISO 3166-1 alpha-2 code. In this example, it retrieves the name of the country 'US'.
const iso3166 = require('iso-3166-2');
const countryName = iso3166.country('US');
console.log(countryName);
The iso-3166-1 package provides utilities for working with ISO 3166-1 codes, which are used to define the names of countries and their subdivisions. It is similar to iso-3166-2 but focuses on the country codes rather than the subdivisions.
The country-data package provides a comprehensive set of data about countries, including ISO 3166-1 and ISO 3166-2 codes, currencies, languages, and more. It offers a broader range of data compared to iso-3166-2.
The i18n-iso-countries package provides utilities for working with ISO 3166-1 and ISO 3166-2 codes, with support for multiple languages. It offers similar functionality to iso-3166-2 but with added internationalization support.
Lookup information about ISO-3166-2 subdivisions.
The country codes in the data are in the ISO 3166-1 alpha 2 format (US,
SE ...), but there is a conversion table that makes possible to input
alpha 3 codes (USA, SWE ...) to the subdivision
and country
functions.
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
> iso3166.subdivision("SE-O");
{ type: 'County',
name: 'Västra Götalands län',
countryName: 'Sweden',
countryCode: 'SE',
regionCode: 'O',
code: 'SE-O' }
> iso3166.subdivision("UN-1");
null
> iso3166.subdivision("SE", "O");
{ type: 'County',
name: 'Västra Götalands län',
countryName: 'Sweden',
countryCode: 'SE',
regionCode: 'O',
code: 'SE-O' }
> iso3166.subdivision("USA", "Indiana");
{ type: 'state',
name: 'Indiana',
countryName: 'United States',
countryCode: 'US',
regionCode: 'IN',
code: 'US-IN' }
> iso3166.country("Sweden");
{ name: 'Sweden',
sub:
{ 'SE-O': { type: 'County', name: 'Västra Götalands län' },
'SE-N': { type: 'County', name: 'Hallands län' },
'SE-M': { type: 'County', name: 'Skåne län' },
'SE-K': { type: 'County', name: 'Blekinge län' },
'SE-I': { type: 'County', name: 'Gotlands län' },
'SE-H': { type: 'County', name: 'Kalmar län' },
'SE-G': { type: 'County', name: 'Kronobergs län' },
'SE-F': { type: 'County', name: 'Jönköpings län' },
'SE-E': { type: 'County', name: 'Östergötlands län' },
'SE-D': { type: 'County', name: 'Södermanlands län' },
'SE-C': { type: 'County', name: 'Uppsala län' },
'SE-W': { type: 'County', name: 'Dalarnas län' },
'SE-Z': { type: 'County', name: 'Jämtlands län' },
'SE-Y': { type: 'County', name: 'Västernorrlands län' },
'SE-X': { type: 'County', name: 'Gävleborgs län' },
'SE-AC': { type: 'County', name: 'Västerbottens län' },
'SE-AB': { type: 'County', name: 'Stockholms län' },
'SE-BD': { type: 'County', name: 'Norrbottens län' },
'SE-T': { type: 'County', name: 'Örebro län' },
'SE-S': { type: 'County', name: 'Värmlands län' },
'SE-U': { type: 'County', name: 'Västmanlands län' } },
code: 'SE' }
> iso3166.country("United Nations");
null
Retrieves a subdivision by its full code, ex "SE-O", "US-IN". Returns
null
if not found.
Retrieves a subdivision by its country code and subdivision code, ex
("SWE", "O"). Returns null
if not found.
Retrieves a subdivision by its country code and subdivision name, ex
("US", "Indiana"). Returns null
if not found.
Retrieves a country by its code, ex "US", "SE", "SWE". Returns null
if not found.
Retrieves a country by its name, ex "United States", "Sweden". Returns
null
if not found.
The raw ISO 3166-2 data, the layout is:
{
country code (alpha 2): {
name: country name, ex Sweden, United States ...
sub: {
subdivision code: {
type: subdivision type, ex county, divison ...
name: subdivision name, ex Västra Götaland, Indiana
}
}
}
}
The ISO 3166-1 alpha 3 to alpha 2 conversion table, the layout is:
{
country code (alpha 3): country code (alpha 2)
}
FAQs
Lookup information about ISO-3166-2 subdivisions.
We found that iso-3166-2 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.