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 / isFalsish.ts

import isString from '../../string/isStringPrimitive'

const matchFalse = /^("|')?(false)("|')?$/

/**
 * @desc is falsy value
 * @since 5.0.0-beta.5
 * @memberOf is
 *
 * @param  {null | undefined | false | 0 | '' | *} x value to check
 * @return {boolean} x is Falsy
 *
 * @name isFalsish
 *
 * @example
 *
 *    isFalsish(null)           //=> true
 *
 */
const isFalsish = (x: any): x is false | 'false' | '"false"' | `'false'` =>
  x === false || (isString(x) && matchFalse.test(x))

export { isFalsish }
export default isFalsish