40 lines
935 B
JavaScript
40 lines
935 B
JavaScript
|
var _curry1 =
|
||
|
/*#__PURE__*/
|
||
|
require("./internal/_curry1.js");
|
||
|
|
||
|
var _isString =
|
||
|
/*#__PURE__*/
|
||
|
require("./internal/_isString.js");
|
||
|
/**
|
||
|
* Returns a new list or string with the elements or characters in reverse
|
||
|
* order.
|
||
|
*
|
||
|
* @func
|
||
|
* @memberOf R
|
||
|
* @since v0.1.0
|
||
|
* @category List
|
||
|
* @sig [a] -> [a]
|
||
|
* @sig String -> String
|
||
|
* @param {Array|String} list
|
||
|
* @return {Array|String}
|
||
|
* @example
|
||
|
*
|
||
|
* R.reverse([1, 2, 3]); //=> [3, 2, 1]
|
||
|
* R.reverse([1, 2]); //=> [2, 1]
|
||
|
* R.reverse([1]); //=> [1]
|
||
|
* R.reverse([]); //=> []
|
||
|
*
|
||
|
* R.reverse('abc'); //=> 'cba'
|
||
|
* R.reverse('ab'); //=> 'ba'
|
||
|
* R.reverse('a'); //=> 'a'
|
||
|
* R.reverse(''); //=> ''
|
||
|
*/
|
||
|
|
||
|
|
||
|
var reverse =
|
||
|
/*#__PURE__*/
|
||
|
_curry1(function reverse(list) {
|
||
|
return _isString(list) ? list.split('').reverse().join('') : Array.prototype.slice.call(list, 0).reverse();
|
||
|
});
|
||
|
|
||
|
module.exports = reverse;
|