Initial commit

This commit is contained in:
libertyspy
2026-02-08 18:05:48 +08:00
parent 82fcedfa97
commit 3bb9178399
3 changed files with 15 additions and 64 deletions

View File

@@ -7,7 +7,16 @@
* that was distributed with this source code.
*/
import type { NullableString } from '@/types';
export const generateKey = (type: string | null = ''): string => {
return `${type ? (type + '_') : ''}${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`
.replace('-', '_').toLowerCase();
};
};
export const substring = (s: NullableString, n: number = 10, p: string = '...') => {
if (s) {
return s.length > n ? (s.substring(0, n) + p) : s;
}
return s;
};