Files
supabase/apps/docs/features/helpers.misc.ts
T
Charis 03dcd51700 feat(content api): search result for cli reference (#35488)
## Before

Search results ignored if they are CLI references.

## After

Search results returned for CLI references.
2025-05-06 19:23:40 -04:00

26 lines
670 B
TypeScript

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
}