Skip to content

Commit

Permalink
export isPaternOrGradient helper with typings
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeLenaleee committed May 2, 2022
1 parent 733fe22 commit 6a6270f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helpers/helpers.color.js
@@ -1,13 +1,13 @@
import colorLib from '@kurkle/color';

const isPatternOrGradient = (value) => {
export function isPatternOrGradient(value) {
if (value && typeof value === 'object') {
const type = value.toString();
return type === '[object CanvasPattern]' || type === '[object CanvasGradient]';
}

return false;
};
}

export function color(value) {
return isPatternOrGradient(value) ? value : colorLib(value);
Expand Down
4 changes: 4 additions & 0 deletions types/helpers/helpers.color.d.ts
@@ -1,3 +1,5 @@
import { AnyObject } from "../basic";

export function color(value: CanvasGradient): CanvasGradient;
export function color(value: CanvasPattern): CanvasPattern;
export function color(
Expand All @@ -8,6 +10,8 @@ export function color(
| [number, number, number, number]
): ColorModel;

export function isPatternOrGradient(value: AnyObject): boolean;

export interface ColorModel {
rgbString(): string;
hexString(): string;
Expand Down

0 comments on commit 6a6270f

Please sign in to comment.