Many of the methods that I have in this module are based off of angles.js up on npmjs, which is still a great module for many of these kinds of tasks. Still the module seems to no longer be support, but still seems to work just find in many situations. I really wanted to just make my own module for this sort of thing though, so I started putting something together of my own that just contains the methods that I seem to use the most often, with just a few slight changes here and there.
The module follows a pattern that I am now using the works well for making a module that will work okay in both a nodejs as well as a browser environment. It involves using an IIFE and passing a value that will be the object to append to when calling the self executing function. This kind of module pattern will not work well in all situations whne it comes to making a module that is very browser, or nodejs centric, but for this kind of module I think it would be a good choice. I will not be getting into this topic in detail here as I have wrote a post on this kind of module that can be used to share code between nodejs and the browser, if you want to read more about it that would be a good place to start.
The shortest direction method seems to work in each case that I have used it thus far. I can just call it pass one angle, and then another, and the returned result will be -1, 1, or zero that I can then easily use in an expression that would be used to update a current angle to end up facing a given target angle. This is then of course a much have kind of method in this kind of module then, because this is something that comes up all the time, in all kinds of games.
I am sure that there will be a lot of other little things that have to do with angles that will pop up now and then, as such I am sure that there will be at least a few additional edits of this post in the future sooner or later. I am also sure that I will be using this module in at least one or two additional examples, or full projects for that matter so I will try to remember to link to those posts when I get around to writing them.