Feature/43320 take two (#44989)

* #43320: typing for R.paths (correction)

* #43320: tests for the cases that return `[undefined]``

Co-authored-by: Petr Motejlek <pmotejle@akamai.com>
This commit is contained in:
Petr Motejlek 2020-07-02 01:48:16 +02:00 committed by GitHub
parent 336f38bc44
commit 6efb01d500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -1373,8 +1373,8 @@ export function pathOr<T>(defaultValue: T): _.F.Curry<(a: Path, b: any) => T>;
/**
* Retrieves the values at given paths of an object.
*/
export function paths<T>(paths: Path[], obj: any): T[] | undefined;
export function paths<T>(paths: Path[]): (obj: any) => T[] | undefined;
export function paths<T>(paths: Path[], obj: any): Array<T|undefined>;
export function paths<T>(paths: Path[]): (obj: any) => Array<T|undefined>;
/**
* Returns true if the specified object property at given path satisfies the given predicate; false otherwise.

View File

@ -6,4 +6,7 @@ import * as R from 'ramda';
R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); // => [2, undefined]
R.paths([['a', 'b'], ['p', 'r']])({a: {b: 2}, p: [{q: 3}]}); // => [2, undefined]
R.paths([['thisKeyIsNotThere']], {}); // => [undefined]
R.paths([['thisKeyIsNotThere']])({}); // => [undefined]
};