UNPKG

niram

Version:

A javascript library to convert between various css colour formats.

13 lines (12 loc) 432 B
export function normaliseNumber(numString) { const num = Number(numString); return num < 0 ? 0 : num < 255 ? num : 255; } export function normaliseFraction(fractionString) { const fraction = Number(fractionString); return fraction < 0 ? 0 : fraction < 1 ? fraction : 1; } export function normaliseDegree(degreeString) { const degree = Number(degreeString) % 360; return degree < 0 ? degree + 360 : degree; }