Color Check is a very tiny library for checking your foreground and backgrounds colors against the WCAG2 color compliance standard. There are a range of methods which can be found in the docs including returning the actual values used in calculating the AA, AA 18, AAA and AAA 18 standards as well as color contrast and color difference checks.
There are other libraries such as the excellent color package which will parse any valid css color syntax and provide methods for checking the values needed. This library is smaller and returns boolean values where possible. Being smaller, it requires you to provide the valid hex string or rgb color object. Errors will simply fail.
npm install color-check
var colorCheck = require('color-check');
colorCheck.aa('#000000', {r:0, g:0, b: 0}) // returns true
For other methods, see the docs
Good accessibility means good UX for everyone!
Enjoy!
MIT License