Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/emphori/promise
- Owner: emphori
- License: mit
- Created: 2022-07-31T16:19:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T15:17:35.000Z (7 months ago)
- Last Synced: 2024-12-20T17:19:41.436Z (7 days ago)
- Topics: promise, promise-chain, typescript
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
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