colorikeet
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -18,13 +18,16 @@ "use strict"; | ||
Colorikeet.from = function (input) { | ||
var result = undefined; | ||
var color; | ||
if (input.startsWith("hsl")) { | ||
result = hsla_1.HSLA.fromHslString(input); | ||
color = hsla_1.HSLA.fromHslString(input); | ||
} | ||
if (input.startsWith("#")) { | ||
result = rgba_1.RGBA.fromHexString(input); | ||
color = rgba_1.RGBA.fromHexString(input); | ||
} | ||
if (input.startsWith("rgb")) { | ||
result = rgba_1.RGBA.fromRgbString(input); | ||
color = rgba_1.RGBA.fromRgbString(input); | ||
} | ||
var color = result ? rgba_1.RGBA.fromNameString(input) : result; | ||
// @ts-ignore | ||
if (!color) { | ||
color = rgba_1.RGBA.fromNameString(input); | ||
} | ||
if (color instanceof Error) { | ||
@@ -31,0 +34,0 @@ return color; |
@@ -61,3 +61,3 @@ "use strict"; | ||
var matcher = dataLength === 3 || dataLength === 4 ? /[a-f0-9]/g : /[a-f0-9]{2}/g; | ||
var data = input.slice(1).match(matcher); | ||
var data = input.slice(1).toLowerCase().match(matcher); | ||
if (data === null) { | ||
@@ -64,0 +64,0 @@ return new Error("Could not parse " + JSON.stringify(input) + " as hex color, it must match pattern #([0-9a-f]+)"); |
@@ -16,13 +16,16 @@ import { RGBA } from "./rgba"; | ||
Colorikeet.from = function (input) { | ||
var result = undefined; | ||
var color; | ||
if (input.startsWith("hsl")) { | ||
result = HSLA.fromHslString(input); | ||
color = HSLA.fromHslString(input); | ||
} | ||
if (input.startsWith("#")) { | ||
result = RGBA.fromHexString(input); | ||
color = RGBA.fromHexString(input); | ||
} | ||
if (input.startsWith("rgb")) { | ||
result = RGBA.fromRgbString(input); | ||
color = RGBA.fromRgbString(input); | ||
} | ||
var color = result ? RGBA.fromNameString(input) : result; | ||
// @ts-ignore | ||
if (!color) { | ||
color = RGBA.fromNameString(input); | ||
} | ||
if (color instanceof Error) { | ||
@@ -29,0 +32,0 @@ return color; |
@@ -52,3 +52,3 @@ import * as colors from "color-name"; | ||
var matcher = dataLength === 3 || dataLength === 4 ? /[a-f0-9]/g : /[a-f0-9]{2}/g; | ||
var data = input.slice(1).match(matcher); | ||
var data = input.slice(1).toLowerCase().match(matcher); | ||
if (data === null) { | ||
@@ -55,0 +55,0 @@ return new Error("Could not parse " + JSON.stringify(input) + " as hex color, it must match pattern #([0-9a-f]+)"); |
{ | ||
"name": "colorikeet", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A minimal color math toolset", | ||
@@ -5,0 +5,0 @@ "main": "lib/colorikeet.js", |
58115
1619