Files
supabase/apps/docs/features/helpers.misc.ts
Charis 3158807579 ci(docs): sync script (#36001)
Add a script for syncing error codes from the repo to the database. This
is part of the newly created rootSync script, where all sync scripts
should be moved eventually.
2025-06-05 12:28:45 -04:00

30 lines
804 B
TypeScript

export function isObject(value: unknown): value is object {
return !!value && typeof value === 'object' && !Array.isArray(value)
}
export function isPlainObject(value: unknown): value is Record<string, unknown> {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
return false
}
const prototype = Object.getPrototypeOf(value)
return prototype === null || prototype === Object.prototype
}
/**
* Creates a short random identifier
*/
export function nanoId(
/**
* The length of the identifier to generate
*/
length?: number
) {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
const l = length || 12
let id = ''
for (let i = 0; i < l; i++) {
id += chars.charAt(Math.floor(Math.random() * chars.length))
}
return id
}