[ramda] Add type for string-based reverse (#23927)

* Add type for string-based reverse

* Add test for string-based reverse

* Use separate documentation for each overload
This commit is contained in:
sgoll
2018-02-26 17:15:46 +01:00
committed by Andy
parent 2e531425dc
commit fda3aeee06
2 changed files with 11 additions and 0 deletions

View File

@@ -1601,6 +1601,10 @@ declare namespace R {
* Returns a new list with the same elements as the original list, just in the reverse order.
*/
reverse<T>(list: ReadonlyArray<T>): T[];
/**
* Returns a new string with the characters in reverse order.
*/
reverse(str: string): string;
/**
* Scan is similar to reduce, but returns a list of successively reduced values from the left.

View File

@@ -977,6 +977,13 @@ type Pair = KeyValuePair<string, number>;
R.reverse([]); // => []
};
() => {
R.reverse('abc'); // => 'cba'
R.reverse('ab'); // => 'ba'
R.reverse('a'); // => 'a'
R.reverse(''); // => ''
};
() => {
const numbers = [1, 2, 3, 4];
R.scan(R.multiply, 1, numbers); // => [1, 1, 2, 6, 24]