Check if an array contains a valid rgb color code
$ npm install --save is-rgb
Or if you prefer yarn:
$ yarn add is-rgb
const is_rgb = require('is-rgb');
// If no callback function is given, is_rgb returns a promise
is_rgb([0, 100, 200])
.then(result => console.log(result)) // true
.catch(err => console.error(err));
// Here with a given callback function
is_rgb([1, 101, 201], (err, result) => {
if (err) console.error(err);
console.log(result); // true
});
// You can also give three single parameters instead of an array
is_rgb(2, 102, 202, (err, result) => {
if (err) console.error(err);
console.log(result); // true
});
$ npm test
- 1.0.0
- Initial Release