0.0.6 • Published 5 years ago

comp-promise v0.0.6

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

comp-promise

Build Status Coverage Status npm version

A tiny Javascript library to help with promises in functional composition

Example Usage

const compose = require('lodash/fp/compose');
const { then } = require('comp-promise');

const fetchUser = id => {
  if (id === 123) {
    return Promise.resolve({
      id: 123,
      firstName: 'John',
	  lastName: 'Smith'
    });
  }
  return Promise.reject(new Error('No such user'));
};

const fullName = user => `${user.firstName} ${user.lastName}`;

const main = compose(
  then(fullName),
  fetchUser
);

main(123); // Returns a promise that resolves to 'John Smith'
main(456); // Returns a promise that rejects with a 'No such user' Error
0.0.6

5 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.3-test-1

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.1-alpha0.0.5

6 years ago

0.0.1-alpha0.0.4

6 years ago

0.0.1-alpha0.0.3

6 years ago

0.0.1-alpha0.0.2

6 years ago

0.0.1-alpha0.0.1

6 years ago