...
This commit is contained in:
25
lib/client-utils.ts
Normal file
25
lib/client-utils.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export function encodePassphrase(passphrase: string) {
|
||||
return encodeURIComponent(passphrase);
|
||||
}
|
||||
|
||||
export function decodePassphrase(base64String: string) {
|
||||
return decodeURIComponent(base64String);
|
||||
}
|
||||
|
||||
export function generateRoomId(): string {
|
||||
return `${randomString(4)}-${randomString(4)}`;
|
||||
}
|
||||
|
||||
export function randomString(length: number): string {
|
||||
let result = '';
|
||||
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function isLowPowerDevice() {
|
||||
return navigator.hardwareConcurrency < 6;
|
||||
}
|
Reference in New Issue
Block a user