@sanity/util
Version:
Utilities shared across projects of Sanity
36 lines • 1.25 kB
TypeScript
declare function isDeepEmptyObject(value: {
[key: string]: any;
}): boolean;
declare function isDeepEmptyArray(value: unknown[]): boolean;
/**
* Looks at the value and determines if it is deeply empty while not considering _type and _key attributes on objects.
* A value will be considered deeply empty if it is:
* - undefined or null
* - an object where all property values are deeply empty
* - an array where all items are deeply empty
* @param value - the value to check for deep emptiness
*/
declare function isDeepEmpty(value: unknown): boolean;
/**
* @deprecated Use `isDeepEmpty` instead
* todo: remove in v4
*/
declare const isEmptyArray: typeof isDeepEmptyArray;
/**
* @deprecated Use `isDeepEmpty` instead
* todo: remove in v4
* @alias
*/
declare const isEmpty: typeof isDeepEmpty;
/**
* @deprecated Use `isDeepEmpty` instead
* todo: remove in v4
*
*/
declare const isEmptyObject: typeof isDeepEmptyObject;
declare function isShallowEmptyObject(value: {
[key: string]: unknown;
}): boolean;
declare function randomKey(length?: number): string;
declare function resolveTypeName(value: unknown): string;
export { isDeepEmpty, isEmpty, isEmptyArray, isEmptyObject, isShallowEmptyObject, randomKey, resolveTypeName };