prepend.js 688 B

123456789101112131415161718192021222324252627
  1. import _concat from "./internal/_concat.js";
  2. import _curry2 from "./internal/_curry2.js";
  3. /**
  4. * Returns a new list with the given element at the front, followed by the
  5. * contents of the list.
  6. *
  7. * @func
  8. * @memberOf R
  9. * @since v0.1.0
  10. * @category List
  11. * @sig a -> [a] -> [a]
  12. * @param {*} el The item to add to the head of the output list.
  13. * @param {Array} list The array to add to the tail of the output list.
  14. * @return {Array} A new array.
  15. * @see R.append
  16. * @example
  17. *
  18. * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum']
  19. */
  20. var prepend =
  21. /*#__PURE__*/
  22. _curry2(function prepend(el, list) {
  23. return _concat([el], list);
  24. });
  25. export default prepend;