diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-06-14 01:21:11 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-06-14 02:53:17 +0800 |
commit | 4f47b123f26d356661702b3d77c5c246be8620d0 (patch) | |
tree | aab52a08c3544b7514d24d68e7127f9aaba76057 /deno/base/lib.ts | |
parent | 0ddd1dc07f7d00723933d832562497af23dce225 (diff) | |
download | crupest-4f47b123f26d356661702b3d77c5c246be8620d0.tar.gz crupest-4f47b123f26d356661702b3d77c5c246be8620d0.tar.bz2 crupest-4f47b123f26d356661702b3d77c5c246be8620d0.zip |
deno: merge utils to one file.
Diffstat (limited to 'deno/base/lib.ts')
-rw-r--r-- | deno/base/lib.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/deno/base/lib.ts b/deno/base/lib.ts new file mode 100644 index 0000000..a5e4a6a --- /dev/null +++ b/deno/base/lib.ts @@ -0,0 +1,10 @@ +export function camelCaseToKebabCase(str: string): string { + return str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()); +} + +export function toFileNameString(date: Date, dateOnly?: boolean): string { + const str = date.toISOString(); + return dateOnly === true + ? str.slice(0, str.indexOf("T")) + : str.replaceAll(/:|\./g, "-"); +} |