Merge pull request #26004 from dm261395/ramda-aperture

[ramda] updated aperture typings for special cases
This commit is contained in:
Benjamin Lichtman
2018-05-31 15:36:35 -07:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -254,6 +254,16 @@ declare namespace R {
* Returns a new list, composed of n-tuples of consecutive elements If n is greater than the length of the list,
* an empty list is returned.
*/
aperture<T>(n: 1, list: T[]): Array<[T]>;
aperture<T>(n: 2, list: T[]): Array<[T, T]>;
aperture<T>(n: 3, list: T[]): Array<[T, T, T]>;
aperture<T>(n: 4, list: T[]): Array<[T, T, T, T]>;
aperture<T>(n: 5, list: T[]): Array<[T, T, T, T, T]>;
aperture<T>(n: 6, list: T[]): Array<[T, T, T, T, T, T]>;
aperture<T>(n: 7, list: T[]): Array<[T, T, T, T, T, T, T]>;
aperture<T>(n: 8, list: T[]): Array<[T, T, T, T, T, T, T, T]>;
aperture<T>(n: 9, list: T[]): Array<[T, T, T, T, T, T, T, T, T]>;
aperture<T>(n: 10, list: T[]): Array<[T, T, T, T, T, T, T, T, T, T]>;
aperture<T>(n: number, list: ReadonlyArray<T>): T[][];
aperture(n: number): <T>(list: ReadonlyArray<T>) => T[][];

View File

@@ -475,6 +475,9 @@ R.times(i, 5);
R.aperture(3, [1, 2, 3, 4, 5]); // => [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
R.aperture(7, [1, 2, 3, 4, 5]); // => []
R.aperture(7)([1, 2, 3, 4, 5]); // => []
const res1: Array<[number, number]> = R.aperture(2, [1, 2, 3, 4, 5]);
const res2: number[][] = R.aperture(11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
};
() => {