Skip to content

Commit c92c6a1

Browse files
authored
perf(isISO31661Alpha3): use a Set along with .has instead of includes
1 parent 8c4b3b3 commit c92c6a1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/lib/isISO31661Alpha3.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import assertString from './util/assertString';
2-
import includes from './util/includes';
32

43
// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
5-
const validISO31661Alpha3CountriesCodes = [
4+
const validISO31661Alpha3CountriesCodes = new Set([
65
'AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE',
76
'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA',
87
'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK',
@@ -19,9 +18,9 @@ const validISO31661Alpha3CountriesCodes = [
1918
'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL',
2019
'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT',
2120
'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE',
22-
];
21+
]);
2322

2423
export default function isISO31661Alpha3(str) {
2524
assertString(str);
26-
return includes(validISO31661Alpha3CountriesCodes, str.toUpperCase());
25+
return validISO31661Alpha3CountriesCodes.has(str.toUpperCase());
2726
}

0 commit comments

Comments
 (0)