head.js 553 B

123456789101112131415161718192021222324252627
  1. import nth from "./nth.js";
  2. /**
  3. * Returns the first element of the given list or string. In some libraries
  4. * this function is named `first`.
  5. *
  6. * @func
  7. * @memberOf R
  8. * @since v0.1.0
  9. * @category List
  10. * @sig [a] -> a | Undefined
  11. * @sig String -> String
  12. * @param {Array|String} list
  13. * @return {*}
  14. * @see R.tail, R.init, R.last
  15. * @example
  16. *
  17. * R.head(['fi', 'fo', 'fum']); //=> 'fi'
  18. * R.head([]); //=> undefined
  19. *
  20. * R.head('abc'); //=> 'a'
  21. * R.head(''); //=> ''
  22. */
  23. var head =
  24. /*#__PURE__*/
  25. nth(0);
  26. export default head;