@wordpress/components
Version:
UI components for WordPress.
43 lines • 1.58 kB
TypeScript
/**
* Determines if a value is null or undefined.
*
* @template T
*
* @param {T} value The value to check.
* @return {value is Exclude<T, null | undefined>} Whether value is not null or undefined.
*/
export declare function isValueDefined<T>(value: T): value is Exclude<T, null | undefined>;
/**
* Determines if a value is empty, null, or undefined.
*
* @param {string | number | null | undefined} value The value to check.
* @return {value is ("" | null | undefined)} Whether value is empty.
*/
export declare function isValueEmpty(value: string | number | null | undefined): value is ("" | null | undefined);
/**
* Get the first defined/non-null value from an array.
*
* @template T
*
* @param {Array<T | null | undefined>} values Values to derive from.
* @param {T} fallbackValue Fallback value if there are no defined values.
* @return {T} A defined value or the fallback value.
*/
export declare function getDefinedValue<T>(values: Array<T | null | undefined> | undefined, fallbackValue: T): T;
/**
* Converts a string to a number.
*
* @param {string} value
* @return {number} String as a number.
*/
export declare const stringToNumber: (value: string) => number;
/**
* Regardless of the input being a string or a number, returns a number.
*
* Returns `undefined` in case the string is `undefined` or not a valid numeric value.
*
* @param {string | number} value
* @return {number} The parsed number.
*/
export declare const ensureNumber: (value: string | number) => number;
//# sourceMappingURL=values.d.ts.map