A parser to find where a country name or abbreviation is in a string.
Full documentation is available at the zerodep.app page.
All @zerodep packages support both ESM and CJS.
import { addressCountry } from '@zerodep/address-country';
// or
const { addressCountry } = require('@zerodep/address-country');
addressCountry('1234 Main Street, Los Angeles CA, America');
// [
// {
// countryIso2: 'US',
// source: 'America',
// ndx: 34,
// length: 7,
// },
// ]
const CHECK_IN_MIDDLE = true;
addressCountry('1234 Main Street, Los Angeles CA, United States 90210', CHECK_IN_MIDDLE);
// [
// {
// countryIso2: 'US',
// source: 'United States',
// ndx: 34,
// length: 13,
// },
// {
// countryIso2: 'CA',
// source: 'CA',
// ndx: 30,
// length: 2,
// },
// ]