Initial commit
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user