Comparing version 0.1.33 to 0.1.34
@@ -47,4 +47,14 @@ export declare type RGBA = [number, number, number, number]; | ||
export declare function toHslaString(base: HSLA | HSL): string; | ||
export declare function toHexaString(base: RGBA | RGB): string; | ||
export declare function toHexString(base: RGBA | RGB): string; | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
export declare function toHexaString(base: RGBA | RGB | string): string; | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
export declare function toHexString(base: RGBA | RGB | string): string; | ||
export { hsl2hsv, hsv2hsl, hsv2rgb, rgb2hsv, rgb2hsl, hsl2rgb } from './convert'; |
@@ -231,3 +231,24 @@ import colors from './colors'; | ||
} | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
export function toHexaString(base) { | ||
if (typeof base === 'string') { | ||
let i; | ||
if (i = hexRegex.exec(base)) { | ||
return `${i[0]}FF`; | ||
} | ||
else if (i = hexaRegex.exec(base)) { | ||
return i[0]; | ||
} | ||
else if (i = sHexRegex.exec(base)) { | ||
return `#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}FF`; | ||
} | ||
else if (i = sHexaRegex.exec(base)) { | ||
return `#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}${i[4]}${i[4]}`; | ||
} | ||
throw new Error(`[seemly/toHexString]: Invalid hex value ${base}.`); | ||
} | ||
const hex = `#${base | ||
@@ -245,3 +266,21 @@ .slice(0, 3) | ||
} | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
export function toHexString(base) { | ||
if (typeof base === 'string') { | ||
let i; | ||
if (i = hexRegex.exec(base)) { | ||
return i[0]; | ||
} | ||
else if (i = hexaRegex.exec(base)) { | ||
return i[0].slice(0, 7); | ||
} | ||
else if (i = (sHexRegex.exec(base) || sHexaRegex.exec(base))) { | ||
return `#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}`; | ||
} | ||
throw new Error(`[seemly/toHexString]: Invalid hex value ${base}.`); | ||
} | ||
return `#${base | ||
@@ -248,0 +287,0 @@ .slice(0, 3) |
@@ -47,4 +47,14 @@ export declare type RGBA = [number, number, number, number]; | ||
export declare function toHslaString(base: HSLA | HSL): string; | ||
export declare function toHexaString(base: RGBA | RGB): string; | ||
export declare function toHexString(base: RGBA | RGB): string; | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
export declare function toHexaString(base: RGBA | RGB | string): string; | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
export declare function toHexString(base: RGBA | RGB | string): string; | ||
export { hsl2hsv, hsv2hsl, hsv2rgb, rgb2hsv, rgb2hsl, hsl2rgb } from './convert'; |
@@ -252,3 +252,24 @@ "use strict"; | ||
exports.toHslaString = toHslaString; | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
function toHexaString(base) { | ||
if (typeof base === 'string') { | ||
let i; | ||
if (i = hexRegex.exec(base)) { | ||
return `${i[0]}FF`; | ||
} | ||
else if (i = hexaRegex.exec(base)) { | ||
return i[0]; | ||
} | ||
else if (i = sHexRegex.exec(base)) { | ||
return `#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}FF`; | ||
} | ||
else if (i = sHexaRegex.exec(base)) { | ||
return `#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}${i[4]}${i[4]}`; | ||
} | ||
throw new Error(`[seemly/toHexString]: Invalid hex value ${base}.`); | ||
} | ||
const hex = `#${base | ||
@@ -267,3 +288,21 @@ .slice(0, 3) | ||
exports.toHexaString = toHexaString; | ||
/** | ||
* | ||
* @param base [255, 255, 255, 255], [255, 255, 255], any hex string | ||
* @returns | ||
*/ | ||
function toHexString(base) { | ||
if (typeof base === 'string') { | ||
let i; | ||
if (i = hexRegex.exec(base)) { | ||
return i[0]; | ||
} | ||
else if (i = hexaRegex.exec(base)) { | ||
return i[0].slice(0, 7); | ||
} | ||
else if (i = (sHexRegex.exec(base) || sHexaRegex.exec(base))) { | ||
return `#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}`; | ||
} | ||
throw new Error(`[seemly/toHexString]: Invalid hex value ${base}.`); | ||
} | ||
return `#${base | ||
@@ -270,0 +309,0 @@ .slice(0, 3) |
{ | ||
"name": "seemly", | ||
"version": "0.1.33", | ||
"version": "0.1.34", | ||
"description": "Utils for user interface.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66584
1670