From c92c6a12413e103ad243e7504da3a0ec07d8b37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Maria=20Pay=C3=A1=20Castillo?= <30294138+jpaya17@users.noreply.github.com> Date: Wed, 18 Aug 2021 05:46:39 +0000 Subject: [PATCH] perf(isISO31661Alpha3): use a Set along with .has instead of includes --- src/lib/isISO31661Alpha3.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/isISO31661Alpha3.js b/src/lib/isISO31661Alpha3.js index 00c3dfb14..34e552cdd 100644 --- a/src/lib/isISO31661Alpha3.js +++ b/src/lib/isISO31661Alpha3.js @@ -1,8 +1,7 @@ import assertString from './util/assertString'; -import includes from './util/includes'; // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 -const validISO31661Alpha3CountriesCodes = [ +const validISO31661Alpha3CountriesCodes = new Set([ 'AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', @@ -19,9 +18,9 @@ const validISO31661Alpha3CountriesCodes = [ 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE', -]; +]); export default function isISO31661Alpha3(str) { assertString(str); - return includes(validISO31661Alpha3CountriesCodes, str.toUpperCase()); + return validISO31661Alpha3CountriesCodes.has(str.toUpperCase()); }