UNPKG

@onesy/utils

Version:
24 lines (23 loc) 897 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const equalDeep_1 = __importDefault(require("./equalDeep")); const countries_1 = __importDefault(require("./countries")); const getCountry = (...args) => { let mostArgsCountry; let mostArgs = 0; for (const country of countries_1.default) { const countryKeys = Object.keys(country).filter(key => args.some((arg) => (0, equalDeep_1.default)(country[key], arg))); if (countryKeys.length) { if (!mostArgsCountry || countryKeys.length > mostArgs) { mostArgsCountry = country; mostArgs = countryKeys.length; } } } return mostArgsCountry; }; exports.default = getCountry;