Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NeXTs
Created March 27, 2018 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeXTs/487f3278ac48728d317a1557f6c63335 to your computer and use it in GitHub Desktop.
Save NeXTs/487f3278ac48728d317a1557f6c63335 to your computer and use it in GitHub Desktop.
Thinnest JS RGB(a) string parser
export const parseRGBa = palette => {
palette = palette.replace(/[^0-9.,]/g, '').split(',').map(Number)
if(palette.length == 3) palette.push(1) // add alpha if missed
return palette
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment