Dojo has a module that seems to do a lot of what you are looking for: http://dojotoolkit.org/reference-guide/1.9/dojox/color/Palette.html
If you want to use it standalone you might have to create a "build" to get one js file since Dojo has a little bit of scaffolding for their require()'s and stuff like that. Or you can have a look at the source: https://github.com/dojo/dojox/tree/master/color .
If needed I can instruct a bit on creating a dojo build for this.