Ramda Adjunct 4.0.0

isTruthy.js

  1. import { curryN } from 'ramda';
  2. /**
  3. * In JavaScript, a `truthy` value is a value that is considered true
  4. * when evaluated in a Boolean context. All values are truthy unless
  5. * they are defined as falsy (i.e., except for `false`, `0`, `""`, `null`, `undefined`, and `NaN`).
  6. *
  7. * @func isTruthy
  8. * @memberOf RA
  9. * @since {@link https://char0n.github.io/ramda-adjunct/2.2.0|v2.2.0}
  10. * @category Type
  11. * @sig * -> Boolean
  12. * @param {*} val The value to test
  13. * @return {boolean}
  14. * @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Truthy|truthy}, {@link RA.isFalsy|isFalsy}
  15. * @example
  16. *
  17. * RA.isTruthy({}); // => true
  18. * RA.isTruthy([]); // => true
  19. * RA.isTruthy(42); // => true
  20. * RA.isTruthy(3.14); // => true
  21. * RA.isTruthy('foo'); // => true
  22. * RA.isTruthy(new Date()); // => true
  23. * RA.isTruthy(Infinity); // => true
  24. */
  25. const isTruthy = curryN(1, Boolean);
  26. export default isTruthy;