Hence the title specifically noting it uses a blacklist.
Hence the title specifically noting it uses a blacklist.
isVegan.isVeganIngredient('ham'); // trueAlthough technically I couldn't find a reference to 'HAM', but rather 'HAM (CURED WITH HONEY, SALT, SUGAR, WATER, DEXTROSE, LACTIC ACID STARTER CULTURE, SODIUM ASCORBATE, SODIUM NITRITE)' [0]
If it had a whitelist, it might tell you that spinach is not vegan instead. With both, it might tell you that both spinach and ham are ?.
If you "know what a blacklist is", how can you fail to understand that it returns true for ham because it's a blacklist and thus assumes any missing item is OK?
Even if they add "ham" to the list, you'll always be able to find stuff that's not on the blacklist, because that's how blacklists work. Hákarl? Not on the blacklist, will be marked as vegan. Whale? Not on the blacklist, will be marked as vegan. Pizzle? Not on the blacklist, will be marked as vegan.
A blacklist means you'll have false negatives (items will pass which should not), and a whitelist means you'll have false positives (items will be flagged which should not). If you can't actually test properties, the only question you're left with is which failure mode is preferrable, but it's one or the other.
And in my opinion, things which have to do with health or safety are the latter (you'd rather avoid something which turns out to be safe than allow something which is not).
I am saying the function should not be called isVeganIngredient if it returns true for ham. It’s misleading. It’s bad design.
Two possible solutions:
1. Invert the return value, and change the function name to isKnownNonVeganIngredient (and take similar steps for the other functions).
2. Even better, scrap the functions entirely, and just release the data (e.g. publish a dumb JSON package on npm called non-vegan-ingredients), so people can use everyday array methods to consume it however they want.
I’m not the one downvoting you btw.