{"library":"moo-color","title":"MooColor","description":"MooColor is a modern TypeScript library designed for comprehensive color parsing, conversion, and manipulation. Currently stable at version 2.0.0, the package maintains an active release cadence with minor updates and patches, and announces significant breaking changes with major versions. Key differentiators include its strictly immutable API, where all manipulation methods return new instances rather than mutating the original, and robust WCAG 2.1 compliance for accurate luminance and contrast ratio calculations. It provides dual ESM, CJS, and IIFE bundles, making it versatile across Node.js environments (requiring Node.js >=18 since v2) and browsers. The library is fully typed, including Template Literal Types for advanced color string representation, and supports a wide array of color models like hex, RGB, HSL, HWB, HSV, and CMYK, alongside named colors.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install moo-color"],"cli":null},"imports":["import { MooColor } from 'moo-color'","import { MooColor } from 'moo-color';\nconst randomColor = MooColor.random();","import type { ColorData } from 'moo-color';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { MooColor } from 'moo-color';\n\n// Parse various color formats, including named colors and RGBA\nconst red = new MooColor('red');\nconst semiTransparentBlue = new MooColor('rgba(0, 0, 255, 0.7)');\nconst orangeHsl = new MooColor('hsl(30, 100%, 50%)');\n\nconsole.log('Original Red (hex):', red.toHex()); // #ff0000\n\n// Manipulation methods return new instances (immutable API since v2.0.0)\nconst lightenedRed = red.lighten(20);\nconst desaturatedBlue = semiTransparentBlue.desaturate(30);\n\nconsole.log('Lightened Red (hex):', lightenedRed.toHex()); // Example: #ff6666\nconsole.log('Original Red is unchanged:', red.toHex()); // #ff0000\n\n// Chaining operations\nconst adjustedOrange = orangeHsl\n  .rotate(60) // Rotate hue by 60 degrees\n  .saturate(15) // Increase saturation\n  .darken(10) // Darken the color\n  .setAlpha(0.9); // Set transparency\n\nconsole.log('Adjusted Orange (RGBA):', adjustedOrange.toRgba()); // Example: rgba(..., 0.9)\n\n// WCAG contrast ratio check\nconst white = new MooColor('#fff');\nconst black = new MooColor('#000');\nconsole.log('Contrast Ratio (Black vs White):', black.contrastRatioWith(white)); // 21\n\n// Generate a random color with specific constraints\nconst randomWarmColor = MooColor.random({ hue: [0, 60], saturation: [50, 100] });\nconsole.log('Random warm color:', randomWarmColor.toHsl());","lang":"typescript","description":"This quickstart demonstrates parsing various color formats, performing immutable manipulations, chaining methods, checking WCAG contrast ratios, and generating constrained random colors.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}