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:
1019 bytes
|
Line | |
---|
1 | import { bind } from 'ramda';
|
---|
2 |
|
---|
3 | /* eslint-disable max-len */
|
---|
4 | /**
|
---|
5 | * Composable shortcut for `Promise.resolve`.
|
---|
6 | *
|
---|
7 | * Returns a Promise object that is resolved with the given value.
|
---|
8 | * If the value is a thenable (i.e. has a "then" method), the returned promise will
|
---|
9 | * "follow" that thenable, adopting its eventual state.
|
---|
10 | *
|
---|
11 | * @func resolveP
|
---|
12 | * @memberOf RA
|
---|
13 | * @since {@link https://char0n.github.io/ramda-adjunct/1.16.0|v1.16.0}
|
---|
14 | * @category Function
|
---|
15 | * @sig a -> Promise a
|
---|
16 | * @param {*} [value=undefined] Argument to be resolved by this Promise. Can also be a Promise or a thenable to resolve
|
---|
17 | * @return {Promise} A Promise that is resolved with the given value, or the promise passed as value, if the value was a promise object
|
---|
18 | * @see {@link RA.rejectP|rejectP}
|
---|
19 | * @example
|
---|
20 | *
|
---|
21 | * RA.resolveP(); //=> Promise(undefined)
|
---|
22 | * RA.resolveP('a'); //=> Promise('a')
|
---|
23 | * RA.resolveP([1, 2, 3]); //=> Promise([1, 2, 3])
|
---|
24 | */
|
---|
25 | /* eslint-enable max-len */
|
---|
26 | const resolveP = bind(Promise.resolve, Promise);
|
---|
27 |
|
---|
28 | export default resolveP;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.