Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

color-parse

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-parse

Color string parser

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

color-parse test size stable

Fast and compact color string parser.

$ npm install color-parse

var parse = require('color-parse')

parse('hsla(12 10% 50% / .3)')
// { space: 'hsl', values: [12, 10, 50], alpha: 0.3 }

Parsed strings

  • Color keywords: red, green etc., see color-name
  • #RGB[A]
  • #RRGGBB[AA]
  • rgb[a](R, G, B[, A])
  • rgb(R G B[ / A])
  • hsl[a](H, S, L[, A]), inc. named hues
  • hsl(H S L [ / A])
  • hwb(H, W, B)
  • cmyk(C, M, Y, K)
  • xyz(X, Y, Z)
  • luv(L, U, V)
  • luv(L U V[ / A])
  • lab(L, A, B)
  • lab(L a b[ / A]) - see limits
  • lch(L, C, H)
  • lch(L C H[ / A]) - see limits
  • oklab(L a b[ / A]) - see limits
  • oklch(L C H[ / A]) - see limits
  • color(space c1 c2 c3[ / A])
  • R:10 G:20 B:30
  • (R10 / G20 / B30)
  • C100/M80/Y0/K35
  • [10, 20, 20] as RGB
  • 10,20,20 as RGB
  • 0x00ff00, 0x0000ff numbers as RGB

Not parsed

  • unknown strings eg. 'yellowblue'
  • not strings: object, arrays etc.
  • color-space — collection of color space conversions.
  • color-rgba — convert any color string to rgba array.
  • color-alpha — change alpha component of any color.

Analogs

  • parse-color — parser by @substack. Performs calculations to every possible space, which bloats size.
  • color-parser — parser by @tjholowaychuk. Supports limited set of spaces.
  • color-string — parsing/serializing module by Heather Arthur. Has extensive API for parsing and serializing from any to any space.

NPM

Keywords

FAQs

Package last updated on 15 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc