rrggbbaa
Version:
Color code utility and converter library for NodeJS.
29 lines (25 loc) • 748 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var Components = exports.Components = Object.freeze({
RED: "r",
GREEN: "g",
BLUE: "b",
ALPHA: "a"
});
var validateRange = exports.validateRange = function validateRange(value, min, max) {
var valueAsInteger = parseInt(value, 10);
return valueAsInteger ? valueAsInteger >= min && value <= max : false;
};
var validateComponent = exports.validateComponent = function validateComponent(component, value) {
switch (component) {
case Components.RED:
case Components.GREEN:
case Components.BLUE:
return validateRange(value, 0, 255);
case Components.ALPHA:
return validateRange(value, 0, 100);
}
};
exports.default = Components;