Template Upload
This commit is contained in:
136
node_modules/engine.io-parser/History.md
generated
vendored
Normal file
136
node_modules/engine.io-parser/History.md
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
|
||||
1.3.1 / 2016-10-20
|
||||
==================
|
||||
|
||||
* [fix] Add safety check for global object (#71)
|
||||
* [fix] decodePacket now accepts both Buffer and ArrayBuffer as data (#64)
|
||||
* [fix] Handle undefined case properly when decoding packet (#74)
|
||||
* [chore] Bump zuul to 3.11.0 & zuul-ngrok to 4.0.0 (#70)
|
||||
* [chore] Update zuul browser settings (#73)
|
||||
|
||||
1.3.0 / 2016-09-26
|
||||
==================
|
||||
|
||||
* [fix] Fix crashes in React Native "navigator is not defined" (#55)
|
||||
* [refactor] Require base64-arraybuffer module conditionally. (#58)
|
||||
* [perf] Split try catch into separate function (#65)
|
||||
* [chore] Use wtf-8 instead of utf8 to prevent lone surrogates from generating parsing error (#68)
|
||||
* [chore] Restrict files included in npm package (#67)
|
||||
* [chore] Update license and repository url (#66)
|
||||
* [chore] Update zuul browser settings following EOL notices (#62)
|
||||
* [chore] bump zuul (#56)
|
||||
|
||||
1.2.4 / 2015-12-04
|
||||
==================
|
||||
|
||||
* fix `ArrayBuffer` encoding in base64 string
|
||||
|
||||
1.2.3 / 2015-11-28
|
||||
==================
|
||||
|
||||
* fix encoding blob as base64
|
||||
|
||||
1.2.2 / 2015-09-09
|
||||
==================
|
||||
|
||||
* fixes for iojs/node
|
||||
|
||||
1.2.1 / 2015-01-17
|
||||
==================
|
||||
|
||||
* pass has-binary result to encodePacket [rase-]
|
||||
* Fix parse error [rase-]
|
||||
|
||||
1.2.0 / 2015-01-11
|
||||
==================
|
||||
|
||||
* fix return type for decodePacket
|
||||
* README fixes
|
||||
* use travis matrix for better test runs
|
||||
* encode into binary only if needed
|
||||
* add test cases for base64 object encoding.
|
||||
* add encodeBase64Object to encoder for browser
|
||||
* avoid sending Blobs on PhantomJS (as on Android)
|
||||
* test that utf8 encoding is not on by default but can be switched on manually
|
||||
|
||||
1.1.0 / 2014-07-16
|
||||
==================
|
||||
|
||||
* make utf8 encoding/decoding optional
|
||||
|
||||
1.0.8 / 2014-07-16
|
||||
==================
|
||||
|
||||
* adjust protocol revision
|
||||
* handle invalid utf8 errors gracefully
|
||||
* fix memory leak on browser
|
||||
|
||||
1.0.7 / 2014-06-24
|
||||
==================
|
||||
|
||||
* fix decodePayloadAsBinary memory leak [christophwitzko]
|
||||
* README improvements
|
||||
|
||||
1.0.6 / 2014-05-30
|
||||
==================
|
||||
|
||||
* utf8 fixes when using binary encoding [nkzawa]
|
||||
|
||||
1.0.5 / 2014-05-06
|
||||
==================
|
||||
|
||||
* fix range error
|
||||
|
||||
1.0.4 / 2014-04-13
|
||||
==================
|
||||
|
||||
* fix `encodePayloadAsBinary` method encodes packets to base64
|
||||
|
||||
1.0.3 / 2014-04-10
|
||||
==================
|
||||
|
||||
* Fix length calculation when encoding as binary [binlain]
|
||||
|
||||
1.0.2 / 2014-03-16
|
||||
==================
|
||||
|
||||
* fix binary for android due to a bug in Blob XHR2 implementation [Rase-]
|
||||
|
||||
1.0.1 / 2014-03-06
|
||||
==================
|
||||
|
||||
* implement `blob` module to simplify code
|
||||
* bump `arraybuffer.slice`
|
||||
* style fixes
|
||||
|
||||
1.0.0 / 2014-02-18
|
||||
==================
|
||||
|
||||
* parser: added binary encoding [Rase-]
|
||||
* parser: switched to an async interface [Rase-]
|
||||
|
||||
0.3.0 / 2013-03-16
|
||||
==================
|
||||
|
||||
* parser: if callback returns `false` ignore rest of payload
|
||||
* test: fixed all broken tests
|
||||
|
||||
0.2.1 / 2013-03-16
|
||||
==================
|
||||
|
||||
* added protocol version to index.js [albertyfwu]
|
||||
|
||||
0.2.0 / 2013-02-26
|
||||
==================
|
||||
|
||||
* Changed `decodePayload` to use a callback instead of returning an array [sweetieSong, albertyfwu]
|
||||
|
||||
0.1.1 / 2013-01-26
|
||||
==================
|
||||
|
||||
* package.json fixes
|
||||
|
||||
0.1.0 / 2013-01-19
|
||||
==================
|
||||
|
||||
* Initial release
|
22
node_modules/engine.io-parser/LICENSE
generated
vendored
Normal file
22
node_modules/engine.io-parser/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2016 Guillermo Rauch (@rauchg)
|
||||
|
||||
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.
|
202
node_modules/engine.io-parser/Readme.md
generated
vendored
Normal file
202
node_modules/engine.io-parser/Readme.md
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
# engine.io-parser
|
||||
|
||||
[](http://travis-ci.org/socketio/engine.io-parser)
|
||||
[](http://badge.fury.io/js/engine.io-parser)
|
||||
|
||||
This is the JavaScript parser for the engine.io protocol encoding,
|
||||
shared by both
|
||||
[engine.io-client](https://github.com/socketio/engine.io-client) and
|
||||
[engine.io](https://github.com/socketio/engine.io).
|
||||
|
||||
## How to use
|
||||
|
||||
### Standalone
|
||||
|
||||
The parser can encode/decode packets, payloads, and payloads as binary
|
||||
with the following methods: `encodePacket`, `decodePacket`, `encodePayload`,
|
||||
`decodePayload`, `encodePayloadAsBinary`, `decodePayloadAsBinary`.
|
||||
|
||||
The browser-side parser also includes `encodePayloadAsArrayBuffer` and `encodePayloadAsBlob`.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var parser = require('engine.io-parser');
|
||||
|
||||
var data = new Buffer(5);
|
||||
for (var i = 0; i < data.length; i++) { data[i] = i; }
|
||||
|
||||
parser.encodePacket({ type: 'message', data: data }, function(encoded) {
|
||||
var decodedData = parser.decodePacket(encoded); // { type: 'message', data: data }
|
||||
});
|
||||
```
|
||||
|
||||
### With browserify
|
||||
|
||||
Engine.IO Parser is a commonjs module, which means you can include it by using
|
||||
`require` on the browser and package using [browserify](http://browserify.org/):
|
||||
|
||||
1. install the parser package
|
||||
|
||||
```shell
|
||||
npm install engine.io-parser
|
||||
```
|
||||
|
||||
1. write your app code
|
||||
|
||||
```js
|
||||
var parser = require('engine.io-parser');
|
||||
|
||||
var testBuffer = new Int8Array(10);
|
||||
for (var i = 0; i < testBuffer.length; i++) testBuffer[i] = i;
|
||||
|
||||
var packets = [{ type: 'message', data: testBuffer.buffer }, { type: 'message', data: 'hello' }];
|
||||
|
||||
parser.encodePayload(packets, function(encoded) {
|
||||
parser.decodePayload(encoded,
|
||||
function(packet, index, total) {
|
||||
var isLast = index + 1 == total;
|
||||
if (!isLast) {
|
||||
var buffer = new Int8Array(packet.data); // testBuffer
|
||||
} else {
|
||||
var message = packet.data; // 'hello'
|
||||
}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
1. build your app bundle
|
||||
|
||||
```bash
|
||||
$ browserify app.js > bundle.js
|
||||
```
|
||||
|
||||
1. include on your page
|
||||
|
||||
```html
|
||||
<script src="/path/to/bundle.js"></script>
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Runs on browser and node.js seamlessly
|
||||
- Runs inside HTML5 WebWorker
|
||||
- Can encode and decode packets
|
||||
- Encodes from/to ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node
|
||||
|
||||
## API
|
||||
|
||||
Note: `cb(type)` means the type is a callback function that contains a parameter of type `type` when called.
|
||||
|
||||
### Node
|
||||
|
||||
- `encodePacket`
|
||||
- Encodes a packet.
|
||||
- **Parameters**
|
||||
- `Object`: the packet to encode, has `type` and `data`.
|
||||
- `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer`
|
||||
- `Boolean`: optional, binary support
|
||||
- `Function`: callback, returns the encoded packet (`cb(String)`)
|
||||
- `decodePacket`
|
||||
- Decodes a packet. Data also available as an ArrayBuffer if requested.
|
||||
- Returns data as `String` or (`Blob` on browser, `ArrayBuffer` on Node)
|
||||
- **Parameters**
|
||||
- `String` | `ArrayBuffer`: the packet to decode, has `type` and `data`
|
||||
- `String`: optional, the binary type
|
||||
|
||||
- `encodeBase64Packet`
|
||||
- Encodes a packet with binary data in a base64 string (`String`)
|
||||
- **Parameters**
|
||||
- `Object`: the packet to encode, has `type` and `data`
|
||||
- `Function`: callback, returns the base64 encoded message (`cb(String)`)
|
||||
- `decodeBase64Packet`
|
||||
- Decodes a packet encoded in a base64 string.
|
||||
- **Parameters**
|
||||
- `String`: the base64 encoded message
|
||||
- `String`: optional, the binary type
|
||||
|
||||
- `encodePayload`
|
||||
- Encodes multiple messages (payload).
|
||||
- If any contents are binary, they will be encoded as base64 strings. Base64
|
||||
encoded strings are marked with a b before the length specifier
|
||||
- **Parameters**
|
||||
- `Array`: an array of packets
|
||||
- `Boolean`: optional, binary support
|
||||
- `Function`: callback, returns the encoded payload (`cb(String)`)
|
||||
- `decodePayload`
|
||||
- Decodes data when a payload is maybe expected. Possible binary contents are
|
||||
decoded from their base64 representation.
|
||||
- **Parameters**
|
||||
- `String`: the payload
|
||||
- `String`: optional, the binary type
|
||||
- `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total))
|
||||
|
||||
- `encodePayloadAsBinary`
|
||||
- Encodes multiple messages (payload) as binary.
|
||||
- **Parameters**
|
||||
- `Array`: an array of packets
|
||||
- `Function`: callback, returns the encoded payload (`cb(Buffer)`)
|
||||
- `decodePayloadAsBinary`
|
||||
- Decodes data when a payload is maybe expected. Strings are decoded by
|
||||
interpreting each byte as a key code for entries marked to start with 0. See
|
||||
description of encodePayloadAsBinary.
|
||||
- **Parameters**
|
||||
- `Buffer`: the buffer
|
||||
- `String`: optional, the binary type
|
||||
- `Function`: callback, returns the decoded packet (`cb(Object)`)
|
||||
|
||||
### Browser
|
||||
|
||||
- `encodePayloadAsArrayBuffer`
|
||||
- Encodes multiple messages (payload) as binary.
|
||||
- **Parameters**
|
||||
- `Array`: an array of packets
|
||||
- `Function`: callback, returns the encoded payload (`cb(ArrayBuffer)`)
|
||||
- `encodePayloadAsBlob`
|
||||
- Encodes multiple messages (payload) as blob.
|
||||
- **Parameters**
|
||||
- `Array`: an array of packets
|
||||
- `Function`: callback, returns the encoded payload (`cb(Blob)`)
|
||||
|
||||
## Tests
|
||||
|
||||
Standalone tests can be run with `make test` which will run both node.js and browser tests.
|
||||
|
||||
Browser tests are run using [zuul](https://github.com/defunctzombie/zuul).
|
||||
(You must have zuul setup with a saucelabs account.)
|
||||
|
||||
You can run the tests locally using the following command:
|
||||
|
||||
```
|
||||
./node_modules/.bin/zuul --local 8080 -- test/index.js
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
The support channels for `engine.io-parser` are the same as `socket.io`:
|
||||
- irc.freenode.net **#socket.io**
|
||||
- [Google Groups](http://groups.google.com/group/socket_io)
|
||||
- [Website](http://socket.io)
|
||||
|
||||
## Development
|
||||
|
||||
To contribute patches, run tests or benchmarks, make sure to clone the
|
||||
repository:
|
||||
|
||||
```bash
|
||||
git clone git://github.com/LearnBoost/engine.io-parser.git
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
```bash
|
||||
cd engine.io-parser
|
||||
npm install
|
||||
```
|
||||
|
||||
See the `Tests` section above for how to run tests before submitting any patches.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
2
node_modules/engine.io-parser/index.js
generated
vendored
Normal file
2
node_modules/engine.io-parser/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
module.exports = require('./lib/');
|
609
node_modules/engine.io-parser/lib/browser.js
generated
vendored
Normal file
609
node_modules/engine.io-parser/lib/browser.js
generated
vendored
Normal file
@ -0,0 +1,609 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var keys = require('./keys');
|
||||
var hasBinary = require('has-binary');
|
||||
var sliceBuffer = require('arraybuffer.slice');
|
||||
var after = require('after');
|
||||
var utf8 = require('wtf-8');
|
||||
|
||||
var base64encoder;
|
||||
if (global && global.ArrayBuffer) {
|
||||
base64encoder = require('base64-arraybuffer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we are running an android browser. That requires us to use
|
||||
* ArrayBuffer with polling transports...
|
||||
*
|
||||
* http://ghinda.net/jpeg-blob-ajax-android/
|
||||
*/
|
||||
|
||||
var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
|
||||
|
||||
/**
|
||||
* Check if we are running in PhantomJS.
|
||||
* Uploading a Blob with PhantomJS does not work correctly, as reported here:
|
||||
* https://github.com/ariya/phantomjs/issues/11395
|
||||
* @type boolean
|
||||
*/
|
||||
var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
|
||||
|
||||
/**
|
||||
* When true, avoids using Blobs to encode payloads.
|
||||
* @type boolean
|
||||
*/
|
||||
var dontSendBlobs = isAndroid || isPhantomJS;
|
||||
|
||||
/**
|
||||
* Current protocol version.
|
||||
*/
|
||||
|
||||
exports.protocol = 3;
|
||||
|
||||
/**
|
||||
* Packet types.
|
||||
*/
|
||||
|
||||
var packets = exports.packets = {
|
||||
open: 0 // non-ws
|
||||
, close: 1 // non-ws
|
||||
, ping: 2
|
||||
, pong: 3
|
||||
, message: 4
|
||||
, upgrade: 5
|
||||
, noop: 6
|
||||
};
|
||||
|
||||
var packetslist = keys(packets);
|
||||
|
||||
/**
|
||||
* Premade error packet.
|
||||
*/
|
||||
|
||||
var err = { type: 'error', data: 'parser error' };
|
||||
|
||||
/**
|
||||
* Create a blob api even for blob builder when vendor prefixes exist
|
||||
*/
|
||||
|
||||
var Blob = require('blob');
|
||||
|
||||
/**
|
||||
* Encodes a packet.
|
||||
*
|
||||
* <packet type id> [ <data> ]
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 5hello world
|
||||
* 3
|
||||
* 4
|
||||
*
|
||||
* Binary is encoded in an identical principle
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
|
||||
if ('function' == typeof supportsBinary) {
|
||||
callback = supportsBinary;
|
||||
supportsBinary = false;
|
||||
}
|
||||
|
||||
if ('function' == typeof utf8encode) {
|
||||
callback = utf8encode;
|
||||
utf8encode = null;
|
||||
}
|
||||
|
||||
var data = (packet.data === undefined)
|
||||
? undefined
|
||||
: packet.data.buffer || packet.data;
|
||||
|
||||
if (global.ArrayBuffer && data instanceof ArrayBuffer) {
|
||||
return encodeArrayBuffer(packet, supportsBinary, callback);
|
||||
} else if (Blob && data instanceof global.Blob) {
|
||||
return encodeBlob(packet, supportsBinary, callback);
|
||||
}
|
||||
|
||||
// might be an object with { base64: true, data: dataAsBase64String }
|
||||
if (data && data.base64) {
|
||||
return encodeBase64Object(packet, callback);
|
||||
}
|
||||
|
||||
// Sending data as a utf-8 string
|
||||
var encoded = packets[packet.type];
|
||||
|
||||
// data fragment is optional
|
||||
if (undefined !== packet.data) {
|
||||
encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data);
|
||||
}
|
||||
|
||||
return callback('' + encoded);
|
||||
|
||||
};
|
||||
|
||||
function encodeBase64Object(packet, callback) {
|
||||
// packet data is an object { base64: true, data: dataAsBase64String }
|
||||
var message = 'b' + exports.packets[packet.type] + packet.data.data;
|
||||
return callback(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode packet helpers for binary types
|
||||
*/
|
||||
|
||||
function encodeArrayBuffer(packet, supportsBinary, callback) {
|
||||
if (!supportsBinary) {
|
||||
return exports.encodeBase64Packet(packet, callback);
|
||||
}
|
||||
|
||||
var data = packet.data;
|
||||
var contentArray = new Uint8Array(data);
|
||||
var resultBuffer = new Uint8Array(1 + data.byteLength);
|
||||
|
||||
resultBuffer[0] = packets[packet.type];
|
||||
for (var i = 0; i < contentArray.length; i++) {
|
||||
resultBuffer[i+1] = contentArray[i];
|
||||
}
|
||||
|
||||
return callback(resultBuffer.buffer);
|
||||
}
|
||||
|
||||
function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
|
||||
if (!supportsBinary) {
|
||||
return exports.encodeBase64Packet(packet, callback);
|
||||
}
|
||||
|
||||
var fr = new FileReader();
|
||||
fr.onload = function() {
|
||||
packet.data = fr.result;
|
||||
exports.encodePacket(packet, supportsBinary, true, callback);
|
||||
};
|
||||
return fr.readAsArrayBuffer(packet.data);
|
||||
}
|
||||
|
||||
function encodeBlob(packet, supportsBinary, callback) {
|
||||
if (!supportsBinary) {
|
||||
return exports.encodeBase64Packet(packet, callback);
|
||||
}
|
||||
|
||||
if (dontSendBlobs) {
|
||||
return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
|
||||
}
|
||||
|
||||
var length = new Uint8Array(1);
|
||||
length[0] = packets[packet.type];
|
||||
var blob = new Blob([length.buffer, packet.data]);
|
||||
|
||||
return callback(blob);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a packet with binary data in a base64 string
|
||||
*
|
||||
* @param {Object} packet, has `type` and `data`
|
||||
* @return {String} base64 encoded message
|
||||
*/
|
||||
|
||||
exports.encodeBase64Packet = function(packet, callback) {
|
||||
var message = 'b' + exports.packets[packet.type];
|
||||
if (Blob && packet.data instanceof global.Blob) {
|
||||
var fr = new FileReader();
|
||||
fr.onload = function() {
|
||||
var b64 = fr.result.split(',')[1];
|
||||
callback(message + b64);
|
||||
};
|
||||
return fr.readAsDataURL(packet.data);
|
||||
}
|
||||
|
||||
var b64data;
|
||||
try {
|
||||
b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
|
||||
} catch (e) {
|
||||
// iPhone Safari doesn't let you apply with typed arrays
|
||||
var typed = new Uint8Array(packet.data);
|
||||
var basic = new Array(typed.length);
|
||||
for (var i = 0; i < typed.length; i++) {
|
||||
basic[i] = typed[i];
|
||||
}
|
||||
b64data = String.fromCharCode.apply(null, basic);
|
||||
}
|
||||
message += global.btoa(b64data);
|
||||
return callback(message);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decodes a packet. Changes format to Blob if requested.
|
||||
*
|
||||
* @return {Object} with `type` and `data` (if any)
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.decodePacket = function (data, binaryType, utf8decode) {
|
||||
if (data === undefined) {
|
||||
return err;
|
||||
}
|
||||
// String data
|
||||
if (typeof data == 'string') {
|
||||
if (data.charAt(0) == 'b') {
|
||||
return exports.decodeBase64Packet(data.substr(1), binaryType);
|
||||
}
|
||||
|
||||
if (utf8decode) {
|
||||
data = tryDecode(data);
|
||||
if (data === false) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
var type = data.charAt(0);
|
||||
|
||||
if (Number(type) != type || !packetslist[type]) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (data.length > 1) {
|
||||
return { type: packetslist[type], data: data.substring(1) };
|
||||
} else {
|
||||
return { type: packetslist[type] };
|
||||
}
|
||||
}
|
||||
|
||||
var asArray = new Uint8Array(data);
|
||||
var type = asArray[0];
|
||||
var rest = sliceBuffer(data, 1);
|
||||
if (Blob && binaryType === 'blob') {
|
||||
rest = new Blob([rest]);
|
||||
}
|
||||
return { type: packetslist[type], data: rest };
|
||||
};
|
||||
|
||||
function tryDecode(data) {
|
||||
try {
|
||||
data = utf8.decode(data);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a packet encoded in a base64 string
|
||||
*
|
||||
* @param {String} base64 encoded message
|
||||
* @return {Object} with `type` and `data` (if any)
|
||||
*/
|
||||
|
||||
exports.decodeBase64Packet = function(msg, binaryType) {
|
||||
var type = packetslist[msg.charAt(0)];
|
||||
if (!base64encoder) {
|
||||
return { type: type, data: { base64: true, data: msg.substr(1) } };
|
||||
}
|
||||
|
||||
var data = base64encoder.decode(msg.substr(1));
|
||||
|
||||
if (binaryType === 'blob' && Blob) {
|
||||
data = new Blob([data]);
|
||||
}
|
||||
|
||||
return { type: type, data: data };
|
||||
};
|
||||
|
||||
/**
|
||||
* Encodes multiple messages (payload).
|
||||
*
|
||||
* <length>:data
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 11:hello world2:hi
|
||||
*
|
||||
* If any contents are binary, they will be encoded as base64 strings. Base64
|
||||
* encoded strings are marked with a b before the length specifier
|
||||
*
|
||||
* @param {Array} packets
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.encodePayload = function (packets, supportsBinary, callback) {
|
||||
if (typeof supportsBinary == 'function') {
|
||||
callback = supportsBinary;
|
||||
supportsBinary = null;
|
||||
}
|
||||
|
||||
var isBinary = hasBinary(packets);
|
||||
|
||||
if (supportsBinary && isBinary) {
|
||||
if (Blob && !dontSendBlobs) {
|
||||
return exports.encodePayloadAsBlob(packets, callback);
|
||||
}
|
||||
|
||||
return exports.encodePayloadAsArrayBuffer(packets, callback);
|
||||
}
|
||||
|
||||
if (!packets.length) {
|
||||
return callback('0:');
|
||||
}
|
||||
|
||||
function setLengthHeader(message) {
|
||||
return message.length + ':' + message;
|
||||
}
|
||||
|
||||
function encodeOne(packet, doneCallback) {
|
||||
exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) {
|
||||
doneCallback(null, setLengthHeader(message));
|
||||
});
|
||||
}
|
||||
|
||||
map(packets, encodeOne, function(err, results) {
|
||||
return callback(results.join(''));
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Async array map using after
|
||||
*/
|
||||
|
||||
function map(ary, each, done) {
|
||||
var result = new Array(ary.length);
|
||||
var next = after(ary.length, done);
|
||||
|
||||
var eachWithIndex = function(i, el, cb) {
|
||||
each(el, function(error, msg) {
|
||||
result[i] = msg;
|
||||
cb(error, result);
|
||||
});
|
||||
};
|
||||
|
||||
for (var i = 0; i < ary.length; i++) {
|
||||
eachWithIndex(i, ary[i], next);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes data when a payload is maybe expected. Possible binary contents are
|
||||
* decoded from their base64 representation
|
||||
*
|
||||
* @param {String} data, callback method
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.decodePayload = function (data, binaryType, callback) {
|
||||
if (typeof data != 'string') {
|
||||
return exports.decodePayloadAsBinary(data, binaryType, callback);
|
||||
}
|
||||
|
||||
if (typeof binaryType === 'function') {
|
||||
callback = binaryType;
|
||||
binaryType = null;
|
||||
}
|
||||
|
||||
var packet;
|
||||
if (data == '') {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
var length = ''
|
||||
, n, msg;
|
||||
|
||||
for (var i = 0, l = data.length; i < l; i++) {
|
||||
var chr = data.charAt(i);
|
||||
|
||||
if (':' != chr) {
|
||||
length += chr;
|
||||
} else {
|
||||
if ('' == length || (length != (n = Number(length)))) {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
msg = data.substr(i + 1, n);
|
||||
|
||||
if (length != msg.length) {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
if (msg.length) {
|
||||
packet = exports.decodePacket(msg, binaryType, true);
|
||||
|
||||
if (err.type == packet.type && err.data == packet.data) {
|
||||
// parser error in individual packet - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
var ret = callback(packet, i + n, l);
|
||||
if (false === ret) return;
|
||||
}
|
||||
|
||||
// advance cursor
|
||||
i += n;
|
||||
length = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (length != '') {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Encodes multiple messages (payload) as binary.
|
||||
*
|
||||
* <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
|
||||
* 255><data>
|
||||
*
|
||||
* Example:
|
||||
* 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
|
||||
*
|
||||
* @param {Array} packets
|
||||
* @return {ArrayBuffer} encoded payload
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.encodePayloadAsArrayBuffer = function(packets, callback) {
|
||||
if (!packets.length) {
|
||||
return callback(new ArrayBuffer(0));
|
||||
}
|
||||
|
||||
function encodeOne(packet, doneCallback) {
|
||||
exports.encodePacket(packet, true, true, function(data) {
|
||||
return doneCallback(null, data);
|
||||
});
|
||||
}
|
||||
|
||||
map(packets, encodeOne, function(err, encodedPackets) {
|
||||
var totalLength = encodedPackets.reduce(function(acc, p) {
|
||||
var len;
|
||||
if (typeof p === 'string'){
|
||||
len = p.length;
|
||||
} else {
|
||||
len = p.byteLength;
|
||||
}
|
||||
return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
|
||||
}, 0);
|
||||
|
||||
var resultArray = new Uint8Array(totalLength);
|
||||
|
||||
var bufferIndex = 0;
|
||||
encodedPackets.forEach(function(p) {
|
||||
var isString = typeof p === 'string';
|
||||
var ab = p;
|
||||
if (isString) {
|
||||
var view = new Uint8Array(p.length);
|
||||
for (var i = 0; i < p.length; i++) {
|
||||
view[i] = p.charCodeAt(i);
|
||||
}
|
||||
ab = view.buffer;
|
||||
}
|
||||
|
||||
if (isString) { // not true binary
|
||||
resultArray[bufferIndex++] = 0;
|
||||
} else { // true binary
|
||||
resultArray[bufferIndex++] = 1;
|
||||
}
|
||||
|
||||
var lenStr = ab.byteLength.toString();
|
||||
for (var i = 0; i < lenStr.length; i++) {
|
||||
resultArray[bufferIndex++] = parseInt(lenStr[i]);
|
||||
}
|
||||
resultArray[bufferIndex++] = 255;
|
||||
|
||||
var view = new Uint8Array(ab);
|
||||
for (var i = 0; i < view.length; i++) {
|
||||
resultArray[bufferIndex++] = view[i];
|
||||
}
|
||||
});
|
||||
|
||||
return callback(resultArray.buffer);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode as Blob
|
||||
*/
|
||||
|
||||
exports.encodePayloadAsBlob = function(packets, callback) {
|
||||
function encodeOne(packet, doneCallback) {
|
||||
exports.encodePacket(packet, true, true, function(encoded) {
|
||||
var binaryIdentifier = new Uint8Array(1);
|
||||
binaryIdentifier[0] = 1;
|
||||
if (typeof encoded === 'string') {
|
||||
var view = new Uint8Array(encoded.length);
|
||||
for (var i = 0; i < encoded.length; i++) {
|
||||
view[i] = encoded.charCodeAt(i);
|
||||
}
|
||||
encoded = view.buffer;
|
||||
binaryIdentifier[0] = 0;
|
||||
}
|
||||
|
||||
var len = (encoded instanceof ArrayBuffer)
|
||||
? encoded.byteLength
|
||||
: encoded.size;
|
||||
|
||||
var lenStr = len.toString();
|
||||
var lengthAry = new Uint8Array(lenStr.length + 1);
|
||||
for (var i = 0; i < lenStr.length; i++) {
|
||||
lengthAry[i] = parseInt(lenStr[i]);
|
||||
}
|
||||
lengthAry[lenStr.length] = 255;
|
||||
|
||||
if (Blob) {
|
||||
var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
|
||||
doneCallback(null, blob);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
map(packets, encodeOne, function(err, results) {
|
||||
return callback(new Blob(results));
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Decodes data when a payload is maybe expected. Strings are decoded by
|
||||
* interpreting each byte as a key code for entries marked to start with 0. See
|
||||
* description of encodePayloadAsBinary
|
||||
*
|
||||
* @param {ArrayBuffer} data, callback method
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.decodePayloadAsBinary = function (data, binaryType, callback) {
|
||||
if (typeof binaryType === 'function') {
|
||||
callback = binaryType;
|
||||
binaryType = null;
|
||||
}
|
||||
|
||||
var bufferTail = data;
|
||||
var buffers = [];
|
||||
|
||||
var numberTooLong = false;
|
||||
while (bufferTail.byteLength > 0) {
|
||||
var tailArray = new Uint8Array(bufferTail);
|
||||
var isString = tailArray[0] === 0;
|
||||
var msgLength = '';
|
||||
|
||||
for (var i = 1; ; i++) {
|
||||
if (tailArray[i] == 255) break;
|
||||
|
||||
if (msgLength.length > 310) {
|
||||
numberTooLong = true;
|
||||
break;
|
||||
}
|
||||
|
||||
msgLength += tailArray[i];
|
||||
}
|
||||
|
||||
if(numberTooLong) return callback(err, 0, 1);
|
||||
|
||||
bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
|
||||
msgLength = parseInt(msgLength);
|
||||
|
||||
var msg = sliceBuffer(bufferTail, 0, msgLength);
|
||||
if (isString) {
|
||||
try {
|
||||
msg = String.fromCharCode.apply(null, new Uint8Array(msg));
|
||||
} catch (e) {
|
||||
// iPhone Safari doesn't let you apply to typed arrays
|
||||
var typed = new Uint8Array(msg);
|
||||
msg = '';
|
||||
for (var i = 0; i < typed.length; i++) {
|
||||
msg += String.fromCharCode(typed[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buffers.push(msg);
|
||||
bufferTail = sliceBuffer(bufferTail, msgLength);
|
||||
}
|
||||
|
||||
var total = buffers.length;
|
||||
buffers.forEach(function(buffer, i) {
|
||||
callback(exports.decodePacket(buffer, binaryType, true), i, total);
|
||||
});
|
||||
};
|
474
node_modules/engine.io-parser/lib/index.js
generated
vendored
Normal file
474
node_modules/engine.io-parser/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var utf8 = require('wtf-8');
|
||||
var after = require('after');
|
||||
var keys = require('./keys');
|
||||
|
||||
/**
|
||||
* Current protocol version.
|
||||
*/
|
||||
exports.protocol = 3;
|
||||
|
||||
/**
|
||||
* Packet types.
|
||||
*/
|
||||
|
||||
var packets = exports.packets = {
|
||||
open: 0 // non-ws
|
||||
, close: 1 // non-ws
|
||||
, ping: 2
|
||||
, pong: 3
|
||||
, message: 4
|
||||
, upgrade: 5
|
||||
, noop: 6
|
||||
};
|
||||
|
||||
var packetslist = keys(packets);
|
||||
|
||||
/**
|
||||
* Premade error packet.
|
||||
*/
|
||||
|
||||
var err = { type: 'error', data: 'parser error' };
|
||||
|
||||
/**
|
||||
* Encodes a packet.
|
||||
*
|
||||
* <packet type id> [ <data> ]
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 5hello world
|
||||
* 3
|
||||
* 4
|
||||
*
|
||||
* Binary is encoded in an identical principle
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
|
||||
if ('function' == typeof supportsBinary) {
|
||||
callback = supportsBinary;
|
||||
supportsBinary = null;
|
||||
}
|
||||
|
||||
if ('function' == typeof utf8encode ) {
|
||||
callback = utf8encode;
|
||||
utf8encode = null;
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(packet.data)) {
|
||||
return encodeBuffer(packet, supportsBinary, callback);
|
||||
} else if (packet.data && (packet.data.buffer || packet.data) instanceof ArrayBuffer) {
|
||||
packet.data = arrayBufferToBuffer(packet.data);
|
||||
return encodeBuffer(packet, supportsBinary, callback);
|
||||
}
|
||||
|
||||
// Sending data as a utf-8 string
|
||||
var encoded = packets[packet.type];
|
||||
|
||||
// data fragment is optional
|
||||
if (undefined !== packet.data) {
|
||||
encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data);
|
||||
}
|
||||
|
||||
return callback('' + encoded);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode Buffer data
|
||||
*/
|
||||
|
||||
function encodeBuffer(packet, supportsBinary, callback) {
|
||||
var data = packet.data;
|
||||
if (!supportsBinary) {
|
||||
return exports.encodeBase64Packet(packet, callback);
|
||||
}
|
||||
|
||||
var typeBuffer = new Buffer(1);
|
||||
typeBuffer[0] = packets[packet.type];
|
||||
return callback(Buffer.concat([typeBuffer, data]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a packet with binary data in a base64 string
|
||||
*
|
||||
* @param {Object} packet, has `type` and `data`
|
||||
* @return {String} base64 encoded message
|
||||
*/
|
||||
|
||||
exports.encodeBase64Packet = function(packet, callback){
|
||||
if (!Buffer.isBuffer(packet.data)) {
|
||||
packet.data = arrayBufferToBuffer(packet.data);
|
||||
}
|
||||
|
||||
var message = 'b' + packets[packet.type];
|
||||
message += packet.data.toString('base64');
|
||||
return callback(message);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decodes a packet. Data also available as an ArrayBuffer if requested.
|
||||
*
|
||||
* @return {Object} with `type` and `data` (if any)
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.decodePacket = function (data, binaryType, utf8decode) {
|
||||
if (data === undefined) {
|
||||
return err;
|
||||
}
|
||||
// String data
|
||||
if (typeof data == 'string') {
|
||||
if (data.charAt(0) == 'b') {
|
||||
return exports.decodeBase64Packet(data.substr(1), binaryType);
|
||||
}
|
||||
|
||||
var type = data.charAt(0);
|
||||
|
||||
if (utf8decode) {
|
||||
data = tryDecode(data);
|
||||
if (data === false) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
if (Number(type) != type || !packetslist[type]) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (data.length > 1) {
|
||||
return { type: packetslist[type], data: data.substring(1) };
|
||||
} else {
|
||||
return { type: packetslist[type] };
|
||||
}
|
||||
}
|
||||
|
||||
// Binary data
|
||||
if (binaryType === 'arraybuffer') {
|
||||
// wrap Buffer/ArrayBuffer data into an Uint8Array
|
||||
var intArray = new Uint8Array(data);
|
||||
var type = intArray[0];
|
||||
return { type: packetslist[type], data: intArray.buffer.slice(1) };
|
||||
}
|
||||
|
||||
if (data instanceof ArrayBuffer) {
|
||||
data = arrayBufferToBuffer(data);
|
||||
}
|
||||
var type = data[0];
|
||||
return { type: packetslist[type], data: data.slice(1) };
|
||||
};
|
||||
|
||||
function tryDecode(data) {
|
||||
try {
|
||||
data = utf8.decode(data);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a packet encoded in a base64 string.
|
||||
*
|
||||
* @param {String} base64 encoded message
|
||||
* @return {Object} with `type` and `data` (if any)
|
||||
*/
|
||||
|
||||
exports.decodeBase64Packet = function(msg, binaryType) {
|
||||
var type = packetslist[msg.charAt(0)];
|
||||
var data = new Buffer(msg.substr(1), 'base64');
|
||||
if (binaryType === 'arraybuffer') {
|
||||
var abv = new Uint8Array(data.length);
|
||||
for (var i = 0; i < abv.length; i++){
|
||||
abv[i] = data[i];
|
||||
}
|
||||
data = abv.buffer;
|
||||
}
|
||||
return { type: type, data: data };
|
||||
};
|
||||
|
||||
/**
|
||||
* Encodes multiple messages (payload).
|
||||
*
|
||||
* <length>:data
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 11:hello world2:hi
|
||||
*
|
||||
* If any contents are binary, they will be encoded as base64 strings. Base64
|
||||
* encoded strings are marked with a b before the length specifier
|
||||
*
|
||||
* @param {Array} packets
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.encodePayload = function (packets, supportsBinary, callback) {
|
||||
if (typeof supportsBinary == 'function') {
|
||||
callback = supportsBinary;
|
||||
supportsBinary = null;
|
||||
}
|
||||
|
||||
if (supportsBinary) {
|
||||
return exports.encodePayloadAsBinary(packets, callback);
|
||||
}
|
||||
|
||||
if (!packets.length) {
|
||||
return callback('0:');
|
||||
}
|
||||
|
||||
function setLengthHeader(message) {
|
||||
return message.length + ':' + message;
|
||||
}
|
||||
|
||||
function encodeOne(packet, doneCallback) {
|
||||
exports.encodePacket(packet, supportsBinary, true, function(message) {
|
||||
doneCallback(null, setLengthHeader(message));
|
||||
});
|
||||
}
|
||||
|
||||
map(packets, encodeOne, function(err, results) {
|
||||
return callback(results.join(''));
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Async array map using after
|
||||
*/
|
||||
|
||||
function map(ary, each, done) {
|
||||
var result = new Array(ary.length);
|
||||
var next = after(ary.length, done);
|
||||
|
||||
var eachWithIndex = function(i, el, cb) {
|
||||
each(el, function(error, msg) {
|
||||
result[i] = msg;
|
||||
cb(error, result);
|
||||
});
|
||||
};
|
||||
|
||||
for (var i = 0; i < ary.length; i++) {
|
||||
eachWithIndex(i, ary[i], next);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes data when a payload is maybe expected. Possible binary contents are
|
||||
* decoded from their base64 representation
|
||||
*
|
||||
* @param {String} data, callback method
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.decodePayload = function (data, binaryType, callback) {
|
||||
if ('string' != typeof data) {
|
||||
return exports.decodePayloadAsBinary(data, binaryType, callback);
|
||||
}
|
||||
|
||||
if (typeof binaryType === 'function') {
|
||||
callback = binaryType;
|
||||
binaryType = null;
|
||||
}
|
||||
|
||||
var packet;
|
||||
if (data == '') {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
var length = ''
|
||||
, n, msg;
|
||||
|
||||
for (var i = 0, l = data.length; i < l; i++) {
|
||||
var chr = data.charAt(i);
|
||||
|
||||
if (':' != chr) {
|
||||
length += chr;
|
||||
} else {
|
||||
if ('' == length || (length != (n = Number(length)))) {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
msg = data.substr(i + 1, n);
|
||||
|
||||
if (length != msg.length) {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
if (msg.length) {
|
||||
packet = exports.decodePacket(msg, binaryType, true);
|
||||
|
||||
if (err.type == packet.type && err.data == packet.data) {
|
||||
// parser error in individual packet - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
var ret = callback(packet, i + n, l);
|
||||
if (false === ret) return;
|
||||
}
|
||||
|
||||
// advance cursor
|
||||
i += n;
|
||||
length = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (length != '') {
|
||||
// parser error - ignoring payload
|
||||
return callback(err, 0, 1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts a buffer to a utf8.js encoded string
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function bufferToString(buffer) {
|
||||
var str = '';
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
str += String.fromCharCode(buffer[i]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts a utf8.js encoded string to a buffer
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringToBuffer(string) {
|
||||
var buf = new Buffer(string.length);
|
||||
for (var i = 0; i < string.length; i++) {
|
||||
buf.writeUInt8(string.charCodeAt(i), i);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts an ArrayBuffer to a Buffer
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function arrayBufferToBuffer(data) {
|
||||
// data is either an ArrayBuffer or ArrayBufferView.
|
||||
var array = new Uint8Array(data.buffer || data);
|
||||
var length = data.byteLength || data.length;
|
||||
var offset = data.byteOffset || 0;
|
||||
var buffer = new Buffer(length);
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
buffer[i] = array[offset + i];
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes multiple messages (payload) as binary.
|
||||
*
|
||||
* <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
|
||||
* 255><data>
|
||||
*
|
||||
* Example:
|
||||
* 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
|
||||
*
|
||||
* @param {Array} packets
|
||||
* @return {Buffer} encoded payload
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.encodePayloadAsBinary = function (packets, callback) {
|
||||
if (!packets.length) {
|
||||
return callback(new Buffer(0));
|
||||
}
|
||||
|
||||
function encodeOne(p, doneCallback) {
|
||||
exports.encodePacket(p, true, true, function(packet) {
|
||||
|
||||
if (typeof packet === 'string') {
|
||||
var encodingLength = '' + packet.length;
|
||||
var sizeBuffer = new Buffer(encodingLength.length + 2);
|
||||
sizeBuffer[0] = 0; // is a string (not true binary = 0)
|
||||
for (var i = 0; i < encodingLength.length; i++) {
|
||||
sizeBuffer[i + 1] = parseInt(encodingLength[i], 10);
|
||||
}
|
||||
sizeBuffer[sizeBuffer.length - 1] = 255;
|
||||
return doneCallback(null, Buffer.concat([sizeBuffer, stringToBuffer(packet)]));
|
||||
}
|
||||
|
||||
var encodingLength = '' + packet.length;
|
||||
var sizeBuffer = new Buffer(encodingLength.length + 2);
|
||||
sizeBuffer[0] = 1; // is binary (true binary = 1)
|
||||
for (var i = 0; i < encodingLength.length; i++) {
|
||||
sizeBuffer[i + 1] = parseInt(encodingLength[i], 10);
|
||||
}
|
||||
sizeBuffer[sizeBuffer.length - 1] = 255;
|
||||
doneCallback(null, Buffer.concat([sizeBuffer, packet]));
|
||||
});
|
||||
}
|
||||
|
||||
map(packets, encodeOne, function(err, results) {
|
||||
return callback(Buffer.concat(results));
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Decodes data when a payload is maybe expected. Strings are decoded by
|
||||
* interpreting each byte as a key code for entries marked to start with 0. See
|
||||
* description of encodePayloadAsBinary
|
||||
|
||||
* @param {Buffer} data, callback method
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.decodePayloadAsBinary = function (data, binaryType, callback) {
|
||||
if (typeof binaryType === 'function') {
|
||||
callback = binaryType;
|
||||
binaryType = null;
|
||||
}
|
||||
|
||||
var bufferTail = data;
|
||||
var buffers = [];
|
||||
|
||||
while (bufferTail.length > 0) {
|
||||
var strLen = '';
|
||||
var isString = bufferTail[0] === 0;
|
||||
var numberTooLong = false;
|
||||
for (var i = 1; ; i++) {
|
||||
if (bufferTail[i] == 255) break;
|
||||
// 310 = char length of Number.MAX_VALUE
|
||||
if (strLen.length > 310) {
|
||||
numberTooLong = true;
|
||||
break;
|
||||
}
|
||||
strLen += '' + bufferTail[i];
|
||||
}
|
||||
if(numberTooLong) return callback(err, 0, 1);
|
||||
bufferTail = bufferTail.slice(strLen.length + 1);
|
||||
|
||||
var msgLength = parseInt(strLen, 10);
|
||||
|
||||
var msg = bufferTail.slice(1, msgLength + 1);
|
||||
if (isString) msg = bufferToString(msg);
|
||||
buffers.push(msg);
|
||||
bufferTail = bufferTail.slice(msgLength + 1);
|
||||
}
|
||||
|
||||
var total = buffers.length;
|
||||
buffers.forEach(function(buffer, i) {
|
||||
callback(exports.decodePacket(buffer, binaryType, true), i, total);
|
||||
});
|
||||
};
|
19
node_modules/engine.io-parser/lib/keys.js
generated
vendored
Normal file
19
node_modules/engine.io-parser/lib/keys.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
/**
|
||||
* Gets the keys for an object.
|
||||
*
|
||||
* @return {Array} keys
|
||||
* @api private
|
||||
*/
|
||||
|
||||
module.exports = Object.keys || function keys (obj){
|
||||
var arr = [];
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
for (var i in obj) {
|
||||
if (has.call(obj, i)) {
|
||||
arr.push(i);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
15
node_modules/engine.io-parser/node_modules/has-binary/.npmignore
generated
vendored
Normal file
15
node_modules/engine.io-parser/node_modules/has-binary/.npmignore
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
npm-debug.log
|
||||
node_modules
|
11
node_modules/engine.io-parser/node_modules/has-binary/History.md
generated
vendored
Normal file
11
node_modules/engine.io-parser/node_modules/has-binary/History.md
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
0.1.6 / 2015-01-24
|
||||
==================
|
||||
|
||||
* fix "undefined function" bug when iterating
|
||||
an object created with Object.create(null) [gunta]
|
||||
|
||||
0.1.5 / 2014-09-04
|
||||
==================
|
||||
|
||||
* prevent browserify from bundling `Buffer`
|
20
node_modules/engine.io-parser/node_modules/has-binary/LICENSE
generated
vendored
Normal file
20
node_modules/engine.io-parser/node_modules/has-binary/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Kevin Roark
|
||||
|
||||
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.
|
3
node_modules/engine.io-parser/node_modules/has-binary/Makefile
generated
vendored
Normal file
3
node_modules/engine.io-parser/node_modules/has-binary/Makefile
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/mocha test.js
|
4
node_modules/engine.io-parser/node_modules/has-binary/README.md
generated
vendored
Normal file
4
node_modules/engine.io-parser/node_modules/has-binary/README.md
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
has-binarydata.js
|
||||
=================
|
||||
|
||||
Simple module to test if an object contains binary data
|
1
node_modules/engine.io-parser/node_modules/has-binary/fixtures/big.json
generated
vendored
Normal file
1
node_modules/engine.io-parser/node_modules/has-binary/fixtures/big.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
58
node_modules/engine.io-parser/node_modules/has-binary/index.js
generated
vendored
Normal file
58
node_modules/engine.io-parser/node_modules/has-binary/index.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
/*
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var isArray = require('isarray');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = hasBinary;
|
||||
|
||||
/**
|
||||
* Checks for binary data.
|
||||
*
|
||||
* Right now only Buffer and ArrayBuffer are supported..
|
||||
*
|
||||
* @param {Object} anything
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function hasBinary(data) {
|
||||
|
||||
function _hasBinary(obj) {
|
||||
if (!obj) return false;
|
||||
|
||||
if ( (global.Buffer && global.Buffer.isBuffer(obj)) ||
|
||||
(global.ArrayBuffer && obj instanceof ArrayBuffer) ||
|
||||
(global.Blob && obj instanceof Blob) ||
|
||||
(global.File && obj instanceof File)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isArray(obj)) {
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
if (_hasBinary(obj[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (obj && 'object' == typeof obj) {
|
||||
if (obj.toJSON) {
|
||||
obj = obj.toJSON();
|
||||
}
|
||||
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return _hasBinary(data);
|
||||
}
|
63
node_modules/engine.io-parser/node_modules/has-binary/package.json
generated
vendored
Normal file
63
node_modules/engine.io-parser/node_modules/has-binary/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"has-binary@0.1.6",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\engine.io-parser"
|
||||
]
|
||||
],
|
||||
"_from": "has-binary@0.1.6",
|
||||
"_id": "has-binary@0.1.6",
|
||||
"_inCache": true,
|
||||
"_location": "/engine.io-parser/has-binary",
|
||||
"_npmUser": {
|
||||
"email": "rauchg@gmail.com",
|
||||
"name": "rauchg"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "has-binary",
|
||||
"raw": "has-binary@0.1.6",
|
||||
"rawSpec": "0.1.6",
|
||||
"scope": null,
|
||||
"spec": "0.1.6",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io-parser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.6.tgz",
|
||||
"_shasum": "25326f39cfa4f616ad8787894e3af2cfbc7b6e10",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "has-binary@0.1.6",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\engine.io-parser",
|
||||
"author": {
|
||||
"name": "Kevin Roark"
|
||||
},
|
||||
"dependencies": {
|
||||
"isarray": "0.0.1"
|
||||
},
|
||||
"description": "A function that takes anything in javascript and returns true if its argument contains binary data.",
|
||||
"devDependencies": {
|
||||
"better-assert": "1.0.0",
|
||||
"mocha": "1.17.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "25326f39cfa4f616ad8787894e3af2cfbc7b6e10",
|
||||
"tarball": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.6.tgz"
|
||||
},
|
||||
"gitHead": "a37d7ed88fb88e49d5ed1ca15e6cc7dd004dd0e8",
|
||||
"installable": true,
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "rauchg",
|
||||
"email": "rauchg@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "has-binary",
|
||||
"optionalDependencies": {},
|
||||
"scripts": {},
|
||||
"version": "0.1.6"
|
||||
}
|
108
node_modules/engine.io-parser/node_modules/has-binary/test.js
generated
vendored
Normal file
108
node_modules/engine.io-parser/node_modules/has-binary/test.js
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
|
||||
var hasBinary = require('./');
|
||||
var assert = require('better-assert');
|
||||
var fs = require('fs');
|
||||
|
||||
var start = new Date();
|
||||
|
||||
describe('has-binarydata', function(){
|
||||
|
||||
it('should work with buffer', function(){
|
||||
assert(hasBinary(fs.readFileSync('./test.js')));
|
||||
});
|
||||
|
||||
it('should work with an array that does not contain binary', function() {
|
||||
var arr = [1, 'cool', 2];
|
||||
assert(!hasBinary(arr));
|
||||
});
|
||||
|
||||
it('should work with an array that contains a buffer', function() {
|
||||
var arr = [1, new Buffer('asdfasdf', 'utf8'), 2];
|
||||
assert(hasBinary(arr));
|
||||
});
|
||||
|
||||
it('should work with an object that does not contain binary', function() {
|
||||
var ob = {a: 'a', b: [], c: 1234};
|
||||
assert(!hasBinary(ob));
|
||||
});
|
||||
|
||||
it('should work with an object that contains a buffer', function() {
|
||||
var ob = {a: 'a', b: new Buffer('abc'), c: 1234};
|
||||
assert(hasBinary(ob));
|
||||
});
|
||||
|
||||
it('should work with null', function() {
|
||||
assert(!hasBinary(null));
|
||||
});
|
||||
|
||||
it('should work with undefined', function() {
|
||||
assert(!hasBinary(undefined));
|
||||
});
|
||||
|
||||
it('should work with a complex object that contains undefined and no binary', function() {
|
||||
var ob = {
|
||||
x: ['a', 'b', 123],
|
||||
y: undefined,
|
||||
z: {a: 'x', b: 'y', c: 3, d: null},
|
||||
w: []
|
||||
};
|
||||
assert(!hasBinary(ob));
|
||||
});
|
||||
|
||||
it('should work with a complex object that contains undefined and binary', function() {
|
||||
var ob = {
|
||||
x: ['a', 'b', 123],
|
||||
y: undefined,
|
||||
z: {a: 'x', b: 'y', c: 3, d: null},
|
||||
w: [],
|
||||
bin: new Buffer('xxx')
|
||||
};
|
||||
assert(hasBinary(ob));
|
||||
});
|
||||
|
||||
it('should handle a very large json object with no binary', function(done) {
|
||||
this.timeout();
|
||||
fs.readFile(__dirname + '/fixtures/big.json', function(err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
assert(false);
|
||||
}
|
||||
data = JSON.parse(data);
|
||||
assert(!hasBinary(data));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle a very large json object with binary', function(done) {
|
||||
this.timeout();
|
||||
fs.readFile(__dirname + '/fixtures/big.json', function(err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
assert(false);
|
||||
}
|
||||
var ob = JSON.parse(data);
|
||||
ob.bin = {bin: {bin: {bin: new Buffer('abc')}}};
|
||||
assert(hasBinary(ob));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
if (global.ArrayBuffer) {
|
||||
it('should work with an ArrayBuffer', function() {
|
||||
assert(hasBinary(new ArrayBuffer()));
|
||||
});
|
||||
}
|
||||
|
||||
if (global.Blob) {
|
||||
it('should work with a Blob', function() {
|
||||
assert(hasBinary(new Blob()));
|
||||
});
|
||||
}
|
||||
|
||||
it('should print the test time', function() {
|
||||
var end = new Date();
|
||||
var diff = end - start;
|
||||
console.log('\ntest time: ' + diff + ' ms');
|
||||
});
|
||||
|
||||
});
|
54
node_modules/engine.io-parser/node_modules/isarray/README.md
generated
vendored
Normal file
54
node_modules/engine.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/engine.io-parser/node_modules/isarray/build/build.js
generated
vendored
Normal file
209
node_modules/engine.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/engine.io-parser/node_modules/isarray/component.json
generated
vendored
Normal file
19
node_modules/engine.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/engine.io-parser/node_modules/isarray/index.js
generated
vendored
Normal file
3
node_modules/engine.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/engine.io-parser/node_modules/isarray/package.json
generated
vendored
Normal file
74
node_modules/engine.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\\engine.io-parser\\node_modules\\has-binary"
|
||||
]
|
||||
],
|
||||
"_from": "isarray@0.0.1",
|
||||
"_id": "isarray@0.0.1",
|
||||
"_inCache": true,
|
||||
"_location": "/engine.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": [
|
||||
"/engine.io-parser/has-binary"
|
||||
],
|
||||
"_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\\engine.io-parser\\node_modules\\has-binary",
|
||||
"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/engine.io-parser/package.json
generated
vendored
Normal file
92
node_modules/engine.io-parser/package.json
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"engine.io-parser@1.3.1",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\engine.io"
|
||||
]
|
||||
],
|
||||
"_from": "engine.io-parser@1.3.1",
|
||||
"_id": "engine.io-parser@1.3.1",
|
||||
"_inCache": true,
|
||||
"_location": "/engine.io-parser",
|
||||
"_nodeVersion": "4.4.7",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-18-east.internal.npmjs.com",
|
||||
"tmp": "tmp/engine.io-parser-1.3.1.tgz_1476967470566_0.9431107800919563"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "damien.arrachequesne@gmail.com",
|
||||
"name": "darrachequesne"
|
||||
},
|
||||
"_npmVersion": "2.15.8",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "engine.io-parser",
|
||||
"raw": "engine.io-parser@1.3.1",
|
||||
"rawSpec": "1.3.1",
|
||||
"scope": null,
|
||||
"spec": "1.3.1",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io",
|
||||
"/engine.io-client"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.3.1.tgz",
|
||||
"_shasum": "9554f1ae33107d6fbd170ca5466d2f833f6a07cf",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "engine.io-parser@1.3.1",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\engine.io",
|
||||
"browser": "./lib/browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/socketio/engine.io-parser/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"after": "0.8.1",
|
||||
"arraybuffer.slice": "0.0.6",
|
||||
"base64-arraybuffer": "0.1.5",
|
||||
"blob": "0.0.4",
|
||||
"has-binary": "0.1.6",
|
||||
"wtf-8": "1.0.0"
|
||||
},
|
||||
"description": "Parser for the client for the realtime Engine",
|
||||
"devDependencies": {
|
||||
"expect.js": "0.3.1",
|
||||
"mocha": "2.2.5",
|
||||
"zuul": "3.11.0",
|
||||
"zuul-ngrok": "4.0.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "9554f1ae33107d6fbd170ca5466d2f833f6a07cf",
|
||||
"tarball": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.3.1.tgz"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"gitHead": "ada9dbe77bf345b5284c7a913bead0295b48ed74",
|
||||
"homepage": "https://github.com/socketio/engine.io-parser",
|
||||
"installable": true,
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "darrachequesne",
|
||||
"email": "damien.arrachequesne@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "rauchg",
|
||||
"email": "rauchg@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "engine.io-parser",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/socketio/engine.io-parser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.3.1"
|
||||
}
|
Reference in New Issue
Block a user