@pkt/utils
Version:
24 lines (23 loc) • 788 B
TypeScript
import type { SafeAny } from '@pkt/utils/types';
/**
* Convert value to a string.
*/
export declare function toString(value: SafeAny): string;
export declare function toBoolean(value: unknown, defaultValue?: boolean | null | undefined): boolean | null | undefined;
export declare function toNumber(value: unknown): number;
export declare function toNumber<D>(value: unknown, fallback: D): number | D;
/**
* Returns the number of elements in the array by returning `value.length`.
*
* toLength([]); //=> 0
* toLength([1, 2, 3]); //=> 3
*
* toLength(null); //=> NaN
* toLength(undefined); //=> NaN
*/
export declare function toLength(value: SafeAny): number;
/**
* Convert value to a Hash.
* return string of length 5
*/
export declare function toHash(value: SafeAny): string;