1.0.9 • Published 4 years ago

swiss-zipcodes v1.0.9

Weekly downloads
18
License
MIT
Repository
-
Last release
4 years ago

Build Status GitHub issues npm GitHub stars

swiss-zipcodes

Purpose

Search and validate swiss zip codes

Usage

npm i --save swiss-zipcodes
# or
npm install https://github.com/creadi/swiss-zipcodes

and

import { search, validate, cityFromZip, allZips } from 'swiss-zipcodes'

search()

Search by any combination of:

  • zip (number)
  • canton (string)
  • commune (string)
search({ zip: 4054 })

returns

[
  {
    zip: 4054,
    canton: 'BS',
    commune: 'Basel'
  }
]

validate()

Validate zip code as number or string

validate(4054)

// or

validate('4054')

returns true

cityFromZip()

Get an array of commune names from a zip code ( number or string)

cityFromZip(4052)

// or

cityFromZip('4052')

returns

[
  'Basel',
  'Münchenstein'
]

allZips

is an array of zipcodes (number)

Data

Data from Federal Statistics.

Direct link to excel sheet.

Update 1.0.6

Add data from geonames extraction

1.0.9

4 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.4

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago