Skip to content

Commit

Permalink
New: add polyfill.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Oct 18, 2018
1 parent 2c88ae5 commit 3124d96
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "An implementation of WHATWG AbortController interface.",
"main": "dist/abort-controller",
"files": [
"dist"
"dist",
"polyfill.*"
],
"engines": {
"node": ">=4"
Expand Down
11 changes: 11 additions & 0 deletions polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*globals require */
const ac = require("./dist/abort-controller")

if (typeof window !== "undefined") {
if (typeof window.AbortController === "undefined") {
window.AbortController = ac.AbortController
}
if (typeof window.AbortSignal === "undefined") {
window.AbortSignal = ac.AbortSignal
}
}
10 changes: 10 additions & 0 deletions polyfill.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as ac from "./dist/abort-controller"

if (typeof window !== "undefined") {
if (typeof window.AbortController === "undefined") {
window.AbortController = ac.AbortController
}
if (typeof window.AbortSignal === "undefined") {
window.AbortSignal = ac.AbortSignal
}
}

0 comments on commit 3124d96

Please sign in to comment.