npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

iso3166-lib

v1.0.4

Published

Librería ISO 3166-2 con subdivisiones por país.

Readme

# 🌍 ISO 3166-2 Lib

Librería para obtener subdivisiones administrativas por país usando códigos **[ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)**.
Ideal para autocompletar formularios, crear selectores de regiones y trabajar con datos geográficos estándar.

---

## 📦 Instalación

```bash
npm install @sinergya/iso3166-2-lib
# o
pnpm add @sinergya/iso3166-2-lib
```

🧰 Uso Básico

import {
  getCountries,
  getSubdivisions,
  getSubdivisionByCode,
} from '@sinergya/iso3166-2-lib';

// 📌 Obtener todos los países disponibles
const countries = getCountries();
console.log(countries);

// 📌 Obtener subdivisiones por nombre o código de país
const subdivisions1 = getSubdivisions('Bolivia');
const subdivisions2 = getSubdivisions('BO');
console.log(subdivisions1);

// 📌 Obtener una subdivisión específica por código ISO 3166-2
const laPaz = getSubdivisionByCode('BO-L');
console.log(laPaz);

✨ Funcionalidades Disponibles

1. getCountries()

Devuelve una lista única de todos los países disponibles en la base de datos.

Retorno:

[
  { code: "AD", name: "Andorra" },
  { code: "BO", name: "Bolivia" },
  { code: "BR", name: "Brasil" },
  ...
]

2. getSubdivisions(country)

Obtiene todas las subdivisiones (departamentos, provincias, estados, etc.) de un país. country puede ser el nombre del país o el código ISO 3166-1 Alpha-2.

getSubdivisions('Bolivia');
getSubdivisions('BO');

Retorno:

[
  {
    country_code: "BO",
    subdivision_name: "La Paz",
    Code1: "L",
    iso3166_2: "BO-L",
    subdivision_name_ascii: "La Paz",
    slug: "la-paz",
    country_name: "Bolivia"
  },
  ...
]

3. getSubdivisionByCode(code)

Obtiene una subdivisión específica por su código ISO 3166-2 (ej. BO-L).

getSubdivisionByCode('BO-L');

Retorno:

{
  country_code: "BO",
  subdivision_name: "La Paz",
  Code1: "L",
  iso3166_2: "BO-L",
  subdivision_name_ascii: "La Paz",
  slug: "la-paz",
  country_name: "Bolivia"
}

Si no se encuentra, devuelve null.


🧭 Estructura del Proyecto

iso-3166-2-lib/
├─ data/
│  └─ iso3166-2-extended.json    # Base de datos de subdivisiones
├─ src/
│  └─ index.js                   # Funciones principales
├─ package.json
├─ README.md

📄 Formato de Datos JSON

Cada entrada en el JSON tiene la siguiente estructura:

{
  "country_code": "BO",
  "subdivision_name": "La Paz",
  "Code1": "L",
  "iso3166_2": "BO-L",
  "subdivision_name_ascii": "La Paz",
  "slug": "la-paz",
  "country_name": "Bolivia"
}

| Campo | Descripción | | ------------------------ | --------------------------------------------- | | country_code | Código ISO 3166-1 Alpha-2 del país | | subdivision_name | Nombre oficial de la subdivisión | | Code1 | Código interno de subdivisión | | iso3166_2 | Código estándar ISO 3166-2 (país-subdivisión) | | subdivision_name_ascii | Nombre sin acentos (útil para búsquedas) | | slug | Versión URL friendly del nombre | | country_name | Nombre completo del país |


🧪 Ejemplos de Uso

import {
  getCountries,
  getSubdivisions,
  getSubdivisionByCode,
} from '@sinergya/iso3166-2-lib';

// Listar todos los países
console.log(getCountries());

// Buscar subdivisiones por nombre
console.log(getSubdivisions('Argentina'));

// Buscar subdivisiones por código
console.log(getSubdivisions('AR'));

// Obtener subdivisión puntual
console.log(getSubdivisionByCode('AR-B'));

🪪 Licencia

MIT © Sinergya America S.R.L.

Desarrollado por Jorge Luis Tancara 🚀 GitHub: @QuantumCode2000 Correo: [email protected]


🏷️ Notas

  • La base de datos ISO 3166-2 proviene de fuentes públicas y puede actualizarse con el tiempo.
  • El JSON está optimizado para consultas rápidas desde Node.js.
  • Compatible con ES Modules ("type": "module").