1
0

Does not work in web worker #5

aberta(s)
2020-06-12 08:17:58 +00:00 aberta(s) por Ghost · 5 comentários

error message:

Uncaught ReferenceError: window is not defined
browser-atob.js:44
error message: ``` Uncaught ReferenceError: window is not defined browser-atob.js:44 ```
Proprietário(a)

Can you propose a solution?

Is atob defined on... self or whatever it is that workers have?

Does globalThis work?

Can you propose a solution? Is `atob` defined on... `self` or whatever it is that workers have? Does `globalThis` work?
Autor(a)
module.exports = function _atob(str) {
  return atob(str)
}

just with the function name works for me (both browser and web work)

reference:
https://caniuse.com/#search=atob

https://github.com/hughsk/atob-lite/blob/master/atob-browser.js

``` module.exports = function _atob(str) { return atob(str) } ``` just with the function name works for me (both browser and web work) reference: https://caniuse.com/#search=atob https://github.com/hughsk/atob-lite/blob/master/atob-browser.js
Proprietário(a)

How about just put var window = self; in your WebWorker script?

So many things depend on this and it is so abused by things like webpack and browserify, etc, etc that I don't want to rock the boat.

How about just put `var window = self;` in your WebWorker script? So many things depend on this and it is so abused by things like webpack and browserify, etc, etc that I don't want to rock the boat.
Proprietário(a)

I could release a version 3 that uses something like:

'undefined' !== typeof window ? window : 'undefined' !== typeof self ? self : golablThis
I could release a version 3 that uses something like: ```js 'undefined' !== typeof window ? window : 'undefined' !== typeof self ? self : golablThis ```
Autor(a)

That seems make sense. Thanks!

That seems make sense. Thanks!
Inicie a sessão para participar neste diálogo.
Sem rótulo
2 Participantes
Notificações
Data de vencimento
Sem data de vencimento definida.
Dependências

Não estão definidas dependências.

Referência: coolaj86/atob.js#5
Nenhuma descrição fornecida.