question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

map(atob) doesn't work without wrapper function

See original GitHub issue

RxJs version 5.5.2 (also in the docs page, in the console, same problem)

Code to reproduce:

Rx.Observable.of("eyJmaXJzdE5hbWUiOiJSYWZhbCIsImxhc3ROYW1lIjoiTWFzemtvd3NraSIsImVtYWlsIjoidGVzdEB0ZXN0LnBsIiwidG9rZW4iOiJ0b2tlbiJ9")
.map(atob)
.subscribe(console.log);

Expected behavior: should log "{"firstName":"Rafal","lastName":"Maszkowski","email":"test@test.pl","token":"token"}"

Actual behavior: logs error: Uncaught TypeError: Illegal invocation at eval (eval at MapSubscriber._next (0-Rx.js:5709)

Additional information: the problem I found in the source code is in MapSubscriber. The project function this.project is called via this.project.call(this.thisArg, value, this.count++); but atob doesn’t work if the thisArg isn’t null/undefined/window.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dengwanccommented, Mar 7, 2018

the correct way is

Rx.Observable.of("eyJmaXJzdE5hbWUiOiJSYWZhbCIsImxhc3ROYW1lIjoiTWFzemtvd3NraSIsImVtYWlsIjoidGVzdEB0ZXN0LnBsIiwidG9rZW4iOiJ0b2tlbiJ9")
.map(i => atob(i))
.subscribe(console.log);

could close this issue @kwonoj

0reactions
lock[bot]commented, Jun 5, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Javascript's atob to decode base64 doesn't properly ...
Show activity on this post. I'm using the Javascript window. atob() function to decode a base64-encoded string (specifically the base64-encoded ...
Read more >
Window atob() Method - W3Schools
Note. The atob() method decodes a string that has been encoded by the btoa() method.
Read more >
atob() - Web APIs - MDN Web Docs
The atob() function decodes a string of data which has been encoded using Base64 encoding. You can use the btoa() method to encode...
Read more >
Map with Driving Route from A to B - JSFiddle
<p>Request a driving route from A to B and display it on the map</p> ... This function will be called once the Routing...
Read more >
Master map, compactMap, flatMap, reduce and filter by ...
We're going to be extending Array without own version of these higher-order functions. We can do that because the standard library does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found