Skip to main content
Module

x/scaffold/src/deps/npm.ts>isPresent

scaffold your next project with style and 💗
Latest
function isPresent
import { isPresent } from "https://deno.land/x/scaffold@0.3.0/src/deps/npm.ts";

Check whether a value is present (non-nullable), meaning it is neither null or undefined.

This can be useful as a type guard, as for example, [1, null].filter(Boolean) does not always type-guard correctly.

Examples

Example 1

import {isPresent} from 'ts-extras';

[1, null, 2, undefined].filter(isPresent);
//=> [1, 2]

Returns

value is NonNullable<T>