Skip to content

Commit

Permalink
Merge pull request #58 from tjni/guard-base64-arraybuffer-require
Browse files Browse the repository at this point in the history
Require base64-arraybuffer module conditionally.
  • Loading branch information
darrachequesne authored Aug 5, 2016
2 parents 342f7d5 + c0d166b commit 073df34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
var keys = require('./keys');
var hasBinary = require('has-binary');
var sliceBuffer = require('arraybuffer.slice');
var base64encoder = require('base64-arraybuffer');
var after = require('after');
var utf8 = require('utf8');

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

/**
* Check if we are running an android browser. That requires us to use
* ArrayBuffer with polling transports...
Expand Down Expand Up @@ -262,7 +266,7 @@ exports.decodePacket = function (data, binaryType, utf8decode) {

exports.decodeBase64Packet = function(msg, binaryType) {
var type = packetslist[msg.charAt(0)];
if (!global.ArrayBuffer) {
if (!base64encoder) {
return { type: type, data: { base64: true, data: msg.substr(1) } };
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"after": "0.8.1",
"arraybuffer.slice": "0.0.6",
"base64-arraybuffer": "0.1.2",
"base64-arraybuffer": "0.1.5",
"blob": "0.0.4",
"has-binary": "0.1.6",
"utf8": "2.1.0"
Expand Down

0 comments on commit 073df34

Please sign in to comment.