Skip to content

Commit

Permalink
add previously uncommited utils.ts file
Browse files Browse the repository at this point in the history
  • Loading branch information
MoustaphaDev committed Dec 24, 2024
1 parent 6997973 commit 320fe96
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/lucide-astro/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Converts string to kebab case
*
* @param {string} string
* @returns {string} A kebabized string
*/
export const toKebabCase = (string: string) =>
string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();

/**
* Merges classes into a single string
*
* @param {array} classes
* @returns {string} A string of classes
*/
export const mergeClasses = <ClassType = string | undefined | null>(
...classes: ClassType[]
) =>
classes
.filter((className, index, array) => {
return (
Boolean(className) &&
(className as string).trim() !== "" &&
array.indexOf(className) === index
);
})
.join(" ")
.trim();

0 comments on commit 320fe96

Please sign in to comment.