New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

abortcontroller-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abortcontroller-polyfill - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

23

dist/abortcontroller-polyfill-only.js

@@ -211,19 +211,16 @@ (function (global, factory) {

function hasBrokenNativeAbortController(userAgent) {
if (userAgent.match(/ (crios|gsa|fxios)\//i)) {
return true;
}
if (userAgent.match(/ Safari\//i) && userAgent.match(/ Version\/(12.0|12.1|11)/i)) {
return true;
}
return false;
function polyfillNeeded(self) {
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection needs the !self.AbortController part.
// The Request.prototype check is also needed because Safari versions 11.1.2
// up to and including 12.1.x has a window.AbortController present but still
// does NOT correctly implement abortable fetch:
// https://bugs.webkit.org/show_bug.cgi?id=174980#c2
return typeof self.Request === 'function' && !self.Request.prototype.hasOwnProperty('signal') || !self.AbortController;
}
function nativeAbortControllerIsBroken(self) {
return self.navigator && self.navigator.userAgent && hasBrokenNativeAbortController(self.navigator.userAgent);
}
(function (self) {
if (self.AbortController && !nativeAbortControllerIsBroken(self)) {
if (!polyfillNeeded(self)) {
return;

@@ -230,0 +227,0 @@ }

@@ -209,2 +209,13 @@ 'use strict';

function polyfillNeeded(self) {
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection needs the !self.AbortController part.
// The Request.prototype check is also needed because Safari versions 11.1.2
// up to and including 12.1.x has a window.AbortController present but still
// does NOT correctly implement abortable fetch:
// https://bugs.webkit.org/show_bug.cgi?id=174980#c2
return typeof self.Request === 'function' && !self.Request.prototype.hasOwnProperty('signal') || !self.AbortController;
}
/**

@@ -231,21 +242,22 @@ * Note: the "fetch.Request" default value is available for fetch imported from

NativeRequest = _patchTargets$Request === undefined ? fetch.Request : _patchTargets$Request,
_patchTargets$AbortCo = _patchTargets.AbortController,
NativeAbortController = _patchTargets$AbortCo === undefined ? AbortController : _patchTargets$AbortCo;
NativeAbortController = _patchTargets.AbortController;
if (!polyfillNeeded({ fetch: fetch, Request: NativeRequest, AbortController: NativeAbortController })) {
return { fetch: fetch, Request: Request };
}
var Request = NativeRequest;
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection is wrapped in if (Request)
if (Request) {
// Do feature detecting
var controller = new NativeAbortController();
var signal = controller.signal;
var request = new Request('/', { signal: signal });
// Browser already supports abortable fetch (like FF v57 and fetch-polyfill)
if (request.signal) {
return { fetch: fetch, Request: Request };
}
// hence we only patch it if it's available. Also we don't patch it if signal
// is already available on the Request prototype because in this case support
// is present and the patching below can cause a crash since it assigns to
// request.signal which is technically a read-only property. This latter error
// happens when you run the main5.js node-fetch example in the repo
// "abortcontroller-polyfill-examples". The exact error is:
// request.signal = init.signal;
// ^
// TypeError: Cannot set property signal of #<Request> which has only a getter
if (Request && !Request.prototype.hasOwnProperty('signal')) {
Request = function Request(input, init) {

@@ -252,0 +264,0 @@ var request = new NativeRequest(input, init);

@@ -211,2 +211,13 @@ (function (global, factory) {

function polyfillNeeded(self) {
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection needs the !self.AbortController part.
// The Request.prototype check is also needed because Safari versions 11.1.2
// up to and including 12.1.x has a window.AbortController present but still
// does NOT correctly implement abortable fetch:
// https://bugs.webkit.org/show_bug.cgi?id=174980#c2
return typeof self.Request === 'function' && !self.Request.prototype.hasOwnProperty('signal') || !self.AbortController;
}
/**

@@ -233,21 +244,22 @@ * Note: the "fetch.Request" default value is available for fetch imported from

NativeRequest = _patchTargets$Request === undefined ? fetch.Request : _patchTargets$Request,
_patchTargets$AbortCo = _patchTargets.AbortController,
NativeAbortController = _patchTargets$AbortCo === undefined ? AbortController : _patchTargets$AbortCo;
NativeAbortController = _patchTargets.AbortController;
if (!polyfillNeeded({ fetch: fetch, Request: NativeRequest, AbortController: NativeAbortController })) {
return { fetch: fetch, Request: Request };
}
var Request = NativeRequest;
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection is wrapped in if (Request)
if (Request) {
// Do feature detecting
var controller = new NativeAbortController();
var signal = controller.signal;
var request = new Request('/', { signal: signal });
// Browser already supports abortable fetch (like FF v57 and fetch-polyfill)
if (request.signal) {
return { fetch: fetch, Request: Request };
}
// hence we only patch it if it's available. Also we don't patch it if signal
// is already available on the Request prototype because in this case support
// is present and the patching below can cause a crash since it assigns to
// request.signal which is technically a read-only property. This latter error
// happens when you run the main5.js node-fetch example in the repo
// "abortcontroller-polyfill-examples". The exact error is:
// request.signal = init.signal;
// ^
// TypeError: Cannot set property signal of #<Request> which has only a getter
if (Request && !Request.prototype.hasOwnProperty('signal')) {
Request = function Request(input, init) {

@@ -300,22 +312,20 @@ var request = new NativeRequest(input, init);

function hasBrokenNativeAbortController(userAgent) {
if (userAgent.match(/ (crios|gsa|fxios)\//i)) {
return true;
(function (self) {
if (!polyfillNeeded(self)) {
return;
}
if (userAgent.match(/ Safari\//i) && userAgent.match(/ Version\/(12.0|12.1|11)/i)) {
return true;
if (!self.fetch) {
console.warn('fetch() is not available, cannot install abortcontroller-polyfill');
return;
}
return false;
}
function nativeAbortControllerIsBroken(self) {
return self.navigator && self.navigator.userAgent && hasBrokenNativeAbortController(self.navigator.userAgent);
}
var _abortableFetch = abortableFetchDecorator(self),
fetch = _abortableFetch.fetch,
Request = _abortableFetch.Request;
(function (self) {
self.fetch = fetch;
self.Request = Request;
if (self.AbortController && !nativeAbortControllerIsBroken(self)) {
return;
}
Object.defineProperty(self, 'AbortController', {

@@ -334,16 +344,4 @@ writable: true,

});
if (!self.fetch) {
console.warn('fetch() is not available, cannot install abortcontroller-polyfill');
return;
}
var _abortableFetch = abortableFetchDecorator(self),
fetch = _abortableFetch.fetch,
Request = _abortableFetch.Request;
self.fetch = fetch;
self.Request = Request;
})(typeof self !== 'undefined' ? self : global);
})));

@@ -211,2 +211,13 @@ (function (global, factory) {

function polyfillNeeded(self) {
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection needs the !self.AbortController part.
// The Request.prototype check is also needed because Safari versions 11.1.2
// up to and including 12.1.x has a window.AbortController present but still
// does NOT correctly implement abortable fetch:
// https://bugs.webkit.org/show_bug.cgi?id=174980#c2
return typeof self.Request === 'function' && !self.Request.prototype.hasOwnProperty('signal') || !self.AbortController;
}
/**

@@ -233,21 +244,22 @@ * Note: the "fetch.Request" default value is available for fetch imported from

NativeRequest = _patchTargets$Request === undefined ? fetch.Request : _patchTargets$Request,
_patchTargets$AbortCo = _patchTargets.AbortController,
NativeAbortController = _patchTargets$AbortCo === undefined ? AbortController : _patchTargets$AbortCo;
NativeAbortController = _patchTargets.AbortController;
if (!polyfillNeeded({ fetch: fetch, Request: NativeRequest, AbortController: NativeAbortController })) {
return { fetch: fetch, Request: Request };
}
var Request = NativeRequest;
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection is wrapped in if (Request)
if (Request) {
// Do feature detecting
var controller = new NativeAbortController();
var signal = controller.signal;
var request = new Request('/', { signal: signal });
// Browser already supports abortable fetch (like FF v57 and fetch-polyfill)
if (request.signal) {
return { fetch: fetch, Request: Request };
}
// hence we only patch it if it's available. Also we don't patch it if signal
// is already available on the Request prototype because in this case support
// is present and the patching below can cause a crash since it assigns to
// request.signal which is technically a read-only property. This latter error
// happens when you run the main5.js node-fetch example in the repo
// "abortcontroller-polyfill-examples". The exact error is:
// request.signal = init.signal;
// ^
// TypeError: Cannot set property signal of #<Request> which has only a getter
if (Request && !Request.prototype.hasOwnProperty('signal')) {
Request = function Request(input, init) {

@@ -300,22 +312,20 @@ var request = new NativeRequest(input, init);

function hasBrokenNativeAbortController(userAgent) {
if (userAgent.match(/ (crios|gsa|fxios)\//i)) {
return true;
(function (self) {
if (!polyfillNeeded(self)) {
return;
}
if (userAgent.match(/ Safari\//i) && userAgent.match(/ Version\/(12.0|12.1|11)/i)) {
return true;
if (!self.fetch) {
console.warn('fetch() is not available, cannot install abortcontroller-polyfill');
return;
}
return false;
}
function nativeAbortControllerIsBroken(self) {
return self.navigator && self.navigator.userAgent && hasBrokenNativeAbortController(self.navigator.userAgent);
}
var _abortableFetch = abortableFetchDecorator(self),
fetch = _abortableFetch.fetch,
Request = _abortableFetch.Request;
(function (self) {
self.fetch = fetch;
self.Request = Request;
if (self.AbortController && !nativeAbortControllerIsBroken(self)) {
return;
}
Object.defineProperty(self, 'AbortController', {

@@ -334,16 +344,4 @@ writable: true,

});
if (!self.fetch) {
console.warn('fetch() is not available, cannot install abortcontroller-polyfill');
return;
}
var _abortableFetch = abortableFetchDecorator(self),
fetch = _abortableFetch.fetch,
Request = _abortableFetch.Request;
self.fetch = fetch;
self.Request = Request;
})(typeof self !== 'undefined' ? self : global);
})));
{
"name": "abortcontroller-polyfill",
"version": "1.2.4",
"version": "1.2.5",
"description": "Polyfill/ponyfill for the AbortController DOM API + optional patching of fetch (stub that calls catch, doesn't actually abort request).",

@@ -5,0 +5,0 @@ "main": "dist/umd-polyfill.js",

@@ -1,3 +0,2 @@

import {default as SyntheticAbortController} from './abortcontroller';
import {polyfillNeeded} from './utils.js';
/**

@@ -23,20 +22,22 @@ * Note: the "fetch.Request" default value is available for fetch imported from

Request: NativeRequest = fetch.Request,
AbortController: NativeAbortController = SyntheticAbortController
AbortController: NativeAbortController,
} = patchTargets;
if (!polyfillNeeded({fetch, Request: NativeRequest, AbortController: NativeAbortController})) {
return {fetch, Request};
}
let Request = NativeRequest;
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection is wrapped in if (Request)
if (Request) {
// Do feature detecting
const controller = new NativeAbortController();
const signal = controller.signal;
const request = new Request('/', { signal });
// Browser already supports abortable fetch (like FF v57 and fetch-polyfill)
if (request.signal) {
return {fetch, Request};
}
// hence we only patch it if it's available. Also we don't patch it if signal
// is already available on the Request prototype because in this case support
// is present and the patching below can cause a crash since it assigns to
// request.signal which is technically a read-only property. This latter error
// happens when you run the main5.js node-fetch example in the repo
// "abortcontroller-polyfill-examples". The exact error is:
// request.signal = init.signal;
// ^
// TypeError: Cannot set property signal of #<Request> which has only a getter
if (Request && !Request.prototype.hasOwnProperty('signal')) {
Request = function Request(input, init) {

@@ -43,0 +44,0 @@ let request = new NativeRequest(input, init);

import AbortController, {AbortSignal} from './abortcontroller';
import {nativeAbortControllerIsBroken} from './utils';
import {polyfillNeeded} from './utils';

@@ -7,3 +7,3 @@ (function(self) {

if (self.AbortController && !nativeAbortControllerIsBroken(self)) {
if (!polyfillNeeded(self)) {
return;

@@ -10,0 +10,0 @@ }

import AbortController, {AbortSignal} from './abortcontroller';
import abortableFetch from './abortableFetch';
import {nativeAbortControllerIsBroken} from './utils';
import {polyfillNeeded} from './utils';

@@ -8,6 +8,15 @@ (function(self) {

if (self.AbortController && !nativeAbortControllerIsBroken(self)) {
if (!polyfillNeeded(self)) {
return;
}
if (!self.fetch) {
console.warn('fetch() is not available, cannot install abortcontroller-polyfill');
return;
}
const {fetch, Request} = abortableFetch(self);
self.fetch = fetch;
self.Request = Request;
Object.defineProperty(self, 'AbortController', {

@@ -27,11 +36,2 @@ writable: true,

if (!self.fetch) {
console.warn('fetch() is not available, cannot install abortcontroller-polyfill');
return;
}
const {fetch, Request} = abortableFetch(self);
self.fetch = fetch;
self.Request = Request;
})(typeof self !== 'undefined' ? self : global);

@@ -1,14 +0,10 @@

function hasBrokenNativeAbortController(userAgent) {
if (userAgent.match(/ (crios|gsa|fxios)\//i)) {
return true;
}
if (userAgent.match(/ Safari\//i) && (userAgent.match(/ Version\/(12.0|12.1|11)/i))) {
return true;
}
return false;
export function polyfillNeeded(self) {
// Note that the "unfetch" minimal fetch polyfill defines fetch() without
// defining window.Request, and this polyfill need to work on top of unfetch
// so the below feature detection needs the !self.AbortController part.
// The Request.prototype check is also needed because Safari versions 11.1.2
// up to and including 12.1.x has a window.AbortController present but still
// does NOT correctly implement abortable fetch:
// https://bugs.webkit.org/show_bug.cgi?id=174980#c2
return (typeof(self.Request) === 'function' && !self.Request.prototype.hasOwnProperty('signal')) || !self.AbortController;
}
export function nativeAbortControllerIsBroken(self) {
return self.navigator && self.navigator.userAgent &&
hasBrokenNativeAbortController(self.navigator.userAgent);
}
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