Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function suggestionsToPresets(presets) {
const brands = nsi.brands.brands;
const wikidata = nsi.wikidata.wikidata;
Object.keys(brands).forEach(kvnd => {
const suggestion = brands[kvnd];
const qid = suggestion.tags['brand:wikidata'];
if (!qid || !/^Q\d+$/.test(qid)) return; // wikidata tag missing or looks wrong..
const parts = kvnd.split('|', 2);
const kv = parts[0];
const name = parts[1].replace('~', ' ');
let presetID, preset;
// sometimes we can choose a more specific preset then key/value..
if (suggestion.tags.cuisine) {
// cuisine can contain multiple values, so try them all in order
let cuisines = suggestion.tags.cuisine.split(';');