china-gb2260
v1.0.11
Published
china-gb2260 ============ - china-gb2260 - 中国行政区编码 省/市/自治区/城市/县 ,校验用
Downloads
11
Readme
china-gb2260
- china-gb2260
- 中国行政区编码 省/市/自治区/城市/县 ,校验用
install
- npm install china-gb2260
usage
example
const {
gb2260,
CODE_DICT,
MSG_DICT,
MD
} = require("china-gb2260")
> gb2260.parse("654301")
{
code: 0,
msg: { province: '新疆维吾尔自治区', city: '阿勒泰地区', county: '阿勒泰市' }
}
> MD[0]
'success'
>
> gb2260.parse("654399")
{ code: 3, msg: { province: '新疆维吾尔自治区', city: '阿勒泰地区' } }
>
> MD[3]
'county-not-valid'
>
> gb2260.parse("659901")
{ code: 2, msg: { province: '新疆维吾尔自治区' } }
>
> MD[2]
'city-not-valid'
>
> gb2260.parse("994301")
{ code: 1, msg: {} }
>
> MD[1]
'province-not-valid'
>
> gb2260.parse("99430")
{ code: 4, msg: {} }
> MD[4]
'length-must-be-6'
>
{
gb2260: _GB2260 {},
CODE_DICT: { succ: 0, province: 1, city: 2, county: 3, length: 4 },
MSG_DICT: {
succ: 'success',
province: 'province-not-valid',
city: 'city-not-valid',
county: 'county-not-valid',
length: 'length-must-be-6'
},
MD: {
'0': 'success',
'1': 'province-not-valid',
'2': 'city-not-valid',
'3': 'county-not-valid',
'4': 'length-must-be-6',
success: 0,
'province-not-valid': 1,
'city-not-valid': 2,
'county-not-valid': 3,
'length-must-be-6': 4
}
}
METHODS
.gb2260.all .gb2260.cities .gb2260.constructor
.gb2260.counties .gb2260.get_code .gb2260.get_name
.gb2260.is_city .gb2260.is_county .gb2260.is_province
.gb2260.is_valid .gb2260.json .gb2260.parse
.gb2260.provinces .gb2260.srch_city .gb2260.srch_county
.gb2260.srch_province
LICENSE
- ISC