Socket
Socket
Sign inDemoInstall

extra-abort

Package Overview
Dependencies
23
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    extra-abort

```sh npm install --save extra-abort # or yarn add extra-abort ```


Version published
Maintainers
1
Created

Changelog

Source

0.3.9 (2023-12-30)

Features

  • add lastCallOnly (994f2bb)

Readme

Source

extra-abort

Install

npm install --save extra-abort
# or
yarn add extra-abort

API

AbortController, AbortSignal

The WHATWG AbortController and AbortSignal.

AbortError

class AbortError extends CustomError {}

It is not the real AbortError of fetch, but you can do err instance AbortError like it is, because it can recognizes other errors that match the pattern of AbortError.

LinkedAbortController

class LinkedAbortController extends AbortController {
  constructor(signal: AbortSignal)
}

It is a special AbortController that takes an AbortSignal as a parameter. It will abort itself when its parameter signal aborts, you can make it abort by calling its abort method too.

timeoutSignal

function timeoutSignal(ms: number): AbortSignal

It will abort after ms milliseconds.

await fetch('http://example.com', { signal: timeoutSignal(5000) })

withAbortSignal

/**
 * @throws {AbortError}
 */
function withAbortSignal<T>(signal: AbortSignal | Falsy, fn: () => PromiseLike<T>): Promise<T>

If AbortSignal is aborted, the promise will be rejected with AbortError.

raceAbortSignals

function raceAbortSignals(signals: Array<AbortSignal | Falsy>): AbortSignal

The Promise.race function for AbortSignal.

isAbortSignal

function isAbortSignal(val: unknown): val is AbortSignal

lastCallOnly

function lastCallOnly<T, Args extends unknown[]>(
  fn: (...args: [...args: Args, signal: AbortSignal]) => PromiseLike<T>
): (...args: [...args: Args, signal: AbortSignal | Falsy]) => Promise<T>

FAQs

Last updated on 30 Dec 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc