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.
16 lines (15 loc) • 324 B
text/typescript
/**
* @public
* Normalizes `undefined` input to `null`.
*
* @remarks
* See {@link fpNormalizeToNull}.
*/
export function fpNormalizeToNull<TValue>(value: TValue): Exclude<TValue, undefined> | null
{
if (value === undefined)
{
return null;
}
return value as Exclude<TValue, undefined> | null;
}