Skip to main content
Module

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

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

Check whether a value is defined, meaning it is not undefined.

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

Examples

Example 1

import {isDefined} from 'ts-extras';

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

Parameters

value: T | undefined

Returns

value is T