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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bitfinex/lib-js-util-location

v1.0.0

Published

utils for location inputs

Readme

lib-js-util-location

Simple utility library for locations.

Supported functions:

  • getCountryCode - useful to parse country names to codes and vice-versa
  • getCurrencyCode - useful to parse currency names/countries to codes and vice-versa
  • getCountryCurrencies - currencies of a country
  • getCurrencyCountries - countries using a currency

Installing

npm install --save-prod https://github.com/bitfinexcom/lib-js-util-location.git

Testing

npm run test

Usage

const {
  CONSTANTS,
  getCountryCode,
  getCanadaProvince,
  getCurrencyCode,
  getCountryCurrencies,
  getCurrencyCountries
} = require('@bitfinex/lib-js-util-location')

console.log(getCountryCode('United Kingdom')) // 'GB'
console.log(getCountryCode('United Kingdom', 'iso-3166-alpha3')) // 'GBR'
console.log(getCountryCode('GB')) // 'GB'
console.log(getCountryCode('Great Britain')) // null
console.log(getCountryCode(CONSTANTS.COUNTRY_ISO_3166_ALPHA_2_NUM.GB)) // 'GB'
console.log(CONSTANTS.COUNTRY_ISO_3166_NAME_ALPHA_2['UNITED KINGDOM']) // 'GB'

console.log(getCanadaProvince('Ontario', 'int_alpha_code')) // 'ON'

console.log(getCurrencyCode('ALL')) // 'ALL'
console.log(getCurrencyCode('ALL', 'iso-4217-num')) // '008'
console.log(getCurrencyCode('ALL', 'iso-4217-name')) // 'LEK'
console.log(getCurrencyCode('008')) // 'ALL'
console.log(getCurrencyCode('Lek')) // 'ALL'
console.log(getCurrencyCode('Albania')) // 'ALL'
console.log(getCurrencyCode('Albanian Lek')) // null
console.log(CONSTANTS.CURRENCY_ISO_4217_NAME_ALPHA_3.LEK) // 'ALL'

console.log(getCurrencyCountries('ALL')) // ['AL']
console.log(getCurrencyCountries('CHF')) // ['LI', 'CH']
console.log(getCurrencyCountries('XAU')) // []

console.log(getCountryCurrencies('Albania')) // ['ALL']
console.log(getCountryCurrencies('Switzerland')) // ['CHF', 'CHE', 'CHW']

Currencies

Currency data is generated from the official ISO 4217 list one published by SIX, the ISO 4217 maintenance agency.

Supported getCurrencyCode formats: iso-4217-alpha3 (default), iso-4217-num, iso-4217-name.

getCurrencyCode accepts a currency in any of those formats, or a country in any format accepted by getCountryCode. For countries with more than one ISO 4217 currency it returns the main one, while getCountryCurrencies returns all of them (main currency first, fund codes last).

Notes:

  • currency codes take precedence over country codes when both match an input, so getCurrencyCode('CHE') is the WIR Euro rather than Switzerland's CHF
  • the list includes fund codes (CLF, USN, ...), precious metals (XAU, XAG, ...), supranational units (XDR, XUA, ...) and the reserved XTS/XXX codes. Those have no country, so getCurrencyCountries returns an empty list for them
  • VED and VES share the name BOLÍVAR SOBERANO, which resolves to the current VES
  • two entries of COUNTRY_ISO_3166_ALPHA_2_NAME are outside ISO 3166-1 and therefore outside ISO 4217, they are mapped manually: XK (Kosovo) to EUR and AN (Netherlands Antilles, deleted from ISO 3166 in 2010) to XCG, the successor of its retired ANG
  • AQ, GS and PS have no currency mapping because ISO 4217 explicitly assigns them no universal currency, and neither do the non standard region entries (CRIMEA, DONETSK, LUHANSK, KHERSON, ZAPORIZHZHIA)

Authors

  • prdn
  • vigan-abd