Skip to content

Commit

Permalink
Bump version, update js-binarypack with remove unused check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Garcia committed Jul 6, 2015
1 parent ed1c11b commit db0e788
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 84 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Client


## Changelog
0.2.2

- Update js-binarypack to 0.0.9, removed unused check.

0.2.1

- Update js-binarypack to 0.0.7, fast utf8 support now on by default.
Expand Down
3 changes: 1 addition & 2 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ var starttagIF = '// if node'
*/

var base = [
'../deps/js-binarypack/lib/bufferbuilder.js'
, '../deps/js-binarypack/lib/binarypack.js'
'../deps/js-binarypack/dist/binarypack.js'
, '../deps/EventEmitter/EventEmitter.js'
, 'util.js'
, 'client/stream.js'
Expand Down
2 changes: 1 addition & 1 deletion deps/js-binarypack
162 changes: 84 additions & 78 deletions dist/binary.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,10 @@
/*! binary.js build:0.2.1, development. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */
/*! binary.js build:0.2.2, development. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */
(function(exports){
var binaryFeatures = {};
binaryFeatures.useBlobBuilder = (function(){
try {
new Blob([]);
return false;
} catch (e) {
return true;
}
})();
/*! binarypack.js build:0.0.9, production. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var BufferBuilder = require('./bufferbuilder').BufferBuilder;
var binaryFeatures = require('./bufferbuilder').binaryFeatures;

binaryFeatures.useArrayBufferView = !binaryFeatures.useBlobBuilder && (function(){
try {
return (new Blob([new Uint8Array([])])).size === 0;
} catch (e) {
return true;
}
})();
binaryFeatures.supportsBinaryWebsockets = (function(){
try {
var wstest = new WebSocket('ws://null');
wstest.onerror = function(){};
if (typeof(wstest.binaryType) !== "undefined") {
return true;
} else {
return false;
}
wstest.close();
wstest = null;
} catch (e) {
return false;
}
})();

exports.binaryFeatures = binaryFeatures;
exports.BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder;

function BufferBuilder(){
this._pieces = [];
this._parts = [];
}

BufferBuilder.prototype.append = function(data) {
if(typeof data === 'number') {
this._pieces.push(data);
} else {
this.flush();
this._parts.push(data);
}
};

BufferBuilder.prototype.flush = function() {
if (this._pieces.length > 0) {
var buf = new Uint8Array(this._pieces);
if(!binaryFeatures.useArrayBufferView) {
buf = buf.buffer;
}
this._parts.push(buf);
this._pieces = [];
}
};

BufferBuilder.prototype.getBuffer = function() {
this.flush();
if(binaryFeatures.useBlobBuilder) {
var builder = new BlobBuilder();
for(var i = 0, ii = this._parts.length; i < ii; i++) {
builder.append(this._parts[i]);
}
return builder.getBlob();
} else {
return new Blob(this._parts);
}
};
exports.BinaryPack = {
var BinaryPack = {
unpack: function(data){
var unpacker = new Unpacker(data);
return unpacker.unpack();
Expand All @@ -86,6 +17,8 @@ exports.BinaryPack = {
}
};

module.exports = BinaryPack;

function Unpacker (data){
// Data is ArrayBuffer
this.index = 0;
Expand All @@ -94,7 +27,6 @@ function Unpacker (data){
this.length = this.dataBuffer.byteLength;
}


Unpacker.prototype.unpack = function(){
var type = this.unpack_uint8();
if (type < 0x80){
Expand Down Expand Up @@ -400,7 +332,6 @@ Packer.prototype.pack_bin = function(blob){
this.pack_uint32(length);
} else{
throw new Error('Invalid length');
return;
}
this.bufferBuilder.append(blob);
}
Expand All @@ -418,7 +349,6 @@ Packer.prototype.pack_string = function(str){
this.pack_uint32(length);
} else{
throw new Error('Invalid length');
return;
}
this.bufferBuilder.append(str);
}
Expand Down Expand Up @@ -590,6 +520,82 @@ function utf8Length(str){
return str.replace(/[^\u0000-\u007F]/g, _utf8Replace).length;
}
}

},{"./bufferbuilder":2}],2:[function(require,module,exports){
var binaryFeatures = {};
binaryFeatures.useBlobBuilder = (function(){
try {
new Blob([]);
return false;
} catch (e) {
return true;
}
})();

binaryFeatures.useArrayBufferView = !binaryFeatures.useBlobBuilder && (function(){
try {
return (new Blob([new Uint8Array([])])).size === 0;
} catch (e) {
return true;
}
})();

module.exports.binaryFeatures = binaryFeatures;
var BlobBuilder = module.exports.BlobBuilder;
if (typeof window != 'undefined') {
BlobBuilder = module.exports.BlobBuilder = window.WebKitBlobBuilder ||
window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder;
}

function BufferBuilder(){
this._pieces = [];
this._parts = [];
}

BufferBuilder.prototype.append = function(data) {
if(typeof data === 'number') {
this._pieces.push(data);
} else {
this.flush();
this._parts.push(data);
}
};

BufferBuilder.prototype.flush = function() {
if (this._pieces.length > 0) {
var buf = new Uint8Array(this._pieces);
if(!binaryFeatures.useArrayBufferView) {
buf = buf.buffer;
}
this._parts.push(buf);
this._pieces = [];
}
};

BufferBuilder.prototype.getBuffer = function() {
this.flush();
if(binaryFeatures.useBlobBuilder) {
var builder = new BlobBuilder();
for(var i = 0, ii = this._parts.length; i < ii; i++) {
builder.append(this._parts[i]);
}
return builder.getBlob();
} else {
return new Blob(this._parts);
}
};

module.exports.BufferBuilder = BufferBuilder;

},{}],3:[function(require,module,exports){
var BufferBuilderExports = require('./bufferbuilder');

window.BufferBuilder = BufferBuilderExports.BufferBuilder;
window.binaryFeatures = BufferBuilderExports.binaryFeatures;
window.BlobBuilder = BufferBuilderExports.BlobBuilder;
window.BinaryPack = require('./binarypack');

},{"./binarypack":1,"./bufferbuilder":2}]},{},[3]);
/**
* Light EventEmitter. Ported from Node.js/events.js
* Eric Zhang
Expand Down Expand Up @@ -629,7 +635,7 @@ EventEmitter.prototype.addListener = function(type, listener, scope, once) {
// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
}
return this;

};

EventEmitter.prototype.on = EventEmitter.prototype.addListener;
Expand Down
Loading

0 comments on commit db0e788

Please sign in to comment.