Skip to content

Commit 8679648

Browse files
curranantfu
andauthored
feat: support Web Workers by using the global btoa (#269)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent 5bfb56d commit 8679648

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"globals": {
2828
"DEBUG": true,
2929
"process": true,
30-
"Buffer": true
30+
"Buffer": true,
31+
"globalThis": true,
3132
},
3233
"extends": "eslint:recommended",
3334
"parserOptions": {

src/SourceMap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { encode } from '@jridgewell/sourcemap-codec';
22

33
function getBtoa() {
4-
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
5-
return (str) => window.btoa(unescape(encodeURIComponent(str)));
4+
if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
5+
return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
66
} else if (typeof Buffer === 'function') {
77
return (str) => Buffer.from(str, 'utf-8').toString('base64');
88
} else {

0 commit comments

Comments
 (0)