New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

make-abortable

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-abortable

Make promises abortable! That's it! :)

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

make-abortable

Make promises abortable! That's it! :)

Install

# if using npm
npm i make-abortable
# if using yarn
yarn add make-abortable

Usage

const abortable = require('make-abortable');
const controller = new AbortController();
const signal = controller.signal;

const promise = new Promise(resolve => {
  setTimeout(() => {
    resolve();
  }, 1000);
});

// abortable(promise, controller) works as well
const abortablePromise = abortable(promise, { signal });

// abort the promise
controller.abort();

abortablePromise
  .then(() => {
    // this will not execute
  })
  .catch((err) => {
    if (err.name === 'AbortError') return;
    // handle real errors here
  });

AbortController

This library utilizes the AbortController api. This api is new so you might need a polyfill. Read about the AbortController api here.

Keywords

promise

FAQs

Package last updated on 30 Mar 2018

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