@@ -9,7 +9,7 @@ var after = require('after');
9
9
var utf8 = require ( './utf8' ) ;
10
10
11
11
var base64encoder ;
12
- if ( global && global . ArrayBuffer ) {
12
+ if ( typeof ArrayBuffer !== 'undefined' ) {
13
13
base64encoder = require ( 'base64-arraybuffer' ) ;
14
14
}
15
15
@@ -101,9 +101,9 @@ exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
101
101
? undefined
102
102
: packet . data . buffer || packet . data ;
103
103
104
- if ( global . ArrayBuffer && data instanceof ArrayBuffer ) {
104
+ if ( typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer ) {
105
105
return encodeArrayBuffer ( packet , supportsBinary , callback ) ;
106
- } else if ( Blob && data instanceof global . Blob ) {
106
+ } else if ( typeof Blob !== 'undefined' && data instanceof Blob ) {
107
107
return encodeBlob ( packet , supportsBinary , callback ) ;
108
108
}
109
109
@@ -189,7 +189,7 @@ function encodeBlob(packet, supportsBinary, callback) {
189
189
190
190
exports . encodeBase64Packet = function ( packet , callback ) {
191
191
var message = 'b' + exports . packets [ packet . type ] ;
192
- if ( Blob && packet . data instanceof global . Blob ) {
192
+ if ( typeof Blob !== 'undefined' && packet . data instanceof Blob ) {
193
193
var fr = new FileReader ( ) ;
194
194
fr . onload = function ( ) {
195
195
var b64 = fr . result . split ( ',' ) [ 1 ] ;
@@ -210,7 +210,7 @@ exports.encodeBase64Packet = function(packet, callback) {
210
210
}
211
211
b64data = String . fromCharCode . apply ( null , basic ) ;
212
212
}
213
- message += global . btoa ( b64data ) ;
213
+ message += btoa ( b64data ) ;
214
214
return callback ( message ) ;
215
215
} ;
216
216
0 commit comments