UNPKG

remeda

Version:

A utility library for JavaScript and Typescript.

35 lines (33 loc) 1.35 kB
import { IterableContainer } from "./IterableContainer-BuT0t52g.js"; //#region src/isEmpty.d.ts /** * A function that checks if the passed parameter is empty. * * `undefined` is also considered empty, but only when it's in a union with a * `string` or string-like type. * * This guard doesn't work negated because of typescript limitations! If you * need to check that an array is *not* empty, use `R.hasAtLeast(data, 1)` * and not `!R.isEmpty(data)`. For strings and objects there's no way in * typescript to narrow the result to a non-empty type. * * @param data - The variable to check. * @returns True if the passed input is empty, false otherwise. * @signature * R.isEmpty(data) * @example * R.isEmpty(undefined) //=>true * R.isEmpty('') //=> true * R.isEmpty([]) //=> true * R.isEmpty({}) //=> true * R.isEmpty('test') //=> false * R.isEmpty([1, 2, 3]) //=> false * R.isEmpty({ length: 0 }) //=> false * @category Guard */ declare function isEmpty<T extends string | undefined>(data: T): data is ("" extends T ? "" : never) | (undefined extends T ? undefined : never); declare function isEmpty(data: IterableContainer): data is []; declare function isEmpty<T extends object>(data: T): data is Record<keyof T, never>; //#endregion export { isEmpty }; //# sourceMappingURL=isEmpty-B-PUqQyj.d.ts.map