Skip to content

Commit ebbd5ea

Browse files
committed
📝 update README.md
1 parent ca4cdbd commit ebbd5ea

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Or download from [`dist` directory](./dist).
3939

4040
## 📖 Usage
4141

42+
### Basic
43+
4244
```js
4345
import AbortController from "abort-controller"
4446
// or
@@ -48,15 +50,30 @@ const AbortController = require("abort-controller")
4850
const AbortController = window.AbortControllerShim
4951
```
5052

51-
### AbortController
53+
If your bundler recognizes `browser` field of `package.json`, the imported `AbortController` is the native one and it doesn't contain shim (even if the native implementation was nothing).
54+
If you wanted to polyfill `AbortController` for IE, use `abort-controller/polyfill`.
55+
56+
### Polyfilling
57+
58+
Importing `abort-controller/polyfill` assigns the `AbortController` shim to the `AbortController` global variable if the native implementation was nothing.
59+
60+
```js
61+
import "abort-controller/polyfill"
62+
// or
63+
require("abort-controller/polyfill")
64+
```
65+
66+
### API
67+
68+
#### AbortController
5269

5370
> https://dom.spec.whatwg.org/#interface-abortcontroller
5471
55-
#### controller.signal
72+
##### controller.signal
5673

5774
The [AbortSignal](https://dom.spec.whatwg.org/#interface-AbortSignal) object which is associated to this controller.
5875

59-
#### controller.abort()
76+
##### controller.abort()
6077

6178
Notify `abort` event to listeners that the `signal` has.
6279

0 commit comments

Comments
 (0)