Skip to content

Commit

Permalink
feat(color): combine color
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Mar 13, 2023
1 parent d3644df commit 101ad04
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/color/src/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ function kolorist(
};
}

export function combine(...fns: ReturnType<typeof kolorist>[]) {
return (str: string | number) => {
for (const fn of fns) {
str = fn(str);
}
return str;
};
}

export function stripColors(str: string | number) {
return ('' + str)
.replace(/\x1b\[[0-9;]+m/g, '')
Expand Down

0 comments on commit 101ad04

Please sign in to comment.