# ts-country-iso-2-to-3

> Convert a country code ISO 3166-1 Alpha-2 to ISO 3166-1 Alpha-3 with types!

Latest version **1.3.0** (published 2024-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-country-iso-2-to-3
pnpm add ts-country-iso-2-to-3
yarn add ts-country-iso-2-to-3
bun add ts-country-iso-2-to-3
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2024-09-23 |
| First published | 2023-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | cjcbusatto |
| Keywords | country, code, country, iso, alpha-3, alpha, 3, alpha-2, alpha, 2, 3166, typescript, ts |

## Links

- npm: https://www.npmjs.com/package/ts-country-iso-2-to-3
- Repository: https://github.com/cjcbusatto/ts-country-iso-2-to-3
- Homepage: https://github.com/cjcbusatto/ts-country-iso-2-to-3#readme
- Issues: https://github.com/cjcbusatto/ts-country-iso-2-to-3/issues
- npm.io page: https://npm.io/package/ts-country-iso-2-to-3

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.3.0 (latest) — 2024-09-23
- 1.2.0 — 2023-08-17
- 1.1.0 — 2023-08-17
- 1.0.1 — 2023-08-17
- 1.0.0 — 2023-08-15

## README

# ts-country-iso-2-to-3

> Convert a country code ISO 3166-1 Alpha-2 to ISO 3166-1 Alpha-3... with types!

## Introduction

This is a fork of [country-iso-2-to-3](https://github.com/vtex/country-iso-2-to-3).

## Install

```sh
$ npm install ts-country-iso-2-to-3
```

## Usage

```ts
import { getCountryISO3 } from 'ts-country-iso-2-to-3'

console.log(getCountryISO3('BR')) // BRA
console.log(getCountryISO3('br')) // BRA
console.log(getCountryISO3('US')) // USA
console.log(getCountryISO3('us')) // USA

console.log(getCountryISO3('')) // Error: Country code is required
console.log(getCountryISO3(123 as string)) // Error: Country code should be a string
console.log(getCountryISO3('USA')) // Error: Country code should be 2 characters long
console.log(getCountryISO3('INVALID_ISO2')) // Error: No ISO3 reference was found for ISO2: "INVALID_ISO2"
```

## API

### getCountryISO3(countryCode: string): string

**Parameter**:
A string with a country code in ISO 3166-1 Alpha-2

**Return**:
A string with the country code in ISO 3166-1 Alpha-3

---

## License

MIT © Balcony207

---
_Source: https://npm.io/package/ts-country-iso-2-to-3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
