How to use the abortcontroller-polyfill/dist/cjs-ponyfill.AbortController function in abortcontroller-polyfill

To help you get started, we’ve selected a few abortcontroller-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parcel-bundler / parcel / packages / core / core / src / Parcel.js View on Github external
async startNextBuild() {
    this.#watchAbortController = new AbortController();

    try {
      this.#watchEvents.emit({
        buildEvent: await this.build({
          signal: this.#watchAbortController.signal,
        }),
      });
    } catch (err) {
      // Ignore BuildAbortErrors and only emit critical errors.
      if (!(err instanceof BuildAbortError)) {
        throw err;
      }
    }
  }
github elbywan / wretch / test / node / wretch.spec.ts View on Github external
it("should abort a request", function (done) {
        let count = 0

        const handleError = error => {
            expect(error.name).toBe("AbortError")
            count++
        }

        const controller = new AbortController()
        wretch(`${_URL}/longResult`)
            .signal(controller)
            .get()
            .res()
            .catch(handleError)
        controller.abort()

        const [c, w] = wretch(`${_URL}/longResult`).get().controller()
        w.res().catch(handleError)
        c.abort()

        wretch(`${_URL}/longResult`)
            .get()
            .setTimeout(100)
            .onAbort(handleError)
            .res()
github Azure / ms-rest-js / test / defaultHttpClientTests.ts View on Github external
function getAbortController(): AbortController {
  let controller: AbortController;
  if (typeof AbortController === "function") {
    controller = new AbortController();
  } else {
    const AbortControllerPonyfill = require("abortcontroller-polyfill/dist/cjs-ponyfill").AbortController;
    controller = new AbortControllerPonyfill();
  }
  return controller;
}
github Azure / autorest.typescript / test / xml / xmlTests.ts View on Github external
function getAbortController(): AbortController {
  let controller: AbortController;
  if (typeof AbortController === "function") {
    controller = new AbortController();
  } else {
    const AbortControllerPonyfill = require("abortcontroller-polyfill/dist/cjs-ponyfill").AbortController;
    controller = new AbortControllerPonyfill();
  }
  return controller;
}
github chainpoint / chainpoint-client-js / lib / utils / network.js View on Github external
nodes.map(async node => {
      try {
        isValidNodeURI(node)
        let controller, signal, timeoutId
        if (AbortController) {
          controller = new AbortController()
          signal = controller.signal
          timeoutId = setTimeout(() => controller.abort(), timeout)
        }
        await fetch(node, { timeout, method: 'GET', signal })

        clearTimeout(timeoutId)
        return node
      } catch (e) {
        failures.push(node)
      }
    })
  )

abortcontroller-polyfill

Polyfill/ponyfill for the AbortController DOM API + optional patching of fetch (stub that calls catch, doesn't actually abort request).

MIT
Latest version published 12 days ago

Package Health Score

85 / 100
Full package analysis

Similar packages