This is a bit of a tricky question, very roughly there are two common ways to do this:

  • based on a map styling mechanism

  • based on presets (with an appropriate matching algorithm)

The later tend tend to handle a lot more different objects because by their very nature they are used to individually map the objects in question and the former tends to be more category orientated.

In any case the page you found in the wiki is very very old (trying to be nice here) and definitely totally out of date. I use icons from http://osm-icons.org/wiki/Main_Page which is an extension of that specific icon set in my presets https://github.com/simonpoole/beautified-JOSM-preset which is probably the closest you will get to a machine readable definition of when to use the specific set of icons. But likely that is way overkill for your application.

From an ease of use in an JS application potentially the iD presets might be a better starting point as they use a JSON format for preset definition, but different icons.