How to use the abortcontroller-polyfill/dist/cjs-ponyfill.js.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 waitingsong / rxxfetch / packages / rxxfetch / src / lib / util.ts View on Github external
function parseAbortController(options: ArgsRequestInitCombined): ArgsRequestInitCombined {
  const { args, requestInit } = options

  /* istanbul ignore else */
  // eslint-disable-next-line @typescript-eslint/unbound-method
  if (! args.abortController || ! args.abortController.signal || typeof args.abortController.abort !== 'function') {
    args.abortController = typeof AbortController === 'function'
      ? new AbortController()
      : new _AbortController()
  }
  /* istanbul ignore else */
  if (args.abortController) {
    requestInit.signal = args.abortController.signal
  }

  return { args, requestInit }
}

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 2 years ago

Package Health Score

70 / 100
Full package analysis

Similar packages