mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
fix: import buffer into correct global/window
This commit is contained in:
parent
325c7b48ed
commit
5172c38913
14
sea.js
14
sea.js
@ -3,9 +3,7 @@
|
||||
/* UNBUILD */
|
||||
var root;
|
||||
if(typeof window !== "undefined"){ root = window }
|
||||
if(typeof Buffer === "undefined") {
|
||||
global.Buffer = require("buffer").Buffer
|
||||
}
|
||||
|
||||
if(typeof global !== "undefined"){ root = global }
|
||||
root = root || {};
|
||||
var console = root.console || {log: function(){}};
|
||||
@ -50,10 +48,12 @@
|
||||
})(USE, './https');
|
||||
|
||||
;USE(function(module){
|
||||
if(typeof global !== "undefined"){
|
||||
var g = global;
|
||||
g.btoa = function (data) { return Buffer.from(data, "binary").toString("base64"); };
|
||||
g.atob = function (data) { return Buffer.from(data, "base64").toString("binary"); };
|
||||
if(typeof Buffer === "undefined") {
|
||||
root.Buffer = require("buffer").Buffer
|
||||
}
|
||||
if(typeof btoa !== "undefined"){
|
||||
root.btoa = function (data) { return Buffer.from(data, "binary").toString("base64"); };
|
||||
root.atob = function (data) { return Buffer.from(data, "base64").toString("binary"); };
|
||||
}
|
||||
})(USE, './base64');
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
|
||||
if(typeof global !== "undefined"){
|
||||
var g = global;
|
||||
g.btoa = function (data) { return Buffer.from(data, "binary").toString("base64"); };
|
||||
g.atob = function (data) { return Buffer.from(data, "base64").toString("binary"); };
|
||||
if(typeof Buffer === "undefined") {
|
||||
root.Buffer = require("buffer").Buffer
|
||||
}
|
||||
if(typeof btoa !== "undefined"){
|
||||
root.btoa = function (data) { return Buffer.from(data, "binary").toString("base64"); };
|
||||
root.atob = function (data) { return Buffer.from(data, "base64").toString("binary"); };
|
||||
}
|
||||
|
@ -6,9 +6,6 @@
|
||||
|
||||
if(SEA.window){
|
||||
api.crypto = window.crypto || window.msCrypto || require('isomorphic-webcrypto');
|
||||
if(!api.crypto) {
|
||||
api.crypto = require('isomorphic-webcrypto');
|
||||
}
|
||||
api.subtle = (api.crypto||o).subtle || (api.crypto||o).webkitSubtle;
|
||||
api.TextEncoder = window.TextEncoder;
|
||||
api.TextDecoder = window.TextDecoder;
|
||||
|
Loading…
x
Reference in New Issue
Block a user