ac-countrylist 1.0.3 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.acsemver.js +1 -1
- package/CHANGELOG.md +51 -0
- package/README.md +4 -1
- package/countrylist.js +2 -1
- package/index.js +21 -3
- package/package.json +8 -8
- package/test/test.js +54 -5
package/.acsemver.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
<a name="1.0.7"></a>
|
|
2
|
+
|
|
3
|
+
## [1.0.7](https://github.com/admiralcloud/ac-countrylist/compare/v1.0.6..v1.0.7) (2022-06-08 18:17:51)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fix
|
|
7
|
+
|
|
8
|
+
* **App:** Changed Turkey to Türkiye | MP | [b1d56db3e8f5cb9d1c6e27c277d0e40df8621caf](https://github.com/admiralcloud/ac-countrylist/commit/b1d56db3e8f5cb9d1c6e27c277d0e40df8621caf)
|
|
9
|
+
Changed Turkey to Türkiye
|
|
10
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
11
|
+
### Chores
|
|
12
|
+
|
|
13
|
+
* **App:** Updated gitignore | MP | [37fd39317aee46af14b497042c94cee1cc6ea01e](https://github.com/admiralcloud/ac-countrylist/commit/37fd39317aee46af14b497042c94cee1cc6ea01e)
|
|
14
|
+
Updated gitignore
|
|
15
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
16
|
+
### Chores
|
|
17
|
+
|
|
18
|
+
* **App:** Updated packages | MP | [6dde63afc641c5a16ba9b2a5b1f5f12e72619e4f](https://github.com/admiralcloud/ac-countrylist/commit/6dde63afc641c5a16ba9b2a5b1f5f12e72619e4f)
|
|
19
|
+
Updated packages
|
|
20
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
21
|
+
<a name="1.0.6"></a>
|
|
22
|
+
|
|
23
|
+
## [1.0.6](https://github.com/admiralcloud/ac-countrylist/compare/v1.0.5..v1.0.6) (2021-10-09 10:44:02)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fix
|
|
27
|
+
|
|
28
|
+
* **App:** Package updates | MP | [1ac55eeefeb838244d51b731afa8082f6034968b](https://github.com/admiralcloud/ac-countrylist/commit/1ac55eeefeb838244d51b731afa8082f6034968b)
|
|
29
|
+
Package updates
|
|
30
|
+
<a name="1.0.5"></a>
|
|
31
|
+
|
|
32
|
+
## [1.0.5](https://github.com/mmpro/ac-countrylist/compare/v1.0.4..v1.0.5) (2020-10-26 15:19:46)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fix
|
|
36
|
+
|
|
37
|
+
* **App:** Allow search for country name | MP | [a6872bed26d3cb8cb64edcbe96e2bb58ef6a7ed7](https://github.com/mmpro/ac-countrylist/commit/a6872bed26d3cb8cb64edcbe96e2bb58ef6a7ed7)
|
|
38
|
+
Search country name in native name, translation and name.
|
|
39
|
+
<a name="1.0.4"></a>
|
|
40
|
+
|
|
41
|
+
## [1.0.4](https://github.com/mmpro/ac-countrylist/compare/v1.0.3..v1.0.4) (2020-10-26 15:04:53)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fix
|
|
45
|
+
|
|
46
|
+
* **App:** Allow iso3 search | MP | [30dcaf6551ee8ef4e27a58969b0d8cc65cc5e447](https://github.com/mmpro/ac-countrylist/commit/30dcaf6551ee8ef4e27a58969b0d8cc65cc5e447)
|
|
47
|
+
Allow iso3 search
|
|
48
|
+
### Chores
|
|
49
|
+
|
|
50
|
+
* **App:** Updated packages | MP | [32b3ba576a751338457fcd93246b8bbfcc36696a](https://github.com/mmpro/ac-countrylist/commit/32b3ba576a751338457fcd93246b8bbfcc36696a)
|
|
51
|
+
Updated packages
|
|
1
52
|
<a name="1.0.3"></a>
|
|
2
53
|
|
|
3
54
|
## [1.0.3](https://github.com/mmpro/ac-countrylist/compare/v1.0.2..v1.0.3) (2020-07-28 11:38:18)
|
package/README.md
CHANGED
|
@@ -21,9 +21,12 @@ const list = acCountryList.showList()
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
### Query list
|
|
24
|
-
Query the country list (currently only iso2 is supported)
|
|
24
|
+
Query the country list (currently only iso2 and iso3 is supported)
|
|
25
25
|
```
|
|
26
26
|
const country = acCountryList.query({ iso2: 'de' })
|
|
27
|
+
// OR
|
|
28
|
+
const country = acCountryList.query({ iso3: 'deu' })
|
|
29
|
+
|
|
27
30
|
// -> { name: 'Germany',
|
|
28
31
|
capital: 'Berlin',
|
|
29
32
|
altSpellings:
|
package/countrylist.js
CHANGED
|
@@ -11326,10 +11326,11 @@ module.exports = [
|
|
|
11326
11326
|
]
|
|
11327
11327
|
},
|
|
11328
11328
|
{
|
|
11329
|
-
name: '
|
|
11329
|
+
name: 'Türkiye',
|
|
11330
11330
|
capital: 'Ankara',
|
|
11331
11331
|
altSpellings: [
|
|
11332
11332
|
'TR',
|
|
11333
|
+
'Turkey',
|
|
11333
11334
|
'Turkiye',
|
|
11334
11335
|
'Republic of Turkey',
|
|
11335
11336
|
'Türkiye Cumhuriyeti'
|
package/index.js
CHANGED
|
@@ -27,13 +27,31 @@ const acCountryList = () => {
|
|
|
27
27
|
* This function ingests a query params (currently iso2 only) and returns the country.
|
|
28
28
|
*
|
|
29
29
|
* @param params.iso2 STRING iso2 code
|
|
30
|
+
* @param params.iso3 STRING iso3 code
|
|
30
31
|
*/
|
|
31
32
|
const query = (params) => {
|
|
32
33
|
const iso2 = _.get(params, 'iso2')
|
|
34
|
+
const iso3 = _.get(params, 'iso3')
|
|
35
|
+
const name = _.upperFirst(_.get(params, 'name'))
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
if (iso2 || iso3) {
|
|
38
|
+
const findQuery = {}
|
|
39
|
+
if (iso2) _.set(findQuery, 'alpha2Code', _.toUpper(iso2))
|
|
40
|
+
else if (iso3) _.set(findQuery, 'alpha3Code', _.toUpper(iso3))
|
|
41
|
+
return _.find(countryList, findQuery)
|
|
42
|
+
}
|
|
43
|
+
else if (name) {
|
|
44
|
+
let countries = _.map(countryList, item => {
|
|
45
|
+
return {
|
|
46
|
+
alpha2Code: item.alpha2Code,
|
|
47
|
+
names: _.concat([_.get(item, 'name'), _.get(item, 'nativeName')], _.values(_.get(item, 'translations')))
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
let match = _.find(countries, item => {
|
|
51
|
+
if (_.indexOf(item.names, name) > -1) return item
|
|
52
|
+
})
|
|
53
|
+
return _.find(countryList, { alpha2Code : _.get(match, 'alpha2Code') })
|
|
54
|
+
}
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
return {
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ac-countrylist",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"
|
|
5
|
+
"chai": "^4.3.6",
|
|
6
|
+
"lodash": "^4.17.21"
|
|
6
7
|
},
|
|
7
|
-
"
|
|
8
|
+
"author": "Mark Poepping",
|
|
9
|
+
"repository": "admiralcloud/ac-countrylist",
|
|
8
10
|
"license": "MIT",
|
|
9
11
|
"devDependencies": {
|
|
10
|
-
"ac-semantic-release": "^0.
|
|
11
|
-
"eslint": "^
|
|
12
|
-
"
|
|
13
|
-
"husky": "^4.2.5",
|
|
14
|
-
"mocha": "^8.0.1"
|
|
12
|
+
"ac-semantic-release": "^0.3.0",
|
|
13
|
+
"eslint": "^8.17.0",
|
|
14
|
+
"mocha": "^10.0.0"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "mocha --bail --colors --reporter spec"
|
package/test/test.js
CHANGED
|
@@ -1,24 +1,73 @@
|
|
|
1
|
-
const expect = require('
|
|
1
|
+
const { expect } = require('chai')
|
|
2
2
|
const _ = require('lodash')
|
|
3
3
|
const acCountryList = require('../index')
|
|
4
4
|
|
|
5
5
|
describe('Start tests', () => {
|
|
6
6
|
it('Fetch list', (done) => {
|
|
7
7
|
let test = acCountryList.shortList()
|
|
8
|
-
expect(test).
|
|
8
|
+
expect(test).to.have.lengthOf(249)
|
|
9
9
|
return done()
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
it('Fetch random country', (done) => {
|
|
13
13
|
let test = _.get(acCountryList.random(), 'name')
|
|
14
14
|
let list = _.map(acCountryList.shortList(), 'name')
|
|
15
|
-
expect(list).
|
|
15
|
+
expect(list).to.include(test)
|
|
16
16
|
return done()
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
it('Query DE - should return Germany', (done) => {
|
|
19
|
+
it('Query ISO2 - DE - should return Germany', (done) => {
|
|
20
20
|
let test = acCountryList.query({ iso2: 'DE' })
|
|
21
|
-
expect(test).
|
|
21
|
+
expect(test).to.have.property('nativeName', 'Deutschland')
|
|
22
|
+
return done()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('Query Türkiye - new spelling as of June 2022', (done) => {
|
|
26
|
+
let test = acCountryList.query({ name: 'Türkiye' })
|
|
27
|
+
expect(test).to.have.property('nativeName', 'Türkiye')
|
|
28
|
+
return done()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('Query Turkey - old spelling of Türkiye - should still work', (done) => {
|
|
32
|
+
let test = acCountryList.query({ name: 'Türkiye' })
|
|
33
|
+
expect(test).to.have.property('nativeName', 'Türkiye')
|
|
34
|
+
return done()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('Query ISO3 - LAO - should return Laos', (done) => {
|
|
38
|
+
let test = acCountryList.query({ iso3: 'LAO' })
|
|
39
|
+
expect(test).to.have.property('name', 'Laos')
|
|
40
|
+
expect(test).to.have.property('nativeName', 'ສປປລາວ')
|
|
41
|
+
return done()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('Query Laos', (done) => {
|
|
45
|
+
let test = acCountryList.query({ name: 'Laos' })
|
|
46
|
+
expect(test).to.have.property('nativeName', 'ສປປລາວ')
|
|
47
|
+
return done()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('Query Laos in japanese - ラオス人民民主共和国', (done) => {
|
|
51
|
+
let test = acCountryList.query({ name: 'ラオス人民民主共和国' })
|
|
52
|
+
expect(test).to.have.property('nativeName', 'ສປປລາວ')
|
|
53
|
+
return done()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('Query Laos in native - ສປປລາວ', (done) => {
|
|
57
|
+
let test = acCountryList.query({ name: 'ラオス人民民主共和国' })
|
|
58
|
+
expect(test).to.have.property('nativeName', 'ສປປລາວ')
|
|
59
|
+
return done()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('Query name with lower first', (done) => {
|
|
63
|
+
let test = acCountryList.query({ name: 'deutschland' })
|
|
64
|
+
expect(test).to.have.property('nativeName', 'Deutschland')
|
|
65
|
+
return done()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('Query name with not match', (done) => {
|
|
69
|
+
let test = acCountryList.query({ name: 'wonderland' })
|
|
70
|
+
expect(test).to.be.undefined
|
|
22
71
|
return done()
|
|
23
72
|
})
|
|
24
73
|
})
|