1.0.1 • Published 1 year ago

@omnicar/sam-zip-city v1.0.1

Weekly downloads
38
License
MIT
Repository
-
Last release
1 year ago

SAM zip-city

This library aims to do city lookups in a fast (client-side), generic way.

The script will dynamically load the appropriate file with zipcodes and city names for a given country.

This allows for smaller bundle size and means that the file(s) are only downloaded when needed.

How to install

npm install @omnicar/sam-zip-city or yarn add @omnicar/sam-zip-city

FAQ

Question:

But are all the zip code files inside the imported package?

Answer: No, only the file(s) with the postal codes (zip codes) of the requested country are retrieved dynamically at run time.

Question:

From where are the file(s) with the postal codes (zip codes) fetched from?

Answer: The postal codes are fetched from admin dot omnicar dot io slash data slash zip-codes slash


How to use

import { getCityFromZip } from '@omnicar/sam-zip-city'

const myFunc = async () => {
  const city = await getCityFromZip({
    zipcode: 2300,
    country: 'DK' 
  })
  console.log(city)
}

Or to initialise a country before requesting a city:

import { initZipCityCountry } from '@omnicar/sam-zip-city'

const myOtherFunc = async () => {
  await initZipCityCountry({ country: 'DK' })
  console.log('Danish zipcodes and cities should be ready!')
}
1.0.1

1 year ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

6 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago