Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test = function(description) {
return query.test(description);
};
// If the query is all lowercase, make a case-insensitive match.
} else if (query.toLowerCase() === query) {
test = function(description) {
return -1 !== description.toLowerCase().indexOf(query);
};
} else {
test = function(description) {
return -1 !== description.indexOf(query);
};
}
return registry.filter(function(record) {
if (!record.Subtag && !all) {
return false;
}
return record.Description.some(test);
// Sort by matched description string length.
// This is a quick way to push precise matches towards the top.
}).sort(function(a, b) {
return Math.min.apply(Math, a.Description.filter(test).map(function(description) {
return description.length;
})) - Math.min.apply(Math, b.Description.filter(test).map(function(description) {
return description.length;
}));
}).map(function(record) {
if (record.Subtag) {