UNPKG

tiny-types

Version:

A tiny library that brings Tiny Types to JavaScript and TypeScript

20 lines (18 loc) 535 B
import { Predicate } from './Predicate'; /** * @desc Ensures that the `value` is a {@link Function}. * * @example * import { ensure, isFunction, TinyType } from 'tiny-types'; * * function myFunction(callback: (error?: Error) => void): void { * ensure('callback', callback, isFunction()); * } * * @returns {Predicate<Function>} */ export function isFunction(): Predicate<(...args: any[]) => any> { return Predicate.to(`be a function`, (value: (...args: any[]) => any) => typeof value === 'function' ); }