always.js 705 B

123456789101112131415161718192021222324252627282930
  1. import _curry1 from "./internal/_curry1.js";
  2. /**
  3. * Returns a function that always returns the given value. Note that for
  4. * non-primitives the value returned is a reference to the original value.
  5. *
  6. * This function is known as `const`, `constant`, or `K` (for K combinator) in
  7. * other languages and libraries.
  8. *
  9. * @func
  10. * @memberOf R
  11. * @since v0.1.0
  12. * @category Function
  13. * @sig a -> (* -> a)
  14. * @param {*} val The value to wrap in a function
  15. * @return {Function} A Function :: * -> val.
  16. * @example
  17. *
  18. * const t = R.always('Tee');
  19. * t(); //=> 'Tee'
  20. */
  21. var always =
  22. /*#__PURE__*/
  23. _curry1(function always(val) {
  24. return function () {
  25. return val;
  26. };
  27. });
  28. export default always;