Ramda Adjunct 2.7.0

appendFlipped.js

  1. import { append, flip } from 'ramda';
  2. /**
  3. * Returns a new list containing the contents of the given list, followed by the given element.
  4. * Like {@link http://ramdajs.com/docs/#append|R.append} but with argument order reversed.
  5. *
  6. * @func appendFlipped
  7. * @memberOf RA
  8. * @since {@link https://char0n.github.io/ramda-adjunct/2.5.0|v2.5.0}
  9. * @category List
  10. * @sig [a] -> a -> [a]
  11. * @param {Array} list The list of elements to add a new item to
  12. * @param {*} el The element to add to the end of the new list
  13. * @return {Array} A new list containing the elements of the old list followed by `el`
  14. * @see {@link http://ramdajs.com/docs/#append|R.append}
  15. * @example
  16. *
  17. * RA.appendFlipped(['write', 'more'], 'tests'); //=> ['write', 'more', 'tests']
  18. * RA.appendFlipped([], 'tests'); //=> ['tests']
  19. * RA.appendFlipped(['write', 'more'], ['tests']); //=> ['write', 'more', ['tests']]
  20. */
  21. const appendFlipped = flip(append);
  22. export default appendFlipped;