Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wealthbar/cancellation-token

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wealthbar/cancellation-token

token used to signal to a routine to cancel an asynchronous request

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
7
Maintainers
4
Weekly downloads
 
Created
Source

cancellationToken

Example

In the rpc system the caller can provide a cancellationToken. If the caller decides to cancel their request before it has been handled the rpc system can reject the pending promise and un-stick the code waiting on the request.

function call(
  {
    name,
    params,
    cancellationToken,
    timeout,
    retries,
  }: {
    name: string,
    params?: object,
    cancellationToken?: cancellationToken,
    timeout?: number,
    retries?: number,
  }): Promise<any> {
  
  ...
  
  if (cancellationToken) {
    cancellationToken.onCancelRequested(() => {
      const pendingPromise = pending[id];
      if (pendingPromise) {
        delete pending[id];
        pendingPromise.reject({err: "cancelled", code: 444});
      }
    });
  }
  
  ...
}

Keywords

FAQs

Package last updated on 18 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc