You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
673 B
22 lines
673 B
import { v1 } from 'uuid'
|
|
import { generateString } from './crypto'
|
|
|
|
export function trimContent(content?: string, length: number = 128): string {
|
|
if (!content) return ''
|
|
if (content.length < length) return content.trim()
|
|
|
|
return content.slice(0, length).trim()
|
|
}
|
|
|
|
export const createId = () => v1().replace(/-/g, '')
|
|
export const createPostId = () => 'p' + createId()
|
|
export const createInvitationCode = () => generateString(8)
|
|
export const createInstallationId = () => 'i' + createId()
|
|
|
|
export async function wait(ms: number = 5000): Promise<void> {
|
|
return new Promise(resolve => {
|
|
setTimeout(() => {
|
|
resolve()
|
|
}, ms)
|
|
})
|
|
}
|