40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
// 版权所有(c).NET基金会。保留所有权利。
|
||
// 在2.0版Apache许可下授权。有关许可证信息,请参见项目根目录中的License.txt。
|
||
//粗略填写 https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
||
//实际上,我们从来没有使用被polyfill填充的API,我们总是使用polyfill,因为
|
||
//它现在还是一个非常新的API。
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
var AbortController = /** @class */ (function () {
|
||
function AbortController() {
|
||
this.isAborted = false;
|
||
this.onabort = null;
|
||
}
|
||
AbortController.prototype.abort = function () {
|
||
if (!this.isAborted) {
|
||
this.isAborted = true;
|
||
if (this.onabort) {
|
||
this.onabort();
|
||
}
|
||
}
|
||
};
|
||
Object.defineProperty(AbortController.prototype, "signal", {
|
||
get: function () {
|
||
return this;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(AbortController.prototype, "aborted", {
|
||
get: function () {
|
||
return this.isAborted;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
return AbortController;
|
||
}());
|
||
export { AbortController };
|