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.7.5 to 1.7.6

163

dist/abortcontroller-polyfill-only.js

@@ -144,2 +144,76 @@ (function (factory) {

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
var Emitter = /*#__PURE__*/function () {

@@ -276,2 +350,90 @@ function Emitter() {

}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
*/
}, {
key: "throwIfAborted",
value: function throwIfAborted() {
var aborted = this.aborted,
_this$reason = this.reason,
reason = _this$reason === void 0 ? 'Aborted' : _this$reason;
if (!aborted) return;
throw reason;
}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
* @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
*/
}], [{
key: "timeout",
value: function timeout(time) {
var controller = new AbortController();
setTimeout(function () {
return controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), 'TimeoutError'));
}, time);
return controller.signal;
}
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
* @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
* @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
* The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
* The `reason` will be set to the reason of the first abort signal that is aborted.
*/
}, {
key: "any",
value: function any(iterable) {
var controller = new AbortController();
/**
* @this AbortSignal
*/
function abort() {
controller.abort(this.reason);
clean();
}
function clean() {
var _iterator = _createForOfIteratorHelper(iterable),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var signal = _step.value;
signal.removeEventListener('abort', abort);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
var _iterator2 = _createForOfIteratorHelper(iterable),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var signal = _step2.value;
if (signal.aborted) {
controller.abort(signal.reason);
break;
} else signal.addEventListener('abort', abort);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return controller.signal;
}
}]);

@@ -331,2 +493,3 @@

signalReason = new DOMException('signal is aborted without reason');
signalReason.name = 'AbortError';
} catch (err) {

@@ -333,0 +496,0 @@ // IE 11 does not support calling the DOMException constructor, use a

@@ -143,2 +143,76 @@ 'use strict';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
var Emitter = /*#__PURE__*/function () {

@@ -275,2 +349,90 @@ function Emitter() {

}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
*/
}, {
key: "throwIfAborted",
value: function throwIfAborted() {
var aborted = this.aborted,
_this$reason = this.reason,
reason = _this$reason === void 0 ? 'Aborted' : _this$reason;
if (!aborted) return;
throw reason;
}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
* @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
*/
}], [{
key: "timeout",
value: function timeout(time) {
var controller = new AbortController();
setTimeout(function () {
return controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), 'TimeoutError'));
}, time);
return controller.signal;
}
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
* @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
* @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
* The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
* The `reason` will be set to the reason of the first abort signal that is aborted.
*/
}, {
key: "any",
value: function any(iterable) {
var controller = new AbortController();
/**
* @this AbortSignal
*/
function abort() {
controller.abort(this.reason);
clean();
}
function clean() {
var _iterator = _createForOfIteratorHelper(iterable),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var signal = _step.value;
signal.removeEventListener('abort', abort);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
var _iterator2 = _createForOfIteratorHelper(iterable),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var signal = _step2.value;
if (signal.aborted) {
controller.abort(signal.reason);
break;
} else signal.addEventListener('abort', abort);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return controller.signal;
}
}]);

@@ -330,2 +492,3 @@

signalReason = new DOMException('signal is aborted without reason');
signalReason.name = 'AbortError';
} catch (err) {

@@ -332,0 +495,0 @@ // IE 11 does not support calling the DOMException constructor, use a

@@ -143,2 +143,76 @@ 'use strict';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
var Emitter = /*#__PURE__*/function () {

@@ -275,2 +349,90 @@ function Emitter() {

}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
*/
}, {
key: "throwIfAborted",
value: function throwIfAborted() {
var aborted = this.aborted,
_this$reason = this.reason,
reason = _this$reason === void 0 ? 'Aborted' : _this$reason;
if (!aborted) return;
throw reason;
}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
* @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
*/
}], [{
key: "timeout",
value: function timeout(time) {
var controller = new AbortController();
setTimeout(function () {
return controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), 'TimeoutError'));
}, time);
return controller.signal;
}
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
* @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
* @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
* The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
* The `reason` will be set to the reason of the first abort signal that is aborted.
*/
}, {
key: "any",
value: function any(iterable) {
var controller = new AbortController();
/**
* @this AbortSignal
*/
function abort() {
controller.abort(this.reason);
clean();
}
function clean() {
var _iterator = _createForOfIteratorHelper(iterable),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var signal = _step.value;
signal.removeEventListener('abort', abort);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
var _iterator2 = _createForOfIteratorHelper(iterable),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var signal = _step2.value;
if (signal.aborted) {
controller.abort(signal.reason);
break;
} else signal.addEventListener('abort', abort);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return controller.signal;
}
}]);

