ramda-adjunct icon indicating copy to clipboard operation
ramda-adjunct copied to clipboard

isFulfilledP, isRejectedP, isPendingP

Open char0n opened this issue 6 years ago • 2 comments

Is your feature request related to a problem? Please describe.

These 3 predicates could inspect the state of the promise or the objects returned by RA.allSettledP. These functions must be synchronous.

Describe the solution you'd like

RA.isFullfilledP(Promise.resolve(3)); // => true
RA.isRejectedP(Promise.reject(3)); // => true
RA.isPendingP(RA.delayP(200)); //=> true

Describe alternatives you've considered

--

Additional context

https://ourcodeworld.com/articles/read/317/how-to-check-if-a-javascript-promise-has-been-fulfilled-rejected-or-resolved

Chais-as-promised contains implementation for two of these predicate functions: https://www.chaijs.com/plugins/chai-as-promised/

RA.isPendingP is true when RA.isFullfilledP and RA.isRejectedP both return false. We can use this fact to compose this predicates.

char0n avatar May 03 '19 20:05 char0n

@char0n could i take this one?

tauantcamargo avatar Jul 15 '22 13:07 tauantcamargo

@tauantcamargo feel free to grad any function you like. All the function described in issues are on the plate.

char0n avatar Sep 18 '22 14:09 char0n