Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/isBIC.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function isBIC(str) {

// toUpperCase() should be removed when a new major version goes out that changes
// the regex to [A-Z] (per the spec).
if (CountryCodes.indexOf(str.slice(4, 6).toUpperCase()) < 0) {
if (!CountryCodes.has(str.slice(4, 6).toUpperCase())) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/isISO31661Alpha2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assertString from './util/assertString';

// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
const validISO31661Alpha2CountriesCodes = [
const validISO31661Alpha2CountriesCodes = new Set([
'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ',
'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ',
'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ',
Expand All @@ -27,11 +27,11 @@ const validISO31661Alpha2CountriesCodes = [
'WF', 'WS',
'YE', 'YT',
'ZA', 'ZM', 'ZW',
];
]);

export default function isISO31661Alpha2(str) {
assertString(str);
return validISO31661Alpha2CountriesCodes.indexOf(str.toUpperCase()) >= 0;
return validISO31661Alpha2CountriesCodes.has(str.toUpperCase());
}

export const CountryCodes = validISO31661Alpha2CountriesCodes;