1.2.0 • Published 3 years ago

cloud-region-shortener v1.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

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 RegionStandardISO 3166
germanywestcentralgewc
eastus2stageeus2s

"Standard"

Abbreviates the long region name 'as is', while following these rules:

  1. A (long) region name is first split into sections.
  2. Each section is then abbreviated according to different rules.
  3. Afterwards abbreviated section are concatenated in the same order

Sections:

  • country / continent
    • always two first characters of section
      germanywestcentral, ==> germany = ge
      eastus2stage, ==> us = us
  • cardinal directions / secondard geographic specifier
    • one character per section
      germanywest central: westcentral ==> wc
      eastus2stage: east ==> e
  • enumerator
    • enumerator is always kept as is (if present)
      germanywestcentral: -
      eastus2stage: 2 ==> 2
  • special characteristic
    • one character per section
      germanywestcentral: -
      eastus2stage: stage ==> s

ISO3166

⚠️ Warning

Not implemented yet

Supported Regions

Azure Region NameStandard
eastuseus
eastus2eus2
southcentralusscus
westus2wus2
westus3wus3
australiaeastaue
southeastasiaseas
northeuropeneu
swedencentralswc
uksouthuks
westeuropeweu
centraluscus
northcentralusncus
westuswus
southafricanorthsan
centralindiacin
eastasiaeas
japaneastjae
jioindiawestjinw
koreacentralkoc
canadacentralcac
francecentralfrc
germanywestcentralgewc
norwayeastnoe
switzerlandnorthswn
uaenorthuan
brazilsouthbrs
centralusstagecuss
eastusstageeuss
eastus2stageeus2s
northcentralusstagencuss
southcentralusstagescuss
westusstagewuss
westus2stagewus2s
asiaas
asiapacificasp
australiaau
brazilbr
canadaca
europeeu
francefr
germanyge
globalgl
indiain
japanja
koreako
norwayno
southafricasaf
switzerlandsw
uaeua
ukuk
unitedstatesus
eastasiastageeass
southeastasiastageseass
centraluseuapcuse
eastus2euapeus2e
westcentraluswcus
southafricawestsafw
australiacentralauc
australiacentral2auc2
australiasoutheastause
japanwestjaw
jioindiacentraljinc
koreasouthkos
southindiasin
westindiawin
canadaeastcae
francesouthfrs
germanynorthgen
norwaywestnow
switzerlandwestswe
ukwestukw
uaecentraluac
brazilsoutheastbrse
1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago