2.2.0 • Published 3 years ago

cancellationtoken v2.2.0

Weekly downloads
820
License
MIT
Repository
github
Last release
3 years ago

Cancellation Token

npm

Cancellation tokens are composable entities that allow cancelling asynchronous operations.

The implementation roughly follows these TC39 proposals:

The implementation is written in TypeScript and therefore comes with typings already bundled.

Installation

Install the library via your favourite package manager.

npm install cancellationtoken

or

yarn add cancellationtoken

Usage

You can create a new cancellation token along with a function to cancel it via create. Functions can consume tokens by accessing the ìsCancelled property.

import CancellationToken from 'cancellationtoken'

const { cancel, token } = CancellationToken.create()
console.log(token.isCancelled) // prints false
cancel()
console.log(token.isCancelled) // prints true

Documentation

Coming soon! Meanwhile you can use the TypeScript definitions and examples.

Examples

git clone https://github.com/conradreuter/cancellationtoken
cd cancellationtoken/
yarn
yarn example 01-usage

Contributors

conradreuter💻 📖 💡 ⚠️Andrew Arnott💻 🐛 📖 ⚠️
2.3.0-rc1

3 years ago

2.2.0

3 years ago

2.1.0-rc1

3 years ago

2.1.0

3 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago