Socket
Socket
Sign inDemoInstall

cancelable-promise

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cancelable-promise

A simple cancelable promise


Version published
Weekly downloads
73K
decreased by-2.24%
Maintainers
3
Weekly downloads
 
Created
Source

CancelablePromise

A simple Cancelable Promise for browser

Install

npm install --save cancelable-promise

This package is based on ES6 Promise. See promise-polyfill for browser support.

Usage

CancelablePromise acts like a ES6 Promise: you can use Promise.all, Promise.race with your CancelablePromise for example. The only difference is you'll have a cancel method on your promise to cancel future execution of then or catch functions. CancelablePromise will also cancel all callbacks attached to new promises returned by then/catch.

import CancelablePromise from 'cancelable-promise';
const myPromise = new CancelablePromise((resolve) => setTimeout(() => resolve('I\'m resolved'), 100));
myPromise.then((response) => console.log(response)).then(() => console.log('not cancel'));
myPromise.cancel();
// Nothing will be displayed in console

Test

You can run tests with npm run test

FAQs

Package last updated on 17 Jul 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