main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import { invoker } from 'ramda';
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 4 | * Composable shortcut for `Promise.then` that allows for success and failure callbacks.
|
---|
| 5 | * The thenCatchP function returns a Promise. It takes three arguments: a callback function for the success of the Promise,
|
---|
| 6 | * a callback function for the failure of the Promise, and the promise instance itself.
|
---|
| 7 | *
|
---|
| 8 | * @func thenCatchP
|
---|
| 9 | * @memberOf RA
|
---|
| 10 | * @since {@link https://char0n.github.io/ramda-adjunct/2.27.0|v2.27.0}
|
---|
| 11 | * @category Function
|
---|
| 12 | * @sig (a -> b) -> (c -> d) -> Promise a -> Promise b | d
|
---|
| 13 | * @param {Function} onFulfilled A Function called if the Promise is fulfilled. This function has one argument, the fulfillment value
|
---|
| 14 | * @param {Function} onRejected A Function called if the Promise is rejected. This function has one argument, the error
|
---|
| 15 | * @param {Promise} promise Any Promise or Thenable object
|
---|
| 16 | * @return {Promise}
|
---|
| 17 | * @see {@link RA.resolveP|resolveP}, {@link RA.rejectP|rejectP}, {@link RA.allP|allP}
|
---|
| 18 | * @example
|
---|
| 19 | *
|
---|
| 20 | * const promise = Promise.resolve(1);
|
---|
| 21 | * const add1 = x => x + 1;
|
---|
| 22 | *
|
---|
| 23 | * RA.thenCatchP(add1, console.error, promise); // => Promise(2)
|
---|
| 24 | */
|
---|
| 25 | export const thenCatchP = invoker(2, 'then');
|
---|
| 26 |
|
---|
| 27 | export default thenCatchP;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.