nodejs with express server, leapmotion for movement control, and threejs for 3d render

This commit is contained in:
idoctnef
2016-05-30 18:14:08 +02:00
parent e2aeac1bae
commit 52b63ee33a
893 changed files with 127726 additions and 0 deletions

5
node_modules/socket.io-parser/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,5 @@
node_modules
build
components
test

11
node_modules/socket.io-parser/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,11 @@
language: node_js
node_js:
- 0.10
notifications:
irc: irc.freenode.org##socket.io
git:
depth: 1
env:
global:
- secure: 28HHk1J0H64KNjzmmlxG/Ro0EPuLnhO0rU+kZjjthDHj/FaugIsqjAVQ1Dl6heWV2/MlVzw6nDCyMNiGwiVk0ruZPQ0SYdAKLplrdMtzAihbU3xx+ULFQPLM3SoW0ZFCEpe8dWPGy4WdgW7aLByeel9TJb3vlhAu7p7AvrcO7Fs=
- secure: rKEG0Cfw0vkw8thk63RHYG7h8XWYcBlvZ0w1IWpr2dAfnnLMi1palSTrBrFQc77flk7rN00zGIe76FhKydV9r4WWYAUYKPqo4k+9/FkpzjZlNtL49QRoNwC9jmJ8OeUwGowA13gZPyl/5P13wVaKCB0YrKnzz5LHo3Sp7So6J8U=

16
node_modules/socket.io-parser/.zuul.yml generated vendored Normal file
View File

@@ -0,0 +1,16 @@
ui: mocha-bdd
browsers:
- name: chrome
version: 29..latest
- name: firefox
version: latest
- name: safari
version: latest
- name: ie
version: 10
platform: Windows 2012
- name: ie
version: 9
version: [6..9, latest]
- name: iphone
version: oldest..latest

87
node_modules/socket.io-parser/History.md generated vendored Normal file
View File

@@ -0,0 +1,87 @@
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

11
node_modules/socket.io-parser/Makefile generated vendored Normal file
View File

@@ -0,0 +1,11 @@
REPORTER = dot
test:
@./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--bail \
test/index.js
@./node_modules/.bin/zuul -- test/index.js
.PHONY: test

73
node_modules/socket.io-parser/Readme.md generated vendored Normal file
View File

