Pretty Please
Pretty Please is a TypeScript library provides Tasks an alternative to Promises.
Documentation of this project is a work in progress. For now, take a look at the example below and lean heavily on TypeScript's information around the public API.
Installation
Yarn
yarn add @tdreyno/pretty-please
NPM
npm install --save @tdreyno/pretty-please
Examples
const getFriendsNames = id =>
Task.fromPromise(fetch(`/user/${id}.json`))
.chain(parseUserData)
.chain(user =>
user.friends
.map(id => HTTP.get(`/user/${id}.json`).chain(parseUserData))
.chain(Task.all)
)
.map(friends => friends.map(f => f.name));
const task = getFriendsNames(1);
task.fork(
e => console.error(e),
names => console.log("Friend names", names)
);
License
Pretty Please is licensed under the the Hippocratic License. It is an Ethical Source license derived from the MIT License, amended to limit the impact of the unethical use of open source software.