You'll find the library here. Just include it in your code, after having imported d3.js, and use
to convert 'color' to the color that a person suffering from 'anomaly' would see. The global variable 'Anomalies' contains the names of all supported color vision anomalies.
You'll see that the code is pretty rough at the moment. It could be adapted to be more developer-friendly for use with D3 color scales. That's on my todo list for rainy weekends.
ColorBrewer's colors are released under the GNU General Public License, version 3. The source code for the 'daltonize.js' library is a slightly adapted version of this code for which I have found no licensing information.