UtilOptional

isDefined

Type guard that drops null and undefined, for use with Array.filter.

Usage

import { isDefined } from 'ngwr/utils';

const items: (string | null | undefined)[] = ['a', null, 'b', undefined];
const present = items.filter(isDefined); // string[]

API

NameDescriptionTypeDefault
isDefined(v)Narrows out null and undefined. Pass it straight to Array.filter.<T>(v: T | null | undefined) => v is T—

See also