UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

22 lines (20 loc) 469 B
/** * @public * Replaces length 0 strings with `undefined`. * @returns `input` if it's a `string` of length greater than 0, otherwise `undefined`. * * @remarks * See {@link stringNormalizeEmptyToUndefined}. */ export function stringNormalizeEmptyToUndefined(input: string | null | undefined): string | undefined { if (input == null) { return undefined; } if (input.length === 0) { return undefined; } return input; }