Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/emphori/promise

A strongly typed Promise override for TypeScript
https://github.com/emphori/promise

promise promise-chain typescript

Last synced: 2 days ago
JSON representation

A strongly typed Promise override for TypeScript

Awesome Lists containing this project

README

        

# Promise

A strongly typed drop-in replacement for Promises in TypeScript.

## Features

* **Type-safe rejections** greatly improve how errors are surfaced, and makes
handling them an absolute joy.

* **A simplified `.then` type signature** that disallows inline rejection
handling in favour of explict calls to `.catch` when required.

* **Incrementally adoptable** and backwards compatible with the weakly typed
Promises shipped with TypeScript.

## Installation

Promise is available from the NPM registry and as a GitHub Package. Whichever
source you prefer to use, the installation should remain the same.

```sh
# Using NPM
npm install @emphori/promise -S

# Or, using Yarn
yarn add @emphori/promise
```

## Examples

```ts
import { Promise } from '@emphori/promise'

// (userId: string) => Promise
function getUser(userId: string): Promise {
return User.getById(userId).then((user) => {
return user ?? Promise.reject(UserNotFound)
})
}
```

## Licence

This project is released under the [MIT License][license]. Enjoy responsibly ❤️

[license]: https://github.com/emphori/promise/blob/HEAD/LICENSE