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.
svelte-kit-vice/src/uix/eidos/lib/utils.ts

19 lines
701 B

export function isPlainRecord(value: unknown): value is Record<string, unknown> {
if (typeof value !== 'object' || value === null || Array.isArray(value)) return false
const proto = Object.getPrototypeOf(value)
return proto === Object.prototype || proto === null
}
export function hasOwn<T extends object>(value: T, key: PropertyKey): boolean {
return Object.prototype.hasOwnProperty.call(value, key)
}
export function toKebab(value: string): string {
return value.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
}
export function clonePlain<T>(value: T): T {
if (typeof structuredClone === 'function') return structuredClone(value)
return JSON.parse(JSON.stringify(value)) as T
}

Powered by TurnKey Linux.