js-util

Home > rc-js-util > arrayNormalizeEmptyToUndefined

arrayNormalizeEmptyToUndefined() function

Replaces length 0 ArrayLike with undefined.

Signature:

export declare function arrayNormalizeEmptyToUndefined<TArray extends ArrayLike<unknown>>(array: TArray | null | undefined): TArray | undefined;

Parameters

Parameter Type Description
array TArray | null | undefined  

Returns:

TArray | undefined

array if it’s an ArrayLike of length greater than 0, otherwise undefined.

Remarks

See arrayNormalizeEmptyToUndefined().