mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #47763 [ramda] R.when does not always apply given function by @JalilArfaoui
This commit is contained in:
parent
e98fe25b32
commit
f8b43fbb7e
4
types/ramda/index.d.ts
vendored
4
types/ramda/index.d.ts
vendored
@ -2082,8 +2082,8 @@ export function view<T, U>(lens: Lens, obj: T): U;
|
||||
* will return the result of calling the whenTrueFn function with the same argument. If the predicate is not satisfied,
|
||||
* the argument is returned as is.
|
||||
*/
|
||||
export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U, obj: T): U;
|
||||
export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U): (obj: T) => U;
|
||||
export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U, obj: T): T | U;
|
||||
export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U): (obj: T) => T | U;
|
||||
|
||||
/**
|
||||
* Takes a spec object and a test object and returns true if the test satisfies the spec.
|
||||
|
||||
@ -11,4 +11,12 @@ import * as R from 'ramda';
|
||||
);
|
||||
const a: string = truncate('12345'); // => '12345'
|
||||
const b: string = truncate('0123456789ABC'); // => '0123456789…'
|
||||
|
||||
const addOneIfNotNil = R.when(
|
||||
R.complement(R.isNil),
|
||||
R.add(1)
|
||||
);
|
||||
|
||||
const nil: undefined = addOneIfNotNil(undefined);
|
||||
const two: number = addOneIfNotNil(1);
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user