@@ -17,6 +17,101 @@ The objects listed here are specific to Node.js. There are [built-in objects][]
1717that are part of the JavaScript language itself, which are also globally
1818accessible.
1919
20+ ## Class: ` AbortController `   
21+ <!-- YAML
22+ added: REPLACEME 
23+ --> 
24+ 
25+ >  Stability: 1 - Experimental
26+ 
27+ <!--  type=global --> 
28+ 
29+ A utility class used to signal cancelation in selected ` Promise ` -based APIs.
30+ The API is based on the Web API [ ` AbortController ` ] [ ] .
31+ 
32+ To use, launch Node.js using the ` --experimental-abortcontroller `  flag.
33+ 
34+ ``` js 
35+ const  ac  =  new  AbortController ();
36+ 
37+ ac .signal .addEventListener (' abort' =>  console .log (' Aborted!' 
38+                            { once:  true  });
39+ 
40+ ac .abort ();
41+ 
42+ console .log (ac .signal .aborted );  //  Prints True
43+ ``` 
44+ 
45+ ### ` abortController.abort() `  
46+ <!--  YAML
47+ added: REPLACEME 
48+ --> 
49+ 
50+ Triggers the abort signal, causing the ` abortController.signal `  to emit
51+ the ` 'abort' `  event.
52+ 
53+ ### ` abortController.signal `  
54+ <!--  YAML
55+ added: REPLACEME 
56+ --> 
57+ 
58+ *  Type: {AbortSignal}
59+ 
60+ ### Class: ` AbortSignal extends EventTarget `   
61+ <!--  YAML
62+ added: REPLACEME 
63+ --> 
64+ 
65+ The ` AbortSignal `  is used to notify observers when the
66+ ` abortController.abort() `  method is called.
67+ 
68+ #### Event: ` 'abort' `   
69+ <!--  YAML
70+ added: REPLACEME 
71+ --> 
72+ 
73+ The ` 'abort' `  event is emitted when the ` abortController.abort() `  method
74+ is called. The callback is invoked with a single object argument with a
75+ single ` type `  propety set to ` 'abort' ` :
76+ 
77+ ``` js 
78+ const  ac  =  new  AbortController ();
79+ 
80+ //  Use either the onabort property...
81+ ac .signal .onabort  =  () =>  console .log (' aborted!' 
82+ 
83+ //  Or the EventTarget API...
84+ ac .signal .addEventListener (' abort' event ) =>  {
85+   console .log (event .type );  //  Prints 'abort'
86+ }, { once:  true  });
87+ 
88+ ac .abort ();
89+ ``` 
90+ 
91+ The ` AbortController `  with which the ` AbortSignal `  is associated will only
92+ ever trigger the ` 'abort' `  event once. Any event listeners attached to the
93+ ` AbortSignal `  * should*  use the ` { once: true } `  option (or, if using the
94+ ` EventEmitter `  APIs to attach a listener, use the ` once() `  method) to ensure
95+ that the event listener is removed as soon as the ` 'abort' `  event is handled.
96+ Failure to do so may result in memory leaks.
97+ 
98+ #### ` abortSignal.aborted `  
99+ <!--  YAML
100+ added: REPLACEME 
101+ --> 
102+ 
103+ *  Type: {boolean} True after the ` AbortController `  has been aborted.
104+ 
105+ #### ` abortSignal.onabort `  
106+ <!--  YAML
107+ added: REPLACEME 
108+ --> 
109+ 
110+ *  Type: {Function}
111+ 
112+ An optional callback function that may be set by user code to be notified
113+ when the ` abortController.abort() `  function has been called.
114+ 
20115## Class: ` Buffer `   
21116<!--  YAML
22117added: v0.1.103 
@@ -226,6 +321,7 @@ The object that acts as the namespace for all W3C
226321[ WebAssembly] [ webassembly-org ]  related functionality. See the
227322[ Mozilla Developer Network] [ webassembly-mdn ]  for usage and compatibility.
228323
324+ [ `AbortController` ] : https://developer.mozilla.org/en-US/docs/Web/API/AbortController 
229325[ `TextDecoder` ] : util.html#util_class_util_textdecoder 
230326[ `TextEncoder` ] : util.html#util_class_util_textencoder 
231327[ `URLSearchParams` ] : url.html#url_class_urlsearchparams 
0 commit comments