I'm building my service on NodeJs. I have a web-scrapping function and I have to call different crawlers for different domains.
if (domain == "aaa.kr") result = await crawlAA(args.url)
else if (domain == "aaa.com") result = await crawlA(args.url)
else if (domain == "bbb.com") result = await crawlB(args.url)
else if (domain == "ccc.com") result = await crawlC(args.url)
else if (domain == "d.com") result = await crawlD(args.url)
else result = await crawlOthers(args.url)
Right now, I have about 10 else if
clauses. However, I will need to add more than 50~100 else-if
s and I am thinking this can be a problem in the future.
Are there any efficient way to handle string if-clauses? Will primarily filtering by the starting alphabet help?
Aucun commentaire:
Enregistrer un commentaire