Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var after = require('after');
var utf8 = require('./utf8');

var base64encoder;
if (global && global.ArrayBuffer) {
if (typeof ArrayBuffer !== 'undefined') {
base64encoder = require('base64-arraybuffer');
}

Expand Down Expand Up @@ -101,9 +101,9 @@ exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
? undefined
: packet.data.buffer || packet.data;

if (global.ArrayBuffer && data instanceof ArrayBuffer) {
if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) {
return encodeArrayBuffer(packet, supportsBinary, callback);
} else if (Blob && data instanceof global.Blob) {
} else if (typeof Blob !== 'undefined' && data instanceof Blob) {
return encodeBlob(packet, supportsBinary, callback);
}

Expand Down Expand Up @@ -189,7 +189,7 @@ function encodeBlob(packet, supportsBinary, callback) {

exports.encodeBase64Packet = function(packet, callback) {
var message = 'b' + exports.packets[packet.type];
if (Blob && packet.data instanceof global.Blob) {
if (typeof Blob !== 'undefined' && packet.data instanceof Blob) {
var fr = new FileReader();
fr.onload = function() {
var b64 = fr.result.split(',')[1];
Expand All @@ -210,7 +210,7 @@ exports.encodeBase64Packet = function(packet, callback) {
}
b64data = String.fromCharCode.apply(null, basic);
}
message += global.btoa(b64data);
message += btoa(b64data);
return callback(message);
};

Expand Down