Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mahanunu/color-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🎨 color-utils
color-utils est une librairie JavaScript/TypeScript simple et légère pour manipuler facilement les couleurs au format HEX et RGB.
📦 Installation
npm install color-utilsOu en local pour test :
npm install ./chemin/vers/color-utils
🚀 Utilisation
import {
hexToRgb,
rgbToHex,
invertColor,
darken,
lighten,
} from 'color-utils';
console.log(hexToRgb('#ffcc00')); // [255, 204, 0]
console.log(rgbToHex(255, 204, 0)); // '#ffcc00'
console.log(invertColor('#000000')); // '#ffffff'
console.log(darken('#ffcc00', 30)); // '#e6b300'
console.log(lighten('#ffcc00', 30)); // '#ffff1e'🧩 API
hexToRgb(hex: string): [number, number, number]
Convertit un code hexadécimal en tableau RGB
rgbToHex(r: number, g: number, b: number): string
Convertit des valeurs RGB en hexadécimal
invertColor(hex: string): string
Retourne la couleur opposée (inversée)
darken(hex: string, amount: number): string
Assombrit une couleur en diminuant ses canaux RGB
lighten(hex: string, amount: number): string
Éclaircit une couleur en augmentant ses canaux RGB
🧪 Tests
npm run testTesté avec Vitest
🧼 Lint & Format
npm run lint # Vérifie les erreurs avec ESLint
npm run format # Reformate automatiquement le code avec Prettier📝 Licence
Distribué sous licence MIT © 2025 Mahalia Pires
Voir le fichier LICENSE