mirror of
https://github.com/supabase/supabase.git
synced 2026-07-04 23:14:28 +08:00
25 lines
577 B
TypeScript
25 lines
577 B
TypeScript
export function deepClone(obj: unknown) {
|
|
try {
|
|
return JSON.parse(JSON.stringify(obj))
|
|
} catch (e) {
|
|
throw e
|
|
}
|
|
}
|
|
|
|
export function formatClipboardValue(value: any) {
|
|
if (!value) return ''
|
|
if (typeof value == 'object' || Array.isArray(value)) {
|
|
return JSON.stringify(value)
|
|
}
|
|
return value
|
|
}
|
|
|
|
export const copyToClipboard = (str: string, callback = () => {}) => {
|
|
const focused = window.document.hasFocus()
|
|
if (focused) {
|
|
window.navigator?.clipboard?.writeText(str).then(callback)
|
|
} else {
|
|
console.warn('Unable to copy to clipboard')
|
|
}
|
|
}
|