Merge pull request #22220 from googol/ramda/signature-fixes

Ramda: Fix signatures for nth, splitAt and splitEvery
This commit is contained in:
Paul van Brenk 2017-12-29 10:55:38 -08:00 committed by GitHub
commit 696158d8eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -1148,8 +1148,8 @@ declare namespace R {
/**
* Returns the nth element in a list.
*/
nth<T>(n: number, list: ReadonlyArray<T>): T;
nth(n: number): <T>(list: ReadonlyArray<T>) => T;
nth<T>(n: number, list: ReadonlyArray<T>): T | undefined;
nth(n: number): <T>(list: ReadonlyArray<T>) => T | undefined;
/**
* Returns a function which returns its nth argument.
@ -1643,16 +1643,22 @@ declare namespace R {
/**
* Splits a given list or string at a given index.
*/
splitAt<T>(index: number, list: T): T[];
splitAt(index: number): <T>(list: T) => T[];
splitAt<T>(index: number, list: ReadonlyArray<T>): T[][];
splitAt(index: number): <T>(list: ReadonlyArray<T>) => T[][];
splitAt<T>(index: number, list: ReadonlyArray<T>): [T[], T[]];
splitAt(index: number, list: string): [string, string];
splitAt(index: number): {
<T>(list: ReadonlyArray<T>): [T[], T[]];
(list: string): [string, string];
};
/**
* Splits a collection into slices of the specified length.
*/
splitEvery<T>(a: number, list: ReadonlyArray<T>): T[][];
splitEvery(a: number): <T>(list: ReadonlyArray<T>) => T[][];
splitEvery(a: number, list: string): string[];
splitEvery(a: number): {
(list: string): string[];
<T>(list: ReadonlyArray<T>): T[][];
};
/**
* Takes a list and a predicate and returns a pair of lists with the following properties:

View File

@ -1899,6 +1899,14 @@ class Rectangle {
const b: number[][] = R.splitAt(1)([1, 2, 3]); // => [[1], [2, 3]]
const c: string[] = R.splitAt(5, "hello world"); // => ['hello', ' world']
const d: string[] = R.splitAt(-1, "foobar"); // => ['fooba', 'r']
const e: string[] = R.splitAt(-1)("foobar"); // => ['fooba', 'r']
};
() => {
const a: number[][] = R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); // => [[1, 2, 3], [4, 5, 6], [7]]
const b: number[][] = R.splitEvery(3)([1, 2, 3, 4, 5, 6, 7]); // => [[1, 2, 3], [4, 5, 6], [7]]
const c: string[] = R.splitEvery(3, 'foobarbaz'); // => ['foo', 'bar', 'baz']
const d: string[] = R.splitEvery(3)('foobarbaz'); // => ['foo', 'bar', 'baz']
};
() => {