UNPKG

@mapcss/preset-svg

Version:
25 lines (24 loc) 634 B
import { isIterable } from "../iterable/is_iterable.js"; import { isLength0 } from "../isLength0/mod.js"; /** Whatever argument is empty or not * ```ts * isEmpty("") // true * isEmpty({}) // true * isEmpty(new Set()) // true * isEmpty([1, 2, 3]) // false * ``` * @beta */ function isEmpty(value) { const iterable = isIterable(value); if (iterable) { const { done } = value[Symbol.iterator]().next(); return done ?? false; } else { // check {} or not return isLength0(Object.keys(value)) && isLength0(Object.getOwnPropertySymbols(value)); } } export { isEmpty };