@@ -330,2 +492,3 @@

signalReason = new DOMException('signal is aborted without reason');
signalReason.name = 'AbortError';
} catch (err) {

@@ -332,0 +495,0 @@ // IE 11 does not support calling the DOMException constructor, use a

@@ -144,2 +144,76 @@ (function (factory) {

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
var Emitter = /*#__PURE__*/function () {

@@ -276,2 +350,90 @@ function Emitter() {

}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
*/
}, {
key: "throwIfAborted",
value: function throwIfAborted() {
var aborted = this.aborted,
_this$reason = this.reason,
reason = _this$reason === void 0 ? 'Aborted' : _this$reason;
if (!aborted) return;
throw reason;
}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
* @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
*/
}], [{
key: "timeout",
value: function timeout(time) {
var controller = new AbortController();
setTimeout(function () {
return controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), 'TimeoutError'));
}, time);
return controller.signal;
}
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
* @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
* @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
* The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
* The `reason` will be set to the reason of the first abort signal that is aborted.
*/
}, {
key: "any",
value: function any(iterable) {
var controller = new AbortController();
/**
* @this AbortSignal
*/
function abort() {
controller.abort(this.reason);
clean();
}
function clean() {
var _iterator = _createForOfIteratorHelper(iterable),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var signal = _step.value;
signal.removeEventListener('abort', abort);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
var _iterator2 = _createForOfIteratorHelper(iterable),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var signal = _step2.value;
if (signal.aborted) {
controller.abort(signal.reason);
break;
} else signal.addEventListener('abort', abort);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return controller.signal;
}
}]);

@@ -331,2 +493,3 @@

signalReason = new DOMException('signal is aborted without reason');
signalReason.name = 'AbortError';
} catch (err) {

@@ -333,0 +496,0 @@ // IE 11 does not support calling the DOMException constructor, use a

@@ -144,2 +144,76 @@ (function (factory) {

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
var Emitter = /*#__PURE__*/function () {

@@ -276,2 +350,90 @@ function Emitter() {

}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
*/
}, {
key: "throwIfAborted",
value: function throwIfAborted() {
var aborted = this.aborted,
_this$reason = this.reason,
reason = _this$reason === void 0 ? 'Aborted' : _this$reason;
if (!aborted) return;
throw reason;
}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
* @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
*/
}], [{
key: "timeout",
value: function timeout(time) {
var controller = new AbortController();
setTimeout(function () {
return controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), 'TimeoutError'));
}, time);
return controller.signal;
}
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
* @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
* @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
* The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
* The `reason` will be set to the reason of the first abort signal that is aborted.
*/
}, {
key: "any",
value: function any(iterable) {
var controller = new AbortController();
/**
* @this AbortSignal
*/
function abort() {
controller.abort(this.reason);
clean();
}
function clean() {
var _iterator = _createForOfIteratorHelper(iterable),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var signal = _step.value;
signal.removeEventListener('abort', abort);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
var _iterator2 = _createForOfIteratorHelper(iterable),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var signal = _step2.value;
if (signal.aborted) {
controller.abort(signal.reason);
break;
} else signal.addEventListener('abort', abort);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return controller.signal;
}
}]);

@@ -331,2 +493,3 @@

