UNPKG

@humanspeak/svelte-motion

Version:

Framer Motion for Svelte 5. Declarative motion.<tag> components with AnimatePresence exit animations, gestures (hover, tap, drag, focus, in-view), variants, FLIP layout animations, shared-layout transitions, spring physics, and scroll-linked motion values

35 lines (34 loc) 913 B
/** * Checks if an object is empty or undefined. * * @param obj - The object to check. Can be a regular object, animation keyframes, or undefined * @returns true if the object is undefined or has no own properties, false otherwise * * @example * ```ts * isEmpty({}) // true * isEmpty(undefined) // true * isEmpty({ opacity: 0 }) // false * ``` */ export const isEmpty = (obj) => { if (!obj) return true; return Object.keys(obj).length === 0; }; /** * Checks if an object is not empty and defined. * * @param obj - The object to check. Can be a regular object, animation keyframes, or undefined * @returns true if the object has at least one own property, false if empty or undefined * * @example * ```ts * isNotEmpty({}) // false * isNotEmpty(undefined) // false * isNotEmpty({ scale: 1 }) // true * ``` */ export const isNotEmpty = (obj) => { return !isEmpty(obj); };