cancellation-token-source
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

cancellationTokenSource.js

CancellationTokenSource implementation for JavaScript based on the C# implementation of the same name

Installation

npm install cancellation-token-source

Usage

import {CancellationTokenSource} from "cancellation-token-source";
 
async function myAsyncFunc(cancellationToken: CancellationToken): Promise<void> {
  const result = await someOtherThing();
  cancellationToken.throwIfCancellationRequested();
 
  // Perform things we don't want to happen when canceled
}
 
const cts = new CancellationTokenSource();
myAsyncFunc(cts.token);

API

See the API docs

/cancellation-token-source/

    Package Sidebar

    Install

    npm i cancellation-token-source

    Weekly Downloads

    2

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    495 kB

    Total Files

    25

    Last publish

    Collaborators

    • xapphire13