@azure/abort-controller 1.0.1-dev.20200728.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History
2
2
 
3
+ ## 1.0.2 (2020-01-07)
4
+
5
+ Updates the `tslib` dependency to version 2.x.
6
+
3
7
  ## 1.0.1 (2019-12-04)
4
8
 
5
9
  Fixes the [bug 6271](https://github.com/Azure/azure-sdk-for-js/issues/6271) that can occur with angular prod builds due to triple-slash directives.
package/dist/index.js CHANGED
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
 
7
+ // Copyright (c) Microsoft Corporation.
8
+ // Licensed under the MIT license.
7
9
  var listenersMap = new WeakMap();
8
10
  var abortedMap = new WeakMap();
9
11
  /**
@@ -14,19 +16,15 @@ var abortedMap = new WeakMap();
14
16
  * cannot or will not ever be cancelled.
15
17
  *
16
18
  * @example
17
- * // Abort without timeout
19
+ * Abort without timeout
20
+ * ```ts
18
21
  * await doAsyncWork(AbortSignal.none);
19
- *
20
- * @export
21
- * @class AbortSignal
22
- * @implements {AbortSignalLike}
22
+ * ```
23
23
  */
24
24
  var AbortSignal = /** @class */ (function () {
25
25
  function AbortSignal() {
26
26
  /**
27
27
  * onabort event listener.
28
- *
29
- * @memberof AbortSignal
30
28
  */
31
29
  this.onabort = null;
32
30
  listenersMap.set(this, []);
@@ -37,8 +35,6 @@ var AbortSignal = /** @class */ (function () {
37
35
  * Status of whether aborted or not.
38
36
  *
39
37
  * @readonly
40
- * @type {boolean}
41
- * @memberof AbortSignal
42
38
  */
43
39
  get: function () {
44
40
  if (!abortedMap.has(this)) {
@@ -54,9 +50,6 @@ var AbortSignal = /** @class */ (function () {
54
50
  * Creates a new AbortSignal instance that will never be aborted.
55
51
  *
56
52
  * @readonly
57
- * @static
58
- * @type {AbortSignal}
59
- * @memberof AbortSignal
60
53
  */
61
54
  get: function () {
62
55
  return new AbortSignal();
@@ -67,9 +60,8 @@ var AbortSignal = /** @class */ (function () {
67
60
  /**
68
61
  * Added new "abort" event listener, only support "abort" event.
69
62
  *
70
- * @param {"abort"} _type Only support "abort" event
71
- * @param {(this: AbortSignalLike, ev: any) => any} listener
72
- * @memberof AbortSignal
63
+ * @param _type - Only support "abort" event
64
+ * @param listener - The listener to be added
73
65
  */
74
66
  AbortSignal.prototype.addEventListener = function (
75
67
  // tslint:disable-next-line:variable-name
@@ -83,9 +75,8 @@ var AbortSignal = /** @class */ (function () {
83
75
  /**
84
76
  * Remove "abort" event listener, only support "abort" event.
85
77
  *
86
- * @param {"abort"} _type Only support "abort" event
87
- * @param {(this: AbortSignalLike, ev: any) => any} listener
88
- * @memberof AbortSignal
78
+ * @param _type - Only support "abort" event
79
+ * @param listener - The listener to be removed
89
80
  */
90
81
  AbortSignal.prototype.removeEventListener = function (
91
82
  // tslint:disable-next-line:variable-name
@@ -114,9 +105,9 @@ var AbortSignal = /** @class */ (function () {
114
105
  * - If there is a timeout, the timer will be cancelled.
115
106
  * - If aborted is true, nothing will happen.
116
107
  *
117
- * @returns
118
108
  * @internal
119
109
  */
110
+ // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
120
111
  function abortSignal(signal) {
121
112
  if (signal.aborted) {
122
113
  return;
@@ -133,12 +124,14 @@ function abortSignal(signal) {
133
124
  abortedMap.set(signal, true);
134
125
  }
135
126
 
127
+ // Copyright (c) Microsoft Corporation.
136
128
  /**
137
129
  * This error is thrown when an asynchronous operation has been aborted.
138
130
  * Check for this error by testing the `name` that the name property of the
139
131
  * error matches `"AbortError"`.
140
132
  *
141
133
  * @example
134
+ * ```ts
142
135
  * const controller = new AbortController();
143
136
  * controller.abort();
144
137
  * try {
@@ -148,6 +141,7 @@ function abortSignal(signal) {
148
141
  * // handle abort error here.
149
142
  * }
150
143
  * }
144
+ * ```
151
145
  */
152
146
  var AbortError = /** @class */ (function (_super) {
153
147
  tslib.__extends(AbortError, _super);
@@ -163,34 +157,37 @@ var AbortError = /** @class */ (function (_super) {
163
157
  * that an asynchronous operation should be aborted.
164
158
  *
165
159
  * @example
166
- * // Abort an operation when another event fires
160
+ * Abort an operation when another event fires
161
+ * ```ts
167
162
  * const controller = new AbortController();
168
163
  * const signal = controller.signal;
169
164
  * doAsyncWork(signal);
170
165
  * button.addEventListener('click', () => controller.abort());
166
+ * ```
171
167
  *
172
168
  * @example
173
- * // Share aborter cross multiple operations in 30s
169
+ * Share aborter cross multiple operations in 30s
170
+ * ```ts
174
171
  * // Upload the same data to 2 different data centers at the same time,
175
172
  * // abort another when any of them is finished
176
173
  * const controller = AbortController.withTimeout(30 * 1000);
177
174
  * doAsyncWork(controller.signal).then(controller.abort);
178
175
  * doAsyncWork(controller.signal).then(controller.abort);
176
+ *```
179
177
  *
180
178
  * @example
181
- * // Cascaded aborting
179
+ * Cascaded aborting
180
+ * ```ts
182
181
  * // All operations can't take more than 30 seconds
183
182
  * const aborter = Aborter.timeout(30 * 1000);
184
183
  *
185
184
  * // Following 2 operations can't take more than 25 seconds
186
185
  * await doAsyncWork(aborter.withTimeout(25 * 1000));
187
186
  * await doAsyncWork(aborter.withTimeout(25 * 1000));
188
- *
189
- * @export
190
- * @class AbortController
191
- * @implements {AbortSignalLike}
187
+ * ```
192
188
  */
193
189
  var AbortController = /** @class */ (function () {
190
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
194
191
  function AbortController(parentSignals) {
195
192
  var _this = this;
196
193
  this._signal = new AbortSignal();
@@ -199,6 +196,7 @@ var AbortController = /** @class */ (function () {
199
196
  }
200
197
  // coerce parentSignals into an array
201
198
  if (!Array.isArray(parentSignals)) {
199
+ // eslint-disable-next-line prefer-rest-params
202
200
  parentSignals = arguments;
203
201
  }
204
202
  for (var _i = 0, parentSignals_1 = parentSignals; _i < parentSignals_1.length; _i++) {
@@ -222,8 +220,6 @@ var AbortController = /** @class */ (function () {
222
220
  * when the abort method is called on this controller.
223
221
  *
224
222
  * @readonly
225
- * @type {AbortSignal}
226
- * @memberof AbortController
227
223
  */
228
224
  get: function () {
229
225
  return this._signal;
@@ -234,18 +230,13 @@ var AbortController = /** @class */ (function () {
234
230
  /**
235
231
  * Signal that any operations passed this controller's associated abort signal
236
232
  * to cancel any remaining work and throw an `AbortError`.
237
- *
238
- * @memberof AbortController
239
233
  */
240
234
  AbortController.prototype.abort = function () {
241
235
  abortSignal(this._signal);
242
236
  };
243
237
  /**
244
238
  * Creates a new AbortSignal instance that will abort after the provided ms.
245
- *
246
- * @static
247
- * @params {number} ms Elapsed time in milliseconds to trigger an abort.
248
- * @returns {AbortSignal}
239
+ * @param ms - Elapsed time in milliseconds to trigger an abort.
249
240
  */
250
241
  AbortController.timeout = function (ms) {
251
242
  var signal = new AbortSignal();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/AbortSignal.ts","../src/AbortController.ts"],"sourcesContent":["/// <reference path=\"./shims-public.d.ts\" />\ntype AbortEventListener = (this: AbortSignalLike, ev?: any) => any;\n\nconst listenersMap = new WeakMap<AbortSignal, AbortEventListener[]>();\nconst abortedMap = new WeakMap<AbortSignal, boolean>();\n\n/**\n * Allows the request to be aborted upon firing of the \"abort\" event.\n * Compatible with the browser built-in AbortSignal and common polyfills.\n */\nexport interface AbortSignalLike {\n /**\n * Indicates if the signal has already been aborted.\n */\n readonly aborted: boolean;\n /**\n * Add new \"abort\" event listener, only support \"abort\" event.\n */\n addEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n */\n removeEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n}\n\n/**\n * An aborter instance implements AbortSignal interface, can abort HTTP requests.\n *\n * - Call AbortSignal.none to create a new AbortSignal instance that cannot be cancelled.\n * Use `AbortSignal.none` when you are required to pass a cancellation token but the operation\n * cannot or will not ever be cancelled.\n *\n * @example\n * // Abort without timeout\n * await doAsyncWork(AbortSignal.none);\n *\n * @export\n * @class AbortSignal\n * @implements {AbortSignalLike}\n */\nexport class AbortSignal implements AbortSignalLike {\n constructor() {\n listenersMap.set(this, []);\n abortedMap.set(this, false);\n }\n\n /**\n * Status of whether aborted or not.\n *\n * @readonly\n * @type {boolean}\n * @memberof AbortSignal\n */\n public get aborted(): boolean {\n if (!abortedMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n return abortedMap.get(this)!;\n }\n\n /**\n * Creates a new AbortSignal instance that will never be aborted.\n *\n * @readonly\n * @static\n * @type {AbortSignal}\n * @memberof AbortSignal\n */\n public static get none(): AbortSignal {\n return new AbortSignal();\n }\n\n /**\n * onabort event listener.\n *\n * @memberof AbortSignal\n */\n public onabort: ((ev?: Event) => any) | null = null;\n\n /**\n * Added new \"abort\" event listener, only support \"abort\" event.\n *\n * @param {\"abort\"} _type Only support \"abort\" event\n * @param {(this: AbortSignalLike, ev: any) => any} listener\n * @memberof AbortSignal\n */\n public addEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n listeners.push(listener);\n }\n\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n *\n * @param {\"abort\"} _type Only support \"abort\" event\n * @param {(this: AbortSignalLike, ev: any) => any} listener\n * @memberof AbortSignal\n */\n public removeEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n\n const index = listeners.indexOf(listener);\n if (index > -1) {\n listeners.splice(index, 1);\n }\n }\n\n /**\n * Dispatches a synthetic event to the AbortSignal.\n */\n dispatchEvent(_event: Event): boolean {\n throw new Error(\n \"This is a stub dispatchEvent implementation that should not be used. It only exists for type-checking purposes.\"\n );\n }\n}\n\n/**\n * Helper to trigger an abort event immediately, the onabort and all abort event listeners will be triggered.\n * Will try to trigger abort event for all linked AbortSignal nodes.\n *\n * - If there is a timeout, the timer will be cancelled.\n * - If aborted is true, nothing will happen.\n *\n * @returns\n * @internal\n */\nexport function abortSignal(signal: AbortSignal) {\n if (signal.aborted) {\n return;\n }\n\n if (signal.onabort) {\n signal.onabort.call(signal);\n }\n\n const listeners = listenersMap.get(signal)!;\n if (listeners) {\n listeners.forEach((listener) => {\n listener.call(signal, { type: \"abort\" });\n });\n }\n\n abortedMap.set(signal, true);\n}\n","import { AbortSignal, abortSignal, AbortSignalLike } from \"./AbortSignal\";\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * const controller = new AbortController();\n * controller.abort();\n * try {\n * doAsyncWork(controller.signal)\n * } catch (e) {\n * if (e.name === 'AbortError') {\n * // handle abort error here.\n * }\n * }\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n\n/**\n * An AbortController provides an AbortSignal and the associated controls to signal\n * that an asynchronous operation should be aborted.\n *\n * @example\n * // Abort an operation when another event fires\n * const controller = new AbortController();\n * const signal = controller.signal;\n * doAsyncWork(signal);\n * button.addEventListener('click', () => controller.abort());\n *\n * @example\n * // Share aborter cross multiple operations in 30s\n * // Upload the same data to 2 different data centers at the same time,\n * // abort another when any of them is finished\n * const controller = AbortController.withTimeout(30 * 1000);\n * doAsyncWork(controller.signal).then(controller.abort);\n * doAsyncWork(controller.signal).then(controller.abort);\n *\n * @example\n * // Cascaded aborting\n * // All operations can't take more than 30 seconds\n * const aborter = Aborter.timeout(30 * 1000);\n *\n * // Following 2 operations can't take more than 25 seconds\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n *\n * @export\n * @class AbortController\n * @implements {AbortSignalLike}\n */\nexport class AbortController {\n private _signal: AbortSignal;\n\n /**\n * @param {AbortSignalLike[]} [parentSignals] The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n * @constructor\n */\n constructor(parentSignals?: AbortSignalLike[]);\n /**\n * @param {...AbortSignalLike} parentSignals The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n * @constructor\n */\n constructor(...parentSignals: AbortSignalLike[]);\n constructor(parentSignals?: any) {\n this._signal = new AbortSignal();\n\n if (!parentSignals) {\n return;\n }\n // coerce parentSignals into an array\n if (!Array.isArray(parentSignals)) {\n parentSignals = arguments;\n }\n for (const parentSignal of parentSignals) {\n // if the parent signal has already had abort() called,\n // then call abort on this signal as well.\n if (parentSignal.aborted) {\n this.abort();\n } else {\n // when the parent signal aborts, this signal should as well.\n parentSignal.addEventListener(\"abort\", () => {\n this.abort();\n });\n }\n }\n }\n\n /**\n * The AbortSignal associated with this controller that will signal aborted\n * when the abort method is called on this controller.\n *\n * @readonly\n * @type {AbortSignal}\n * @memberof AbortController\n */\n public get signal() {\n return this._signal;\n }\n\n /**\n * Signal that any operations passed this controller's associated abort signal\n * to cancel any remaining work and throw an `AbortError`.\n *\n * @memberof AbortController\n */\n abort() {\n abortSignal(this._signal);\n }\n\n /**\n * Creates a new AbortSignal instance that will abort after the provided ms.\n *\n * @static\n * @params {number} ms Elapsed time in milliseconds to trigger an abort.\n * @returns {AbortSignal}\n */\n public static timeout(ms: number): AbortSignal {\n const signal = new AbortSignal();\n const timer = setTimeout(abortSignal, ms, signal);\n // Prevent the active Timer from keeping the Node.js event loop active.\n if (typeof timer.unref === \"function\") {\n timer.unref();\n }\n return signal;\n }\n}\n"],"names":["__extends"],"mappings":";;;;;;AAGA,IAAM,YAAY,GAAG,IAAI,OAAO,EAAqC,CAAC;AACtE,IAAM,UA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AA;;;YAGrB,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,IAAI,CAAC,KAAK,EAAE,CAAC;aACd;iBAAM;;gBAEL,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE;oBACrC,KAAI,CAAC,KAAK,EAAE,CAAC;iBACd,CAAC,CAAC;aACJ;SACF;KACF;IAUD,sBAAW,mCAAM;;;;;;;;;aAAjB;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;SACrB;;;OAAA;;;;;;;IAQD,+BAAK,GAAL;QACE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC3B;;;;;;;;IASa,uBAAO,GAArB,UAAsB,EAAU;QAC9B,IAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,IAAM,KAAK,GAAG,UAAU,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;;QAElD,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE;YACrC,KAAK,CAAC,KAAK,EAAE,CAAC;SACf;QACD,OAAO,MAAM,CAAC;KACf;IACH,sBAAC;AAAD,CAAC;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/AbortSignal.ts","../src/AbortController.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../shims-public.d.ts\" />\n\ntype AbortEventListener = (this: AbortSignalLike, ev?: any) => any;\n\nconst listenersMap = new WeakMap<AbortSignal, AbortEventListener[]>();\nconst abortedMap = new WeakMap<AbortSignal, boolean>();\n\n/**\n * Allows the request to be aborted upon firing of the \"abort\" event.\n * Compatible with the browser built-in AbortSignal and common polyfills.\n */\nexport interface AbortSignalLike {\n /**\n * Indicates if the signal has already been aborted.\n */\n readonly aborted: boolean;\n /**\n * Add new \"abort\" event listener, only support \"abort\" event.\n */\n addEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n */\n removeEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n}\n\n/**\n * An aborter instance implements AbortSignal interface, can abort HTTP requests.\n *\n * - Call AbortSignal.none to create a new AbortSignal instance that cannot be cancelled.\n * Use `AbortSignal.none` when you are required to pass a cancellation token but the operation\n * cannot or will not ever be cancelled.\n *\n * @example\n * Abort without timeout\n * ```ts\n * await doAsyncWork(AbortSignal.none);\n * ```\n */\nexport class AbortSignal implements AbortSignalLike {\n constructor() {\n listenersMap.set(this, []);\n abortedMap.set(this, false);\n }\n\n /**\n * Status of whether aborted or not.\n *\n * @readonly\n */\n public get aborted(): boolean {\n if (!abortedMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n return abortedMap.get(this)!;\n }\n\n /**\n * Creates a new AbortSignal instance that will never be aborted.\n *\n * @readonly\n */\n public static get none(): AbortSignal {\n return new AbortSignal();\n }\n\n /**\n * onabort event listener.\n */\n public onabort: ((ev?: Event) => any) | null = null;\n\n /**\n * Added new \"abort\" event listener, only support \"abort\" event.\n *\n * @param _type - Only support \"abort\" event\n * @param listener - The listener to be added\n */\n public addEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n listeners.push(listener);\n }\n\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n *\n * @param _type - Only support \"abort\" event\n * @param listener - The listener to be removed\n */\n public removeEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n\n const index = listeners.indexOf(listener);\n if (index > -1) {\n listeners.splice(index, 1);\n }\n }\n\n /**\n * Dispatches a synthetic event to the AbortSignal.\n */\n dispatchEvent(_event: Event): boolean {\n throw new Error(\n \"This is a stub dispatchEvent implementation that should not be used. It only exists for type-checking purposes.\"\n );\n }\n}\n\n/**\n * Helper to trigger an abort event immediately, the onabort and all abort event listeners will be triggered.\n * Will try to trigger abort event for all linked AbortSignal nodes.\n *\n * - If there is a timeout, the timer will be cancelled.\n * - If aborted is true, nothing will happen.\n *\n * @internal\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\nexport function abortSignal(signal: AbortSignal): void {\n if (signal.aborted) {\n return;\n }\n\n if (signal.onabort) {\n signal.onabort.call(signal);\n }\n\n const listeners = listenersMap.get(signal)!;\n if (listeners) {\n listeners.forEach((listener) => {\n listener.call(signal, { type: \"abort\" });\n });\n }\n\n abortedMap.set(signal, true);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignal, abortSignal, AbortSignalLike } from \"./AbortSignal\";\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * ```ts\n * const controller = new AbortController();\n * controller.abort();\n * try {\n * doAsyncWork(controller.signal)\n * } catch (e) {\n * if (e.name === 'AbortError') {\n * // handle abort error here.\n * }\n * }\n * ```\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n\n/**\n * An AbortController provides an AbortSignal and the associated controls to signal\n * that an asynchronous operation should be aborted.\n *\n * @example\n * Abort an operation when another event fires\n * ```ts\n * const controller = new AbortController();\n * const signal = controller.signal;\n * doAsyncWork(signal);\n * button.addEventListener('click', () => controller.abort());\n * ```\n *\n * @example\n * Share aborter cross multiple operations in 30s\n * ```ts\n * // Upload the same data to 2 different data centers at the same time,\n * // abort another when any of them is finished\n * const controller = AbortController.withTimeout(30 * 1000);\n * doAsyncWork(controller.signal).then(controller.abort);\n * doAsyncWork(controller.signal).then(controller.abort);\n *```\n *\n * @example\n * Cascaded aborting\n * ```ts\n * // All operations can't take more than 30 seconds\n * const aborter = Aborter.timeout(30 * 1000);\n *\n * // Following 2 operations can't take more than 25 seconds\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n * ```\n */\nexport class AbortController {\n private _signal: AbortSignal;\n\n /**\n * @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n */\n constructor(parentSignals?: AbortSignalLike[]);\n /**\n * @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n */\n constructor(...parentSignals: AbortSignalLike[]);\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n constructor(parentSignals?: any) {\n this._signal = new AbortSignal();\n\n if (!parentSignals) {\n return;\n }\n // coerce parentSignals into an array\n if (!Array.isArray(parentSignals)) {\n // eslint-disable-next-line prefer-rest-params\n parentSignals = arguments;\n }\n for (const parentSignal of parentSignals) {\n // if the parent signal has already had abort() called,\n // then call abort on this signal as well.\n if (parentSignal.aborted) {\n this.abort();\n } else {\n // when the parent signal aborts, this signal should as well.\n parentSignal.addEventListener(\"abort\", () => {\n this.abort();\n });\n }\n }\n }\n\n /**\n * The AbortSignal associated with this controller that will signal aborted\n * when the abort method is called on this controller.\n *\n * @readonly\n */\n public get signal(): AbortSignal {\n return this._signal;\n }\n\n /**\n * Signal that any operations passed this controller's associated abort signal\n * to cancel any remaining work and throw an `AbortError`.\n */\n abort(): void {\n abortSignal(this._signal);\n }\n\n /**\n * Creates a new AbortSignal instance that will abort after the provided ms.\n * @param ms - Elapsed time in milliseconds to trigger an abort.\n */\n public static timeout(ms: number): AbortSignal {\n const signal = new AbortSignal();\n const timer = setTimeout(abortSignal, ms, signal);\n // Prevent the active Timer from keeping the Node.js event loop active.\n if (typeof timer.unref === \"function\") {\n timer.unref();\n }\n return signal;\n }\n}\n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Aa,GAAG,SAAS,CAAC;SAC3B;QACD,KAA2B,UAAa,EAAb,+BAAa,EAAb,2BAAa,EAAb,IAAa,EAAE;YAArC,IAAM,YAAY,sBAAA;;;YAGrB,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,IAAI,CAAC,KAAK,EAAE,CAAC;aACd;iBAAM;;gBAEL,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE;oBACrC,KAAI,CAAC,KAAK,EAAE,CAAC;iBACd,CAAC,CAAC;aACJ;SACF;KACF;IAQD,sBAAW,mCAAM;;;;;;;aAAjB;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;SACrB;;;OAAA;;;;;IAMD,+BAAK,GAAL;QACE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC3B;;;;;IAMa,uBAAO,GAArB,UAAsB,EAAU;QAC9B,IAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,IAAM,KAAK,GAAG,UAAU,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;;QAElD,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE;YACrC,KAAK,CAAC,KAAK,EAAE,CAAC;SACf;QACD,OAAO,MAAM,CAAC;KACf;IACH,sBAAC;AAAD,CAAC;;;;;;"}
@@ -1,3 +1,5 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
1
3
  import { __extends } from "tslib";
2
4
  import { AbortSignal, abortSignal } from "./AbortSignal";
3
5
  /**
@@ -6,6 +8,7 @@ import { AbortSignal, abortSignal } from "./AbortSignal";
6
8
  * error matches `"AbortError"`.
7
9
  *
8
10
  * @example
11
+ * ```ts
9
12
  * const controller = new AbortController();
10
13
  * controller.abort();
11
14
  * try {
@@ -15,6 +18,7 @@ import { AbortSignal, abortSignal } from "./AbortSignal";
15
18
  * // handle abort error here.
16
19
  * }
17
20
  * }
21
+ * ```
18
22
  */
19
23
  var AbortError = /** @class */ (function (_super) {
20
24
  __extends(AbortError, _super);
@@ -31,34 +35,37 @@ export { AbortError };
31
35
  * that an asynchronous operation should be aborted.
32
36
  *
33
37
  * @example
34
- * // Abort an operation when another event fires
38
+ * Abort an operation when another event fires
39
+ * ```ts
35
40
  * const controller = new AbortController();
36
41
  * const signal = controller.signal;
37
42
  * doAsyncWork(signal);
38
43
  * button.addEventListener('click', () => controller.abort());
44
+ * ```
39
45
  *
40
46
  * @example
41
- * // Share aborter cross multiple operations in 30s
47
+ * Share aborter cross multiple operations in 30s
48
+ * ```ts
42
49
  * // Upload the same data to 2 different data centers at the same time,
43
50
  * // abort another when any of them is finished
44
51
  * const controller = AbortController.withTimeout(30 * 1000);
45
52
  * doAsyncWork(controller.signal).then(controller.abort);
46
53
  * doAsyncWork(controller.signal).then(controller.abort);
54
+ *```
47
55
  *
48
56
  * @example
49
- * // Cascaded aborting
57
+ * Cascaded aborting
58
+ * ```ts
50
59
  * // All operations can't take more than 30 seconds
51
60
  * const aborter = Aborter.timeout(30 * 1000);
52
61
  *
53
62
  * // Following 2 operations can't take more than 25 seconds
54
63
  * await doAsyncWork(aborter.withTimeout(25 * 1000));
55
64
  * await doAsyncWork(aborter.withTimeout(25 * 1000));
56
- *
57
- * @export
58
- * @class AbortController
59
- * @implements {AbortSignalLike}
65
+ * ```
60
66
  */
61
67
  var AbortController = /** @class */ (function () {
68
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
62
69
  function AbortController(parentSignals) {
63
70
  var _this = this;
64
71
  this._signal = new AbortSignal();
@@ -67,6 +74,7 @@ var AbortController = /** @class */ (function () {
67
74
  }
68
75
  // coerce parentSignals into an array
69
76
  if (!Array.isArray(parentSignals)) {
77
+ // eslint-disable-next-line prefer-rest-params
70
78
  parentSignals = arguments;
71
79
  }
72
80
  for (var _i = 0, parentSignals_1 = parentSignals; _i < parentSignals_1.length; _i++) {
@@ -90,8 +98,6 @@ var AbortController = /** @class */ (function () {
90
98
  * when the abort method is called on this controller.
91
99
  *
92
100
  * @readonly
93
- * @type {AbortSignal}
94
- * @memberof AbortController
95
101
  */
96
102
  get: function () {
97
103
  return this._signal;
@@ -102,18 +108,13 @@ var AbortController = /** @class */ (function () {
102
108
  /**
103
109
  * Signal that any operations passed this controller's associated abort signal
104
110
  * to cancel any remaining work and throw an `AbortError`.
105
- *
106
- * @memberof AbortController
107
111
  */
108
112
  AbortController.prototype.abort = function () {
109
113
  abortSignal(this._signal);
110
114
  };
111
115
  /**
112
116
  * Creates a new AbortSignal instance that will abort after the provided ms.
113
- *
114
- * @static
115
- * @params {number} ms Elapsed time in milliseconds to trigger an abort.
116
- * @returns {AbortSignal}
117
+ * @param ms - Elapsed time in milliseconds to trigger an abort.
117
118
  */
118
119
  AbortController.timeout = function (ms) {
119
120
  var signal = new AbortSignal();
@@ -1 +1 @@
1
- {"version":3,"file":"AbortController.js","sourceRoot":"","sources":["../../src/AbortController.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAC;AAE1E;;;;;;;;;;;;;;;GAeG;AACH;IAAgC,8BAAK;IACnC,oBAAY,OAAgB;QAA5B,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,IAAI,GAAG,YAAY,CAAC;;IAC3B,CAAC;IACH,iBAAC;AAAD,CAAC,AALD,CAAgC,KAAK,GAKpC;;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;IAaE,yBAAY,aAAmB;QAA/B,iBAsBC;QArBC,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAEjC,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO;SACR;QACD,qCAAqC;QACrC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YACjC,aAAa,GAAG,SAAS,CAAC;SAC3B;QACD,KAA2B,UAAa,EAAb,+BAAa,EAAb,2BAAa,EAAb,IAAa,EAAE;YAArC,IAAM,YAAY,sBAAA;YACrB,uDAAuD;YACvD,0CAA0C;YAC1C,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,IAAI,CAAC,KAAK,EAAE,CAAC;aACd;iBAAM;gBACL,6DAA6D;gBAC7D,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE;oBACrC,KAAI,CAAC,KAAK,EAAE,CAAC;gBACf,CAAC,CAAC,CAAC;aACJ;SACF;IACH,CAAC;IAUD,sBAAW,mCAAM;QARjB;;;;;;;WAOG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAED;;;;;OAKG;IACH,+BAAK,GAAL;QACE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACW,uBAAO,GAArB,UAAsB,EAAU;QAC9B,IAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,IAAM,KAAK,GAAG,UAAU,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAClD,uEAAuE;QACvE,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE;YACrC,KAAK,CAAC,KAAK,EAAE,CAAC;SACf;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,sBAAC;AAAD,CAAC,AA3ED,IA2EC","sourcesContent":["import { AbortSignal, abortSignal, AbortSignalLike } from \"./AbortSignal\";\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * const controller = new AbortController();\n * controller.abort();\n * try {\n * doAsyncWork(controller.signal)\n * } catch (e) {\n * if (e.name === 'AbortError') {\n * // handle abort error here.\n * }\n * }\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n\n/**\n * An AbortController provides an AbortSignal and the associated controls to signal\n * that an asynchronous operation should be aborted.\n *\n * @example\n * // Abort an operation when another event fires\n * const controller = new AbortController();\n * const signal = controller.signal;\n * doAsyncWork(signal);\n * button.addEventListener('click', () => controller.abort());\n *\n * @example\n * // Share aborter cross multiple operations in 30s\n * // Upload the same data to 2 different data centers at the same time,\n * // abort another when any of them is finished\n * const controller = AbortController.withTimeout(30 * 1000);\n * doAsyncWork(controller.signal).then(controller.abort);\n * doAsyncWork(controller.signal).then(controller.abort);\n *\n * @example\n * // Cascaded aborting\n * // All operations can't take more than 30 seconds\n * const aborter = Aborter.timeout(30 * 1000);\n *\n * // Following 2 operations can't take more than 25 seconds\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n *\n * @export\n * @class AbortController\n * @implements {AbortSignalLike}\n */\nexport class AbortController {\n private _signal: AbortSignal;\n\n /**\n * @param {AbortSignalLike[]} [parentSignals] The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n * @constructor\n */\n constructor(parentSignals?: AbortSignalLike[]);\n /**\n * @param {...AbortSignalLike} parentSignals The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n * @constructor\n */\n constructor(...parentSignals: AbortSignalLike[]);\n constructor(parentSignals?: any) {\n this._signal = new AbortSignal();\n\n if (!parentSignals) {\n return;\n }\n // coerce parentSignals into an array\n if (!Array.isArray(parentSignals)) {\n parentSignals = arguments;\n }\n for (const parentSignal of parentSignals) {\n // if the parent signal has already had abort() called,\n // then call abort on this signal as well.\n if (parentSignal.aborted) {\n this.abort();\n } else {\n // when the parent signal aborts, this signal should as well.\n parentSignal.addEventListener(\"abort\", () => {\n this.abort();\n });\n }\n }\n }\n\n /**\n * The AbortSignal associated with this controller that will signal aborted\n * when the abort method is called on this controller.\n *\n * @readonly\n * @type {AbortSignal}\n * @memberof AbortController\n */\n public get signal() {\n return this._signal;\n }\n\n /**\n * Signal that any operations passed this controller's associated abort signal\n * to cancel any remaining work and throw an `AbortError`.\n *\n * @memberof AbortController\n */\n abort() {\n abortSignal(this._signal);\n }\n\n /**\n * Creates a new AbortSignal instance that will abort after the provided ms.\n *\n * @static\n * @params {number} ms Elapsed time in milliseconds to trigger an abort.\n * @returns {AbortSignal}\n */\n public static timeout(ms: number): AbortSignal {\n const signal = new AbortSignal();\n const timer = setTimeout(abortSignal, ms, signal);\n // Prevent the active Timer from keeping the Node.js event loop active.\n if (typeof timer.unref === \"function\") {\n timer.unref();\n }\n return signal;\n }\n}\n"]}
1
+ {"version":3,"file":"AbortController.js","sourceRoot":"","sources":["../../src/AbortController.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAC;AAE1E;;;;;;;;;;;;;;;;;GAiBG;AACH;IAAgC,8BAAK;IACnC,oBAAY,OAAgB;QAA5B,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,IAAI,GAAG,YAAY,CAAC;;IAC3B,CAAC;IACH,iBAAC;AAAD,CAAC,AALD,CAAgC,KAAK,GAKpC;;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;IAWE,6EAA6E;IAC7E,yBAAY,aAAmB;QAA/B,iBAuBC;QAtBC,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAEjC,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO;SACR;QACD,qCAAqC;QACrC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YACjC,8CAA8C;YAC9C,aAAa,GAAG,SAAS,CAAC;SAC3B;QACD,KAA2B,UAAa,EAAb,+BAAa,EAAb,2BAAa,EAAb,IAAa,EAAE;YAArC,IAAM,YAAY,sBAAA;YACrB,uDAAuD;YACvD,0CAA0C;YAC1C,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,IAAI,CAAC,KAAK,EAAE,CAAC;aACd;iBAAM;gBACL,6DAA6D;gBAC7D,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE;oBACrC,KAAI,CAAC,KAAK,EAAE,CAAC;gBACf,CAAC,CAAC,CAAC;aACJ;SACF;IACH,CAAC;IAQD,sBAAW,mCAAM;QANjB;;;;;WAKG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAED;;;OAGG;IACH,+BAAK,GAAL;QACE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACW,uBAAO,GAArB,UAAsB,EAAU;QAC9B,IAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,IAAM,KAAK,GAAG,UAAU,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAClD,uEAAuE;QACvE,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE;YACrC,KAAK,CAAC,KAAK,EAAE,CAAC;SACf;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,sBAAC;AAAD,CAAC,AApED,IAoEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignal, abortSignal, AbortSignalLike } from \"./AbortSignal\";\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * ```ts\n * const controller = new AbortController();\n * controller.abort();\n * try {\n * doAsyncWork(controller.signal)\n * } catch (e) {\n * if (e.name === 'AbortError') {\n * // handle abort error here.\n * }\n * }\n * ```\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n\n/**\n * An AbortController provides an AbortSignal and the associated controls to signal\n * that an asynchronous operation should be aborted.\n *\n * @example\n * Abort an operation when another event fires\n * ```ts\n * const controller = new AbortController();\n * const signal = controller.signal;\n * doAsyncWork(signal);\n * button.addEventListener('click', () => controller.abort());\n * ```\n *\n * @example\n * Share aborter cross multiple operations in 30s\n * ```ts\n * // Upload the same data to 2 different data centers at the same time,\n * // abort another when any of them is finished\n * const controller = AbortController.withTimeout(30 * 1000);\n * doAsyncWork(controller.signal).then(controller.abort);\n * doAsyncWork(controller.signal).then(controller.abort);\n *```\n *\n * @example\n * Cascaded aborting\n * ```ts\n * // All operations can't take more than 30 seconds\n * const aborter = Aborter.timeout(30 * 1000);\n *\n * // Following 2 operations can't take more than 25 seconds\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n * await doAsyncWork(aborter.withTimeout(25 * 1000));\n * ```\n */\nexport class AbortController {\n private _signal: AbortSignal;\n\n /**\n * @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n */\n constructor(parentSignals?: AbortSignalLike[]);\n /**\n * @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.\n */\n constructor(...parentSignals: AbortSignalLike[]);\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n constructor(parentSignals?: any) {\n this._signal = new AbortSignal();\n\n if (!parentSignals) {\n return;\n }\n // coerce parentSignals into an array\n if (!Array.isArray(parentSignals)) {\n // eslint-disable-next-line prefer-rest-params\n parentSignals = arguments;\n }\n for (const parentSignal of parentSignals) {\n // if the parent signal has already had abort() called,\n // then call abort on this signal as well.\n if (parentSignal.aborted) {\n this.abort();\n } else {\n // when the parent signal aborts, this signal should as well.\n parentSignal.addEventListener(\"abort\", () => {\n this.abort();\n });\n }\n }\n }\n\n /**\n * The AbortSignal associated with this controller that will signal aborted\n * when the abort method is called on this controller.\n *\n * @readonly\n */\n public get signal(): AbortSignal {\n return this._signal;\n }\n\n /**\n * Signal that any operations passed this controller's associated abort signal\n * to cancel any remaining work and throw an `AbortError`.\n */\n abort(): void {\n abortSignal(this._signal);\n }\n\n /**\n * Creates a new AbortSignal instance that will abort after the provided ms.\n * @param ms - Elapsed time in milliseconds to trigger an abort.\n */\n public static timeout(ms: number): AbortSignal {\n const signal = new AbortSignal();\n const timer = setTimeout(abortSignal, ms, signal);\n // Prevent the active Timer from keeping the Node.js event loop active.\n if (typeof timer.unref === \"function\") {\n timer.unref();\n }\n return signal;\n }\n}\n"]}
@@ -1,3 +1,5 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
1
3
  var listenersMap = new WeakMap();
2
4
  var abortedMap = new WeakMap();
3
5
  /**
@@ -8,19 +10,15 @@ var abortedMap = new WeakMap();
8
10
  * cannot or will not ever be cancelled.
9
11
  *
10
12
  * @example
11
- * // Abort without timeout
13
+ * Abort without timeout
14
+ * ```ts
12
15
  * await doAsyncWork(AbortSignal.none);
13
- *
14
- * @export
15
- * @class AbortSignal
16
- * @implements {AbortSignalLike}
16
+ * ```
17
17
  */
18
18
  var AbortSignal = /** @class */ (function () {
19
19
  function AbortSignal() {
20
20
  /**
21
21
  * onabort event listener.
22
- *
23
- * @memberof AbortSignal
24
22
  */
25
23
  this.onabort = null;
26
24
  listenersMap.set(this, []);
@@ -31,8 +29,6 @@ var AbortSignal = /** @class */ (function () {
31
29
  * Status of whether aborted or not.
32
30
  *
33
31
  * @readonly
34
- * @type {boolean}
35
- * @memberof AbortSignal
36
32
  */
37
33
  get: function () {
38
34
  if (!abortedMap.has(this)) {
@@ -48,9 +44,6 @@ var AbortSignal = /** @class */ (function () {
48
44
  * Creates a new AbortSignal instance that will never be aborted.
49
45
  *
50
46
  * @readonly
51
- * @static
52
- * @type {AbortSignal}
53
- * @memberof AbortSignal
54
47
  */
55
48
  get: function () {
56
49
  return new AbortSignal();
@@ -61,9 +54,8 @@ var AbortSignal = /** @class */ (function () {
61
54
  /**
62
55
  * Added new "abort" event listener, only support "abort" event.
63
56
  *
64
- * @param {"abort"} _type Only support "abort" event
65
- * @param {(this: AbortSignalLike, ev: any) => any} listener
66
- * @memberof AbortSignal
57
+ * @param _type - Only support "abort" event
58
+ * @param listener - The listener to be added
67
59
  */
68
60
  AbortSignal.prototype.addEventListener = function (
69
61
  // tslint:disable-next-line:variable-name
@@ -77,9 +69,8 @@ var AbortSignal = /** @class */ (function () {
77
69
  /**
78
70
  * Remove "abort" event listener, only support "abort" event.
79
71
  *
80
- * @param {"abort"} _type Only support "abort" event
81
- * @param {(this: AbortSignalLike, ev: any) => any} listener
82
- * @memberof AbortSignal
72
+ * @param _type - Only support "abort" event
73
+ * @param listener - The listener to be removed
83
74
  */
84
75
  AbortSignal.prototype.removeEventListener = function (
85
76
  // tslint:disable-next-line:variable-name
@@ -109,9 +100,9 @@ export { AbortSignal };
109
100
  * - If there is a timeout, the timer will be cancelled.
110
101
  * - If aborted is true, nothing will happen.
111
102
  *
112
- * @returns
113
103
  * @internal
114
104
  */
105
+ // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
115
106
  export function abortSignal(signal) {
116
107
  if (signal.aborted) {
117
108
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"AbortSignal.js","sourceRoot":"","sources":["../../src/AbortSignal.ts"],"names":[],"mappings":"AAGA,IAAM,YAAY,GAAG,IAAI,OAAO,EAAqC,CAAC;AACtE,IAAM,UAAU,GAAG,IAAI,OAAO,EAAwB,CAAC;AA6BvD;;;;;;;;;;;;;;GAcG;AACH;IACE;QAgCA;;;;WAIG;QACI,YAAO,GAAiC,IAAI,CAAC;QApClD,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3B,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IASD,sBAAW,gCAAO;QAPlB;;;;;;WAMG;aACH;YACE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACzB,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;aAC1E;YAED,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QAC/B,CAAC;;;OAAA;IAUD,sBAAkB,mBAAI;QARtB;;;;;;;WAOG;aACH;YACE,OAAO,IAAI,WAAW,EAAE,CAAC;QAC3B,CAAC;;;OAAA;IASD;;;;;;OAMG;IACI,sCAA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;YACzB,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;KACJ;IAED,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/// <reference path=\"./shims-public.d.ts\" />\ntype AbortEventListener = (this: AbortSignalLike, ev?: any) => any;\n\nconst listenersMap = new WeakMap<AbortSignal, AbortEventListener[]>();\nconst abortedMap = new WeakMap<AbortSignal, boolean>();\n\n/**\n * Allows the request to be aborted upon firing of the \"abort\" event.\n * Compatible with the browser built-in AbortSignal and common polyfills.\n */\nexport interface AbortSignalLike {\n /**\n * Indicates if the signal has already been aborted.\n */\n readonly aborted: boolean;\n /**\n * Add new \"abort\" event listener, only support \"abort\" event.\n */\n addEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n */\n removeEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n}\n\n/**\n * An aborter instance implements AbortSignal interface, can abort HTTP requests.\n *\n * - Call AbortSignal.none to create a new AbortSignal instance that cannot be cancelled.\n * Use `AbortSignal.none` when you are required to pass a cancellation token but the operation\n * cannot or will not ever be cancelled.\n *\n * @example\n * // Abort without timeout\n * await doAsyncWork(AbortSignal.none);\n *\n * @export\n * @class AbortSignal\n * @implements {AbortSignalLike}\n */\nexport class AbortSignal implements AbortSignalLike {\n constructor() {\n listenersMap.set(this, []);\n abortedMap.set(this, false);\n }\n\n /**\n * Status of whether aborted or not.\n *\n * @readonly\n * @type {boolean}\n * @memberof AbortSignal\n */\n public get aborted(): boolean {\n if (!abortedMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n return abortedMap.get(this)!;\n }\n\n /**\n * Creates a new AbortSignal instance that will never be aborted.\n *\n * @readonly\n * @static\n * @type {AbortSignal}\n * @memberof AbortSignal\n */\n public static get none(): AbortSignal {\n return new AbortSignal();\n }\n\n /**\n * onabort event listener.\n *\n * @memberof AbortSignal\n */\n public onabort: ((ev?: Event) => any) | null = null;\n\n /**\n * Added new \"abort\" event listener, only support \"abort\" event.\n *\n * @param {\"abort\"} _type Only support \"abort\" event\n * @param {(this: AbortSignalLike, ev: any) => any} listener\n * @memberof AbortSignal\n */\n public addEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n listeners.push(listener);\n }\n\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n *\n * @param {\"abort\"} _type Only support \"abort\" event\n * @param {(this: AbortSignalLike, ev: any) => any} listener\n * @memberof AbortSignal\n */\n public removeEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n\n const index = listeners.indexOf(listener);\n if (index > -1) {\n listeners.splice(index, 1);\n }\n }\n\n /**\n * Dispatches a synthetic event to the AbortSignal.\n */\n dispatchEvent(_event: Event): boolean {\n throw new Error(\n \"This is a stub dispatchEvent implementation that should not be used. It only exists for type-checking purposes.\"\n );\n }\n}\n\n/**\n * Helper to trigger an abort event immediately, the onabort and all abort event listeners will be triggered.\n * Will try to trigger abort event for all linked AbortSignal nodes.\n *\n * - If there is a timeout, the timer will be cancelled.\n * - If aborted is true, nothing will happen.\n *\n * @returns\n * @internal\n */\nexport function abortSignal(signal: AbortSignal) {\n if (signal.aborted) {\n return;\n }\n\n if (signal.onabort) {\n signal.onabort.call(signal);\n }\n\n const listeners = listenersMap.get(signal)!;\n if (listeners) {\n listeners.forEach((listener) => {\n listener.call(signal, { type: \"abort\" });\n });\n }\n\n abortedMap.set(signal, true);\n}\n"]}
1
+ {"version":3,"file":"AbortSignal.js","sourceRoot":"","sources":["../../src/AbortSignal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,IAAM,YAAY,GAAG,IAAI,OAAO,EAAqC,CAAC;AACtE,IAAM,UAAU,GAAG,IAAI,OAAO,EAAwB,CAAC;AA6BvD;;;;;;;;;;;;GAYG;AACH;IACE;QA2BA;;WAEG;QACI,YAAO,GAAiC,IAAI,CAAC;QA7BlD,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3B,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAOD,sBAAW,gCAAO;QALlB;;;;WAIG;aACH;YACE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACzB,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;aAC1E;YAED,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QAC/B,CAAC;;;OAAA;IAOD,sBAAkB,mBAAI;QALtB;;;;WAIG;aACH;YACE,OAAO,IAAI,WAAW,EAAE,CAAC;QAC3B,CAAC;;;OAAA;IAOD;;;;;OAKG;IACI,sCAAgB,GAAvB;IACE,yCAAyC;IACzC,KAAc,EACd,QAAiD;QAEjD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC3B,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;SAC1E;QAED,IAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QAC1C,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACI,yCAAmB,GAA1B;IACE,yCAAyC;IACzC,KAAc,EACd,QAAiD;QAEjD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC3B,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;SAC1E;QAED,IAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QAE1C,IAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACd,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC5B;IACH,CAAC;IAED;;OAEG;IACH,mCAAa,GAAb,UAAc,MAAa;QACzB,MAAM,IAAI,KAAK,CACb,kHAAkH,CACnH,CAAC;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AAnFD,IAmFC;;AAED;;;;;;;;GAQG;AACH,wEAAwE;AACxE,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,OAAO;KACR;IAED,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC7B;IAED,IAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;IAC5C,IAAI,SAAS,EAAE;QACb,SAAS,CAAC,OAAO,CAAC,UAAC,QAAQ;YACzB,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;KACJ;IAED,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../shims-public.d.ts\" />\n\ntype AbortEventListener = (this: AbortSignalLike, ev?: any) => any;\n\nconst listenersMap = new WeakMap<AbortSignal, AbortEventListener[]>();\nconst abortedMap = new WeakMap<AbortSignal, boolean>();\n\n/**\n * Allows the request to be aborted upon firing of the \"abort\" event.\n * Compatible with the browser built-in AbortSignal and common polyfills.\n */\nexport interface AbortSignalLike {\n /**\n * Indicates if the signal has already been aborted.\n */\n readonly aborted: boolean;\n /**\n * Add new \"abort\" event listener, only support \"abort\" event.\n */\n addEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n */\n removeEventListener(\n type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any,\n options?: any\n ): void;\n}\n\n/**\n * An aborter instance implements AbortSignal interface, can abort HTTP requests.\n *\n * - Call AbortSignal.none to create a new AbortSignal instance that cannot be cancelled.\n * Use `AbortSignal.none` when you are required to pass a cancellation token but the operation\n * cannot or will not ever be cancelled.\n *\n * @example\n * Abort without timeout\n * ```ts\n * await doAsyncWork(AbortSignal.none);\n * ```\n */\nexport class AbortSignal implements AbortSignalLike {\n constructor() {\n listenersMap.set(this, []);\n abortedMap.set(this, false);\n }\n\n /**\n * Status of whether aborted or not.\n *\n * @readonly\n */\n public get aborted(): boolean {\n if (!abortedMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n return abortedMap.get(this)!;\n }\n\n /**\n * Creates a new AbortSignal instance that will never be aborted.\n *\n * @readonly\n */\n public static get none(): AbortSignal {\n return new AbortSignal();\n }\n\n /**\n * onabort event listener.\n */\n public onabort: ((ev?: Event) => any) | null = null;\n\n /**\n * Added new \"abort\" event listener, only support \"abort\" event.\n *\n * @param _type - Only support \"abort\" event\n * @param listener - The listener to be added\n */\n public addEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n listeners.push(listener);\n }\n\n /**\n * Remove \"abort\" event listener, only support \"abort\" event.\n *\n * @param _type - Only support \"abort\" event\n * @param listener - The listener to be removed\n */\n public removeEventListener(\n // tslint:disable-next-line:variable-name\n _type: \"abort\",\n listener: (this: AbortSignalLike, ev: any) => any\n ): void {\n if (!listenersMap.has(this)) {\n throw new TypeError(\"Expected `this` to be an instance of AbortSignal.\");\n }\n\n const listeners = listenersMap.get(this)!;\n\n const index = listeners.indexOf(listener);\n if (index > -1) {\n listeners.splice(index, 1);\n }\n }\n\n /**\n * Dispatches a synthetic event to the AbortSignal.\n */\n dispatchEvent(_event: Event): boolean {\n throw new Error(\n \"This is a stub dispatchEvent implementation that should not be used. It only exists for type-checking purposes.\"\n );\n }\n}\n\n/**\n * Helper to trigger an abort event immediately, the onabort and all abort event listeners will be triggered.\n * Will try to trigger abort event for all linked AbortSignal nodes.\n *\n * - If there is a timeout, the timer will be cancelled.\n * - If aborted is true, nothing will happen.\n *\n * @internal\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\nexport function abortSignal(signal: AbortSignal): void {\n if (signal.aborted) {\n return;\n }\n\n if (signal.onabort) {\n signal.onabort.call(signal);\n }\n\n const listeners = listenersMap.get(signal)!;\n if (listeners) {\n listeners.forEach((listener) => {\n listener.call(signal, { type: \"abort\" });\n });\n }\n\n abortedMap.set(signal, true);\n}\n"]}
@@ -1,3 +1,5 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
1
3
  // Changes to Aborter
2
4
  // * Rename Aborter to AbortSignal
3
5
  // * Remove withValue and getValue - async context should be solved differently/wholistically, not tied to cancellation
@@ -7,4 +9,4 @@
7
9
  // * dispatchEvent on Signal
8
10
  export { AbortController, AbortError } from "./AbortController";
9
11
  export { AbortSignal } from "./AbortSignal";
10
- //# sourceMappingURL=aborter.js.map
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,qBAAqB;AACrB,kCAAkC;AAClC,uHAAuH;AACvH,qDAAqD;AACrD,2GAA2G;AAE3G,2CAA2C;AAC3C,4BAA4B;AAE5B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// Changes to Aborter\n// * Rename Aborter to AbortSignal\n// * Remove withValue and getValue - async context should be solved differently/wholistically, not tied to cancellation\n// * Remove withTimeout, it's moved to the controller\n// * AbortSignal constructor no longer takes a parent. Cancellation graphs are created from the controller.\n\n// Potential changes to align with DOM Spec\n// * dispatchEvent on Signal\n\nexport { AbortController, AbortError } from \"./AbortController\";\nexport { AbortSignal, AbortSignalLike } from \"./AbortSignal\";\n"]}
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@azure/abort-controller",
3
3
  "sdk-type": "client",
4
- "version": "1.0.1-dev.20200728.1",
4
+ "version": "1.0.2",
5
5
  "description": "Microsoft Azure SDK for JavaScript - Aborter",
6
6
  "main": "./dist/index.js",
7
- "module": "./dist-esm/src/aborter.js",
7
+ "module": "dist-esm/src/index.js",
8
8
  "scripts": {
9
9
  "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
10
10
  "build:es6": "tsc -p tsconfig.json",
11
11
  "build:nodebrowser": "rollup -c 2>&1",
12
12
  "build:test": "rollup -c rollup.test.config.js 2>&1",
13
13
  "build": "npm run build:es6 && npm run build:nodebrowser",
14
- "check-format": "prettier --list-different --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
14
+ "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
15
15
  "clean": "rimraf dist dist-esm dist-test types temp dist-browser/*.js* dist-browser/*.zip statistics.html coverage coverage-browser .nyc_output *.tgz *.log test*.xml TEST*.xml",
16
16
  "execute:samples": "echo skipped",
17
17
  "extract-api": "tsc -p . && api-extractor run --local",
18
- "format": "prettier --write --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
18
+ "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
19
19
  "integration-test:browser": "echo skipped",
20
20
  "integration-test:node": "echo skipped",
21
21
  "integration-test": "npm run integration-test:node && npm run integration-test:browser",
22
- "lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.ts\" -c ../../.eslintrc.old.json --fix --fix-type [problem,suggestion]",
23
- "lint": "eslint -c ../../.eslintrc.old.json src test --ext .ts -f html -o abort-controller-lintReport.html || exit 0",
22
+ "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
23
+ "lint": "eslint package.json api-extractor.json src test --ext .ts",
24
24
  "pack": "npm pack 2>&1",
25
25
  "prebuild": "npm run clean",
26
26
  "pretest": "npm run build:test",
@@ -29,44 +29,49 @@
29
29
  "test": "npm run build:test && npm run unit-test && npm run integration-test",
30
30
  "unit-test:browser": "karma start --single-run",
31
31
  "unit-test:node": "cross-env TS_NODE_FILES=true TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\": \\\"commonjs\\\"}\" mocha --require ts-node/register --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace --no-timeouts test/*.spec.ts",
32
- "unit-test": "npm run unit-test:node && npm run unit-test:browser"
32
+ "unit-test": "npm run unit-test:node && npm run unit-test:browser",
33
+ "build:samples": "echo Skipped.",
34
+ "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --mode file --out ./dist/docs ./src"
33
35
  },
34
- "types": "./types/src/aborter.d.ts",
36
+ "types": "./types/src/index.d.ts",
35
37
  "engine": {
36
38
  "node": ">=8.0.0"
37
39
  },
38
40
  "files": [
39
41
  "dist/",
40
42
  "dist-esm/src/",
43
+ "shims-public.d.ts",
41
44
  "types/src",
42
45
  "README.md",
43
46
  "LICENSE"
44
47
  ],
45
- "repository": {
46
- "type": "git",
47
- "url": "git+https://github.com/Azure/azure-sdk-for-js.git"
48
+ "engines": {
49
+ "node": ">=8.0.0"
48
50
  },
51
+ "repository": "github:Azure/azure-sdk-for-js",
49
52
  "keywords": [
50
- "Azure",
51
- "Aborter",
52
- "AbortSignal",
53
- "Cancellation",
54
- "Node.js",
55
- "TypeScript",
56
- "JavaScript",
57
- "Browser"
53
+ "azure",
54
+ "aborter",
55
+ "abortsignal",
56
+ "cancellation",
57
+ "node.js",
58
+ "typescript",
59
+ "javascript",
60
+ "browser",
61
+ "cloud"
58
62
  ],
59
63
  "author": "Microsoft Corporation",
60
64
  "license": "MIT",
61
65
  "bugs": {
62
66
  "url": "https://github.com/Azure/azure-sdk-for-js/issues"
63
67
  },
64
- "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/abort-controller",
68
+ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/abort-controller/README.md",
65
69
  "sideEffects": false,
66
70
  "dependencies": {
67
71
  "tslib": "^2.0.0"
68
72
  },
69
73
  "devDependencies": {
74
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
70
75
  "@microsoft/api-extractor": "7.7.11",
71
76
  "@rollup/plugin-commonjs": "11.0.2",
72
77
  "@rollup/plugin-multi-entry": "^3.0.0",
@@ -74,16 +79,10 @@
74
79
  "@rollup/plugin-replace": "^2.2.0",
75
80
  "@types/mocha": "^7.0.2",
76
81
  "@types/node": "^8.0.0",
77
- "@typescript-eslint/eslint-plugin": "^2.0.0",
78
- "@typescript-eslint/parser": "^2.0.0",
79
82
  "assert": "^1.4.1",
80
83
  "cross-env": "^7.0.2",
81
84
  "delay": "^4.2.0",
82
- "eslint": "^6.1.0",
83
- "eslint-config-prettier": "^6.0.0",
84
- "eslint-plugin-no-null": "^1.0.2",
85
- "eslint-plugin-no-only-tests": "^2.3.0",
86
- "eslint-plugin-promise": "^4.1.1",
85
+ "eslint": "^7.15.0",
87
86
  "karma": "^5.1.0",
88
87
  "karma-chrome-launcher": "^3.0.0",
89
88
  "karma-coverage": "^2.0.0",
@@ -104,6 +103,7 @@
104
103
  "rollup-plugin-sourcemaps": "^0.4.2",
105
104
  "rollup-plugin-terser": "^5.1.1",
106
105
  "ts-node": "^8.3.0",
107
- "typescript": "~3.9.3"
106
+ "typescript": "4.1.2",
107
+ "typedoc": "0.15.0"
108
108
  }
109
109
  }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ // forward declaration of Event in case DOM libs are not present.
5
+ interface Event {}
@@ -5,6 +5,7 @@ import { AbortSignal, AbortSignalLike } from "./AbortSignal";
5
5
  * error matches `"AbortError"`.
6
6
  *
7
7
  * @example
8
+ * ```ts
8
9
  * const controller = new AbortController();
9
10
  * controller.abort();
10
11
  * try {
@@ -14,6 +15,7 @@ import { AbortSignal, AbortSignalLike } from "./AbortSignal";
14
15
  * // handle abort error here.
15
16
  * }
16
17
  * }
18
+ * ```
17
19
  */
18
20
  export declare class AbortError extends Error {
19
21
  constructor(message?: string);
@@ -23,43 +25,43 @@ export declare class AbortError extends Error {
23
25
  * that an asynchronous operation should be aborted.
24
26
  *
25
27
  * @example
26
- * // Abort an operation when another event fires
28
+ * Abort an operation when another event fires
29
+ * ```ts
27
30
  * const controller = new AbortController();
28
31
  * const signal = controller.signal;
29
32
  * doAsyncWork(signal);
30
33
  * button.addEventListener('click', () => controller.abort());
34
+ * ```
31
35
  *
32
36
  * @example
33
- * // Share aborter cross multiple operations in 30s
37
+ * Share aborter cross multiple operations in 30s
38
+ * ```ts
34
39
  * // Upload the same data to 2 different data centers at the same time,
35
40
  * // abort another when any of them is finished
36
41
  * const controller = AbortController.withTimeout(30 * 1000);
37
42
  * doAsyncWork(controller.signal).then(controller.abort);
38
43
  * doAsyncWork(controller.signal).then(controller.abort);
44
+ *```
39
45
  *
40
46
  * @example
41
- * // Cascaded aborting
47
+ * Cascaded aborting
48
+ * ```ts
42
49
  * // All operations can't take more than 30 seconds
43
50
  * const aborter = Aborter.timeout(30 * 1000);
44
51
  *
45
52
  * // Following 2 operations can't take more than 25 seconds
46
53
  * await doAsyncWork(aborter.withTimeout(25 * 1000));
47
54
  * await doAsyncWork(aborter.withTimeout(25 * 1000));
48
- *
49
- * @export
50
- * @class AbortController
51
- * @implements {AbortSignalLike}
55
+ * ```
52
56
  */
53
57
  export declare class AbortController {
54
58
  private _signal;
55
59
  /**
56
- * @param {AbortSignalLike[]} [parentSignals] The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
57
- * @constructor
60
+ * @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
58
61
  */
59
62
  constructor(parentSignals?: AbortSignalLike[]);
60
63
  /**
61
- * @param {...AbortSignalLike} parentSignals The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
62
- * @constructor
64
+ * @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
63
65
  */
64
66
  constructor(...parentSignals: AbortSignalLike[]);
65
67
  /**
@@ -67,23 +69,16 @@ export declare class AbortController {
67
69
  * when the abort method is called on this controller.
68
70
  *
69
71
  * @readonly
70
- * @type {AbortSignal}
71
- * @memberof AbortController
72
72
  */
73
73
  get signal(): AbortSignal;
74
74
  /**
75
75
  * Signal that any operations passed this controller's associated abort signal
76
76
  * to cancel any remaining work and throw an `AbortError`.
77
- *
78
- * @memberof AbortController
79
77
  */
80
78
  abort(): void;
81
79
  /**
82
80
  * Creates a new AbortSignal instance that will abort after the provided ms.
83
- *
84
- * @static
85
- * @params {number} ms Elapsed time in milliseconds to trigger an abort.
86
- * @returns {AbortSignal}
81
+ * @param ms - Elapsed time in milliseconds to trigger an abort.
87
82
  */
88
83
  static timeout(ms: number): AbortSignal;
89
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AbortController.d.ts","sourceRoot":"","sources":["../../src/AbortController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1E;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,CAAC,EAAE,MAAM;CAI7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAc;IAE7B;;;OAGG;gBACS,aAAa,CAAC,EAAE,eAAe,EAAE;IAC7C;;;OAGG;gBACS,GAAG,aAAa,EAAE,eAAe,EAAE;IAyB/C;;;;;;;OAOG;IACH,IAAW,MAAM,gBAEhB;IAED;;;;;OAKG;IACH,KAAK;IAIL;;;;;;OAMG;WACW,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW;CAS/C"}
1
+ {"version":3,"file":"AbortController.d.ts","sourceRoot":"","sources":["../../src/AbortController.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAe,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1E;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,CAAC,EAAE,MAAM;CAI7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAc;IAE7B;;OAEG;gBACS,aAAa,CAAC,EAAE,eAAe,EAAE;IAC7C;;OAEG;gBACS,GAAG,aAAa,EAAE,eAAe,EAAE;IA2B/C;;;;;OAKG;IACH,IAAW,MAAM,IAAI,WAAW,CAE/B;IAED;;;OAGG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;WACW,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW;CAS/C"}
@@ -1,4 +1,4 @@
1
- /// <reference path="../../src/shims-public.d.ts" />
1
+ /// <reference path="../../shims-public.d.ts" />
2
2
  /**
3
3
  * Allows the request to be aborted upon firing of the "abort" event.
4
4
  * Compatible with the browser built-in AbortSignal and common polyfills.
@@ -25,12 +25,10 @@ export interface AbortSignalLike {
25
25
  * cannot or will not ever be cancelled.
26
26
  *
27
27
  * @example
28
- * // Abort without timeout
28
+ * Abort without timeout
29
+ * ```ts
29
30
  * await doAsyncWork(AbortSignal.none);
30
- *
31
- * @export
32
- * @class AbortSignal
33
- * @implements {AbortSignalLike}
31
+ * ```
34
32
  */
35
33
  export declare class AbortSignal implements AbortSignalLike {
36
34
  constructor();
@@ -38,39 +36,30 @@ export declare class AbortSignal implements AbortSignalLike {
38
36
  * Status of whether aborted or not.
39
37
  *
40
38
  * @readonly
41
- * @type {boolean}
42
- * @memberof AbortSignal
43
39
  */
44
40
  get aborted(): boolean;
45
41
  /**
46
42
  * Creates a new AbortSignal instance that will never be aborted.
47
43
  *
48
44
  * @readonly
49
- * @static
50
- * @type {AbortSignal}
51
- * @memberof AbortSignal
52
45
  */
53
46
  static get none(): AbortSignal;
54
47
  /**
55
48
  * onabort event listener.
56
- *
57
- * @memberof AbortSignal
58
49
  */
59
50
  onabort: ((ev?: Event) => any) | null;
60
51
  /**
61
52
  * Added new "abort" event listener, only support "abort" event.
62
53
  *
63
- * @param {"abort"} _type Only support "abort" event
64
- * @param {(this: AbortSignalLike, ev: any) => any} listener
65
- * @memberof AbortSignal
54
+ * @param _type - Only support "abort" event
55
+ * @param listener - The listener to be added
66
56
  */
67
57
  addEventListener(_type: "abort", listener: (this: AbortSignalLike, ev: any) => any): void;
68
58
  /**
69
59
  * Remove "abort" event listener, only support "abort" event.
70
60
  *
71
- * @param {"abort"} _type Only support "abort" event
72
- * @param {(this: AbortSignalLike, ev: any) => any} listener
73
- * @memberof AbortSignal
61
+ * @param _type - Only support "abort" event
62
+ * @param listener - The listener to be removed
74
63
  */
75
64
  removeEventListener(_type: "abort", listener: (this: AbortSignalLike, ev: any) => any): void;
76
65
  /**
@@ -85,7 +74,6 @@ export declare class AbortSignal implements AbortSignalLike {
85
74
  * - If there is a timeout, the timer will be cancelled.
86
75
  * - If aborted is true, nothing will happen.
87
76
  *
88
- * @returns
89
77
  * @internal
90
78
  */
91
79
  export declare function abortSignal(signal: AbortSignal): void;
@@ -1 +1 @@
1
- {"version":3,"file":"AbortSignal.d.ts","sourceRoot":"","sources":["../../src/AbortSignal.ts"],"names":[],"mappings":";AAMA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,gBAAgB,CACd,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,GAAG,KAAK,GAAG,EACjD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI,CAAC;IACR;;OAEG;IACH,mBAAmB,CACjB,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,GAAG,KAAK,GAAG,EACjD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI,CAAC;CACT;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,WAAY,YAAW,eAAe;;IAMjD;;;;;;OAMG;IACH,IAAW,OAAO,IAAI,OAAO,CAM5B;IAED;;;;;;;OAOG;IACH,WAAkB,IAAI,IAAI,WAAW,CAEpC;IAED;;;;OAIG;IACI,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,CAAQ;IAEpD;;;;;;OAMG;IACI,gBAAgB,CAErB,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,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E,GAAG,KAAK,GAAG,GAChD,IAAI;IASP;;;;;OAKG;IACI,mBAAmB,CAExB,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,GAAG,KAAK,GAAG,GAChD,IAAI;IAaP;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO;CAKtC;AAED;;;;;;;;GAQG;AAEH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAiBrD"}
@@ -1,3 +1,3 @@
1
1
  export { AbortController, AbortError } from "./AbortController";
2
2
  export { AbortSignal, AbortSignalLike } from "./AbortSignal";
3
- //# sourceMappingURL=aborter.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"aborter.js","sourceRoot":"","sources":["../../src/aborter.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,kCAAkC;AAClC,uHAAuH;AACvH,qDAAqD;AACrD,2GAA2G;AAE3G,2CAA2C;AAC3C,4BAA4B;AAE5B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAC","sourcesContent":["// Changes to Aborter\n// * Rename Aborter to AbortSignal\n// * Remove withValue and getValue - async context should be solved differently/wholistically, not tied to cancellation\n// * Remove withTimeout, it's moved to the controller\n// * AbortSignal constructor no longer takes a parent. Cancellation graphs are created from the controller.\n\n// Potential changes to align with DOM Spec\n// * dispatchEvent on Signal\n\nexport { AbortController, AbortError } from \"./AbortController\";\nexport { AbortSignal, AbortSignalLike } from \"./AbortSignal\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"aborter.d.ts","sourceRoot":"","sources":["../../src/aborter.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}