Skip to content

Commit ec16621

Browse files
committed
🎨 tweak browser.js/.mjs
1 parent 09fd3cd commit ec16621

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

browser.js

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
'use strict'
2-
// ref: https://github.com/tc39/proposal-global
3-
var getGlobal = function() {
4-
// the only reliable means to get the global object is
5-
// `Function('return this')()`
6-
// However, this causes CSP violations in Chrome apps.
7-
if (typeof self !== 'undefined') {
8-
return self
9-
}
10-
if (typeof window !== 'undefined') {
11-
return window
12-
}
13-
if (typeof global !== 'undefined') {
14-
return global
15-
}
16-
throw new Error('unable to locate global object')
17-
}
1+
/*globals self, window */
2+
"use strict"
183

19-
var global = getGlobal()
4+
/*eslint-disable @mysticatea/prettier */
5+
const { AbortController, AbortSignal } =
6+
typeof self !== "undefined" ? self :
7+
typeof window !== "undefined" ? window :
8+
/* otherwise */ undefined
9+
/*eslint-enable @mysticatea/prettier */
2010

21-
module.exports = exports = global.AbortController
22-
// Needed for TypeScript and Webpack.
23-
exports.default = global.AbortController
11+
module.exports = AbortController
12+
module.exports.AbortSignal = AbortSignal
13+
module.exports.default = AbortController

browser.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*globals self, window */
2+
3+
/*eslint-disable @mysticatea/prettier */
4+
const { AbortController, AbortSignal } =
5+
typeof self !== "undefined" ? self :
6+
typeof window !== "undefined" ? window :
7+
/* otherwise */ undefined
8+
/*eslint-enable @mysticatea/prettier */
9+
10+
export default AbortController
11+
export { AbortController, AbortSignal }

0 commit comments

Comments
 (0)