cloud-region-shortener
v1.2.0
Published
Shorten region names of cloud providers for use in resource names
Downloads
25
Maintainers
Readme
Cloud Region Shortener
Abbreviate region names of cloud providers in a standardized way.
Features
- Convert (long) region names to abbreviated form
- Specify a maximum length for abbreviations
- Select from different abbreviation styles (set default style)
Usage
Basic
import { getShortRegion } from 'cloud-region-shortener'
console.log(getShortRegion('westeurope'));
// weu
More Options
import { getShortRegion, Styles } from 'cloud-region-shortener'
// --- MaxLength ---
console.log(getShortRegion('northcentralusstage'));
// ncuss
console.log(getShortRegion('northcentralusstage', Styles.standard, 4));
// ncus
setMaxLength(4);
console.log(getShortRegion('northcentralusstage'));
// ncus
// --- Style ---
console.log(getShortRegion('westeurope', Styles.iso3166)); // style not supported yet
// nl
setDefaultStyle(Styles.iso3166); // style not supported yet
console.log(getShortRegion('westeurope')); // style not supported yet
// nl
Styles
The following will demonstrate different style types and rules using regions germanywestcentral
and eastus2stage
as an example.
| Example Region | Standard | ISO 3166 |
| -------------------- | -------- | -------- |
| germanywestcentral
| gewc
| `` |
| eastus2stage
| eus2s
| |
"Standard"
Abbreviates the long region name 'as is', while following these rules:
- A (long) region name is first split into sections.
- Each section is then abbreviated according to different rules.
- Afterwards abbreviated section are concatenated in the same order
Sections:
- country / continent
- always two first characters of section
germanywestcentral, ==> germany = ge
eastus2stage, ==> us = us
- always two first characters of section
- cardinal directions / secondard geographic specifier
- one character per section
germanywest central: westcentral ==> wc
eastus2stage: east ==> e
- one character per section
- enumerator
- enumerator is always kept as is (if present)
germanywestcentral: -
eastus2stage: 2 ==> 2
- enumerator is always kept as is (if present)
- special characteristic
- one character per section
germanywestcentral: -
eastus2stage: stage ==> s
- one character per section
ISO3166
⚠️ Warning
Not implemented yet
Supported Regions
| Azure Region Name | Standard | | ------------------- | -------- | | eastus | eus | | eastus2 | eus2 | | southcentralus | scus | | westus2 | wus2 | | westus3 | wus3 | | australiaeast | aue | | southeastasia | seas | | northeurope | neu | | swedencentral | swc | | uksouth | uks | | westeurope | weu | | centralus | cus | | northcentralus | ncus | | westus | wus | | southafricanorth | san | | centralindia | cin | | eastasia | eas | | japaneast | jae | | jioindiawest | jinw | | koreacentral | koc | | canadacentral | cac | | francecentral | frc | | germanywestcentral | gewc | | norwayeast | noe | | switzerlandnorth | swn | | uaenorth | uan | | brazilsouth | brs | | centralusstage | cuss | | eastusstage | euss | | eastus2stage | eus2s | | northcentralusstage | ncuss | | southcentralusstage | scuss | | westusstage | wuss | | westus2stage | wus2s | | asia | as | | asiapacific | asp | | australia | au | | brazil | br | | canada | ca | | europe | eu | | france | fr | | germany | ge | | global | gl | | india | in | | japan | ja | | korea | ko | | norway | no | | southafrica | saf | | switzerland | sw | | uae | ua | | uk | uk | | unitedstates | us | | eastasiastage | eass | | southeastasiastage | seass | | centraluseuap | cuse | | eastus2euap | eus2e | | westcentralus | wcus | | southafricawest | safw | | australiacentral | auc | | australiacentral2 | auc2 | | australiasoutheast | ause | | japanwest | jaw | | jioindiacentral | jinc | | koreasouth | kos | | southindia | sin | | westindia | win | | canadaeast | cae | | francesouth | frs | | germanynorth | gen | | norwaywest | now | | switzerlandwest | swe | | ukwest | ukw | | uaecentral | uac | | brazilsoutheast | brse |