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

ember-countries

v2.0.2

Published

Ember utils for countries lists and extra helpers.

Downloads

419

Readme

Ember-countries

npm version Ember Observer Score

A simple Addon that contains the 6 following lists:

  • all the countries in ISO2 (US), ISO3 (USA), ISO-Numeric (840) and English name (United States) formats.
  • the countries without ZIP Code.
  • the countries with states.
  • the US states & military states
  • the US states that require customs declaration
  • the Canadian states

Here are a list of the main helpers:

  • Country ISO2, ISO3 or ISO-Numeric to Country object.
  • Is country with state.
  • Is country without ZIP Code.
  • State ISO2 to State object

You can find more information about ISO codes here:

Installation

  • ember install ember-countries

Upgrading from 1.x.x to 2.0.0

Here are all the information that you need to migrate from version 1.x.x to 2.0.0: Migrating from 1.x.x to 2.0.0

Usage

All imports

import { COUNTRIES_LIST, COUNTRIES_WITHOUT_ZIP_LIST, COUNTRIES_WITH_STATES_LIST } from 'ember-countries';
import { US_STATES_LIST, US_MILITARY_STATES_LIST, US_REQUIRING_CUSTOM_DECLARATION_STATES_LIST, CA_STATES_LIST, STATES_BY_COUNTRIES } from 'ember-countries';
import { getCountry, isCountryWithState, isCountryWithoutZip } from 'ember-countries';
import { getStatesForCountry, isCustomsDeclarationRequiredInUS, countryContainsState, getState } from 'ember-countries';
import defaultEmberCountries from 'ember-countries';

Example 1: countries lists

import Em from 'ember';
import { COUNTRIES_LIST } from 'ember-countries';

export default Em.Controller.extend({

  COUNTRIES_LIST: COUNTRIES_LIST,
  ...
});

Example 2: countries properties

import Em from 'ember';
import { getCountry, isCountryWithState, isCountryWithoutZip } from 'ember-countries';

export default Em.Controller.extend({

  countryHelper() {
    let expect   = {name: "United States", iso2: "US", iso3: "USA", isoNumeric: "840"}
    let country1 = getCountry('US');
    let country2 = getCountry('USA');
    let country3 = getCountry('840');
    
    country1 === expect  // true
    country2 === expect  // true
    country3 === expect  // true
    
    isCountryWithState('US')  // true
    isCountryWithoutZip('US')  // false
  },
  ...
});

Example 3: states lists

import Em from 'ember';
import emberCountries from 'ember-countries';

export default Em.Controller.extend({

  US_STATES: emberCountries.US_STATES_LIST,
  ...
});

Example 4: states properties

import Em from 'ember';
import { getState, countryContainsState } from 'ember-countries';

export default Em.Controller.extend({

  countryHelper() {
    let expect = {name: "California", iso2: "CA"}
    let state1 = getState('US', 'CA');
    let state2 = getState('USA', 'CA');
    let state3 = getState('840', 'CA');
    
    state1 === expect  // true
    state2 === expect  // true
    state3 === expect  // true
    
    countryContainsState('US', 'CA')  // true
  },
  ...
});

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.

Contributing

PRs welcome!