Ramda Adjunct 2.31.0

isFunction.js

import { anyPass, type, pipe, identical } from 'ramda';

import isGeneratorFunction from './isGeneratorFunction';
import isAsyncFunction from './isAsyncFunction';

/**
 * Checks if input value is `Function`.
 *
 * @func isFunction
 * @memberOf RA
 * @since {@link https://char0n.github.io/ramda-adjunct/0.5.0|v0.5.0}
 * @category Type
 * @sig * -> Boolean
 * @param {*} val The value to test
 * @return {boolean}
 * @see {@link RA.isNotFunction|isNotFunction}, {@link RA.isAsyncFunction|isNotAsyncFunction}, {@link RA.isGeneratorFunction|isGeneratorFunction}
 * @example
 *
 * RA.isFunction(function test() { }); //=> true
 * RA.isFunction(function* test() { }); //=> true
 * RA.isFunction(async function test() { }); //=> true
 * RA.isFunction(() => {}); //=> true
 * RA.isFunction(null); //=> false
 * RA.isFunction('abc'); //=> false
 */
const isFunction = anyPass([
  pipe(type, identical('Function')),
  isGeneratorFunction,
  isAsyncFunction,
]);

export default isFunction;