hasValue
Checks whether a value should be treated as present. It uses emptyOrNull, so null, undefined, empty arrays, and blank strings are considered missing.
The function is a type guard for the non-nullable value.
Importing
ts
import { hasValue } from '@almighty-shogun/utils';Usage
ts
import { hasValue } from '@almighty-shogun/utils';
const value: string | null = 'project';
if (hasValue(value)) {
value.toUpperCase();
}Parameters
value: NullableOrUndefinable<T>
Value to test.
Returns
true when the value is not normalized to null by emptyOrNull.Uses
Type signature
ts
declare function hasValue<T>(value: NullableOrUndefinable<T>): value is T;