@lodestar/utils
Version:
Utilities required across multiple lodestar packages
12 lines (11 loc) • 351 B
text/typescript
/**
* Type-safe helper to filter out nullist values from an array
* ```js
* const array: (string | null)[] = ['foo', null];
* const filteredArray: string[] = array.filter(notEmpty);
* ```
* @param value
*/
export function notNullish<TValue>(value: TValue | null | undefined): value is TValue {
return value !== null && value !== undefined;
}