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:
965 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import { invoker } from 'ramda';
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 4 | * Composable shortcut for `Promise.catch`.
|
---|
| 5 | * The catchP function returns a Promise. It takes two arguments: a callback function for the failure of the Promise
|
---|
| 6 | * and the promise instance itself.
|
---|
| 7 | *
|
---|
| 8 | * @func catchP
|
---|
| 9 | * @memberOf RA
|
---|
| 10 | * @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0}
|
---|
| 11 | * @category Function
|
---|
| 12 | * @sig (a -> Promise b | b) -> Promise b
|
---|
| 13 | * @param {Function} onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason.
|
---|
| 14 | * @param {Promise} promise Any Promise
|
---|
| 15 | * @return {Promise} Returns a Promise with dealt rejected cases
|
---|
| 16 | * @see {@link RA.thenP|thenP}, {@link RA.resolveP|resolveP}, {@link RA.rejectP|rejectP}, {@link RA.allP|allP}
|
---|
| 17 | *
|
---|
| 18 | * @example
|
---|
| 19 | *
|
---|
| 20 | * RA.catchP(() => 'b', Promise.resolve('a')); //=> Promise('a')
|
---|
| 21 | * RA.catchP(() => 'b', Promise.reject('a')); //=> Promise('b')
|
---|
| 22 | */
|
---|
| 23 | const catchP = invoker(1, 'catch');
|
---|
| 24 |
|
---|
| 25 | export default catchP;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.