propEq with one argument returns a curried function (#22923)

This commit is contained in:
Charles-Philippe Clermont
2018-01-17 12:51:52 -05:00
committed by Wesley Wigham
parent 6af5b8d3a5
commit 2037b3b9ba
2 changed files with 13 additions and 8 deletions

View File

@@ -1487,14 +1487,12 @@ declare namespace R {
* value according to strict equality (`===`). Most likely used to
* filter a list.
*/
// propEq<T>(name: string, val: T, obj: {[index:string]: T}): boolean;
// propEq<T>(name: string, val: T, obj: {[index:number]: T}): boolean;
propEq<T>(name: string, val: T, obj: any): boolean;
// propEq<T>(name: number, val: T, obj: any): boolean;
propEq<T>(name: string, val: T): (obj: any) => boolean;
// propEq<T>(name: number, val: T): (obj: any) => boolean;
propEq(name: string): <T>(val: T, obj: any) => boolean;
// propEq(name: number): <T>(val: T, obj: any) => boolean;
propEq<T>(name: string | number, val: T, obj: any): boolean;
propEq<T>(name: string | number, val: T): (obj: any) => boolean;
propEq(name: string | number): {
<T>(val: T, obj: any): boolean;
<T>(val: T): (obj: any) => boolean;
};
/**
* Returns true if the specified object property is of the given type; false otherwise.

View File

@@ -583,6 +583,13 @@ R.times(i, 5);
R.filter(isFamous, users); // => [ user1 ]
};
() => {
const coll = [{ type: 'BUY' }, { type: 'SELL' }, { type: 'BUY' }];
const typeIs = R.propEq('type');
const isBuy = typeIs('BUY');
R.filter(isBuy, coll); // [{ type: 'BUY' }, { type: 'BUY' }]
};
() => {
const xs: { [key: string]: string } = {a: "1", b: "0"};
R.propEq("a", "1", xs); // => true