Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / exotic   js

Repository URL to install this package:

Version: 2.0.8 

/ src / types / primitive / boolean / check / isBooleanPrimitive.ts

import isTrue from './isTrue'
import isFalse from './isFalse'

/**
 * @desc Checks if `value` is classified as a boolean primitive NOT object.
 * @category Lang
 * @since 5.0.0-beta.4
 *
 * @param  {*} x value
 * @return {boolean} isBooleanPrimitive
 *
 * @extends isTrue
 * @extends isFalse
 * @see is/toS
 * @memberOf is
 * @func isBooleanPrimitive
 *
 * @NOTE could also have typeof x === 'boolean' || (/true|false/).test(x)
 *
 * @example
 *
 *  isBooleanPrimitive(false)
 *  //=> true
 *  isBooleanPrimitive(new Boolean(1))
 *  //=> false
 *
 *  isBooleanPrimitive(1)
 *  //=> false
 *  isBooleanPrimitive('')
 *  //=> false
 *
 */
function isBooleanPrimitive(x: any): x is boolean {
  return isTrue(x) || isFalse(x)
}

export { isBooleanPrimitive }
export default isBooleanPrimitive