1.4.1 • Published 6 months ago

@emphori/promise v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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 instructions should remain the same.

# Using NPM
npm install @emphori/promise -S

# Or, using Yarn
yarn add @emphori/promise

Examples

import { Promise } from '@emphori/promise'

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

Licence

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

1.4.1

6 months ago

1.4.0

6 months ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

2 years ago

1.0.0

2 years ago