compose-p

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
2 KB
Performs right-to-left composition of one or more Promise-returning functions.
1 contributor
Install compose-p as a package?
Copied
npm i @bit/justin-capalbo.ramda.compose-p
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
composeP (
functions:...Function
) : Function

Performs right-to-left composition of one or more Promise-returning functions. The rightmost function may have any arity; the remaining functions must be unary.

Example
const db = {
       users: {
         JOE: {
           name: 'Joe',
           followers: ['STEVE', 'SUZY']
         }
       }
     }

     // We'll pretend to do a db lookup which returns a promise
     const lookupUser = (userId) => Promise.resolve(db.users[userId])
     const lookupFollowers = (user) => Promise.resolve(user.followers)
     lookupUser('JOE').then(lookupFollowers)

     //  followersForUser :: String -> Promise [UserId]
     const followersForUser = R.composeP(lookupFollowers, lookupUser);
     followersForUser('JOE').then(followers => console.log('Followers:', followers))
     // Followers: ["STEVE","SUZY"]
Argument
functions: ...Function

The functions to compose

Returns
Function

Help and resources