Skip to content

Commit

Permalink
return type updates for hexToRGBA, hexToRGB
Browse files Browse the repository at this point in the history
  • Loading branch information
heyjul3s committed Feb 4, 2021
1 parent 8cbe0f9 commit 6c89fe5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/hextorgb/src/hextorgb.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { RGBColor } from './typings';

export function hexToRGBA(hex: string, alpha = 1): string | undefined {
export function hexToRGBA(hex: string, alpha = 1): string | void {
const color = hexToRGB(hex);

return !!color
? `rgba(${color.r}, ${color.g}, ${color.b}, ${alpha})`
: void 0;
if (!!color) {
return `rgba(${color.r}, ${color.g}, ${color.b}, ${alpha})`;
}
}

export function hexToRGB(hex: string): RGBColor | undefined {
export function hexToRGB(hex: string): RGBColor | void {
const hexValue = formatHexValue(hex);

return !!hexValue
? {
r: parseInt(hexValue[1], 16),
g: parseInt(hexValue[2], 16),
b: parseInt(hexValue[3], 16)
}
: void 0;
if (!!hexValue) {
return {
r: parseInt(hexValue[1], 16),
g: parseInt(hexValue[2], 16),
b: parseInt(hexValue[3], 16)
};
}
}

export function formatHexValue(
Expand Down

0 comments on commit 6c89fe5

Please sign in to comment.