@@ -0,0 +1,73 @@
# socket.io-parser
[![Build Status](https://secure.travis-ci.org/Automattic/socket.io-parser.svg)](http://travis-ci.org/Automattic/socket.io-parser)
[![NPM version](https://badge.fury.io/js/socket.io-parser.svg)](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/learnboost/socket.io-protocol).
Used by [socket.io](https://github.com/learnboost/socket.io) and
[socket.io-client](https://github.com/learnboost/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

10
node_modules/socket.io-parser/bench/bench.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
var bencher = require('./index');
bencher(function(benchmark) {
function logMean(test) {
console.log(test.name + ' mean run time: ' + test.stats.mean);
}
for (var i = 0; i < benchmark.length; i++) {
logMean(benchmark[i]);
}
});

81
node_modules/socket.io-parser/bench/index.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
var Benchmark = require('benchmark');
var parser = require('../index');
function test(packet, deferred) {
var encoder = new parser.Encoder();
var decoder = new parser.Decoder();
encoder.encode(packet, function(encodedPackets) {
var decoder = new parser.Decoder();
decoder.on('decoded', function(packet) {
deferred.resolve();
});
decoder.add(encodedPackets[0]);
});
}
var dataObject = {
'a': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],
'b': 'xxxyyyzzzalsdfalskdjfalksdjfalksdjfalksdjfjjfjfjfjjfjfjfj',
'data': {
'is': 'cool',
'or': {
'is': {
'it': true
}
}
}
};
var bigArray = [];
for (var i = 0; i < 250; i++) {
bigArray.push(dataObject);
}
module.exports = function(callback) {
var suite = new Benchmark.Suite();
suite.add('small json parse', {defer: true, fn: function(deferred) {
var packet = {
type: parser.EVENT,
nsp: '/bench',
data: dataObject
};
test(packet, deferred);
}})
.add('big json parse', {defer: true, fn: function(deferred) {
var packet = {
type: parser.EVENT,
nsp: '/bench',
data: bigArray
};
test(packet, deferred);
}})
.add('json with small binary parse', {defer: true, fn: function(deferred) {
var packet = {
type: parser.EVENT,
nsp: '/bench',
data: {'a': [1, 2, 3], 'b': 'xxxyyyzzz', 'data': new Buffer(1000)}
};
test(packet, deferred);
}})
.add('json with big binary parse', {defer: true, fn: function(deferred) {
var bigBinaryData = {
bin1: new Buffer(10000),
arr: bigArray,
bin2: new Buffer(10000),
bin3: new Buffer(10000)
};
var packet = {
type: parser.EVENT,
nsp: '/bench',
data: bigBinaryData
};
test(packet, deferred);
}})
.on('complete', function() {
callback(this);
})
.run({'async': true});
};

141
node_modules/socket.io-parser/binary.js generated vendored Normal file
View 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);
}
};

396
node_modules/socket.io-parser/index.js generated vendored Normal file
View File

@@ -0,0 +1,396 @@
/**
* Module dependencies.
*/
var debug = require('debug')('socket.io-parser');
var json = require('json3');
var isArray = require('isarray');
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',
'BINARY_EVENT',
'ACK',
'BINARY_ACK',
'ERROR'
];
/**
* 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) {
p.attachments = '';
while (str.charAt(++i) != '-') {
p.attachments += str.charAt(i);
}
p.attachments = Number(p.attachments);
}
// 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 + 1 == 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 + 1 == str.length) break;
}
p.id = Number(p.id);
}
// look up json data
if (str.charAt(++i)) {
try {
p.data = json.parse(str.substr(i));
} catch(e){
return error();
}
}
debug('decoded %s as %j', str, p);
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
View 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);
}

View File

@@ -0,0 +1,115 @@
# debug
tiny node.js debugging utility modelled after node core's debugging technique.
## Installation
```
$ npm install debug
```
## Usage
With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
Example _app.js_:
```js
var debug = require('debug')('http')
, http = require('http')
, name = 'My App';
// fake app
debug('booting %s', name);
http.createServer(function(req, res){
debug(req.method + ' ' + req.url);
res.end('hello\n');
}).listen(3000, function(){
debug('listening');
});
// fake worker of some kind
require('./worker');
```
Example _worker.js_:
```js
var debug = require('debug')('worker');
setInterval(function(){
debug('doing some work');
}, 1000);
```
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png)
![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png)
## Millisecond diff
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)
When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
_(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_
![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png)
## Conventions
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
## Wildcards
The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with "connect:".
## Browser support
Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`.
```js
a = debug('worker:a');
b = debug('worker:b');
setInterval(function(){
a('doing some work');
}, 1000);
setInterval(function(){
a('doing some work');
}, 1200);
```
## License
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
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.

View File

@@ -0,0 +1,137 @@
/**
* Expose `debug()` as the module.
*/
module.exports = debug;
/**
* Create a debugger with the given `name`.
*
* @param {String} name
* @return {Type}
* @api public
*/
function debug(name) {
if (!debug.enabled(name)) return function(){};
return function(fmt){
fmt = coerce(fmt);
var curr = new Date;
var ms = curr - (debug[name] || curr);
debug[name] = curr;
fmt = name
+ ' '
+ fmt
+ ' +' + debug.humanize(ms);
// This hackery is required for IE8
// where `console.log` doesn't have 'apply'
window.console
&& console.log
&& Function.prototype.apply.call(console.log, console, arguments);
}
}
/**
* The currently active debug mode names.
*/
debug.names = [];
debug.skips = [];
/**
* Enables a debug mode by name. This can include modes
* separated by a colon and wildcards.
*
* @param {String} name
* @api public
*/
debug.enable = function(name) {
try {
localStorage.debug = name;
} catch(e){}
var split = (name || '').split(/[\s,]+/)
, len = split.length;
for (var i = 0; i < len; i++) {
name = split[i].replace('*', '.*?');
if (name[0] === '-') {
debug.skips.push(new RegExp('^' + name.substr(1) + '$'));
}
else {
debug.names.push(new RegExp('^' + name + '$'));
}
}
};
/**
* Disable debug output.
*
* @api public
*/
debug.disable = function(){
debug.enable('');
};
/**
* Humanize the given `ms`.
*
* @param {Number} m
* @return {String}
* @api private
*/
debug.humanize = function(ms) {
var sec = 1000
, min = 60 * 1000
, hour = 60 * min;
if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
if (ms >= min) return (ms / min).toFixed(1) + 'm';
if (ms >= sec) return (ms / sec | 0) + 's';
return ms + 'ms';
};
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
debug.enabled = function(name) {
for (var i = 0, len = debug.skips.length; i < len; i++) {
if (debug.skips[i].test(name)) {
return false;
}
}
for (var i = 0, len = debug.names.length; i < len; i++) {
if (debug.names[i].test(name)) {
return true;
}
}
return false;
};
/**
* Coerce `val`.
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
// persist
try {
if (window.localStorage) debug.enable(localStorage.debug);
} catch(e){}

View File

@@ -0,0 +1,5 @@
if ('undefined' == typeof window) {
module.exports = require('./lib/debug');
} else {
module.exports = require('./debug');
}

View File

@@ -0,0 +1,147 @@
/**
* Module dependencies.
*/
var tty = require('tty');
/**
* Expose `debug()` as the module.
*/
module.exports = debug;
/**
* Enabled debuggers.
*/
var names = []
, skips = [];
(process.env.DEBUG || '')
.split(/[\s,]+/)
.forEach(function(name){
name = name.replace('*', '.*?');
if (name[0] === '-') {
skips.push(new RegExp('^' + name.substr(1) + '$'));
} else {
names.push(new RegExp('^' + name + '$'));
}
});
/**
* Colors.
*/
var colors = [6, 2, 3, 4, 5, 1];
/**
* Previous debug() call.
*/
var prev = {};
/**
* Previously assigned color.
*/
var prevColor = 0;
/**
* Is stdout a TTY? Colored output is disabled when `true`.
*/
var isatty = tty.isatty(2);
/**
* Select a color.
*
* @return {Number}
* @api private
*/
function color() {
return colors[prevColor++ % colors.length];
}
/**
* Humanize the given `ms`.
*
* @param {Number} m
* @return {String}
* @api private
*/
function humanize(ms) {
var sec = 1000
, min = 60 * 1000
, hour = 60 * min;
if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
if (ms >= min) return (ms / min).toFixed(1) + 'm';
if (ms >= sec) return (ms / sec | 0) + 's';
return ms + 'ms';
}
/**
* Create a debugger with the given `name`.
*
* @param {String} name
* @return {Type}
* @api public
*/
function debug(name) {
function disabled(){}
disabled.enabled = false;
var match = skips.some(function(re){
return re.test(name);
});
if (match) return disabled;
match = names.some(function(re){
return re.test(name);
});
if (!match) return disabled;
var c = color();
function colored(fmt) {
fmt = coerce(fmt);
var curr = new Date;
var ms = curr - (prev[name] || curr);
prev[name] = curr;
fmt = ' \u001b[9' + c + 'm' + name + ' '
+ '\u001b[3' + c + 'm\u001b[90m'
+ fmt + '\u001b[3' + c + 'm'
+ ' +' + humanize(ms) + '\u001b[0m';
console.error.apply(this, arguments);
}
function plain(fmt) {
fmt = coerce(fmt);
fmt = new Date().toUTCString()
+ ' ' + name + ' ' + fmt;
console.error.apply(this, arguments);
}
colored.enabled = plain.enabled = true;
return isatty || process.env.DEBUG_COLORS
? colored
: plain;
}
/**
* Coerce `val`.
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}

View File

@@ -0,0 +1,88 @@
{
"_args": [
[
"debug@0.7.4",
"C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\socket.io-parser"
]
],
"_from": "debug@0.7.4",
"_id": "debug@0.7.4",
"_inCache": true,
"_installable": true,
"_location": "/socket.io-parser/debug",
"_npmUser": {
"email": "tj@vision-media.ca",
"name": "tjholowaychuk"
},
"_npmVersion": "1.3.13",
"_phantomChildren": {},
"_requested": {
"name": "debug",
"raw": "debug@0.7.4",
"rawSpec": "0.7.4",
"scope": null,
"spec": "0.7.4",
"type": "version"
},
"_requiredBy": [
"/socket.io-parser"
],
"_resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz",
"_shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39",
"_shrinkwrap": null,
"_spec": "debug@0.7.4",
"_where": "C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\socket.io-parser",
"author": {
"email": "tj@vision-media.ca",
"name": "TJ Holowaychuk"
},
"browser": "./debug.js",
"bugs": {
"url": "https://github.com/visionmedia/debug/issues"
},
"component": {
"scripts": {
"debug/debug.js": "debug.js",
"debug/index.js": "index.js"
}
},
"dependencies": {},
"description": "small debugging utility",
"devDependencies": {
"mocha": "*"
},
"directories": {},
"dist": {
"shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39",
"tarball": "http://registry.npmjs.org/debug/-/debug-0.7.4.tgz"
},
"engines": {
"node": "*"
},
"files": [
"lib/debug.js",
"debug.js",
"index.js"
],
"homepage": "https://github.com/visionmedia/debug",
"keywords": [
"debug",
"log",
"debugger"
],
"main": "lib/debug.js",
"maintainers": [
{
"email": "tj@vision-media.ca",
"name": "tjholowaychuk"
}
],
"name": "debug",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/visionmedia/debug.git"
},
"version": "0.7.4"
}

78
node_modules/socket.io-parser/package.json generated vendored Normal file
View File

@@ -0,0 +1,78 @@
{
"_args": [
[
"socket.io-parser@2.2.2",
"C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\socket.io"
]
],
"_from": "socket.io-parser@2.2.2",
"_id": "socket.io-parser@2.2.2",
"_inCache": true,
"_installable": true,
"_location": "/socket.io-parser",
"_npmUser": {
"email": "rauchg@gmail.com",
"name": "rauchg"
},
"_npmVersion": "1.4.25",
"_phantomChildren": {},
"_requested": {
"name": "socket.io-parser",
"raw": "socket.io-parser@2.2.2",
"rawSpec": "2.2.2",
"scope": null,
"spec": "2.2.2",
"type": "version"
},
"_requiredBy": [
"/socket.io",
"/socket.io-adapter",
"/socket.io-client"
],
"_resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.2.2.tgz",
"_shasum": "3d7af6b64497e956b7d9fe775f999716027f9417",
"_shrinkwrap": null,
"_spec": "socket.io-parser@2.2.2",
"_where": "C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\socket.io",
"bugs": {
"url": "https://github.com/Automattic/socket.io-parser/issues"
},
"dependencies": {
"benchmark": "1.0.0",
"component-emitter": "1.1.2",
"debug": "0.7.4",
"isarray": "0.0.1",
"json3": "3.2.6"
},
"description": "socket.io protocol parser",
"devDependencies": {
"expect.js": "0.2.0",
"mocha": "1.16.2",
"zuul": "1.6.3"
},
"directories": {},
"dist": {
"shasum": "3d7af6b64497e956b7d9fe775f999716027f9417",
"tarball": "http://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.2.2.tgz"
},
"gitHead": "83c68c7a715ac54e95c5dae6445f751b3a4dfe9f",
"homepage": "https://github.com/Automattic/socket.io-parser",
"license": "MIT",
"maintainers": [
{
"email": "rauchg@gmail.com",
"name": "rauchg"
}
],
"name": "socket.io-parser",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/Automattic/socket.io-parser.git"
},
"scripts": {
"test": "make test"
},
"version": "2.2.2"
}