npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

postal-address-field-names

v1.0.4

Published

Internationalisation library for postal address field names, using the Oasis XAL standard

Downloads

464

Readme

postal-address-field-names

Built with
typescript version dependants license

This module exports address field names for every country, in English. This is useful as many countries have subtle differences in field names (e.g. Postcode in the UK vs ZIP code in the US). It is based on the Oasis XAL standard for addresses.

The output is c.33kb (minified) with no dependencies, and it will work on both node & the browser. It also includes Typescript types for your convenience.

Sample

[
  //...
  {
    name: "United Kingdom",
    iso: "GB",
    fields: {
      addressLine1: "Address 1",
      addressLine2: "Address 2",
      locality: "Town/city",
      administrativeArea: "County",
      postalCode: "Postcode",
    },
  },
  {
    name: "United States",
    iso: "US",
    fields: {
      addressLine1: "Address 1",
      addressLine2: "Address 2",
      locality: "City",
      administrativeArea: "State",
      postalCode: "ZIP code",
    },
  },
  //...
];

Note that several fields are excluded from this array to save space, as they exist (and are named the same) for all countries. These are:

  • givenName
  • additionalNames
  • familyName
  • organisation
  • sortingCode - Rarely used so this is omitted, but some regions use sorting code as well as postal code (often users will place this in address line 2 instead).
  • country

Use

Get field names for a specific country

import countryAddressDetails, {
  CountryCodes,
} from "postal-address-field-names";

function getFieldNames(countryISO: CountryCodes) {
  const countryISO = "GB";
  const country = countryAddressDetails.find(
    (country) => country.iso === countryISO
  );
  return country.fields;
}

Typescript Helpers

The module includes a few useful Typescript helpers:

  • CountryCodes - ENUM with each 2-letter country code in capital letters
  • AddressFields - Full OASIS XAL address field names interface
  • CountryAddressDetails - The type exported by this module (as Array<CountryAddressDetails>)

Built by Skyhook

This module is contributed by the team at Skyhook