1 | var pipeP =
|
2 | /*#__PURE__*/
|
3 | require("./pipeP");
|
4 |
|
5 | var reverse =
|
6 | /*#__PURE__*/
|
7 | require("./reverse");
|
8 | /**
|
9 | * Performs right-to-left composition of one or more Promise-returning
|
10 | * functions. The last arguments may have any arity; the remaining
|
11 | * arguments must be unary.
|
12 | *
|
13 | * @func
|
14 | * @memberOf R
|
15 | * @since v0.10.0
|
16 | * @category Function
|
17 | * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z)
|
18 | * @param {...Function} functions The functions to compose
|
19 | * @return {Function}
|
20 | * @see R.pipeP
|
21 | * @deprecated since v0.26.0
|
22 | * @example
|
23 | *
|
24 | * const db = {
|
25 | * users: {
|
26 | * JOE: {
|
27 | * name: 'Joe',
|
28 | * followers: ['STEVE', 'SUZY']
|
29 | * }
|
30 | * }
|
31 | * }
|
32 | *
|
33 | * // We'll pretend to do a db lookup which returns a promise
|
34 | * const lookupUser = (userId) => Promise.resolve(db.users[userId])
|
35 | * const lookupFollowers = (user) => Promise.resolve(user.followers)
|
36 | * lookupUser('JOE').then(lookupFollowers)
|
37 | *
|
38 | * // followersForUser :: String -> Promise [UserId]
|
39 | * const followersForUser = R.composeP(lookupFollowers, lookupUser);
|
40 | * followersForUser('JOE').then(followers => console.log('Followers:', followers))
|
41 | * // Followers: ["STEVE","SUZY"]
|
42 | */
|
43 |
|
44 |
|
45 | function composeP() {
|
46 | if (arguments.length === 0) {
|
47 | throw new Error('composeP requires at least one argument');
|
48 | }
|
49 |
|
50 | return pipeP.apply(this, reverse(arguments));
|
51 | }
|
52 |
|
53 | module.exports = composeP; |
\ | No newline at end of file |