Template Upload
This commit is contained in:
127
node_modules/socket.io-parser/History.md
generated
vendored
Normal file
127
node_modules/socket.io-parser/History.md
generated
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
|
||||
2.3.1 / 2016-10-24
|
||||
==================
|
||||
|
||||
* [chore] Revert "Remove deprecated isarray dependency" (#50)
|
||||
|
||||
2.3.0 / 2016-10-21
|
||||
==================
|
||||
|
||||
* [perf] Split try catch into separate function (#40)
|
||||
* [chore] remove browsers setting from .zuul.yml (#34)
|
||||
* [chore] bump zuul (#37)
|
||||
* [chore] Bump zuul to 3.11.0 & zuul-ngrok to 4.0.0 (#41)
|
||||
* [chore] Update zuul browser settings following EOL notices (#42)
|
||||
* [chore] Restrict files included in npm package (#45)
|
||||
* [chore] Update zuul browser settings (#44)
|
||||
* [chore] Remove deprecated isarray dependency (#46)
|
||||
* [chore] Make the build status badge point towards master (#47)
|
||||
* [chore] Move benchmark to dev dependencies (#48)
|
||||
|
||||
2.2.6 / 2015-11-25
|
||||
==================
|
||||
|
||||
* fix the order of exported events [chylli]
|
||||
|
||||
2.2.5 / 2015-11-21
|
||||
==================
|
||||
|
||||
* package: bump debug
|
||||
* update JSON3 to 3.3.2
|
||||
|
||||
2.2.4 / 2015-03-03
|
||||
==================
|
||||
|
||||
* index: fix off-by-one bound checks
|
||||
|
||||
2.2.3 / 2015-02-03
|
||||
==================
|
||||
|
||||
* index: fix potential infinite loop with malicious binary packet
|
||||
|
||||
2.2.2 / 2014-09-04
|
||||
==================
|
||||
|
||||
* prevent direct `Buffer` reference that breaks browserify
|
||||
* binary: reuse `isBuf` helper
|
||||
|
||||
2.2.1 / 2014-06-20
|
||||
==================
|
||||
|
||||
* added benchmarking [kevin-roark]
|
||||
* upgrade component-emitter to 1.1.2 [kevin-roark]
|
||||
* update protocol version [kevin-roark]
|
||||
* less indentation and a small optimization [kevin-roark]
|
||||
|
||||
2.2.0 / 2014-05-30
|
||||
==================
|
||||
|
||||
* added a BINARY_ACK type [kevin-roark]
|
||||
|
||||
2.1.5 / 2014-05-24
|
||||
==================
|
||||
|
||||
* don't iterate keys of `Date` objects [Rase-]
|
||||
|
||||
2.1.4 / 2014-05-17
|
||||
==================
|
||||
|
||||
* fix null reconstruction bug [kevin-roark]
|
||||
|
||||
2.1.3 / 2014-04-27
|
||||
==================
|
||||
|
||||
* bump zuul version
|
||||
* updated protocol version
|
||||
|
||||
2.1.2 / 2014-03-06
|
||||
==================
|
||||
|
||||
* added support for binary in ACK packets
|
||||
|
||||
2.1.1 / 2014-03-04
|
||||
==================
|
||||
|
||||
* removed has-binary-data dependency
|
||||
* fixed the object check in binary.removeBlobs
|
||||
|
||||
2.1.0 / 2014-03-01
|
||||
==================
|
||||
|
||||
* faster and smaller binary parser and protocol [kevin-roark]
|
||||
|
||||
2.0.0 / 2014-02-19
|
||||
==================
|
||||
|
||||
* binary support [kevin-roark]
|
||||
|
||||
1.1.2 / 2014-02-11
|
||||
==================
|
||||
|
||||
* package: bump `json3` to fix IE6-7
|
||||
|
||||
1.1.1 / 2014-02-10
|
||||
==================
|
||||
|
||||
* package: bump debug to fix browserify issues
|
||||
|
||||
1.1.0 / 2013-12-25
|
||||
==================
|
||||
|
||||
* index: use `json3`
|
||||
|
||||
1.0.3 / 2012-12-18
|
||||
==================
|
||||
|
||||
* index: added instrumentation through `debug`
|
||||
* index: make sure decoded `id` is a `Number`
|
||||
|
||||
1.0.2 / 2012-12-18
|
||||
==================
|
||||
|
||||
* index: allow for falsy values in `id` and `data`
|
||||
|
||||
1.0.1 / 2012-12-10
|
||||
==================
|
||||
|
||||
* Revision 1
|
20
node_modules/socket.io-parser/LICENSE
generated
vendored
Normal file
20
node_modules/socket.io-parser/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Guillermo Rauch <guillermo@learnboost.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the 'Software'), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
73
node_modules/socket.io-parser/Readme.md
generated
vendored
Normal file
73
node_modules/socket.io-parser/Readme.md
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
# socket.io-parser
|
||||
|
||||
[](http://travis-ci.org/socketio/socket.io-parser)
|
||||
[](http://badge.fury.io/js/socket.io-parser)
|
||||
|
||||
A socket.io encoder and decoder written in JavaScript complying with version `3`
|
||||
of [socket.io-protocol](https://github.com/socketio/socket.io-protocol).
|
||||
Used by [socket.io](https://github.com/automattic/socket.io) and
|
||||
[socket.io-client](https://github.com/automattic/socket.io-client).
|
||||
|
||||
## Parser API
|
||||
|
||||
socket.io-parser is the reference implementation of socket.io-protocol. Read
|
||||
the full API here:
|
||||
[socket.io-protocol](https://github.com/learnboost/socket.io-protocol).
|
||||
|
||||
## Example Usage
|
||||
|
||||
### Encoding and decoding a packet
|
||||
|
||||
```js
|
||||
var parser = require('socket.io-parser');
|
||||
var encoder = new parser.Encoder();
|
||||
var packet = {
|
||||
type: parser.EVENT,
|
||||
data: 'test-packet',
|
||||
id: 13
|
||||
};
|
||||
encoder.encode(packet, function(encodedPackets) {
|
||||
var decoder = new parser.Decoder();
|
||||
decoder.on('decoded', function(decodedPacket) {
|
||||
// decodedPacket.type == parser.EVENT
|
||||
// decodedPacket.data == 'test-packet'
|
||||
// decodedPacket.id == 13
|
||||
});
|
||||
|
||||
for (var i = 0; i < encodedPackets.length; i++) {
|
||||
decoder.add(encodedPackets[i]);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Encoding and decoding a packet with binary data
|
||||
|
||||
```js
|
||||
var parser = require('socket.io-parser');
|
||||
var encoder = new parser.Encoder();
|
||||
var packet = {
|
||||
type: parser.BINARY_EVENT,
|
||||
data: {i: new Buffer(1234), j: new Blob([new ArrayBuffer(2)])}
|
||||
id: 15
|
||||
};
|
||||
encoder.encode(packet, function(encodedPackets) {
|
||||
var decoder = new parser.Decoder();
|
||||
decoder.on('decoded', function(decodedPacket) {
|
||||
// decodedPacket.type == parser.BINARY_EVENTEVENT
|
||||
// Buffer.isBuffer(decodedPacket.data.i) == true
|
||||
// Buffer.isBuffer(decodedPacket.data.j) == true
|
||||
// decodedPacket.id == 15
|
||||
});
|
||||
|
||||
for (var i = 0; i < encodedPackets.length; i++) {
|
||||
decoder.add(encodedPackets[i]);
|
||||
}
|
||||
});
|
||||
```
|
||||
See the test suite for more examples of how socket.io-parser is used.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
141
node_modules/socket.io-parser/binary.js
generated
vendored
Normal file
141
node_modules/socket.io-parser/binary.js
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
/*global Blob,File*/
|
||||
|
||||
/**
|
||||
* Module requirements
|
||||
*/
|
||||
|
||||
var isArray = require('isarray');
|
||||
var isBuf = require('./is-buffer');
|
||||
|
||||
/**
|
||||
* Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
|
||||
* Anything with blobs or files should be fed through removeBlobs before coming
|
||||
* here.
|
||||
*
|
||||
* @param {Object} packet - socket.io event packet
|
||||
* @return {Object} with deconstructed packet and list of buffers
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.deconstructPacket = function(packet){
|
||||
var buffers = [];
|
||||
var packetData = packet.data;
|
||||
|
||||
function _deconstructPacket(data) {
|
||||
if (!data) return data;
|
||||
|
||||
if (isBuf(data)) {
|
||||
var placeholder = { _placeholder: true, num: buffers.length };
|
||||
buffers.push(data);
|
||||
return placeholder;
|
||||
} else if (isArray(data)) {
|
||||
var newData = new Array(data.length);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
newData[i] = _deconstructPacket(data[i]);
|
||||
}
|
||||
return newData;
|
||||
} else if ('object' == typeof data && !(data instanceof Date)) {
|
||||
var newData = {};
|
||||
for (var key in data) {
|
||||
newData[key] = _deconstructPacket(data[key]);
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
var pack = packet;
|
||||
pack.data = _deconstructPacket(packetData);
|
||||
pack.attachments = buffers.length; // number of binary 'attachments'
|
||||
return {packet: pack, buffers: buffers};
|
||||
};
|
||||
|
||||
/**
|
||||
* Reconstructs a binary packet from its placeholder packet and buffers
|
||||
*
|
||||
* @param {Object} packet - event packet with placeholders
|
||||
* @param {Array} buffers - binary buffers to put in placeholder positions
|
||||
* @return {Object} reconstructed packet
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.reconstructPacket = function(packet, buffers) {
|
||||
var curPlaceHolder = 0;
|
||||
|
||||
function _reconstructPacket(data) {
|
||||
if (data && data._placeholder) {
|
||||
var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway)
|
||||
return buf;
|
||||
} else if (isArray(data)) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
data[i] = _reconstructPacket(data[i]);
|
||||
}
|
||||
return data;
|
||||
} else if (data && 'object' == typeof data) {
|
||||
for (var key in data) {
|
||||
data[key] = _reconstructPacket(data[key]);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
packet.data = _reconstructPacket(packet.data);
|
||||
packet.attachments = undefined; // no longer useful
|
||||
return packet;
|
||||
};
|
||||
|
||||
/**
|
||||
* Asynchronously removes Blobs or Files from data via
|
||||
* FileReader's readAsArrayBuffer method. Used before encoding
|
||||
* data as msgpack. Calls callback with the blobless data.
|
||||
*
|
||||
* @param {Object} data
|
||||
* @param {Function} callback
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.removeBlobs = function(data, callback) {
|
||||
function _removeBlobs(obj, curKey, containingObject) {
|
||||
if (!obj) return obj;
|
||||
|
||||
// convert any blob
|
||||
if ((global.Blob && obj instanceof Blob) ||
|
||||
(global.File && obj instanceof File)) {
|
||||
pendingBlobs++;
|
||||
|
||||
// async filereader
|
||||
var fileReader = new FileReader();
|
||||
fileReader.onload = function() { // this.result == arraybuffer
|
||||
if (containingObject) {
|
||||
containingObject[curKey] = this.result;
|
||||
}
|
||||
else {
|
||||
bloblessData = this.result;
|
||||
}
|
||||
|
||||
// if nothing pending its callback time
|
||||
if(! --pendingBlobs) {
|
||||
callback(bloblessData);
|
||||
}
|
||||
};
|
||||
|
||||
fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer
|
||||
} else if (isArray(obj)) { // handle array
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
_removeBlobs(obj[i], i, obj);
|
||||
}
|
||||
} else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object
|
||||
for (var key in obj) {
|
||||
_removeBlobs(obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pendingBlobs = 0;
|
||||
var bloblessData = data;
|
||||
_removeBlobs(bloblessData);
|
||||
if (!pendingBlobs) {
|
||||
callback(bloblessData);
|
||||
}
|
||||
};
|
404
node_modules/socket.io-parser/index.js
generated
vendored
Normal file
404
node_modules/socket.io-parser/index.js
generated
vendored
Normal file
@ -0,0 +1,404 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var debug = require('debug')('socket.io-parser');
|
||||
var json = require('json3');
|
||||
var Emitter = require('component-emitter');
|
||||
var binary = require('./binary');
|
||||
var isBuf = require('./is-buffer');
|
||||
|
||||
/**
|
||||
* Protocol version.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.protocol = 4;
|
||||
|
||||
/**
|
||||
* Packet types.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.types = [
|
||||
'CONNECT',
|
||||
'DISCONNECT',
|
||||
'EVENT',
|
||||
'ACK',
|
||||
'ERROR',
|
||||
'BINARY_EVENT',
|
||||
'BINARY_ACK'
|
||||
];
|
||||
|
||||
/**
|
||||
* Packet type `connect`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.CONNECT = 0;
|
||||
|
||||
/**
|
||||
* Packet type `disconnect`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.DISCONNECT = 1;
|
||||
|
||||
/**
|
||||
* Packet type `event`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.EVENT = 2;
|
||||
|
||||
/**
|
||||
* Packet type `ack`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.ACK = 3;
|
||||
|
||||
/**
|
||||
* Packet type `error`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.ERROR = 4;
|
||||
|
||||
/**
|
||||
* Packet type 'binary event'
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.BINARY_EVENT = 5;
|
||||
|
||||
/**
|
||||
* Packet type `binary ack`. For acks with binary arguments.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.BINARY_ACK = 6;
|
||||
|
||||
/**
|
||||
* Encoder constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.Encoder = Encoder;
|
||||
|
||||
/**
|
||||
* Decoder constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.Decoder = Decoder;
|
||||
|
||||
/**
|
||||
* A socket.io Encoder instance
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Encoder() {}
|
||||
|
||||
/**
|
||||
* Encode a packet as a single string if non-binary, or as a
|
||||
* buffer sequence, depending on packet type.
|
||||
*
|
||||
* @param {Object} obj - packet object
|
||||
* @param {Function} callback - function to handle encodings (likely engine.write)
|
||||
* @return Calls callback with Array of encodings
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Encoder.prototype.encode = function(obj, callback){
|
||||
debug('encoding packet %j', obj);
|
||||
|
||||
if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {
|
||||
encodeAsBinary(obj, callback);
|
||||
}
|
||||
else {
|
||||
var encoding = encodeAsString(obj);
|
||||
callback([encoding]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode packet as string.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @return {String} encoded
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function encodeAsString(obj) {
|
||||
var str = '';
|
||||
var nsp = false;
|
||||
|
||||
// first is type
|
||||
str += obj.type;
|
||||
|
||||
// attachments if we have them
|
||||
if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {
|
||||
str += obj.attachments;
|
||||
str += '-';
|
||||
}
|
||||
|
||||
// if we have a namespace other than `/`
|
||||
// we append it followed by a comma `,`
|
||||
if (obj.nsp && '/' != obj.nsp) {
|
||||
nsp = true;
|
||||
str += obj.nsp;
|
||||
}
|
||||
|
||||
// immediately followed by the id
|
||||
if (null != obj.id) {
|
||||
if (nsp) {
|
||||
str += ',';
|
||||
nsp = false;
|
||||
}
|
||||
str += obj.id;
|
||||
}
|
||||
|
||||
// json data
|
||||
if (null != obj.data) {
|
||||
if (nsp) str += ',';
|
||||
str += json.stringify(obj.data);
|
||||
}
|
||||
|
||||
debug('encoded %j as %s', obj, str);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode packet as 'buffer sequence' by removing blobs, and
|
||||
* deconstructing packet into object with placeholders and
|
||||
* a list of buffers.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @return {Buffer} encoded
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function encodeAsBinary(obj, callback) {
|
||||
|
||||
function writeEncoding(bloblessData) {
|
||||
var deconstruction = binary.deconstructPacket(bloblessData);
|
||||
var pack = encodeAsString(deconstruction.packet);
|
||||
var buffers = deconstruction.buffers;
|
||||
|
||||
buffers.unshift(pack); // add packet info to beginning of data list
|
||||
callback(buffers); // write all the buffers
|
||||
}
|
||||
|
||||
binary.removeBlobs(obj, writeEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* A socket.io Decoder instance
|
||||
*
|
||||
* @return {Object} decoder
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Decoder() {
|
||||
this.reconstructor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix in `Emitter` with Decoder.
|
||||
*/
|
||||
|
||||
Emitter(Decoder.prototype);
|
||||
|
||||
/**
|
||||
* Decodes an ecoded packet string into packet JSON.
|
||||
*
|
||||
* @param {String} obj - encoded packet
|
||||
* @return {Object} packet
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Decoder.prototype.add = function(obj) {
|
||||
var packet;
|
||||
if ('string' == typeof obj) {
|
||||
packet = decodeString(obj);
|
||||
if (exports.BINARY_EVENT == packet.type || exports.BINARY_ACK == packet.type) { // binary packet's json
|
||||
this.reconstructor = new BinaryReconstructor(packet);
|
||||
|
||||
// no attachments, labeled binary but no binary data to follow
|
||||
if (this.reconstructor.reconPack.attachments === 0) {
|
||||
this.emit('decoded', packet);
|
||||
}
|
||||
} else { // non-binary full packet
|
||||
this.emit('decoded', packet);
|
||||
}
|
||||
}
|
||||
else if (isBuf(obj) || obj.base64) { // raw binary data
|
||||
if (!this.reconstructor) {
|
||||
throw new Error('got binary data when not reconstructing a packet');
|
||||
} else {
|
||||
packet = this.reconstructor.takeBinaryData(obj);
|
||||
if (packet) { // received final buffer
|
||||
this.reconstructor = null;
|
||||
this.emit('decoded', packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error('Unknown type: ' + obj);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode a packet String (JSON data)
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Object} packet
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function decodeString(str) {
|
||||
var p = {};
|
||||
var i = 0;
|
||||
|
||||
// look up type
|
||||
p.type = Number(str.charAt(0));
|
||||
if (null == exports.types[p.type]) return error();
|
||||
|
||||
// look up attachments if type binary
|
||||
if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) {
|
||||
var buf = '';
|
||||
while (str.charAt(++i) != '-') {
|
||||
buf += str.charAt(i);
|
||||
if (i == str.length) break;
|
||||
}
|
||||
if (buf != Number(buf) || str.charAt(i) != '-') {
|
||||
throw new Error('Illegal attachments');
|
||||
}
|
||||
p.attachments = Number(buf);
|
||||
}
|
||||
|
||||
// look up namespace (if any)
|
||||
if ('/' == str.charAt(i + 1)) {
|
||||
p.nsp = '';
|
||||
while (++i) {
|
||||
var c = str.charAt(i);
|
||||
if (',' == c) break;
|
||||
p.nsp += c;
|
||||
if (i == str.length) break;
|
||||
}
|
||||
} else {
|
||||
p.nsp = '/';
|
||||
}
|
||||
|
||||
// look up id
|
||||
var next = str.charAt(i + 1);
|
||||
if ('' !== next && Number(next) == next) {
|
||||
p.id = '';
|
||||
while (++i) {
|
||||
var c = str.charAt(i);
|
||||
if (null == c || Number(c) != c) {
|
||||
--i;
|
||||
break;
|
||||
}
|
||||
p.id += str.charAt(i);
|
||||
if (i == str.length) break;
|
||||
}
|
||||
p.id = Number(p.id);
|
||||
}
|
||||
|
||||
// look up json data
|
||||
if (str.charAt(++i)) {
|
||||
p = tryParse(p, str.substr(i));
|
||||
}
|
||||
|
||||
debug('decoded %s as %j', str, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
function tryParse(p, str) {
|
||||
try {
|
||||
p.data = json.parse(str);
|
||||
} catch(e){
|
||||
return error();
|
||||
}
|
||||
return p;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deallocates a parser's resources
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Decoder.prototype.destroy = function() {
|
||||
if (this.reconstructor) {
|
||||
this.reconstructor.finishedReconstruction();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A manager of a binary event's 'buffer sequence'. Should
|
||||
* be constructed whenever a packet of type BINARY_EVENT is
|
||||
* decoded.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @return {BinaryReconstructor} initialized reconstructor
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function BinaryReconstructor(packet) {
|
||||
this.reconPack = packet;
|
||||
this.buffers = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to be called when binary data received from connection
|
||||
* after a BINARY_EVENT packet.
|
||||
*
|
||||
* @param {Buffer | ArrayBuffer} binData - the raw binary data received
|
||||
* @return {null | Object} returns null if more binary data is expected or
|
||||
* a reconstructed packet object if all buffers have been received.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
BinaryReconstructor.prototype.takeBinaryData = function(binData) {
|
||||
this.buffers.push(binData);
|
||||
if (this.buffers.length == this.reconPack.attachments) { // done with buffer list
|
||||
var packet = binary.reconstructPacket(this.reconPack, this.buffers);
|
||||
this.finishedReconstruction();
|
||||
return packet;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Cleans up binary packet reconstruction variables.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
BinaryReconstructor.prototype.finishedReconstruction = function() {
|
||||
this.reconPack = null;
|
||||
this.buffers = [];
|
||||
};
|
||||
|
||||
function error(data){
|
||||
return {
|
||||
type: exports.ERROR,
|
||||
data: 'parser error'
|
||||
};
|
||||
}
|
13
node_modules/socket.io-parser/is-buffer.js
generated
vendored
Normal file
13
node_modules/socket.io-parser/is-buffer.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
module.exports = isBuf;
|
||||
|
||||
/**
|
||||
* Returns true if obj is a buffer or an arraybuffer.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function isBuf(obj) {
|
||||
return (global.Buffer && global.Buffer.isBuffer(obj)) ||
|
||||
(global.ArrayBuffer && obj instanceof ArrayBuffer);
|
||||
}
|
54
node_modules/socket.io-parser/node_modules/isarray/README.md
generated
vendored
Normal file
54
node_modules/socket.io-parser/node_modules/isarray/README.md
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
# isarray
|
||||
|
||||
`Array#isArray` for older browsers.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isArray = require('isarray');
|
||||
|
||||
console.log(isArray([])); // => true
|
||||
console.log(isArray({})); // => false
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](http://npmjs.org) do
|
||||
|
||||
```bash
|
||||
$ npm install isarray
|
||||
```
|
||||
|
||||
Then bundle for the browser with
|
||||
[browserify](https://github.com/substack/browserify).
|
||||
|
||||
With [component](http://component.io) do
|
||||
|
||||
```bash
|
||||
$ component install juliangruber/isarray
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
209
node_modules/socket.io-parser/node_modules/isarray/build/build.js
generated
vendored
Normal file
209
node_modules/socket.io-parser/node_modules/isarray/build/build.js
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
|
||||
/**
|
||||
* Require the given path.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Object} exports
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function require(path, parent, orig) {
|
||||
var resolved = require.resolve(path);
|
||||
|
||||
// lookup failed
|
||||
if (null == resolved) {
|
||||
orig = orig || path;
|
||||
parent = parent || 'root';
|
||||
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
|
||||
err.path = orig;
|
||||
err.parent = parent;
|
||||
err.require = true;
|
||||
throw err;
|
||||
}
|
||||
|
||||
var module = require.modules[resolved];
|
||||
|
||||
// perform real require()
|
||||
// by invoking the module's
|
||||
// registered function
|
||||
if (!module.exports) {
|
||||
module.exports = {};
|
||||
module.client = module.component = true;
|
||||
module.call(this, module.exports, require.relative(resolved), module);
|
||||
}
|
||||
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registered modules.
|
||||
*/
|
||||
|
||||
require.modules = {};
|
||||
|
||||
/**
|
||||
* Registered aliases.
|
||||
*/
|
||||
|
||||
require.aliases = {};
|
||||
|
||||
/**
|
||||
* Resolve `path`.
|
||||
*
|
||||
* Lookup:
|
||||
*
|
||||
* - PATH/index.js
|
||||
* - PATH.js
|
||||
* - PATH
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {String} path or null
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.resolve = function(path) {
|
||||
if (path.charAt(0) === '/') path = path.slice(1);
|
||||
var index = path + '/index.js';
|
||||
|
||||
var paths = [
|
||||
path,
|
||||
path + '.js',
|
||||
path + '.json',
|
||||
path + '/index.js',
|
||||
path + '/index.json'
|
||||
];
|
||||
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
var path = paths[i];
|
||||
if (require.modules.hasOwnProperty(path)) return path;
|
||||
}
|
||||
|
||||
if (require.aliases.hasOwnProperty(index)) {
|
||||
return require.aliases[index];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize `path` relative to the current path.
|
||||
*
|
||||
* @param {String} curr
|
||||
* @param {String} path
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.normalize = function(curr, path) {
|
||||
var segs = [];
|
||||
|
||||
if ('.' != path.charAt(0)) return path;
|
||||
|
||||
curr = curr.split('/');
|
||||
path = path.split('/');
|
||||
|
||||
for (var i = 0; i < path.length; ++i) {
|
||||
if ('..' == path[i]) {
|
||||
curr.pop();
|
||||
} else if ('.' != path[i] && '' != path[i]) {
|
||||
segs.push(path[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return curr.concat(segs).join('/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Register module at `path` with callback `definition`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} definition
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.register = function(path, definition) {
|
||||
require.modules[path] = definition;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias a module definition.
|
||||
*
|
||||
* @param {String} from
|
||||
* @param {String} to
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.alias = function(from, to) {
|
||||
if (!require.modules.hasOwnProperty(from)) {
|
||||
throw new Error('Failed to alias "' + from + '", it does not exist');
|
||||
}
|
||||
require.aliases[to] = from;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a require function relative to the `parent` path.
|
||||
*
|
||||
* @param {String} parent
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.relative = function(parent) {
|
||||
var p = require.normalize(parent, '..');
|
||||
|
||||
/**
|
||||
* lastIndexOf helper.
|
||||
*/
|
||||
|
||||
function lastIndexOf(arr, obj) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === obj) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The relative require() itself.
|
||||
*/
|
||||
|
||||
function localRequire(path) {
|
||||
var resolved = localRequire.resolve(path);
|
||||
return require(resolved, parent, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve relative to the parent.
|
||||
*/
|
||||
|
||||
localRequire.resolve = function(path) {
|
||||
var c = path.charAt(0);
|
||||
if ('/' == c) return path.slice(1);
|
||||
if ('.' == c) return require.normalize(p, path);
|
||||
|
||||
// resolve deps by returning
|
||||
// the dep in the nearest "deps"
|
||||
// directory
|
||||
var segs = parent.split('/');
|
||||
var i = lastIndexOf(segs, 'deps') + 1;
|
||||
if (!i) i = 0;
|
||||
path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if module is defined at `path`.
|
||||
*/
|
||||
|
||||
localRequire.exists = function(path) {
|
||||
return require.modules.hasOwnProperty(localRequire.resolve(path));
|
||||
};
|
||||
|
||||
return localRequire;
|
||||
};
|
||||
require.register("isarray/index.js", function(exports, require, module){
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return Object.prototype.toString.call(arr) == '[object Array]';
|
||||
};
|
||||
|
||||
});
|
||||
require.alias("isarray/index.js", "isarray/index.js");
|
||||
|
19
node_modules/socket.io-parser/node_modules/isarray/component.json
generated
vendored
Normal file
19
node_modules/socket.io-parser/node_modules/isarray/component.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name" : "isarray",
|
||||
"description" : "Array#isArray for older browsers",
|
||||
"version" : "0.0.1",
|
||||
"repository" : "juliangruber/isarray",
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"main" : "index.js",
|
||||
"scripts" : [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies" : {},
|
||||
"keywords": ["browser","isarray","array"],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
3
node_modules/socket.io-parser/node_modules/isarray/index.js
generated
vendored
Normal file
3
node_modules/socket.io-parser/node_modules/isarray/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return Object.prototype.toString.call(arr) == '[object Array]';
|
||||
};
|
74
node_modules/socket.io-parser/node_modules/isarray/package.json
generated
vendored
Normal file
74
node_modules/socket.io-parser/node_modules/isarray/package.json
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"isarray@0.0.1",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\socket.io-parser"
|
||||
]
|
||||
],
|
||||
"_from": "isarray@0.0.1",
|
||||
"_id": "isarray@0.0.1",
|
||||
"_inCache": true,
|
||||
"_location": "/socket.io-parser/isarray",
|
||||
"_npmUser": {
|
||||
"email": "julian@juliangruber.com",
|
||||
"name": "juliangruber"
|
||||
},
|
||||
"_npmVersion": "1.2.18",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "isarray",
|
||||
"raw": "isarray@0.0.1",
|
||||
"rawSpec": "0.0.1",
|
||||
"scope": null,
|
||||
"spec": "0.0.1",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/socket.io-parser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "isarray@0.0.1",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\socket.io-parser",
|
||||
"author": {
|
||||
"email": "mail@juliangruber.com",
|
||||
"name": "Julian Gruber",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Array#isArray for older browsers",
|
||||
"devDependencies": {
|
||||
"tap": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf",
|
||||
"tarball": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"array",
|
||||
"browser",
|
||||
"isarray"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "juliangruber",
|
||||
"email": "julian@juliangruber.com"
|
||||
}
|
||||
],
|
||||
"name": "isarray",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/isarray.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "0.0.1"
|
||||
}
|
92
node_modules/socket.io-parser/package.json
generated
vendored
Normal file
92
node_modules/socket.io-parser/package.json
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"socket.io-parser@2.3.1",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\socket.io"
|
||||
]
|
||||
],
|
||||
"_from": "socket.io-parser@2.3.1",
|
||||
"_id": "socket.io-parser@2.3.1",
|
||||
"_inCache": true,
|
||||
"_location": "/socket.io-parser",
|
||||
"_nodeVersion": "4.4.7",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/socket.io-parser-2.3.1.tgz_1477269125715_0.3387652209494263"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "damien.arrachequesne@gmail.com",
|
||||
"name": "darrachequesne"
|
||||
},
|
||||
"_npmVersion": "2.15.8",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "socket.io-parser",
|
||||
"raw": "socket.io-parser@2.3.1",
|
||||
"rawSpec": "2.3.1",
|
||||
"scope": null,
|
||||
"spec": "2.3.1",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/socket.io",
|
||||
"/socket.io-adapter",
|
||||
"/socket.io-client"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz",
|
||||
"_shasum": "dd532025103ce429697326befd64005fcfe5b4a0",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "socket.io-parser@2.3.1",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\socket.io",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Automattic/socket.io-parser/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"component-emitter": "1.1.2",
|
||||
"debug": "2.2.0",
|
||||
"isarray": "0.0.1",
|
||||
"json3": "3.3.2"
|
||||
},
|
||||
"description": "socket.io protocol parser",
|
||||
"devDependencies": {
|
||||
"benchmark": "1.0.0",
|
||||
"expect.js": "0.2.0",
|
||||
"mocha": "1.16.2",
|
||||
"zuul": "3.11.0",
|
||||
"zuul-ngrok": "4.0.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "dd532025103ce429697326befd64005fcfe5b4a0",
|
||||
"tarball": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz"
|
||||
},
|
||||
"files": [
|
||||
"binary.js",
|
||||
"index.js",
|
||||
"is-buffer.js"
|
||||
],
|
||||
"gitHead": "64455b432c9af2f9692a0eb845b17129eec0442a",
|
||||
"homepage": "https://github.com/Automattic/socket.io-parser#readme",
|
||||
"installable": true,
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "darrachequesne",
|
||||
"email": "damien.arrachequesne@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "rauchg",
|
||||
"email": "rauchg@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "socket.io-parser",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Automattic/socket.io-parser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "2.3.1"
|
||||
}
|
Reference in New Issue
Block a user