UNPKG

tiny-types

Version:

A tiny library that brings Tiny Types to JavaScript and TypeScript

20 lines (18 loc) 541 B
import { Predicate } from './Predicate'; /** * @desc Ensures that the `value` is a {@link Boolean} value. * * @example * import { ensure, isBoolean, TinyType } from 'tiny-types'; * * class MarketingOptIn extends TinyType { * constructor(public readonly value: boolean) { * ensure('MarketingOptIn', value, isBoolean()); * } * } * * @returns {Predicate<boolean>} */ export function isBoolean(): Predicate<boolean> { return Predicate.to(`be a boolean value`, (value: boolean) => typeof value === 'boolean'); }