signalReason = new DOMException('signal is aborted without reason');
signalReason.name = 'AbortError';
} catch (err) {

@@ -333,0 +496,0 @@ // IE 11 does not support calling the DOMException constructor, use a

26

package.json
{
"name": "abortcontroller-polyfill",
"version": "1.7.5",
"version": "1.7.6",
"description": "Polyfill/ponyfill for the AbortController DOM API + optional patching of fetch (stub that calls catch, doesn't actually abort request).",

@@ -14,9 +14,9 @@ "main": "dist/umd-polyfill.js",

"test": "npm run build && npm-run-all test-headless eslint",
"test-headless": "SELENIUM_BROWSER=chrome E2E_HEADLESS=1 ./scripts/wdio-suppress-exitcode",
"test-chrome": "SELENIUM_BROWSER=chrome ./scripts/wdio-suppress-exitcode",
"test-firefox": "SELENIUM_BROWSER=firefox ./scripts/wdio-suppress-exitcode",
"test-inspect-brk": "E2E_WDIO_EXEC_ARGV=--inspect-brk npm run test-chrome",
"test-verbose": "SELENIUM_BROWSER=chrome E2E_LOG_LEVEL=verbose wdio wdio.conf.js",
"test-headless": "cross-env EE_BROWSER=chrome EE_HEADLESS=1 ./scripts/wdio-suppress-exitcode",
"test-chrome": "cross-env EE_BROWSER=chrome ./scripts/wdio-suppress-exitcode",
"test-firefox": "cross-env EE_BROWSER=firefox ./scripts/wdio-suppress-exitcode",
"test-inspect-brk": "cross-env EE_WDIO_EXEC_ARGV=--inspect-brk npm run test-chrome",
"test-verbose": "cross-env EE_BROWSER=chrome EE_LOG_LEVEL=verbose wdio wdio.conf.js",
"upgrade-packages": "npx npm-check --update",
"eslint": "eslint src/ tests/"
"eslint": "eslint --fix src/ tests/"
},

@@ -32,7 +32,7 @@ "keywords": [],

"@babel/preset-env": "^7.19.3",
"@wdio/cli": "^7.25.1",
"@wdio/jasmine-framework": "^7.25.1",
"@wdio/local-runner": "^7.25.1",
"@wdio/selenium-standalone-service": "^7.25.1",
"@wdio/spec-reporter": "^7.25.1",
"@wdio/cli": "^9.2.10",
"@wdio/jasmine-framework": "^9.2.8",
"@wdio/local-runner": "^9.2.8",
"@wdio/spec-reporter": "^9.2.8",
"cross-env": "^7.0.3",
"detect-browser": "^5.3.0",

@@ -44,4 +44,4 @@ "eslint": "^8.25.0",

"rollup-plugin-babel": "^4.4.0",
"webdriverio": "^7.25.1"
"webdriverio": "^9.2.8"
}
}

@@ -160,2 +160,4 @@ # AbortController polyfill for abortable fetch()

* [Ambar Lee](https://github.com/ambar)
* [Sebastian Silbermann](https://github.com/eps1lon)
* [Yao Shi](https://github.com/TechQuery)

@@ -162,0 +164,0 @@ # License

@@ -78,2 +78,57 @@ class Emitter {

}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
*/
throwIfAborted() {
const { aborted, reason = 'Aborted' } = this;
if (!aborted) return;
throw reason;
}
/**
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
* @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
*/
static timeout(time) {
const controller = new AbortController();
setTimeout(() => controller.abort(new DOMException(`This signal is timeout in ${time}ms`, 'TimeoutError')), time);
return controller.signal;
}
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
* @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
* @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
* The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
* The `reason` will be set to the reason of the first abort signal that is aborted.
*/
static any(iterable) {
const controller = new AbortController();
/**
* @this AbortSignal
*/
function abort() {
controller.abort(this.reason);
clean();
}
function clean() {
for (const signal of iterable) signal.removeEventListener('abort', abort);
}
for (const signal of iterable)
if (signal.aborted) {
controller.abort(signal.reason);
break;
} else signal.addEventListener('abort', abort);
return controller.signal;
}
}

@@ -120,2 +175,3 @@

signalReason = new DOMException('signal is aborted without reason');
signalReason.name = 'AbortError';
} catch (err) {

@@ -122,0 +178,0 @@ // IE 11 does not support calling the DOMException constructor, use a

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