import { Predicate } from './Predicate.js'; /** * @desc Ensures that the `value` is defined as anything other than {@link null} or {@link undefined}. * * @example * import { ensure, isDefined, TinyType } from 'tiny-types'; * * class Name extends TinyType { * constructor(public readonly value: string) { * ensure('Name', value, isDefined()); * } * } * * @returns {Predicate} */ export function isDefined(): Predicate { return Predicate.to(`be defined`, (value: T) => ! (value === null || value === undefined), ); }