Skip to content

Commit

Permalink
add idgen function
Browse files Browse the repository at this point in the history
  • Loading branch information
Inglan committed Jan 3, 2025
1 parent aa25a7a commit acb3efe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@sveltejs/adapter-static": "^3.0.8",
"@sveltejs/kit": "^2.15.1",
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@types/md5": "^2.3.5",
"autoprefixer": "^10.4.20",
"bits-ui": "1.0.0-next.76",
"clsx": "^2.1.1",
Expand All @@ -36,6 +37,7 @@
"vite": "^6.0.6"
},
"dependencies": {
"md5": "^2.3.0",
"svelte-persisted-store": "^0.12.0"
}
}
35 changes: 35 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/lib/idgen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import md5 from 'md5';

export function generate(name: string) {
const hash = md5(name);
return hash.replace(/[a-f]/g, (match) => '10'.charAt('abcdef'.indexOf(match)));
}

0 comments on commit acb3efe

Please sign in to comment.