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

import isString from '../../string/isStringPrimitive'
import { isTrue } from './isTrue'

const matchTrue = /^("|')?(true)("|')?$/

/**
 * @param  {*} x value
 * @return {boolean} isTrue
 *
 * @since 4.0.0-alpha.1
 * @memberOf is
 * @func isTrue
 *
 * @example
 *
 *  isTrue('true')
 *  //=> true
 *  isTrue('false')
 *  //=> false
 *
 */
const isTruish = (x: any): x is true | 'true' | '"true"' | `'true'` =>
  isTrue(x) || (isString(x) && matchTrue.test(x))

export { isTruish, matchTrue }
export default isTruish