Methods
byAll(str) → {MexicoState}
- Source:
byAll searches byAbbr, byInternal, byIso, and byName for a match of the given string
Example
const msc = require('@nuskin/mexico-state-lookup')
// How to find the state by any attribute
const state = msc.byAll('Nuevo León')
Parameters:
Name | Type | Description |
---|---|---|
str |
String | The string to search by. |
Returns:
Returns a MexicoState
object if one is found. Else
an empty Object
is returned.
- Type
- MexicoState
byInternal(internalName) → {MexicoState}
- Source:
byInternal will search Mexico states by Nu Skin's internal name.
Example
const msc = require('@nuskin/mexico-state-lookup')
// How to lookup 'Nuevo León' by iso code
const state = msc.byIso('NL') // or 'NLE'
Parameters:
Name | Type | Description |
---|---|---|
internalName |
String | The internal name to search by. |
Returns:
Returns a MexicoState
object if one is found. Else
an empty Object
is returned.
- Type
- MexicoState
byIso(code) → {MexicoState}
- Source:
byIso will search Mexico states by ISO2 or ISO3 codes
Example
const msc = require('@nuskin/mexico-state-lookup')
// How to lookup 'Nuevo León' by iso code
const state = msc.byIso('NL') // or 'NLE'
Parameters:
Name | Type | Description |
---|---|---|
code |
String | The iso code to search by. |
Returns:
Returns a MexicoState
object if one is found. Else
an empty Object
is returned.
- Type
- MexicoState
byName(name) → {MexicoState}
- Source:
byName will search Mexico states by the state name
Example
const msc = require('@nuskin/mexico-state-lookup')
// How to lookup 'Nuevo León' by name
const state = msc.byName('Nuevo León')
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The federative name to search for. |
Returns:
Returns a MexicoState
object if one is found. Else
an empty Object
is returned.
- Type
- MexicoState
getStates() → {Array.<MexicoState>}
- Source:
getStates returns a list of all the Mexico states.
Example
const msc = require('@nuskin/mexico-state-lookup')
const states = msc.getStates()
states.forEach(state => {
console.log({state})
})
Returns:
Returns a list of all the Mexico states
- Type
- Array.<MexicoState>
Type Definitions
MexicoState
- Source:
Properties:
Name | Type | Description |
---|---|---|
name |
String | Name of the federative entity |
abbreviation |
Array.<String> | Conventional abbreviations |
internal |
String | internal Nu Skin name |
iso2 |
String | 2-letter ISO code |
iso3 |
String | 3-letter ISO code |
Type:
- Object
Example
{
name: 'Michoacán',
abbreviation: ['Mich.'],
internal: 'MIC',
iso2: 'MI',
iso3: 'MIC'
}