mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
25 lines
585 B
TypeScript
25 lines
585 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 === null) 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')
|
|
}
|
|
}
|