Skip to content

Commit

Permalink
fix: only include buffer if no btoa/atob
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpy committed Nov 29, 2019
1 parent ef49a73 commit b2709e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sea.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
})(USE, './https');

;USE(function(module){
if(typeof Buffer === "undefined") {
root.Buffer = require("buffer").Buffer
}
if(typeof btoa === "undefined"){
if(typeof Buffer === "undefined") {
root.Buffer = require("buffer").Buffer
}
root.btoa = function (data) { return Buffer.from(data, "binary").toString("base64"); };
root.atob = function (data) { return Buffer.from(data, "base64").toString("binary"); };
}
Expand Down
6 changes: 3 additions & 3 deletions sea/base64.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

if(typeof Buffer === "undefined") {
root.Buffer = require("buffer").Buffer
}
if(typeof btoa === "undefined"){
if(typeof Buffer === "undefined") {
root.Buffer = require("buffer").Buffer
}
root.btoa = function (data) { return Buffer.from(data, "binary").toString("base64"); };
root.atob = function (data) { return Buffer.from(data, "base64").toString("binary"); };
}
Expand Down

1 comment on commit b2709e2

@mhelander
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This to my understanding works under NodeJS control. How well it plays in browser and/or transpilers, dunno.

Please sign in to comment.