Initial commit
This commit is contained in:
commit
f17a921ca3
794 changed files with 133975 additions and 0 deletions
338
index.html
Normal file
338
index.html
Normal file
|
@ -0,0 +1,338 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>🏓 Pong</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { height: 100vh; width: 100vw; overflow: hidden; }
|
||||
canvas {border: black solid 1px; top:-1px; left:-1px; position: absolute;}
|
||||
div { position: fixed; top: 0; right: 0; width: 130px; height: 60px; background: rgba(0, 0, 0, .5); color: white; padding: 5px; font-family: monospace; z-index: 100; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="debug">FPS: <fps>...</fps><br/>Ping: <ping>...</ping><br />ID: <id>...</id></div>
|
||||
<canvas id="test"></canvas>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script>
|
||||
var socket = io();
|
||||
var pid;
|
||||
socket.on('handshake', function(id, state, c_width, c_height, sp, fn){
|
||||
$('id').text(id);
|
||||
pid = id;
|
||||
gameState = state;
|
||||
cube_width = c_width;
|
||||
cube_height = c_height;
|
||||
speed = sp;
|
||||
fn($(window).width(), $(window).height());
|
||||
});
|
||||
|
||||
socket.on('size', function(w, h){
|
||||
width = w;
|
||||
height = h;
|
||||
c.width = w;
|
||||
c.height = h;
|
||||
text = 'Starting in 5';
|
||||
});
|
||||
|
||||
socket.on('gamestate', function(state){
|
||||
gameState = state;
|
||||
});
|
||||
|
||||
/** Make Countdown serversided No cheating possible **/
|
||||
socket.on('countdown', function(i){
|
||||
text = 'Starting in ' + i;
|
||||
});
|
||||
|
||||
socket.on('start', function(){
|
||||
leftOr = 'none';
|
||||
rightOr = 'none';
|
||||
leftKeyPressed = false;
|
||||
rightKeyPressed = false;
|
||||
leftY = 0;
|
||||
rightY = 0;
|
||||
leftV = 0;
|
||||
rightV = 0;
|
||||
gameState = 2;
|
||||
});
|
||||
|
||||
socket.on('setOrr', function(id, orr){
|
||||
console.log(id);
|
||||
if(id == 1){
|
||||
leftOr = orr;
|
||||
leftKeyPressed = true;
|
||||
}
|
||||
if(id == 2){
|
||||
rightOr = orr;
|
||||
rightKeyPressed = true;// TODO CHANGE!
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('test', function(arg){
|
||||
console.log(arg);
|
||||
});
|
||||
/** Initialize Canvas **/
|
||||
var c = document.getElementById("test");
|
||||
var ctx = c.getContext("2d");
|
||||
c.width = $(window).width();
|
||||
c.height = $(window).height();
|
||||
|
||||
|
||||
var leftY = 0;
|
||||
var rightY = 0;
|
||||
var leftV = 0;
|
||||
var rightV = 0;
|
||||
var leftColor = 'red';
|
||||
var rightColor = 'blue';
|
||||
var leftKeyPressed = false;
|
||||
var rightKeyPressed = false;
|
||||
var gameState = 0; // 0 == Waiting for Players, 1 == Countdown, 2 == inGame, 3 == ??Win??
|
||||
|
||||
/** FPS Vars **/
|
||||
var lastCalledTime,
|
||||
lastFPSshown,
|
||||
fps;
|
||||
|
||||
/** Global Configuration **/
|
||||
var localcoop = true, // Local Coop in 1 window
|
||||
width = $(window).width(),
|
||||
height = $(window).height();
|
||||
|
||||
/** Prop-Config **/
|
||||
var cube_width = 50,
|
||||
cube_height = 200,
|
||||
speed = 7,
|
||||
ball_size = 15,
|
||||
ball_speed = 8,
|
||||
ballX = cube_width+ball_size,
|
||||
ballY = cube_height/2,
|
||||
ball_owner = 1,
|
||||
ball_VX = 0,
|
||||
ball_VY = 0,
|
||||
ball_maxAngle = 5*Math.PI/12;
|
||||
|
||||
|
||||
/** Messaure Ping and show **/
|
||||
setInterval(function(){
|
||||
var connTime = Date.now();
|
||||
socket.emit('appping', function(data){
|
||||
$('ping').text(Date.now()-connTime + 'ms');
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
var texti = 0,
|
||||
nativtext = 'Waiting for Players',
|
||||
text = nativtext;
|
||||
function draw() {
|
||||
|
||||
|
||||
/** FPS Calculation **/
|
||||
if(!lastCalledTime) {
|
||||
lastCalledTime = Date.now();
|
||||
fps = 0;
|
||||
}
|
||||
delta = (Date.now() - lastCalledTime)/1000;
|
||||
lastCalledTime = Date.now();
|
||||
fps = 1/delta;
|
||||
|
||||
/** Show FPS in Debug-Window **/
|
||||
if(!lastFPSshown) {
|
||||
lastFPSshown = Date.now();
|
||||
$('fps').text('...');
|
||||
}
|
||||
if(lastFPSshown+1000 < Date.now()) {
|
||||
lastFPSshown = Date.now();
|
||||
$('fps').text(Math.round(fps));
|
||||
|
||||
/** Use this timer for displaying loading indicator **/
|
||||
if(gameState == 0)
|
||||
switch(texti){
|
||||
case 0: text = nativtext; texti++; break;
|
||||
case 1 :
|
||||
case 2 : text+='.'; texti++; break;
|
||||
case 3 : text+='.'; texti = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Clear Drawing-Region **/
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
|
||||
if(gameState < 2){
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.font = '30px monospace';
|
||||
ctx.fillText(text, width/2-text.length*8, height/2-30);
|
||||
}
|
||||
|
||||
if(gameState == 2 && pid > 2){
|
||||
var specstr = "Spectator-Mode"
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.font = '15px monospace';
|
||||
ctx.fillText(specstr, width/2-specstr.length*8, 50);
|
||||
}
|
||||
|
||||
if(leftY > height-cube_height || leftY < 0)
|
||||
leftV = 0;
|
||||
if(rightY > height-cube_height || rightY < 0)
|
||||
rightV = 0;
|
||||
if(leftY < 0 ) leftY = 0;
|
||||
if(rightY < 0 ) rightY = 0;
|
||||
if(leftY > height-cube_height) leftY = height-cube_height;
|
||||
if(rightY > height-cube_height) rightY = height-cube_height;
|
||||
|
||||
|
||||
|
||||
/** Draw Cube **/
|
||||
/** Note: Get position by multiplying it with the "Render-Delta" - for same speed on every system **/
|
||||
|
||||
leftY -= leftV*Math.round((1*delta)*60*speed);
|
||||
rightY -= rightV*Math.round((1*delta)*60*speed);
|
||||
|
||||
|
||||
ctx.fillStyle = leftColor;
|
||||
ctx.fillRect(0, leftY, cube_width, cube_height);
|
||||
ctx.fillStyle = rightColor;
|
||||
ctx.fillRect(width-cube_width, rightY, cube_width, cube_height);
|
||||
|
||||
/** Move Ball with Paddle if owned by owner (@roundstart) **/
|
||||
if(ball_owner == 1){
|
||||
ballX = cube_width+ball_size,
|
||||
ballY = leftY+cube_height/2;
|
||||
}
|
||||
else if(ball_owner == 2){
|
||||
ballX = width-cube_width-ball_size,
|
||||
ballY = rightY+cube_height/2;
|
||||
}
|
||||
|
||||
/** ############ **/
|
||||
/** Ball Physics **/
|
||||
/** ############ **/
|
||||
|
||||
/** Collide with right Paddle or get point and respawn **/
|
||||
if(ballX > width - cube_width){
|
||||
if(ballY < rightY || ballY > rightY+cube_height){
|
||||
console.log('Point for Left');
|
||||
ball_VX = 0;
|
||||
ball_VY = 0;
|
||||
ball_owner = 1;
|
||||
} else {
|
||||
var intersect = ((rightY+cube_height/2)-ballY)/(cube_height/2);
|
||||
console.log(intersect);
|
||||
ball_VX = -ball_speed*Math.cos(intersect*ball_maxAngle);
|
||||
ball_VY = -ball_speed*Math.sin(intersect*ball_maxAngle);
|
||||
}
|
||||
}
|
||||
|
||||
/** Collide with left Paddle or get point and respawn **/
|
||||
if(ballX < cube_width){
|
||||
if(ballY < leftY || ballY > leftY+cube_height){
|
||||
console.log('Point for Right');
|
||||
ball_VX = 0;
|
||||
ball_VY = 0;
|
||||
ball_owner = 2;
|
||||
} else {
|
||||
var intersect = ((leftY+cube_height/2)-ballY)/(cube_height/2);
|
||||
console.log(intersect);
|
||||
ball_VX = ball_speed*Math.cos(intersect*ball_maxAngle);
|
||||
ball_VY = ball_speed*Math.sin(intersect*ball_maxAngle);
|
||||
}
|
||||
}
|
||||
|
||||
/** TODO INCREASE SPEED ON PADDLE HIT (weiter außen = schneller) **/
|
||||
|
||||
/** Collide with walls **/
|
||||
if(ballY <= 0 || ballY >= height-ball_size){
|
||||
ball_VY = -ball_VY;
|
||||
}
|
||||
|
||||
/** Draw Ball **/
|
||||
ctx.fillStyle = 'black';
|
||||
ballX += Math.round((1*delta)*60)*ball_VX;
|
||||
ballY += Math.round((1*delta)*60)*ball_VY;
|
||||
ctx.beginPath();
|
||||
ctx.arc(ballX, ballY, ball_size, 0, 2*Math.PI);
|
||||
ctx.fill();
|
||||
|
||||
}
|
||||
|
||||
/** ############## **/
|
||||
/** Input Handlers **/
|
||||
/** ############## **/
|
||||
|
||||
$(window).on('keydown', function(e) {
|
||||
if(localcoop){
|
||||
switch(e.keyCode) {
|
||||
case 38 : if(leftY <= 0) break; leftV = 1; leftKeyPressed = true; break;
|
||||
case 40 : if(leftY >= height-cube_height) break; leftV = -1; leftKeyPressed = true; break;
|
||||
case 87 : if(rightY <= 0) break; rightV = 1; rightKeyPressed = true; break;
|
||||
case 83 : if(rightY >= height-cube_height) break; rightV = -1; rightKeyPressed = true; break;
|
||||
case 37 :
|
||||
case 39 : if(ball_owner != 1) break; shootBall(); break;
|
||||
case 65 :
|
||||
case 68 : if(ball_owner != 2) break; shootBall(); break;
|
||||
}
|
||||
}// TODO !localcoop
|
||||
});
|
||||
|
||||
$(window).on('keyup', function(e) {
|
||||
if(localcoop){
|
||||
switch(e.keyCode) {
|
||||
case 38 :
|
||||
case 40 :
|
||||
// case 40 : var i = 100;
|
||||
// var interval = setInterval(function(){
|
||||
// i--;
|
||||
// leftV = i/100*(0,002-i/100);
|
||||
// if(i == 0) clearInterval(interval);
|
||||
// }, Math.round((1*delta)*60)*10);
|
||||
leftV = 0; leftKeyPressed = false; break;
|
||||
case 87 :
|
||||
case 83 : rightV = 0; rightKeyPressed = false; break;
|
||||
}
|
||||
}
|
||||
// TODO edit
|
||||
// } else if(pid == 1 || pid == 2){
|
||||
// switch(e.keyCode) {
|
||||
// case 38 :
|
||||
// case 87 : if(pid == 1){
|
||||
// if(leftY <= 0) break; leftOr = 'up'; leftKeyPressed = true;
|
||||
// } else if(pid == 2) {
|
||||
// if(rightY <= 0) break; rightOr = 'up'; rightKeyPressed = true;
|
||||
// }
|
||||
// socket.emit('keydown', pid, 'up'); break;
|
||||
//
|
||||
// case 40 :
|
||||
// case 83 : if(pid == 1){
|
||||
// if(leftY >= height-cube_height) break; leftOr = 'down'; leftKeyPressed = true;
|
||||
// } else if(pid == 2){
|
||||
// if(rightY >= height-cube_height) break; rightOr = 'down'; rightKeyPressed = true;
|
||||
// }
|
||||
// socket.emit('keydown', pid, 'down'); break;
|
||||
// case 37 :
|
||||
// case 39 :
|
||||
// case 65 :
|
||||
// case 68 : if(ball_owner != pid)break; shootBall(); break;
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
|
||||
function shootBall() {
|
||||
/** TODO Tewak and Add MAX_Speed **/
|
||||
if(ball_owner == 1)
|
||||
ball_VX = ball_speed;
|
||||
else if(ball_owner == 2)
|
||||
ball_VX = -ball_speed;
|
||||
ball_owner = 0;
|
||||
}
|
||||
|
||||
function animloop() {
|
||||
draw();
|
||||
window.requestAnimationFrame(animloop);
|
||||
}
|
||||
animloop();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
151
index.js
Normal file
151
index.js
Normal file
|
@ -0,0 +1,151 @@
|
|||
var app = require('express')();
|
||||
var http = require('http').Server(app);
|
||||
var io = require('socket.io')(http);
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.sendFile(__dirname + '/index.html');
|
||||
});
|
||||
|
||||
var sockets = [];
|
||||
var gameState = 0;
|
||||
var width, height;
|
||||
|
||||
/** Game-Config **/
|
||||
var cube_width = 50,
|
||||
cube_height = 200,
|
||||
speed = 7;
|
||||
|
||||
/** ########## **/
|
||||
/** CONNECTION **/
|
||||
/** ########## **/
|
||||
io.on('connection', function(socket){
|
||||
var id = sockets.length + 1;
|
||||
if(sockets.length == 1)
|
||||
if(sockets[0].id == 2) id = 1;
|
||||
var clientkey = sockets.push(new Client(id, socket)) - 1;
|
||||
console.log('Client connected. ID=' + id);
|
||||
|
||||
/** ######### **/
|
||||
/** HANDSHAKE **/
|
||||
/** ######### **/
|
||||
socket.emit('handshake', id, gameState, cube_width, cube_height, speed, function(w, h){ // Callback function for 1st Client to set screen size //
|
||||
sockets[clientkey].width = w;
|
||||
sockets[clientkey].height = h;
|
||||
if(sockets.length > 1 && gameState == 0) setUp(socket);
|
||||
});
|
||||
|
||||
if(gameState > 0) socket.emit('size', width, height);
|
||||
/** #### **/
|
||||
/** Ping **/
|
||||
/** ### **/
|
||||
socket.on('appping', function(fn){
|
||||
fn(Date.now());
|
||||
});
|
||||
|
||||
/** ######## **/
|
||||
/** KEYPRESS **/
|
||||
/** ######## **/
|
||||
/** TODO!!!! */
|
||||
socket.on('keydown', function(id, or){
|
||||
console.log('Keypress'+ id + or);
|
||||
socket.broadcast.emit('setOrr', id, or);
|
||||
});
|
||||
socket.on('keyup', function(id, or){
|
||||
console.log('Keypress'+ id + or);
|
||||
socket.broadcast.emit('setOrr', id, or);
|
||||
});
|
||||
|
||||
/** ########## **/
|
||||
/** DISCONNECT **/
|
||||
/** ########## **/
|
||||
socket.on('disconnect', function(){
|
||||
var index;
|
||||
sockets.forEach(function(sock, ind){
|
||||
if (sock.socket == socket){
|
||||
index = ind;
|
||||
return;
|
||||
}
|
||||
});
|
||||
var oldid = sockets[index].id;
|
||||
sockets.splice(index, 1);
|
||||
console.log('Client disconnected. ID=' + (oldid+1));
|
||||
if(sockets.length == 1){
|
||||
sockets[0].socket.emit('test', 'player_left'); //TODO win-event
|
||||
console.log('Only one Player left. Sending win-event');
|
||||
// Debug Restart:
|
||||
gameState = 0;
|
||||
broadcastGameState(socket);
|
||||
return;
|
||||
}
|
||||
else if(sockets.length == 0){
|
||||
console.log('All Players left. Reseting lobby...');
|
||||
gameState = 0;
|
||||
id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
var key = 0;
|
||||
if(sockets[0].id == 1 || sockets[0].id == 2) key = 1;
|
||||
switch(oldid){
|
||||
case 1 : sockets[key].id = 1; sockets[key].socket.emit('handshake', 1); console.log('New Player 1 selected.'); setUp(); break;
|
||||
case 2 : sockets[key].id = 2; sockets[key].socket.emit('handshake', 2); console.log('New Player 2 selected.'); setUp(); break;
|
||||
default : console.log('Spectator left. Nothing need to select new Players.'); break;
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
http.listen(3000, function(){
|
||||
console.log('listening on *:3000');
|
||||
});
|
||||
|
||||
function setUp(socket){
|
||||
gameState = 1;
|
||||
broadcastGameState(socket);
|
||||
console.log('Starting SetUp...');
|
||||
/** Select smalest screensize and set for all clients **/
|
||||
sockets.forEach(function(sock){
|
||||
broadcastGameState(socket);
|
||||
if(sock.id == 1)
|
||||
sockets.forEach(function(sock2){
|
||||
if(sock2.id == 2){
|
||||
if(sock.width < sock2.width)
|
||||
width = sock.width;
|
||||
else
|
||||
width = sock2.width;
|
||||
if(sock.height < sock2.height)
|
||||
height = sock.height;
|
||||
else
|
||||
height = sock2.height;
|
||||
}
|
||||
});
|
||||
});
|
||||
socket.emit('size', width, height);
|
||||
socket.broadcast.emit('size', width, height);
|
||||
var i = 5;
|
||||
var interval = setInterval(function(){
|
||||
i--;
|
||||
socket.emit('countdown', i);
|
||||
socket.broadcast.emit('countdown', i);
|
||||
if(i == 0){
|
||||
clearInterval(interval);
|
||||
gameState = 2;
|
||||
broadcastGameState(socket);
|
||||
socket.emit('start');
|
||||
socket.broadcast.emit('start');
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function broadcastGameState(socket){
|
||||
socket.emit('gamestate', gameState);
|
||||
socket.broadcast.emit('gamestate', gameState);
|
||||
}
|
||||
|
||||
function Client(id, socket){
|
||||
this.id = id;
|
||||
this.socket = socket;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
}
|
1
node_modules/.bin/uuid
generated
vendored
Symbolic link
1
node_modules/.bin/uuid
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../node-uuid/bin/uuid
|
74
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
74
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
1.1.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.4
|
||||
- deps: mime-db@~1.3.0
|
||||
|
||||
1.1.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.3
|
||||
- deps: mime-db@~1.2.0
|
||||
|
||||
1.1.2 / 2014-10-14
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.9
|
||||
- Fix error when media type has invalid parameter
|
||||
|
||||
1.1.1 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.2
|
||||
- deps: mime-db@~1.1.0
|
||||
* deps: negotiator@0.4.8
|
||||
- Fix all negotiations to be case-insensitive
|
||||
- Stable sort preferences of same quality according to client order
|
||||
|
||||
1.1.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* update `mime-types`
|
||||
|
||||
1.0.7 / 2014-07-04
|
||||
==================
|
||||
|
||||
* Fix wrong type returned from `type` when match after unknown extension
|
||||
|
||||
1.0.6 / 2014-06-24
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.7
|
||||
|
||||
1.0.5 / 2014-06-20
|
||||
==================
|
||||
|
||||
* fix crash when unknown extension given
|
||||
|
||||
1.0.4 / 2014-06-19
|
||||
==================
|
||||
|
||||
* use `mime-types`
|
||||
|
||||
1.0.3 / 2014-06-11
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.6
|
||||
- Order by specificity when quality is the same
|
||||
|
||||
1.0.2 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix interpretation when header not in request
|
||||
* deps: pin negotiator@0.4.5
|
||||
|
||||
1.0.1 / 2014-01-18
|
||||
==================
|
||||
|
||||
* Identity encoding isn't always acceptable
|
||||
* deps: negotiator@~0.4.0
|
||||
|
||||
1.0.0 / 2013-12-27
|
||||
==================
|
||||
|
||||
* Genesis
|
22
node_modules/accepts/LICENSE
generated
vendored
Normal file
22
node_modules/accepts/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.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.
|
94
node_modules/accepts/README.md
generated
vendored
Normal file
94
node_modules/accepts/README.md
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
# accepts
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Higher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use.
|
||||
|
||||
In addition to negotatior, it allows:
|
||||
|
||||
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.
|
||||
- Allows type shorthands such as `json`.
|
||||
- Returns `false` when no types match
|
||||
- Treats non-existent headers as `*`
|
||||
|
||||
## API
|
||||
|
||||
### var accept = new Accepts(req)
|
||||
|
||||
```js
|
||||
var accepts = require('accepts')
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
var accept = accepts(req)
|
||||
})
|
||||
```
|
||||
|
||||
### accept\[property\]\(\)
|
||||
|
||||
Returns all the explicitly accepted content property as an array in descending priority.
|
||||
|
||||
- `accept.types()`
|
||||
- `accept.encodings()`
|
||||
- `accept.charsets()`
|
||||
- `accept.languages()`
|
||||
|
||||
They are also aliased in singular form such as `accept.type()`. `accept.languages()` is also aliased as `accept.langs()`, etc.
|
||||
|
||||
Note: you should almost never do this in a real app as it defeats the purpose of content negotiation.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// in Google Chrome
|
||||
var encodings = accept.encodings() // -> ['sdch', 'gzip', 'deflate']
|
||||
```
|
||||
|
||||
Since you probably don't support `sdch`, you should just supply the encodings you support:
|
||||
|
||||
```js
|
||||
var encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably
|
||||
```
|
||||
|
||||
### accept\[property\]\(values, ...\)
|
||||
|
||||
You can either have `values` be an array or have an argument list of values.
|
||||
|
||||
If the client does not accept any `values`, `false` will be returned.
|
||||
If the client accepts any `values`, the preferred `value` will be return.
|
||||
|
||||
For `accept.types()`, shorthand mime types are allowed.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// req.headers.accept = 'application/json'
|
||||
|
||||
accept.types('json') // -> 'json'
|
||||
accept.types('html', 'json') // -> 'json'
|
||||
accept.types('html') // -> false
|
||||
|
||||
// req.headers.accept = ''
|
||||
// which is equivalent to `*`
|
||||
|
||||
accept.types() // -> [], no explicit types
|
||||
accept.types('text/html', 'text/json') // -> 'text/html', since it was first
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/accepts.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/accepts
|
||||
[node-version-image]: https://img.shields.io/node/v/accepts.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/accepts.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/accepts
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/accepts
|
||||
[downloads-image]: https://img.shields.io/npm/dm/accepts.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/accepts
|
160
node_modules/accepts/index.js
generated
vendored
Normal file
160
node_modules/accepts/index.js
generated
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
var Negotiator = require('negotiator')
|
||||
var mime = require('mime-types')
|
||||
|
||||
var slice = [].slice
|
||||
|
||||
module.exports = Accepts
|
||||
|
||||
function Accepts(req) {
|
||||
if (!(this instanceof Accepts))
|
||||
return new Accepts(req)
|
||||
|
||||
this.headers = req.headers
|
||||
this.negotiator = Negotiator(req)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given `type(s)` is acceptable, returning
|
||||
* the best match when true, otherwise `undefined`, in which
|
||||
* case you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* The `type` value may be a single mime type string
|
||||
* such as "application/json", the extension name
|
||||
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
||||
* or array is given the _best_ match, if any is returned.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // Accept: text/html
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
* this.types('text/html');
|
||||
* // => "text/html"
|
||||
* this.types('json', 'text');
|
||||
* // => "json"
|
||||
* this.types('application/json');
|
||||
* // => "application/json"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('image/png');
|
||||
* this.types('png');
|
||||
* // => undefined
|
||||
*
|
||||
* // Accept: text/*;q=.5, application/json
|
||||
* this.types(['html', 'json']);
|
||||
* this.types('html', 'json');
|
||||
* // => "json"
|
||||
*
|
||||
* @param {String|Array} type(s)...
|
||||
* @return {String|Array|Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.type =
|
||||
Accepts.prototype.types = function (types) {
|
||||
if (!Array.isArray(types)) types = slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!types.length) return n.mediaTypes();
|
||||
if (!this.headers.accept) return types[0];
|
||||
var mimes = types.map(extToMime);
|
||||
var accepts = n.mediaTypes(mimes.filter(validMime));
|
||||
var first = accepts[0];
|
||||
if (!first) return false;
|
||||
return types[mimes.indexOf(first)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted encodings or best fit based on `encodings`.
|
||||
*
|
||||
* Given `Accept-Encoding: gzip, deflate`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['gzip', 'deflate']
|
||||
*
|
||||
* @param {String|Array} encoding(s)...
|
||||
* @return {String|Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.encoding =
|
||||
Accepts.prototype.encodings = function (encodings) {
|
||||
if (!Array.isArray(encodings)) encodings = slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!encodings.length) return n.encodings();
|
||||
return n.encodings(encodings)[0] || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted charsets or best fit based on `charsets`.
|
||||
*
|
||||
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['utf-8', 'utf-7', 'iso-8859-1']
|
||||
*
|
||||
* @param {String|Array} charset(s)...
|
||||
* @return {String|Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.charset =
|
||||
Accepts.prototype.charsets = function (charsets) {
|
||||
if (!Array.isArray(charsets)) charsets = [].slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!charsets.length) return n.charsets();
|
||||
if (!this.headers['accept-charset']) return charsets[0];
|
||||
return n.charsets(charsets)[0] || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted languages or best fit based on `langs`.
|
||||
*
|
||||
* Given `Accept-Language: en;q=0.8, es, pt`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['es', 'pt', 'en']
|
||||
*
|
||||
* @param {String|Array} lang(s)...
|
||||
* @return {Array|String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.lang =
|
||||
Accepts.prototype.langs =
|
||||
Accepts.prototype.language =
|
||||
Accepts.prototype.languages = function (langs) {
|
||||
if (!Array.isArray(langs)) langs = slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!langs.length) return n.languages();
|
||||
if (!this.headers['accept-language']) return langs[0];
|
||||
return n.languages(langs)[0] || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert extnames to mime.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function extToMime(type) {
|
||||
if (~type.indexOf('/')) return type;
|
||||
return mime.lookup(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mime is valid.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function validMime(type) {
|
||||
return typeof type === 'string';
|
||||
}
|
125
node_modules/accepts/package.json
generated
vendored
Normal file
125
node_modules/accepts/package.json
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "accepts@~1.1.3",
|
||||
"scope": null,
|
||||
"escapedName": "accepts",
|
||||
"name": "accepts",
|
||||
"rawSpec": "~1.1.3",
|
||||
"spec": ">=1.1.3 <1.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/express"
|
||||
]
|
||||
],
|
||||
"_from": "accepts@>=1.1.3 <1.2.0",
|
||||
"_id": "accepts@1.1.4",
|
||||
"_inCache": true,
|
||||
"_location": "/accepts",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"_npmVersion": "1.4.21",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "accepts@~1.1.3",
|
||||
"scope": null,
|
||||
"escapedName": "accepts",
|
||||
"name": "accepts",
|
||||
"rawSpec": "~1.1.3",
|
||||
"spec": ">=1.1.3 <1.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.1.4.tgz",
|
||||
"_shasum": "d71c96f7d41d0feda2c38cd14e8a27c04158df4a",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "accepts@~1.1.3",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/express",
|
||||
"author": {
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/accepts/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"mime-types": "~2.0.4",
|
||||
"negotiator": "0.4.9"
|
||||
},
|
||||
"description": "Higher-level content negotiation",
|
||||
"devDependencies": {
|
||||
"istanbul": "~0.3.4",
|
||||
"mocha": "~2.0.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "d71c96f7d41d0feda2c38cd14e8a27c04158df4a",
|
||||
"tarball": "https://registry.npmjs.org/accepts/-/accepts-1.1.4.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "df66414d80f096627b28f137127fce0a851d7900",
|
||||
"homepage": "https://github.com/jshttp/accepts",
|
||||
"keywords": [
|
||||
"content",
|
||||
"negotiation",
|
||||
"accept",
|
||||
"accepts"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "federomero",
|
||||
"email": "federomero@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "mscdex",
|
||||
"email": "mscdex@mscdex.net"
|
||||
},
|
||||
{
|
||||
"name": "fishrock123",
|
||||
"email": "fishrock123@rocketmail.com"
|
||||
}
|
||||
],
|
||||
"name": "accepts",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jshttp/accepts.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
||||
},
|
||||
"version": "1.1.4"
|
||||
}
|
2
node_modules/after/.npmignore
generated
vendored
Normal file
2
node_modules/after/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
.monitor
|
12
node_modules/after/.travis.yml
generated
vendored
Normal file
12
node_modules/after/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
- 0.9
|
||||
- 0.10
|
||||
- 0.12
|
||||
- 4.2.4
|
||||
- 5.4.1
|
||||
- iojs-1
|
||||
- iojs-2
|
||||
- iojs-3
|
19
node_modules/after/LICENCE
generated
vendored
Normal file
19
node_modules/after/LICENCE
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2011 Raynos.
|
||||
|
||||
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.
|
115
node_modules/after/README.md
generated
vendored
Normal file
115
node_modules/after/README.md
generated
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
# After [![Build Status][1]][2]
|
||||
|
||||
Invoke callback after n calls
|
||||
|
||||
## Status: production ready
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var after = require("after")
|
||||
var db = require("./db") // some db.
|
||||
|
||||
var updateUser = function (req, res) {
|
||||
// use after to run two tasks in parallel,
|
||||
// namely get request body and get session
|
||||
// then run updateUser with the results
|
||||
var next = after(2, updateUser)
|
||||
var results = {}
|
||||
|
||||
getJSONBody(req, res, function (err, body) {
|
||||
if (err) return next(err)
|
||||
|
||||
results.body = body
|
||||
next(null, results)
|
||||
})
|
||||
|
||||
getSessionUser(req, res, function (err, user) {
|
||||
if (err) return next(err)
|
||||
|
||||
results.user = user
|
||||
next(null, results)
|
||||
})
|
||||
|
||||
// now do the thing!
|
||||
function updateUser(err, result) {
|
||||
if (err) {
|
||||
res.statusCode = 500
|
||||
return res.end("Unexpected Error")
|
||||
}
|
||||
|
||||
if (!result.user || result.user.role !== "admin") {
|
||||
res.statusCode = 403
|
||||
return res.end("Permission Denied")
|
||||
}
|
||||
|
||||
db.put("users:" + req.params.userId, result.body, function (err) {
|
||||
if (err) {
|
||||
res.statusCode = 500
|
||||
return res.end("Unexpected Error")
|
||||
}
|
||||
|
||||
res.statusCode = 200
|
||||
res.end("Ok")
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Naive Example
|
||||
|
||||
```js
|
||||
var after = require("after")
|
||||
, next = after(3, logItWorks)
|
||||
|
||||
next()
|
||||
next()
|
||||
next() // it works
|
||||
|
||||
function logItWorks() {
|
||||
console.log("it works!")
|
||||
}
|
||||
```
|
||||
|
||||
## Example with error handling
|
||||
|
||||
```js
|
||||
var after = require("after")
|
||||
, next = after(3, logError)
|
||||
|
||||
next()
|
||||
next(new Error("oops")) // logs oops
|
||||
next() // does nothing
|
||||
|
||||
// This callback is only called once.
|
||||
// If there is an error the callback gets called immediately
|
||||
// this avoids the situation where errors get lost.
|
||||
function logError(err) {
|
||||
console.log(err)
|
||||
}
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
`npm install after`
|
||||
|
||||
## Tests
|
||||
|
||||
`npm test`
|
||||
|
||||
## Contributors
|
||||
|
||||
- Raynos
|
||||
- defunctzombie
|
||||
|
||||
## MIT Licenced
|
||||
|
||||
[1]: https://secure.travis-ci.org/Raynos/after.png
|
||||
[2]: http://travis-ci.org/Raynos/after
|
||||
[3]: http://raynos.org/blog/2/Flow-control-in-node.js
|
||||
[4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307
|
||||
[5]: http://stackoverflow.com/questions/6869872/in-javascript-what-are-best-practices-for-executing-multiple-asynchronous-functi/6870031#6870031
|
||||
[6]: http://stackoverflow.com/questions/6864397/javascript-performance-long-running-tasks/6889419#6889419
|
||||
[7]: http://stackoverflow.com/questions/6597493/synchronous-database-queries-with-node-js/6620091#6620091
|
||||
[8]: http://github.com/Raynos/iterators
|
||||
[9]: http://github.com/Raynos/composite
|
28
node_modules/after/index.js
generated
vendored
Normal file
28
node_modules/after/index.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
module.exports = after
|
||||
|
||||
function after(count, callback, err_cb) {
|
||||
var bail = false
|
||||
err_cb = err_cb || noop
|
||||
proxy.count = count
|
||||
|
||||
return (count === 0) ? callback() : proxy
|
||||
|
||||
function proxy(err, result) {
|
||||
if (proxy.count <= 0) {
|
||||
throw new Error('after called too many times')
|
||||
}
|
||||
--proxy.count
|
||||
|
||||
// after first error, rest are passed to err_cb
|
||||
if (err) {
|
||||
bail = true
|
||||
callback(err)
|
||||
// future error callbacks will go to error handler
|
||||
callback = err_cb
|
||||
} else if (proxy.count === 0 && !bail) {
|
||||
callback(null, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function noop() {}
|
103
node_modules/after/package.json
generated
vendored
Normal file
103
node_modules/after/package.json
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "after@0.8.2",
|
||||
"scope": null,
|
||||
"escapedName": "after",
|
||||
"name": "after",
|
||||
"rawSpec": "0.8.2",
|
||||
"spec": "0.8.2",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/engine.io-parser"
|
||||
]
|
||||
],
|
||||
"_from": "after@0.8.2",
|
||||
"_id": "after@0.8.2",
|
||||
"_inCache": true,
|
||||
"_location": "/after",
|
||||
"_nodeVersion": "0.10.32",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/after-0.8.2.tgz_1471308639186_0.9132961586583406"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "raynos",
|
||||
"email": "raynos2@gmail.com"
|
||||
},
|
||||
"_npmVersion": "2.15.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "after@0.8.2",
|
||||
"scope": null,
|
||||
"escapedName": "after",
|
||||
"name": "after",
|
||||
"rawSpec": "0.8.2",
|
||||
"spec": "0.8.2",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io-parser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
|
||||
"_shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "after@0.8.2",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/engine.io-parser",
|
||||
"author": {
|
||||
"name": "Raynos",
|
||||
"email": "raynos2@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Raynos/after/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Raynos",
|
||||
"email": "raynos2@gmail.com",
|
||||
"url": "http://raynos.org"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "after - tiny flow control",
|
||||
"devDependencies": {
|
||||
"mocha": "~1.8.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f",
|
||||
"tarball": "https://registry.npmjs.org/after/-/after-0.8.2.tgz"
|
||||
},
|
||||
"gitHead": "e8c26046f36962b90e68dc5df33a9672a54b25f5",
|
||||
"homepage": "https://github.com/Raynos/after#readme",
|
||||
"keywords": [
|
||||
"flowcontrol",
|
||||
"after",
|
||||
"flow",
|
||||
"control",
|
||||
"arch"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "raynos",
|
||||
"email": "raynos2@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "defunctzombie",
|
||||
"email": "shtylman@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "after",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Raynos/after.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --ui tdd --reporter spec test/*.js"
|
||||
},
|
||||
"version": "0.8.2"
|
||||
}
|
120
node_modules/after/test/after-test.js
generated
vendored
Normal file
120
node_modules/after/test/after-test.js
generated
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*global suite, test*/
|
||||
|
||||
var assert = require("assert")
|
||||
, after = require("../")
|
||||
|
||||
test("exists", function () {
|
||||
assert(typeof after === "function", "after is not a function")
|
||||
})
|
||||
|
||||
test("after when called with 0 invokes", function (done) {
|
||||
after(0, done)
|
||||
});
|
||||
|
||||
test("after 1", function (done) {
|
||||
var next = after(1, done)
|
||||
next()
|
||||
})
|
||||
|
||||
test("after 5", function (done) {
|
||||
var next = after(5, done)
|
||||
, i = 5
|
||||
|
||||
while (i--) {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
test("manipulate count", function (done) {
|
||||
var next = after(1, done)
|
||||
, i = 5
|
||||
|
||||
next.count = i
|
||||
while (i--) {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
test("after terminates on error", function (done) {
|
||||
var next = after(2, function(err) {
|
||||
assert.equal(err.message, 'test');
|
||||
done();
|
||||
})
|
||||
next(new Error('test'))
|
||||
next(new Error('test2'))
|
||||
})
|
||||
|
||||
test('gee', function(done) {
|
||||
done = after(2, done)
|
||||
|
||||
function cb(err) {
|
||||
assert.equal(err.message, 1);
|
||||
done()
|
||||
}
|
||||
|
||||
var next = after(3, cb, function(err) {
|
||||
assert.equal(err.message, 2)
|
||||
done()
|
||||
});
|
||||
|
||||
next()
|
||||
next(new Error(1))
|
||||
next(new Error(2))
|
||||
})
|
||||
|
||||
test('eee', function(done) {
|
||||
done = after(3, done)
|
||||
|
||||
function cb(err) {
|
||||
assert.equal(err.message, 1);
|
||||
done()
|
||||
}
|
||||
|
||||
var next = after(3, cb, function(err) {
|
||||
assert.equal(err.message, 2)
|
||||
done()
|
||||
});
|
||||
|
||||
next(new Error(1))
|
||||
next(new Error(2))
|
||||
next(new Error(2))
|
||||
})
|
||||
|
||||
test('gge', function(done) {
|
||||
function cb(err) {
|
||||
assert.equal(err.message, 1);
|
||||
done()
|
||||
}
|
||||
|
||||
var next = after(3, cb, function(err) {
|
||||
// should not happen
|
||||
assert.ok(false);
|
||||
});
|
||||
|
||||
next()
|
||||
next()
|
||||
next(new Error(1))
|
||||
})
|
||||
|
||||
test('egg', function(done) {
|
||||
function cb(err) {
|
||||
assert.equal(err.message, 1);
|
||||
done()
|
||||
}
|
||||
|
||||
var next = after(3, cb, function(err) {
|
||||
// should not happen
|
||||
assert.ok(false);
|
||||
});
|
||||
|
||||
next(new Error(1))
|
||||
next()
|
||||
next()
|
||||
})
|
||||
|
||||
test('throws on too many calls', function(done) {
|
||||
var next = after(1, done);
|
||||
next()
|
||||
assert.throws(next, /after called too many times/);
|
||||
});
|
||||
|
17
node_modules/arraybuffer.slice/.npmignore
generated
vendored
Normal file
17
node_modules/arraybuffer.slice/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
lib-cov
|
||||
lcov.info
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
build
|
||||
.grunt
|
||||
|
||||
node_modules
|
8
node_modules/arraybuffer.slice/Makefile
generated
vendored
Normal file
8
node_modules/arraybuffer.slice/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
REPORTER = dot
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--reporter $(REPORTER)
|
||||
|
||||
.PHONY: test
|
17
node_modules/arraybuffer.slice/README.md
generated
vendored
Normal file
17
node_modules/arraybuffer.slice/README.md
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# How to
|
||||
```javascript
|
||||
var sliceBuffer = require('arraybuffer.slice');
|
||||
var ab = (new Int8Array(5)).buffer;
|
||||
var sliced = sliceBuffer(ab, 1, 3);
|
||||
sliced = sliceBuffer(ab, 1);
|
||||
```
|
||||
|
||||
# Licence (MIT)
|
||||
Copyright (C) 2013 Rase-
|
||||
|
||||
|
||||
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.
|
29
node_modules/arraybuffer.slice/index.js
generated
vendored
Normal file
29
node_modules/arraybuffer.slice/index.js
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* An abstraction for slicing an arraybuffer even when
|
||||
* ArrayBuffer.prototype.slice is not supported
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(arraybuffer, start, end) {
|
||||
var bytes = arraybuffer.byteLength;
|
||||
start = start || 0;
|
||||
end = end || bytes;
|
||||
|
||||
if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
|
||||
|
||||
if (start < 0) { start += bytes; }
|
||||
if (end < 0) { end += bytes; }
|
||||
if (end > bytes) { end = bytes; }
|
||||
|
||||
if (start >= bytes || start >= end || bytes === 0) {
|
||||
return new ArrayBuffer(0);
|
||||
}
|
||||
|
||||
var abv = new Uint8Array(arraybuffer);
|
||||
var result = new Uint8Array(end - start);
|
||||
for (var i = start, ii = 0; i < end; i++, ii++) {
|
||||
result[ii] = abv[i];
|
||||
}
|
||||
return result.buffer;
|
||||
};
|
72
node_modules/arraybuffer.slice/package.json
generated
vendored
Normal file
72
node_modules/arraybuffer.slice/package.json
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "arraybuffer.slice@0.0.6",
|
||||
"scope": null,
|
||||
"escapedName": "arraybuffer.slice",
|
||||
"name": "arraybuffer.slice",
|
||||
"rawSpec": "0.0.6",
|
||||
"spec": "0.0.6",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/engine.io-parser"
|
||||
]
|
||||
],
|
||||
"_from": "arraybuffer.slice@0.0.6",
|
||||
"_id": "arraybuffer.slice@0.0.6",
|
||||
"_inCache": true,
|
||||
"_location": "/arraybuffer.slice",
|
||||
"_npmUser": {
|
||||
"name": "rase-",
|
||||
"email": "tonykovanen@hotmail.com"
|
||||
},
|
||||
"_npmVersion": "1.3.5",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "arraybuffer.slice@0.0.6",
|
||||
"scope": null,
|
||||
"escapedName": "arraybuffer.slice",
|
||||
"name": "arraybuffer.slice",
|
||||
"rawSpec": "0.0.6",
|
||||
"spec": "0.0.6",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io-parser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz",
|
||||
"_shasum": "f33b2159f0532a3f3107a272c0ccfbd1ad2979ca",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "arraybuffer.slice@0.0.6",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/engine.io-parser",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rase-/arraybuffer.slice/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Exports a function for slicing ArrayBuffers (no polyfilling)",
|
||||
"devDependencies": {
|
||||
"expect.js": "0.2.0",
|
||||
"mocha": "1.17.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "f33b2159f0532a3f3107a272c0ccfbd1ad2979ca",
|
||||
"tarball": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/rase-/arraybuffer.slice",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "rase-",
|
||||
"email": "tonykovanen@hotmail.com"
|
||||
}
|
||||
],
|
||||
"name": "arraybuffer.slice",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/rase-/arraybuffer.slice.git"
|
||||
},
|
||||
"version": "0.0.6"
|
||||
}
|
227
node_modules/arraybuffer.slice/test/slice-buffer.js
generated
vendored
Normal file
227
node_modules/arraybuffer.slice/test/slice-buffer.js
generated
vendored
Normal file
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* Test dependencies
|
||||
*/
|
||||
|
||||
var sliceBuffer = require('../index.js');
|
||||
var expect = require('expect.js');
|
||||
|
||||
/**
|
||||
* Tests
|
||||
*/
|
||||
|
||||
describe('sliceBuffer', function() {
|
||||
describe('using standard slice', function() {
|
||||
it('should slice correctly with only start provided', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, 3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = 3, ii = 0; i < abv.length; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with start and end provided', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, 3, 8);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = 3, ii = 0; i < 8; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with negative start', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, -3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with negative end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, 0, -3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with negative start and end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, -6, -3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with equal start and end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, 1, 1);
|
||||
expect(sliced.byteLength).to.equal(0);
|
||||
});
|
||||
|
||||
it('should slice correctly when end larger than buffer', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, 0, 100);
|
||||
expect(new Uint8Array(sliced)).to.eql(abv);
|
||||
});
|
||||
|
||||
it('shoud slice correctly when start larger than end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
|
||||
var sliced = sliceBuffer(abv.buffer, 6, 5);
|
||||
expect(sliced.byteLength).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('using fallback', function() {
|
||||
it('should slice correctly with only start provided', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
var sliced = sliceBuffer(ab, 3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = 3, ii = 0; i < abv.length; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with start and end provided', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
|
||||
var sliced = sliceBuffer(ab, 3, 8);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = 3, ii = 0; i < 8; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with negative start', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
|
||||
var sliced = sliceBuffer(ab, -3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with negative end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
var sliced = sliceBuffer(ab, 0, -3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with negative start and end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
var sliced = sliceBuffer(ab, -6, -3);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) {
|
||||
expect(abv[i]).to.equal(sabv[ii]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should slice correctly with equal start and end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
var sliced = sliceBuffer(ab, 1, 1);
|
||||
expect(sliced.byteLength).to.equal(0);
|
||||
});
|
||||
|
||||
it('should slice correctly when end larger than buffer', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
var sliced = sliceBuffer(ab, 0, 100);
|
||||
var sabv = new Uint8Array(sliced);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
expect(abv[i]).to.equal(sabv[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('shoud slice correctly when start larger than end', function() {
|
||||
var abv = new Uint8Array(10);
|
||||
for (var i = 0; i < abv.length; i++) {
|
||||
abv[i] = i;
|
||||
}
|
||||
var ab = abv.buffer;
|
||||
ab.slice = undefined;
|
||||
|
||||
var sliced = sliceBuffer(ab, 6, 5);
|
||||
expect(sliced.byteLength).to.equal(0);
|
||||
});
|
||||
});
|
||||
});
|
1
node_modules/backo2/.npmignore
generated
vendored
Normal file
1
node_modules/backo2/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
node_modules/
|
12
node_modules/backo2/History.md
generated
vendored
Normal file
12
node_modules/backo2/History.md
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
1.0.1 / 2014-02-17
|
||||
==================
|
||||
|
||||
* go away decimal point
|
||||
* history
|
||||
|
||||
1.0.0 / 2014-02-17
|
||||
==================
|
||||
|
||||
* add jitter option
|
||||
* Initial commit
|
8
node_modules/backo2/Makefile
generated
vendored
Normal file
8
node_modules/backo2/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter dot \
|
||||
--bail
|
||||
|
||||
.PHONY: test
|
34
node_modules/backo2/Readme.md
generated
vendored
Normal file
34
node_modules/backo2/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
# backo
|
||||
|
||||
Simple exponential backoff because the others seem to have weird abstractions.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ npm install backo
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
- `min` initial timeout in milliseconds [100]
|
||||
- `max` max timeout [10000]
|
||||
- `jitter` [0]
|
||||
- `factor` [2]
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var Backoff = require('backo');
|
||||
var backoff = new Backoff({ min: 100, max: 20000 });
|
||||
|
||||
setTimeout(function(){
|
||||
something.reconnect();
|
||||
}, backoff.duration());
|
||||
|
||||
// later when something works
|
||||
backoff.reset()
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
11
node_modules/backo2/component.json
generated
vendored
Normal file
11
node_modules/backo2/component.json
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "backo",
|
||||
"repo": "segmentio/backo",
|
||||
"dependencies": {},
|
||||
"version": "1.0.1",
|
||||
"description": "simple backoff without the weird abstractions",
|
||||
"keywords": ["backoff"],
|
||||
"license": "MIT",
|
||||
"scripts": ["index.js"],
|
||||
"main": "index.js"
|
||||
}
|
85
node_modules/backo2/index.js
generated
vendored
Normal file
85
node_modules/backo2/index.js
generated
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
|
||||
/**
|
||||
* Expose `Backoff`.
|
||||
*/
|
||||
|
||||
module.exports = Backoff;
|
||||
|
||||
/**
|
||||
* Initialize backoff timer with `opts`.
|
||||
*
|
||||
* - `min` initial timeout in milliseconds [100]
|
||||
* - `max` max timeout [10000]
|
||||
* - `jitter` [0]
|
||||
* - `factor` [2]
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Backoff(opts) {
|
||||
opts = opts || {};
|
||||
this.ms = opts.min || 100;
|
||||
this.max = opts.max || 10000;
|
||||
this.factor = opts.factor || 2;
|
||||
this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
|
||||
this.attempts = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the backoff duration.
|
||||
*
|
||||
* @return {Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Backoff.prototype.duration = function(){
|
||||
var ms = this.ms * Math.pow(this.factor, this.attempts++);
|
||||
if (this.jitter) {
|
||||
var rand = Math.random();
|
||||
var deviation = Math.floor(rand * this.jitter * ms);
|
||||
ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
|
||||
}
|
||||
return Math.min(ms, this.max) | 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset the number of attempts.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Backoff.prototype.reset = function(){
|
||||
this.attempts = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the minimum duration
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Backoff.prototype.setMin = function(min){
|
||||
this.ms = min;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the maximum duration
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Backoff.prototype.setMax = function(max){
|
||||
this.max = max;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the jitter
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Backoff.prototype.setJitter = function(jitter){
|
||||
this.jitter = jitter;
|
||||
};
|
||||
|
78
node_modules/backo2/package.json
generated
vendored
Normal file
78
node_modules/backo2/package.json
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "backo2@1.0.2",
|
||||
"scope": null,
|
||||
"escapedName": "backo2",
|
||||
"name": "backo2",
|
||||
"rawSpec": "1.0.2",
|
||||
"spec": "1.0.2",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/socket.io-client"
|
||||
]
|
||||
],
|
||||
"_from": "backo2@1.0.2",
|
||||
"_id": "backo2@1.0.2",
|
||||
"_inCache": true,
|
||||
"_location": "/backo2",
|
||||
"_npmUser": {
|
||||
"name": "mokesmokes",
|
||||
"email": "mokesmokes@gmail.com"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "backo2@1.0.2",
|
||||
"scope": null,
|
||||
"escapedName": "backo2",
|
||||
"name": "backo2",
|
||||
"rawSpec": "1.0.2",
|
||||
"spec": "1.0.2",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/socket.io-client"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
|
||||
"_shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "backo2@1.0.2",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/socket.io-client",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mokesmokes/backo/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "simple backoff based on segmentio/backo",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947",
|
||||
"tarball": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz"
|
||||
},
|
||||
"gitHead": "3e695bade7756fef2295e8883bf3570a06e5d9ec",
|
||||
"homepage": "https://github.com/mokesmokes/backo",
|
||||
"keywords": [
|
||||
"backoff"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "mokesmokes",
|
||||
"email": "mokesmokes@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "backo2",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mokesmokes/backo.git"
|
||||
},
|
||||
"scripts": {},
|
||||
"version": "1.0.2"
|
||||
}
|
18
node_modules/backo2/test/index.js
generated
vendored
Normal file
18
node_modules/backo2/test/index.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
var Backoff = require('..');
|
||||
var assert = require('assert');
|
||||
|
||||
describe('.duration()', function(){
|
||||
it('should increase the backoff', function(){
|
||||
var b = new Backoff;
|
||||
|
||||
assert(100 == b.duration());
|
||||
assert(200 == b.duration());
|
||||
assert(400 == b.duration());
|
||||
assert(800 == b.duration());
|
||||
|
||||
b.reset();
|
||||
assert(100 == b.duration());
|
||||
assert(200 == b.duration());
|
||||
})
|
||||
})
|
3
node_modules/base64-arraybuffer/.npmignore
generated
vendored
Normal file
3
node_modules/base64-arraybuffer/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/node_modules/
|
||||
Gruntfile.js
|
||||
/test/
|
19
node_modules/base64-arraybuffer/.travis.yml
generated
vendored
Normal file
19
node_modules/base64-arraybuffer/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- '0.12'
|
||||
- iojs-1
|
||||
- iojs-2
|
||||
- iojs-3
|
||||
- '4.1'
|
||||
before_script:
|
||||
- npm install
|
||||
before_install: npm install -g npm@'>=2.13.5'
|
||||
deploy:
|
||||
provider: npm
|
||||
email: niklasvh@gmail.com
|
||||
api_key:
|
||||
secure: oHV9ArprTj5WOk7MP1UF7QMJ70huXw+y7xXb5wF4+V2H8Hyfa5TfE0DiOmqrube1WXTeH1FLgq54shp/sJWi47Hkg/GyeoB5NnsPhYEaJkaON9UG5blML+ODiNVsEnq/1kNBQ8e0+0JItMPLGySKyFmuZ3yflulXKS8O88mfINo=
|
||||
on:
|
||||
tags: true
|
||||
branch: master
|
||||
repo: niklasvh/base64-arraybuffer
|
22
node_modules/base64-arraybuffer/LICENSE-MIT
generated
vendored
Normal file
22
node_modules/base64-arraybuffer/LICENSE-MIT
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) 2012 Niklas von Hertzen
|
||||
|
||||
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.
|
20
node_modules/base64-arraybuffer/README.md
generated
vendored
Normal file
20
node_modules/base64-arraybuffer/README.md
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
# base64-arraybuffer
|
||||
|
||||
[![Build Status](https://travis-ci.org/niklasvh/base64-arraybuffer.png)](https://travis-ci.org/niklasvh/base64-arraybuffer)
|
||||
[![NPM Downloads](https://img.shields.io/npm/dm/base64-arraybuffer.svg)](https://www.npmjs.org/package/base64-arraybuffer)
|
||||
[![NPM Version](https://img.shields.io/npm/v/base64-arraybuffer.svg)](https://www.npmjs.org/package/base64-arraybuffer)
|
||||
|
||||
Encode/decode base64 data into ArrayBuffers
|
||||
|
||||
## Getting Started
|
||||
Install the module with: `npm install base64-arraybuffer`
|
||||
|
||||
## API
|
||||
The library encodes and decodes base64 to and from ArrayBuffers
|
||||
|
||||
- __encode(buffer)__ - Encodes `ArrayBuffer` into base64 string
|
||||
- __decode(str)__ - Decodes base64 string to `ArrayBuffer`
|
||||
|
||||
## License
|
||||
Copyright (c) 2012 Niklas von Hertzen
|
||||
Licensed under the MIT license.
|
67
node_modules/base64-arraybuffer/lib/base64-arraybuffer.js
generated
vendored
Normal file
67
node_modules/base64-arraybuffer/lib/base64-arraybuffer.js
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* base64-arraybuffer
|
||||
* https://github.com/niklasvh/base64-arraybuffer
|
||||
*
|
||||
* Copyright (c) 2012 Niklas von Hertzen
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
// Use a lookup table to find the index.
|
||||
var lookup = new Uint8Array(256);
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
lookup[chars.charCodeAt(i)] = i;
|
||||
}
|
||||
|
||||
exports.encode = function(arraybuffer) {
|
||||
var bytes = new Uint8Array(arraybuffer),
|
||||
i, len = bytes.length, base64 = "";
|
||||
|
||||
for (i = 0; i < len; i+=3) {
|
||||
base64 += chars[bytes[i] >> 2];
|
||||
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
|
||||
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
|
||||
base64 += chars[bytes[i + 2] & 63];
|
||||
}
|
||||
|
||||
if ((len % 3) === 2) {
|
||||
base64 = base64.substring(0, base64.length - 1) + "=";
|
||||
} else if (len % 3 === 1) {
|
||||
base64 = base64.substring(0, base64.length - 2) + "==";
|
||||
}
|
||||
|
||||
return base64;
|
||||
};
|
||||
|
||||
exports.decode = function(base64) {
|
||||
var bufferLength = base64.length * 0.75,
|
||||
len = base64.length, i, p = 0,
|
||||
encoded1, encoded2, encoded3, encoded4;
|
||||
|
||||
if (base64[base64.length - 1] === "=") {
|
||||
bufferLength--;
|
||||
if (base64[base64.length - 2] === "=") {
|
||||
bufferLength--;
|
||||
}
|
||||
}
|
||||
|
||||
var arraybuffer = new ArrayBuffer(bufferLength),
|
||||
bytes = new Uint8Array(arraybuffer);
|
||||
|
||||
for (i = 0; i < len; i+=4) {
|
||||
encoded1 = lookup[base64.charCodeAt(i)];
|
||||
encoded2 = lookup[base64.charCodeAt(i+1)];
|
||||
encoded3 = lookup[base64.charCodeAt(i+2)];
|
||||
encoded4 = lookup[base64.charCodeAt(i+3)];
|
||||
|
||||
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
|
||||
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
|
||||
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
|
||||
}
|
||||
|
||||
return arraybuffer;
|
||||
};
|
||||
})();
|
96
node_modules/base64-arraybuffer/package.json
generated
vendored
Normal file
96
node_modules/base64-arraybuffer/package.json
generated
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "base64-arraybuffer@0.1.5",
|
||||
"scope": null,
|
||||
"escapedName": "base64-arraybuffer",
|
||||
"name": "base64-arraybuffer",
|
||||
"rawSpec": "0.1.5",
|
||||
"spec": "0.1.5",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/engine.io-parser"
|
||||
]
|
||||
],
|
||||
"_from": "base64-arraybuffer@0.1.5",
|
||||
"_id": "base64-arraybuffer@0.1.5",
|
||||
"_inCache": true,
|
||||
"_location": "/base64-arraybuffer",
|
||||
"_nodeVersion": "2.5.0",
|
||||
"_npmUser": {
|
||||
"name": "niklasvh",
|
||||
"email": "niklasvh@gmail.com"
|
||||
},
|
||||
"_npmVersion": "3.4.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "base64-arraybuffer@0.1.5",
|
||||
"scope": null,
|
||||
"escapedName": "base64-arraybuffer",
|
||||
"name": "base64-arraybuffer",
|
||||
"rawSpec": "0.1.5",
|
||||
"spec": "0.1.5",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io-parser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
|
||||
"_shasum": "73926771923b5a19747ad666aa5cd4bf9c6e9ce8",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "base64-arraybuffer@0.1.5",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/engine.io-parser",
|
||||
"author": {
|
||||
"name": "Niklas von Hertzen",
|
||||
"email": "niklasvh@gmail.com",
|
||||
"url": "http://hertzen.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/niklasvh/base64-arraybuffer/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Encode/decode base64 data into ArrayBuffers",
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-cli": "^0.1.13",
|
||||
"grunt-contrib-jshint": "^0.11.2",
|
||||
"grunt-contrib-nodeunit": "^0.4.1",
|
||||
"grunt-contrib-watch": "^0.6.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "73926771923b5a19747ad666aa5cd4bf9c6e9ce8",
|
||||
"tarball": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
},
|
||||
"gitHead": "e9457ccb7b140f5ae54a2880c8e9b967ffb03a7d",
|
||||
"homepage": "https://github.com/niklasvh/base64-arraybuffer",
|
||||
"keywords": [],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/niklasvh/base64-arraybuffer/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"main": "lib/base64-arraybuffer",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "niklasvh",
|
||||
"email": "niklasvh@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "base64-arraybuffer",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/niklasvh/base64-arraybuffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt nodeunit"
|
||||
},
|
||||
"version": "0.1.5"
|
||||
}
|
3
node_modules/base64id/.npmignore
generated
vendored
Normal file
3
node_modules/base64id/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
support
|
||||
test
|
||||
examples
|
22
node_modules/base64id/LICENSE
generated
vendored
Normal file
22
node_modules/base64id/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2016 Kristian Faeldt <faeldt_kristian@cyberagent.co.jp>
|
||||
|
||||
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.
|
18
node_modules/base64id/README.md
generated
vendored
Normal file
18
node_modules/base64id/README.md
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
base64id
|
||||
========
|
||||
|
||||
Node.js module that generates a base64 id.
|
||||
|
||||
Uses crypto.randomBytes when available, falls back to unsafe methods for node.js <= 0.4.
|
||||
|
||||
To increase performance, random bytes are buffered to minimize the number of synchronous calls to crypto.randomBytes.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install base64id
|
||||
|
||||
## Usage
|
||||
|
||||
var base64id = require('base64id');
|
||||
|
||||
var id = base64id.generateId();
|
103
node_modules/base64id/lib/base64id.js
generated
vendored
Normal file
103
node_modules/base64id/lib/base64id.js
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*!
|
||||
* base64id v0.1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
var Base64Id = function() { };
|
||||
|
||||
/**
|
||||
* Get random bytes
|
||||
*
|
||||
* Uses a buffer if available, falls back to crypto.randomBytes
|
||||
*/
|
||||
|
||||
Base64Id.prototype.getRandomBytes = function(bytes) {
|
||||
|
||||
var BUFFER_SIZE = 4096
|
||||
var self = this;
|
||||
|
||||
bytes = bytes || 12;
|
||||
|
||||
if (bytes > BUFFER_SIZE) {
|
||||
return crypto.randomBytes(bytes);
|
||||
}
|
||||
|
||||
var bytesInBuffer = parseInt(BUFFER_SIZE/bytes);
|
||||
var threshold = parseInt(bytesInBuffer*0.85);
|
||||
|
||||
if (!threshold) {
|
||||
return crypto.randomBytes(bytes);
|
||||
}
|
||||
|
||||
if (this.bytesBufferIndex == null) {
|
||||
this.bytesBufferIndex = -1;
|
||||
}
|
||||
|
||||
if (this.bytesBufferIndex == bytesInBuffer) {
|
||||
this.bytesBuffer = null;
|
||||
this.bytesBufferIndex = -1;
|
||||
}
|
||||
|
||||
// No buffered bytes available or index above threshold
|
||||
if (this.bytesBufferIndex == -1 || this.bytesBufferIndex > threshold) {
|
||||
|
||||
if (!this.isGeneratingBytes) {
|
||||
this.isGeneratingBytes = true;
|
||||
crypto.randomBytes(BUFFER_SIZE, function(err, bytes) {
|
||||
self.bytesBuffer = bytes;
|
||||
self.bytesBufferIndex = 0;
|
||||
self.isGeneratingBytes = false;
|
||||
});
|
||||
}
|
||||
|
||||
// Fall back to sync call when no buffered bytes are available
|
||||
if (this.bytesBufferIndex == -1) {
|
||||
return crypto.randomBytes(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
var result = this.bytesBuffer.slice(bytes*this.bytesBufferIndex, bytes*(this.bytesBufferIndex+1));
|
||||
this.bytesBufferIndex++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a base64 id
|
||||
*
|
||||
* (Original version from socket.io <http://socket.io>)
|
||||
*/
|
||||
|
||||
Base64Id.prototype.generateId = function () {
|
||||
var rand = new Buffer(15); // multiple of 3 for base64
|
||||
if (!rand.writeInt32BE) {
|
||||
return Math.abs(Math.random() * Math.random() * Date.now() | 0).toString()
|
||||
+ Math.abs(Math.random() * Math.random() * Date.now() | 0).toString();
|
||||
}
|
||||
this.sequenceNumber = (this.sequenceNumber + 1) | 0;
|
||||
rand.writeInt32BE(this.sequenceNumber, 11);
|
||||
if (crypto.randomBytes) {
|
||||
this.getRandomBytes(12).copy(rand);
|
||||
} else {
|
||||
// not secure for node 0.4
|
||||
[0, 4, 8].forEach(function(i) {
|
||||
rand.writeInt32BE(Math.random() * Math.pow(2, 32) | 0, i);
|
||||
});
|
||||
}
|
||||
return rand.toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
|
||||
};
|
||||
|
||||
/**
|
||||
* Export
|
||||
*/
|
||||
|
||||
exports = module.exports = new Base64Id();
|
89
node_modules/base64id/package.json
generated
vendored
Normal file
89
node_modules/base64id/package.json
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "base64id@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "base64id",
|
||||
"name": "base64id",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/engine.io"
|
||||
]
|
||||
],
|
||||
"_from": "base64id@1.0.0",
|
||||
"_id": "base64id@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/base64id",
|
||||
"_nodeVersion": "4.4.7",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-18-east.internal.npmjs.com",
|
||||
"tmp": "tmp/base64id-1.0.0.tgz_1480551701495_0.042360062478110194"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "darrachequesne",
|
||||
"email": "damien.arrachequesne@gmail.com"
|
||||
},
|
||||
"_npmVersion": "2.15.8",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "base64id@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "base64id",
|
||||
"name": "base64id",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz",
|
||||
"_shasum": "47688cb99bb6804f0e06d3e763b1c32e57d8e6b6",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "base64id@1.0.0",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/engine.io",
|
||||
"author": {
|
||||
"name": "Kristian Faeldt",
|
||||
"email": "faeldt_kristian@cyberagent.co.jp"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/faeldt/base64id/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Generates a base64 id",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "47688cb99bb6804f0e06d3e763b1c32e57d8e6b6",
|
||||
"tarball": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"gitHead": "3c846f0818ff88b683ad39fde2f8e015ce0f9807",
|
||||
"homepage": "https://github.com/faeldt/base64id#readme",
|
||||
"license": "MIT",
|
||||
"main": "./lib/base64id.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "darrachequesne",
|
||||
"email": "damien.arrachequesne@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "faeldt_kristian",
|
||||
"email": "kristian.faeldt@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "base64id",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/faeldt/base64id.git"
|
||||
},
|
||||
"scripts": {},
|
||||
"version": "1.0.0"
|
||||
}
|
4
node_modules/better-assert/.npmignore
generated
vendored
Normal file
4
node_modules/better-assert/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
support
|
||||
test
|
||||
examples
|
||||
*.sock
|
15
node_modules/better-assert/History.md
generated
vendored
Normal file
15
node_modules/better-assert/History.md
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
1.0.0 / 2013-02-03
|
||||
==================
|
||||
|
||||
* Stop using the removed magic __stack global getter
|
||||
|
||||
0.1.0 / 2012-10-04
|
||||
==================
|
||||
|
||||
* add throwing of AssertionError for test frameworks etc
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
5
node_modules/better-assert/Makefile
generated
vendored
Normal file
5
node_modules/better-assert/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
test:
|
||||
@echo "populate me"
|
||||
|
||||
.PHONY: test
|
61
node_modules/better-assert/Readme.md
generated
vendored
Normal file
61
node_modules/better-assert/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
|
||||
# better-assert
|
||||
|
||||
Better c-style assertions using [callsite](https://github.com/visionmedia/callsite) for
|
||||
self-documenting failure messages.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install better-assert
|
||||
|
||||
## Example
|
||||
|
||||
By default assertions are enabled, however the __NO_ASSERT__ environment variable
|
||||
will deactivate them when truthy.
|
||||
|
||||
```js
|
||||
var assert = require('better-assert');
|
||||
|
||||
test();
|
||||
|
||||
function test() {
|
||||
var user = { name: 'tobi' };
|
||||
assert('tobi' == user.name);
|
||||
assert('number' == typeof user.age);
|
||||
}
|
||||
|
||||
AssertionError: 'number' == typeof user.age
|
||||
at test (/Users/tj/projects/better-assert/example.js:9:3)
|
||||
at Object.<anonymous> (/Users/tj/projects/better-assert/example.js:4:1)
|
||||
at Module._compile (module.js:449:26)
|
||||
at Object.Module._extensions..js (module.js:467:10)
|
||||
at Module.load (module.js:356:32)
|
||||
at Function.Module._load (module.js:312:12)
|
||||
at Module.runMain (module.js:492:10)
|
||||
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
10
node_modules/better-assert/example.js
generated
vendored
Normal file
10
node_modules/better-assert/example.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
var assert = require('./');
|
||||
|
||||
test();
|
||||
|
||||
function test() {
|
||||
var user = { name: 'tobi' };
|
||||
assert('tobi' == user.name);
|
||||
assert('number' == typeof user.age);
|
||||
}
|
38
node_modules/better-assert/index.js
generated
vendored
Normal file
38
node_modules/better-assert/index.js
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var AssertionError = require('assert').AssertionError
|
||||
, callsite = require('callsite')
|
||||
, fs = require('fs')
|
||||
|
||||
/**
|
||||
* Expose `assert`.
|
||||
*/
|
||||
|
||||
module.exports = process.env.NO_ASSERT
|
||||
? function(){}
|
||||
: assert;
|
||||
|
||||
/**
|
||||
* Assert the given `expr`.
|
||||
*/
|
||||
|
||||
function assert(expr) {
|
||||
if (expr) return;
|
||||
|
||||
var stack = callsite();
|
||||
var call = stack[1];
|
||||
var file = call.getFileName();
|
||||
var lineno = call.getLineNumber();
|
||||
var src = fs.readFileSync(file, 'utf8');
|
||||
var line = src.split('\n')[lineno-1];
|
||||
var src = line.match(/assert\((.*)\)/)[1];
|
||||
|
||||
var err = new AssertionError({
|
||||
message: src,
|
||||
stackStartFunction: stack[0].getFunction()
|
||||
});
|
||||
|
||||
throw err;
|
||||
}
|
100
node_modules/better-assert/package.json
generated
vendored
Normal file
100
node_modules/better-assert/package.json
generated
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "better-assert@~1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "better-assert",
|
||||
"name": "better-assert",
|
||||
"rawSpec": "~1.0.0",
|
||||
"spec": ">=1.0.0 <1.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/parsejson"
|
||||
]
|
||||
],
|
||||
"_from": "better-assert@>=1.0.0 <1.1.0",
|
||||
"_id": "better-assert@1.0.2",
|
||||
"_inCache": true,
|
||||
"_location": "/better-assert",
|
||||
"_npmUser": {
|
||||
"name": "tony_ado",
|
||||
"email": "coolhzb@163.com"
|
||||
},
|
||||
"_npmVersion": "1.4.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "better-assert@~1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "better-assert",
|
||||
"name": "better-assert",
|
||||
"rawSpec": "~1.0.0",
|
||||
"spec": ">=1.0.0 <1.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/parsejson",
|
||||
"/parseqs",
|
||||
"/parseuri"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz",
|
||||
"_shasum": "40866b9e1b9e0b55b481894311e68faffaebc522",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "better-assert@~1.0.0",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/parsejson",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/visionmedia/better-assert/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "TonyHe",
|
||||
"email": "coolhzb@163.com"
|
||||
},
|
||||
{
|
||||
"name": "ForbesLindesay"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"callsite": "1.0.0"
|
||||
},
|
||||
"description": "Better assertions for node, reporting the expr, filename, lineno etc",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "40866b9e1b9e0b55b481894311e68faffaebc522",
|
||||
"tarball": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/visionmedia/better-assert",
|
||||
"keywords": [
|
||||
"assert",
|
||||
"stack",
|
||||
"trace",
|
||||
"debug"
|
||||
],
|
||||
"main": "index",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "tony_ado",
|
||||
"email": "coolhzb@163.com"
|
||||
}
|
||||
],
|
||||
"name": "better-assert",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/visionmedia/better-assert.git"
|
||||
},
|
||||
"version": "1.0.2"
|
||||
}
|
2
node_modules/blob/.npmignore
generated
vendored
Normal file
2
node_modules/blob/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
blob.js
|
14
node_modules/blob/.zuul.yml
generated
vendored
Normal file
14
node_modules/blob/.zuul.yml
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
ui: mocha-bdd
|
||||
browsers:
|
||||
- name: chrome
|
||||
version: 8..latest
|
||||
- name: firefox
|
||||
version: 7..latest
|
||||
- name: safari
|
||||
version: 6..latest
|
||||
- name: opera
|
||||
version: 12.1..latest
|
||||
- name: ie
|
||||
version: 10..latest
|
||||
- name: android
|
||||
version: latest
|
14
node_modules/blob/Makefile
generated
vendored
Normal file
14
node_modules/blob/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
REPORTER = dot
|
||||
|
||||
build: blob.js
|
||||
|
||||
blob.js:
|
||||
@./node_modules/.bin/browserify --standalone blob index.js > blob.js
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/zuul -- test/index.js
|
||||
|
||||
clean:
|
||||
rm blob.js
|
||||
|
||||
.PHONY: test blob.js
|
14
node_modules/blob/README.md
generated
vendored
Normal file
14
node_modules/blob/README.md
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
Blob
|
||||
====
|
||||
|
||||
A module that exports a constructor that uses window.Blob when available, and a BlobBuilder with any vendor prefix in other cases. If neither is available, it exports undefined.
|
||||
|
||||
Usage:
|
||||
|
||||
```javascript
|
||||
var Blob = require('blob');
|
||||
var b = new Blob(['hi', 'constructing', 'a', 'blob']);
|
||||
```
|
||||
|
||||
## Licence
|
||||
MIT
|
96
node_modules/blob/index.js
generated
vendored
Normal file
96
node_modules/blob/index.js
generated
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* Create a blob builder even when vendor prefixes exist
|
||||
*/
|
||||
|
||||
var BlobBuilder = global.BlobBuilder
|
||||
|| global.WebKitBlobBuilder
|
||||
|| global.MSBlobBuilder
|
||||
|| global.MozBlobBuilder;
|
||||
|
||||
/**
|
||||
* Check if Blob constructor is supported
|
||||
*/
|
||||
|
||||
var blobSupported = (function() {
|
||||
try {
|
||||
var a = new Blob(['hi']);
|
||||
return a.size === 2;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* Check if Blob constructor supports ArrayBufferViews
|
||||
* Fails in Safari 6, so we need to map to ArrayBuffers there.
|
||||
*/
|
||||
|
||||
var blobSupportsArrayBufferView = blobSupported && (function() {
|
||||
try {
|
||||
var b = new Blob([new Uint8Array([1,2])]);
|
||||
return b.size === 2;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* Check if BlobBuilder is supported
|
||||
*/
|
||||
|
||||
var blobBuilderSupported = BlobBuilder
|
||||
&& BlobBuilder.prototype.append
|
||||
&& BlobBuilder.prototype.getBlob;
|
||||
|
||||
/**
|
||||
* Helper function that maps ArrayBufferViews to ArrayBuffers
|
||||
* Used by BlobBuilder constructor and old browsers that didn't
|
||||
* support it in the Blob constructor.
|
||||
*/
|
||||
|
||||
function mapArrayBufferViews(ary) {
|
||||
for (var i = 0; i < ary.length; i++) {
|
||||
var chunk = ary[i];
|
||||
if (chunk.buffer instanceof ArrayBuffer) {
|
||||
var buf = chunk.buffer;
|
||||
|
||||
// if this is a subarray, make a copy so we only
|
||||
// include the subarray region from the underlying buffer
|
||||
if (chunk.byteLength !== buf.byteLength) {
|
||||
var copy = new Uint8Array(chunk.byteLength);
|
||||
copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
|
||||
buf = copy.buffer;
|
||||
}
|
||||
|
||||
ary[i] = buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function BlobBuilderConstructor(ary, options) {
|
||||
options = options || {};
|
||||
|
||||
var bb = new BlobBuilder();
|
||||
mapArrayBufferViews(ary);
|
||||
|
||||
for (var i = 0; i < ary.length; i++) {
|
||||
bb.append(ary[i]);
|
||||
}
|
||||
|
||||
return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
|
||||
};
|
||||
|
||||
function BlobConstructor(ary, options) {
|
||||
mapArrayBufferViews(ary);
|
||||
return new Blob(ary, options || {});
|
||||
};
|
||||
|
||||
module.exports = (function() {
|
||||
if (blobSupported) {
|
||||
return blobSupportsArrayBufferView ? global.Blob : BlobConstructor;
|
||||
} else if (blobBuilderSupported) {
|
||||
return BlobBuilderConstructor;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})();
|
77
node_modules/blob/package.json
generated
vendored
Normal file
77
node_modules/blob/package.json
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "blob@0.0.4",
|
||||
"scope": null,
|
||||
"escapedName": "blob",
|
||||
"name": "blob",
|
||||
"rawSpec": "0.0.4",
|
||||
"spec": "0.0.4",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/engine.io-parser"
|
||||
]
|
||||
],
|
||||
"_from": "blob@0.0.4",
|
||||
"_id": "blob@0.0.4",
|
||||
"_inCache": true,
|
||||
"_location": "/blob",
|
||||
"_npmUser": {
|
||||
"name": "rase-",
|
||||
"email": "tonykovanen@hotmail.com"
|
||||
},
|
||||
"_npmVersion": "1.4.6",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "blob@0.0.4",
|
||||
"scope": null,
|
||||
"escapedName": "blob",
|
||||
"name": "blob",
|
||||
"rawSpec": "0.0.4",
|
||||
"spec": "0.0.4",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io-parser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz",
|
||||
"_shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "blob@0.0.4",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/engine.io-parser",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rase-/blob/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Abstracts out Blob and uses BlobBulder in cases where it is supported with any vendor prefix.",
|
||||
"devDependencies": {
|
||||
"browserify": "3.30.1",
|
||||
"expect.js": "0.2.0",
|
||||
"mocha": "1.17.1",
|
||||
"zuul": "1.5.4"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921",
|
||||
"tarball": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/rase-/blob",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "rase-",
|
||||
"email": "tonykovanen@hotmail.com"
|
||||
}
|
||||
],
|
||||
"name": "blob",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/rase-/blob.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "0.0.4"
|
||||
}
|
94
node_modules/blob/test/index.js
generated
vendored
Normal file
94
node_modules/blob/test/index.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
var Blob = require('../');
|
||||
var expect = require('expect.js');
|
||||
|
||||
describe('blob', function() {
|
||||
if (!Blob) {
|
||||
it('should not have a blob or a blob builder in the global namespace, or blob should not be a constructor function if the module exports false', function() {
|
||||
try {
|
||||
var ab = (new Uint8Array(5)).buffer;
|
||||
global.Blob([ab]);
|
||||
expect().fail('Blob shouldn\'t be constructable');
|
||||
} catch (e) {}
|
||||
|
||||
var BlobBuilder = global.BlobBuilder
|
||||
|| global.WebKitBlobBuilder
|
||||
|| global.MSBlobBuilder
|
||||
|| global.MozBlobBuilder;
|
||||
expect(BlobBuilder).to.be(undefined);
|
||||
});
|
||||
} else {
|
||||
it('should encode a proper sized blob when given a string argument', function() {
|
||||
var b = new Blob(['hi']);
|
||||
expect(b.size).to.be(2);
|
||||
});
|
||||
|
||||
it('should encode a blob with proper size when given two strings as arguments', function() {
|
||||
var b = new Blob(['hi', 'hello']);
|
||||
expect(b.size).to.be(7);
|
||||
});
|
||||
|
||||
it('should encode arraybuffers with right content', function(done) {
|
||||
var ary = new Uint8Array(5);
|
||||
for (var i = 0; i < 5; i++) ary[i] = i;
|
||||
var b = new Blob([ary.buffer]);
|
||||
var fr = new FileReader();
|
||||
fr.onload = function() {
|
||||
var newAry = new Uint8Array(this.result);
|
||||
for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
|
||||
done();
|
||||
};
|
||||
fr.readAsArrayBuffer(b);
|
||||
});
|
||||
|
||||
it('should encode typed arrays with right content', function(done) {
|
||||
var ary = new Uint8Array(5);
|
||||
for (var i = 0; i < 5; i++) ary[i] = i;
|
||||
var b = new Blob([ary]);
|
||||
var fr = new FileReader();
|
||||
fr.onload = function() {
|
||||
var newAry = new Uint8Array(this.result);
|
||||
for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
|
||||
done();
|
||||
};
|
||||
fr.readAsArrayBuffer(b);
|
||||
});
|
||||
|
||||
it('should encode sliced typed arrays with right content', function(done) {
|
||||
var ary = new Uint8Array(5);
|
||||
for (var i = 0; i < 5; i++) ary[i] = i;
|
||||
var b = new Blob([ary.subarray(2)]);
|
||||
var fr = new FileReader();
|
||||
fr.onload = function() {
|
||||
var newAry = new Uint8Array(this.result);
|
||||
for (var i = 0; i < 3; i++) expect(newAry[i]).to.be(i + 2);
|
||||
done();
|
||||
};
|
||||
fr.readAsArrayBuffer(b);
|
||||
});
|
||||
|
||||
it('should encode with blobs', function(done) {
|
||||
var ary = new Uint8Array(5);
|
||||
for (var i = 0; i < 5; i++) ary[i] = i;
|
||||
var b = new Blob([new Blob([ary.buffer])]);
|
||||
var fr = new FileReader();
|
||||
fr.onload = function() {
|
||||
var newAry = new Uint8Array(this.result);
|
||||
for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
|
||||
done();
|
||||
};
|
||||
fr.readAsArrayBuffer(b);
|
||||
});
|
||||
|
||||
it('should enode mixed contents to right size', function() {
|
||||
var ary = new Uint8Array(5);
|
||||
for (var i = 0; i < 5; i++) ary[i] = i;
|
||||
var b = new Blob([ary.buffer, 'hello']);
|
||||
expect(b.size).to.be(10);
|
||||
});
|
||||
|
||||
it('should accept mime type', function() {
|
||||
var b = new Blob(['hi', 'hello'], { type: 'text/html' });
|
||||
expect(b.type).to.be('text/html');
|
||||
});
|
||||
}
|
||||
});
|
4
node_modules/callsite/.npmignore
generated
vendored
Normal file
4
node_modules/callsite/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
support
|
||||
test
|
||||
examples
|
||||
*.sock
|
10
node_modules/callsite/History.md
generated
vendored
Normal file
10
node_modules/callsite/History.md
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
1.0.0 / 2013-01-24
|
||||
==================
|
||||
|
||||
* remove lame magical getters
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
6
node_modules/callsite/Makefile
generated
vendored
Normal file
6
node_modules/callsite/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should
|
||||
|
||||
.PHONY: test
|
44
node_modules/callsite/Readme.md
generated
vendored
Normal file
44
node_modules/callsite/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
# callstack
|
||||
|
||||
Access to v8's "raw" `CallSite`s.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install callsite
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var stack = require('callsite');
|
||||
|
||||
foo();
|
||||
|
||||
function foo() {
|
||||
bar();
|
||||
}
|
||||
|
||||
function bar() {
|
||||
baz();
|
||||
}
|
||||
|
||||
function baz() {
|
||||
console.log();
|
||||
stack().forEach(function(site){
|
||||
console.log(' \033[36m%s\033[90m in %s:%d\033[0m'
|
||||
, site.getFunctionName() || 'anonymous'
|
||||
, site.getFileName()
|
||||
, site.getLineNumber());
|
||||
});
|
||||
console.log();
|
||||
}
|
||||
```
|
||||
|
||||
## Why?
|
||||
|
||||
Because you can do weird, stupid, clever, wacky things such as:
|
||||
|
||||
- [better-assert](https://github.com/visionmedia/better-assert)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
10
node_modules/callsite/index.js
generated
vendored
Normal file
10
node_modules/callsite/index.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
module.exports = function(){
|
||||
var orig = Error.prepareStackTrace;
|
||||
Error.prepareStackTrace = function(_, stack){ return stack; };
|
||||
var err = new Error;
|
||||
Error.captureStackTrace(err, arguments.callee);
|
||||
var stack = err.stack;
|
||||
Error.prepareStackTrace = orig;
|
||||
return stack;
|
||||
};
|
77
node_modules/callsite/package.json
generated
vendored
Normal file
77
node_modules/callsite/package.json
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "callsite@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "callsite",
|
||||
"name": "callsite",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/better-assert"
|
||||
]
|
||||
],
|
||||
"_from": "callsite@1.0.0",
|
||||
"_id": "callsite@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/callsite",
|
||||
"_npmUser": {
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"_npmVersion": "1.2.2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "callsite@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "callsite",
|
||||
"name": "callsite",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/better-assert"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
|
||||
"_shasum": "280398e5d664bd74038b6f0905153e6e8af1bc20",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "callsite@1.0.0",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/better-assert",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "access to v8's CallSites",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "280398e5d664bd74038b6f0905153e6e8af1bc20",
|
||||
"tarball": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"stack",
|
||||
"trace",
|
||||
"line"
|
||||
],
|
||||
"main": "index",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
}
|
||||
],
|
||||
"name": "callsite",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"version": "1.0.0"
|
||||
}
|
4
node_modules/component-bind/.npmignore
generated
vendored
Normal file
4
node_modules/component-bind/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
support
|
||||
test
|
||||
examples
|
||||
*.sock
|
13
node_modules/component-bind/History.md
generated
vendored
Normal file
13
node_modules/component-bind/History.md
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
1.0.0 / 2014-05-27
|
||||
==================
|
||||
|
||||
* index: use slice ref (#7, @viatropos)
|
||||
* package: rename package to "component-bind"
|
||||
* package: add "repository" field (#6, @repoify)
|
||||
* package: add "component" section
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
7
node_modules/component-bind/Makefile
generated
vendored
Normal file
7
node_modules/component-bind/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter spec
|
||||
|
||||
.PHONY: test
|
64
node_modules/component-bind/Readme.md
generated
vendored
Normal file
64
node_modules/component-bind/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
# bind
|
||||
|
||||
Function binding utility.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ component install component/bind
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
- [bind(obj, fn)](#bindobj-fn)
|
||||
- [bind(obj, fn, ...)](#bindobj-fn-)
|
||||
- [bind(obj, name)](#bindobj-name)
|
||||
<a name=""></a>
|
||||
|
||||
<a name="bindobj-fn"></a>
|
||||
### bind(obj, fn)
|
||||
should bind the function to the given object.
|
||||
|
||||
```js
|
||||
var tobi = { name: 'tobi' };
|
||||
|
||||
function name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
var fn = bind(tobi, name);
|
||||
fn().should.equal('tobi');
|
||||
```
|
||||
|
||||
<a name="bindobj-fn-"></a>
|
||||
### bind(obj, fn, ...)
|
||||
should curry the remaining arguments.
|
||||
|
||||
```js
|
||||
function add(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
bind(null, add)(1, 2).should.equal(3);
|
||||
bind(null, add, 1)(2).should.equal(3);
|
||||
bind(null, add, 1, 2)().should.equal(3);
|
||||
```
|
||||
|
||||
<a name="bindobj-name"></a>
|
||||
### bind(obj, name)
|
||||
should bind the method of the given name.
|
||||
|
||||
```js
|
||||
var tobi = { name: 'tobi' };
|
||||
|
||||
tobi.getName = function() {
|
||||
return this.name;
|
||||
};
|
||||
|
||||
var fn = bind(tobi, 'getName');
|
||||
fn().should.equal('tobi');
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
13
node_modules/component-bind/component.json
generated
vendored
Normal file
13
node_modules/component-bind/component.json
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "bind",
|
||||
"version": "1.0.0",
|
||||
"description": "function binding utility",
|
||||
"keywords": [
|
||||
"bind",
|
||||
"utility"
|
||||
],
|
||||
"dependencies": {},
|
||||
"scripts": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
23
node_modules/component-bind/index.js
generated
vendored
Normal file
23
node_modules/component-bind/index.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Slice reference.
|
||||
*/
|
||||
|
||||
var slice = [].slice;
|
||||
|
||||
/**
|
||||
* Bind `obj` to `fn`.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {Function|String} fn or string
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(obj, fn){
|
||||
if ('string' == typeof fn) fn = obj[fn];
|
||||
if ('function' != typeof fn) throw new Error('bind() requires a function');
|
||||
var args = slice.call(arguments, 2);
|
||||
return function(){
|
||||
return fn.apply(obj, args.concat(slice.call(arguments)));
|
||||
}
|
||||
};
|
81
node_modules/component-bind/package.json
generated
vendored
Normal file
81
node_modules/component-bind/package.json
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "component-bind@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "component-bind",
|
||||
"name": "component-bind",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/socket.io-client"
|
||||
]
|
||||
],
|
||||
"_from": "component-bind@1.0.0",
|
||||
"_id": "component-bind@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/component-bind",
|
||||
"_npmUser": {
|
||||
"name": "tootallnate",
|
||||
"email": "nathan@tootallnate.net"
|
||||
},
|
||||
"_npmVersion": "1.4.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "component-bind@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "component-bind",
|
||||
"name": "component-bind",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/socket.io-client"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
|
||||
"_shasum": "00c608ab7dcd93897c0009651b1d3a8e1e73bbd1",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "component-bind@1.0.0",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/socket.io-client",
|
||||
"bugs": {
|
||||
"url": "https://github.com/component/bind/issues"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"bind/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "function binding utility",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "00c608ab7dcd93897c0009651b1d3a8e1e73bbd1",
|
||||
"tarball": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/component/bind",
|
||||
"keywords": [
|
||||
"bind",
|
||||
"utility"
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tootallnate",
|
||||
"email": "nathan@tootallnate.net"
|
||||
}
|
||||
],
|
||||
"name": "component-bind",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/component/bind.git"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
2
node_modules/component-emitter/.npmignore
generated
vendored
Normal file
2
node_modules/component-emitter/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
test
|
4
node_modules/component-emitter/.travis.yml
generated
vendored
Normal file
4
node_modules/component-emitter/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
language: node_js
|
52
node_modules/component-emitter/History.md
generated
vendored
Normal file
52
node_modules/component-emitter/History.md
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
|
||||
1.1.2 / 2014-02-10
|
||||
==================
|
||||
|
||||
* package: rename to "component-emitter"
|
||||
* package: update "main" and "component" fields
|
||||
* Add license to Readme (same format as the other components)
|
||||
* created .npmignore
|
||||
* travis stuff
|
||||
|
||||
1.1.1 / 2013-12-01
|
||||
==================
|
||||
|
||||
* fix .once adding .on to the listener
|
||||
* docs: Emitter#off()
|
||||
* component: add `.repo` prop
|
||||
|
||||
1.1.0 / 2013-10-20
|
||||
==================
|
||||
|
||||
* add `.addEventListener()` and `.removeEventListener()` aliases
|
||||
|
||||
1.0.1 / 2013-06-27
|
||||
==================
|
||||
|
||||
* add support for legacy ie
|
||||
|
||||
1.0.0 / 2013-02-26
|
||||
==================
|
||||
|
||||
* add `.off()` support for removing all listeners
|
||||
|
||||
0.0.6 / 2012-10-08
|
||||
==================
|
||||
|
||||
* add `this._callbacks` initialization to prevent funky gotcha
|
||||
|
||||
0.0.5 / 2012-09-07
|
||||
==================
|
||||
|
||||
* fix `Emitter.call(this)` usage
|
||||
|
||||
0.0.3 / 2012-07-11
|
||||
==================
|
||||
|
||||
* add `.listeners()`
|
||||
* rename `.has()` to `.hasListeners()`
|
||||
|
||||
0.0.2 / 2012-06-28
|
||||
==================
|
||||
|
||||
* fix `.off()` with `.once()`-registered callbacks
|
7
node_modules/component-emitter/Makefile
generated
vendored
Normal file
7
node_modules/component-emitter/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter spec
|
||||
|
||||
.PHONY: test
|
74
node_modules/component-emitter/Readme.md
generated
vendored
Normal file
74
node_modules/component-emitter/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter)
|
||||
|
||||
Event emitter component.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ component install component/emitter
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Emitter(obj)
|
||||
|
||||
The `Emitter` may also be used as a mixin. For example
|
||||
a "plain" object may become an emitter, or you may
|
||||
extend an existing prototype.
|
||||
|
||||
As an `Emitter` instance:
|
||||
|
||||
```js
|
||||
var Emitter = require('emitter');
|
||||
var emitter = new Emitter;
|
||||
emitter.emit('something');
|
||||
```
|
||||
|
||||
As a mixin:
|
||||
|
||||
```js
|
||||
var Emitter = require('emitter');
|
||||
var user = { name: 'tobi' };
|
||||
Emitter(user);
|
||||
|
||||
user.emit('im a user');
|
||||
```
|
||||
|
||||
As a prototype mixin:
|
||||
|
||||
```js
|
||||
var Emitter = require('emitter');
|
||||
Emitter(User.prototype);
|
||||
```
|
||||
|
||||
### Emitter#on(event, fn)
|
||||
|
||||
Register an `event` handler `fn`.
|
||||
|
||||
### Emitter#once(event, fn)
|
||||
|
||||
Register a single-shot `event` handler `fn`,
|
||||
removed immediately after it is invoked the
|
||||
first time.
|
||||
|
||||
### Emitter#off(event, fn)
|
||||
|
||||
* Pass `event` and `fn` to remove a listener.
|
||||
* Pass `event` to remove all listeners on that event.
|
||||
* Pass nothing to remove all listeners on all events.
|
||||
|
||||
### Emitter#emit(event, ...)
|
||||
|
||||
Emit an `event` with variable option args.
|
||||
|
||||
### Emitter#listeners(event)
|
||||
|
||||
Return an array of callbacks, or an empty array.
|
||||
|
||||
### Emitter#hasListeners(event)
|
||||
|
||||
Check if this emitter has `event` handlers.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
21
node_modules/component-emitter/bower.json
generated
vendored
Normal file
21
node_modules/component-emitter/bower.json
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "emitter",
|
||||
"description": "Event emitter",
|
||||
"keywords": [
|
||||
"emitter",
|
||||
"events"
|
||||
],
|
||||
"version": "1.1.2",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"homepage": "https://github.com/component/emitter",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"Makefile",
|
||||
"package.json",
|
||||
"component.json"
|
||||
]
|
||||
}
|
14
node_modules/component-emitter/component.json
generated
vendored
Normal file
14
node_modules/component-emitter/component.json
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "emitter",
|
||||
"repo": "component/emitter",
|
||||
"description": "Event emitter",
|
||||
"keywords": [
|
||||
"emitter",
|
||||
"events"
|
||||
],
|
||||
"version": "1.1.2",
|
||||
"scripts": [
|
||||
"index.js"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
164
node_modules/component-emitter/index.js
generated
vendored
Normal file
164
node_modules/component-emitter/index.js
generated
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
|
||||
/**
|
||||
* Expose `Emitter`.
|
||||
*/
|
||||
|
||||
module.exports = Emitter;
|
||||
|
||||
/**
|
||||
* Initialize a new `Emitter`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Emitter(obj) {
|
||||
if (obj) return mixin(obj);
|
||||
};
|
||||
|
||||
/**
|
||||
* Mixin the emitter properties.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function mixin(obj) {
|
||||
for (var key in Emitter.prototype) {
|
||||
obj[key] = Emitter.prototype[key];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen on the given `event` with `fn`.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Function} fn
|
||||
* @return {Emitter}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.on =
|
||||
Emitter.prototype.addEventListener = function(event, fn){
|
||||
this._callbacks = this._callbacks || {};
|
||||
(this._callbacks[event] = this._callbacks[event] || [])
|
||||
.push(fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds an `event` listener that will be invoked a single
|
||||
* time then automatically removed.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Function} fn
|
||||
* @return {Emitter}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.once = function(event, fn){
|
||||
var self = this;
|
||||
this._callbacks = this._callbacks || {};
|
||||
|
||||
function on() {
|
||||
self.off(event, on);
|
||||
fn.apply(this, arguments);
|
||||
}
|
||||
|
||||
on.fn = fn;
|
||||
this.on(event, on);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the given callback for `event` or all
|
||||
* registered callbacks.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Function} fn
|
||||
* @return {Emitter}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.off =
|
||||
Emitter.prototype.removeListener =
|
||||
Emitter.prototype.removeAllListeners =
|
||||
Emitter.prototype.removeEventListener = function(event, fn){
|
||||
this._callbacks = this._callbacks || {};
|
||||
|
||||
// all
|
||||
if (0 == arguments.length) {
|
||||
this._callbacks = {};
|
||||
return this;
|
||||
}
|
||||
|
||||
// specific event
|
||||
var callbacks = this._callbacks[event];
|
||||
if (!callbacks) return this;
|
||||
|
||||
// remove all handlers
|
||||
if (1 == arguments.length) {
|
||||
delete this._callbacks[event];
|
||||
return this;
|
||||
}
|
||||
|
||||
// remove specific handler
|
||||
var cb;
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
cb = callbacks[i];
|
||||
if (cb === fn || cb.fn === fn) {
|
||||
callbacks.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit `event` with the given args.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Mixed} ...
|
||||
* @return {Emitter}
|
||||
*/
|
||||
|
||||
Emitter.prototype.emit = function(event){
|
||||
this._callbacks = this._callbacks || {};
|
||||
var args = [].slice.call(arguments, 1)
|
||||
, callbacks = this._callbacks[event];
|
||||
|
||||
if (callbacks) {
|
||||
callbacks = callbacks.slice(0);
|
||||
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
||||
callbacks[i].apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return array of callbacks for `event`.
|
||||
*
|
||||
* @param {String} event
|
||||
* @return {Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.listeners = function(event){
|
||||
this._callbacks = this._callbacks || {};
|
||||
return this._callbacks[event] || [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this emitter has `event` handlers.
|
||||
*
|
||||
* @param {String} event
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.hasListeners = function(event){
|
||||
return !! this.listeners(event).length;
|
||||
};
|
81
node_modules/component-emitter/package.json
generated
vendored
Normal file
81
node_modules/component-emitter/package.json
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "component-emitter@1.1.2",
|
||||
"scope": null,
|
||||
"escapedName": "component-emitter",
|
||||
"name": "component-emitter",
|
||||
"rawSpec": "1.1.2",
|
||||
"spec": "1.1.2",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/socket.io-parser"
|
||||
]
|
||||
],
|
||||
"_from": "component-emitter@1.1.2",
|
||||
"_id": "component-emitter@1.1.2",
|
||||
"_inCache": true,
|
||||
"_location": "/component-emitter",
|
||||
"_npmUser": {
|
||||
"name": "tootallnate",
|
||||
"email": "nathan@tootallnate.net"
|
||||
},
|
||||
"_npmVersion": "1.3.24",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "component-emitter@1.1.2",
|
||||
"scope": null,
|
||||
"escapedName": "component-emitter",
|
||||
"name": "component-emitter",
|
||||
"rawSpec": "1.1.2",
|
||||
"spec": "1.1.2",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/socket.io-parser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz",
|
||||
"_shasum": "296594f2753daa63996d2af08d15a95116c9aec3",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "component-emitter@1.1.2",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/socket.io-parser",
|
||||
"bugs": {
|
||||
"url": "https://github.com/component/emitter/issues"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"emitter/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Event emitter",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "296594f2753daa63996d2af08d15a95116c9aec3",
|
||||
"tarball": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/component/emitter",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tootallnate",
|
||||
"email": "nathan@tootallnate.net"
|
||||
}
|
||||
],
|
||||
"name": "component-emitter",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/component/emitter.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.1.2"
|
||||
}
|
3
node_modules/component-inherit/.npmignore
generated
vendored
Normal file
3
node_modules/component-inherit/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
components
|
||||
build
|
||||
node_modules
|
5
node_modules/component-inherit/History.md
generated
vendored
Normal file
5
node_modules/component-inherit/History.md
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
0.0.2 / 2012-09-03
|
||||
==================
|
||||
|
||||
* fix typo in package.json
|
16
node_modules/component-inherit/Makefile
generated
vendored
Normal file
16
node_modules/component-inherit/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
build: components index.js
|
||||
@component build
|
||||
|
||||
components:
|
||||
@Component install
|
||||
|
||||
clean:
|
||||
rm -fr build components template.js
|
||||
|
||||
test:
|
||||
@node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter spec
|
||||
|
||||
.PHONY: clean test
|
24
node_modules/component-inherit/Readme.md
generated
vendored
Normal file
24
node_modules/component-inherit/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# inherit
|
||||
|
||||
Prototype inheritance utility.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ component install component/inherit
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var inherit = require('inherit');
|
||||
|
||||
function Human() {}
|
||||
function Woman() {}
|
||||
|
||||
inherit(Woman, Human);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
10
node_modules/component-inherit/component.json
generated
vendored
Normal file
10
node_modules/component-inherit/component.json
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "inherit",
|
||||
"description": "Prototype inheritance utility",
|
||||
"version": "0.0.3",
|
||||
"keywords": ["inherit", "utility"],
|
||||
"dependencies": {},
|
||||
"scripts": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
7
node_modules/component-inherit/index.js
generated
vendored
Normal file
7
node_modules/component-inherit/index.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
module.exports = function(a, b){
|
||||
var fn = function(){};
|
||||
fn.prototype = b.prototype;
|
||||
a.prototype = new fn;
|
||||
a.prototype.constructor = a;
|
||||
};
|
78
node_modules/component-inherit/package.json
generated
vendored
Normal file
78
node_modules/component-inherit/package.json
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "component-inherit@0.0.3",
|
||||
"scope": null,
|
||||
"escapedName": "component-inherit",
|
||||
"name": "component-inherit",
|
||||
"rawSpec": "0.0.3",
|
||||
"spec": "0.0.3",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/engine.io-client"
|
||||
]
|
||||
],
|
||||
"_from": "component-inherit@0.0.3",
|
||||
"_id": "component-inherit@0.0.3",
|
||||
"_inCache": true,
|
||||
"_location": "/component-inherit",
|
||||
"_npmUser": {
|
||||
"name": "coreh",
|
||||
"email": "thecoreh@gmail.com"
|
||||
},
|
||||
"_npmVersion": "1.3.24",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "component-inherit@0.0.3",
|
||||
"scope": null,
|
||||
"escapedName": "component-inherit",
|
||||
"name": "component-inherit",
|
||||
"rawSpec": "0.0.3",
|
||||
"spec": "0.0.3",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io-client"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz",
|
||||
"_shasum": "645fc4adf58b72b649d5cae65135619db26ff143",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "component-inherit@0.0.3",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/engine.io-client",
|
||||
"bugs": {
|
||||
"url": "https://github.com/component/inherit/issues"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"inherit/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Prototype inheritance utility",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "645fc4adf58b72b649d5cae65135619db26ff143",
|
||||
"tarball": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/component/inherit",
|
||||
"keywords": [
|
||||
"inherit",
|
||||
"utility"
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "coreh",
|
||||
"email": "thecoreh@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "component-inherit",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/component/inherit.git"
|
||||
},
|
||||
"version": "0.0.3"
|
||||
}
|
21
node_modules/component-inherit/test/inherit.js
generated
vendored
Normal file
21
node_modules/component-inherit/test/inherit.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var inherit = require('..');
|
||||
|
||||
describe('inherit(a, b)', function(){
|
||||
it('should inherit b\'s prototype', function(){
|
||||
function Loki(){}
|
||||
function Animal(){}
|
||||
|
||||
Animal.prototype.species = 'unknown';
|
||||
|
||||
inherit(Loki, Animal);
|
||||
|
||||
var loki = new Loki;
|
||||
loki.species.should.equal('unknown');
|
||||
loki.constructor.should.equal(Loki);
|
||||
})
|
||||
})
|
40
node_modules/content-disposition/HISTORY.md
generated
vendored
Normal file
40
node_modules/content-disposition/HISTORY.md
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
0.5.0 / 2014-10-11
|
||||
==================
|
||||
|
||||
* Add `parse` function
|
||||
|
||||
0.4.0 / 2014-09-21
|
||||
==================
|
||||
|
||||
* Expand non-Unicode `filename` to the full ISO-8859-1 charset
|
||||
|
||||
0.3.0 / 2014-09-20
|
||||
==================
|
||||
|
||||
* Add `fallback` option
|
||||
* Add `type` option
|
||||
|
||||
0.2.0 / 2014-09-19
|
||||
==================
|
||||
|
||||
* Reduce ambiguity of file names with hex escape in buggy browsers
|
||||
|
||||
0.1.2 / 2014-09-19
|
||||
==================
|
||||
|
||||
* Fix periodic invalid Unicode filename header
|
||||
|
||||
0.1.1 / 2014-09-19
|
||||
==================
|
||||
|
||||
* Fix invalid characters appearing in `filename*` parameter
|
||||
|
||||
0.1.0 / 2014-09-18
|
||||
==================
|
||||
|
||||
* Make the `filename` argument optional
|
||||
|
||||
0.0.0 / 2014-09-18
|
||||
==================
|
||||
|
||||
* Initial release
|
22
node_modules/content-disposition/LICENSE
generated
vendored
Normal file
22
node_modules/content-disposition/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
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.
|
141
node_modules/content-disposition/README.md
generated
vendored
Normal file
141
node_modules/content-disposition/README.md
generated
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
# content-disposition
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Create and parse HTTP `Content-Disposition` header
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install content-disposition
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var contentDisposition = require('content-disposition')
|
||||
```
|
||||
|
||||
### contentDisposition(filename, options)
|
||||
|
||||
Create an attachment `Content-Disposition` header value using the given file name,
|
||||
if supplied. The `filename` is optional and if no file name is desired, but you
|
||||
want to specify `options`, set `filename` to `undefined`.
|
||||
|
||||
```js
|
||||
res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf'))
|
||||
```
|
||||
|
||||
**note** HTTP headers are of the ISO-8859-1 character set. If you are writing this
|
||||
header through a means different from `setHeader` in Node.js, you'll want to specify
|
||||
the `'binary'` encoding in Node.js.
|
||||
|
||||
#### Options
|
||||
|
||||
`contentDisposition` accepts these properties in the options object.
|
||||
|
||||
##### fallback
|
||||
|
||||
If the `filename` option is outside ISO-8859-1, then the file name is actually
|
||||
stored in a supplemental field for clients that support Unicode file names and
|
||||
a ISO-8859-1 version of the file name is automatically generated.
|
||||
|
||||
This specifies the ISO-8859-1 file name to override the automatic generation or
|
||||
disables the generation all together, defaults to `true`.
|
||||
|
||||
- A string will specify the ISO-8859-1 file name to use in place of automatic
|
||||
generation.
|
||||
- `false` will disable including a ISO-8859-1 file name and only include the
|
||||
Unicode version (unless the file name is already ISO-8859-1).
|
||||
- `true` will enable automatic generation if the file name is outside ISO-8859-1.
|
||||
|
||||
If the `filename` option is ISO-8859-1 and this option is specified and has a
|
||||
different value, then the `filename` option is encoded in the extended field
|
||||
and this set as the fallback field, even though they are both ISO-8859-1.
|
||||
|
||||
##### type
|
||||
|
||||
Specifies the disposition type, defaults to `"attachment"`. This can also be
|
||||
`"inline"`, or any other value (all values except inline are treated like
|
||||
`attachment`, but can convey additional information if both parties agree to
|
||||
it). The type is normalized to lower-case.
|
||||
|
||||
### contentDisposition.parse(string)
|
||||
|
||||
```js
|
||||
var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt"');
|
||||
```
|
||||
|
||||
Parse a `Content-Disposition` header string. This automatically handles extended
|
||||
("Unicode") parameters by decoding them and providing them under the standard
|
||||
parameter name. This will return an object with the following properties (examples
|
||||
are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`):
|
||||
|
||||
- `type`: The disposition type (always lower case). Example: `'attachment'`
|
||||
|
||||
- `parameters`: An object of the parameters in the disposition (name of parameter
|
||||
always lower case and extended versions replace non-extended versions). Example:
|
||||
`{filename: "€ rates.txt"}`
|
||||
|
||||
## Examples
|
||||
|
||||
### Send a file for download
|
||||
|
||||
```js
|
||||
var contentDisposition = require('content-disposition')
|
||||
var destroy = require('destroy')
|
||||
var http = require('http')
|
||||
var onFinished = require('on-finished')
|
||||
|
||||
var filePath = '/path/to/public/plans.pdf'
|
||||
|
||||
http.createServer(function onRequest(req, res) {
|
||||
// set headers
|
||||
res.setHeader('Content-Type', 'application/pdf')
|
||||
res.setHeader('Content-Disposition', contentDisposition(filePath))
|
||||
|
||||
// send file
|
||||
var stream = fs.createReadStream(filePath)
|
||||
stream.pipe(res)
|
||||
onFinished(res, function (err) {
|
||||
destroy(stream)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616]
|
||||
- [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987]
|
||||
- [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266]
|
||||
- [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231]
|
||||
|
||||
[rfc-2616]: https://tools.ietf.org/html/rfc2616
|
||||
[rfc-5987]: https://tools.ietf.org/html/rfc5987
|
||||
[rfc-6266]: https://tools.ietf.org/html/rfc6266
|
||||
[tc-2231]: http://greenbytes.de/tech/tc2231/
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/content-disposition.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/content-disposition
|
||||
[node-version-image]: https://img.shields.io/node/v/content-disposition.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/content-disposition
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/content-disposition
|
443
node_modules/content-disposition/index.js
generated
vendored
Normal file
443
node_modules/content-disposition/index.js
generated
vendored
Normal file
|
@ -0,0 +1,443 @@
|
|||
/*!
|
||||
* content-disposition
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = contentDisposition
|
||||
module.exports.parse = parse
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var basename = require('path').basename
|
||||
|
||||
/**
|
||||
* RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
|
||||
*/
|
||||
|
||||
var encodeUriAttrCharRegExp = /[\x00-\x20"'\(\)*,\/:;<=>?@\[\\\]\{\}\x7f]/g
|
||||
|
||||
/**
|
||||
* RegExp to match percent encoding escape.
|
||||
*/
|
||||
|
||||
var hexEscapeRegExp = /%[0-9A-Fa-f]{2}/
|
||||
var hexEscapeReplaceRegExp = /%([0-9A-Fa-f]{2})/g
|
||||
|
||||
/**
|
||||
* RegExp to match non-latin1 characters.
|
||||
*/
|
||||
|
||||
var nonLatin1RegExp = /[^\x20-\x7e\xa0-\xff]/g
|
||||
|
||||
/**
|
||||
* RegExp to match quoted-pair in RFC 2616
|
||||
*
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
*/
|
||||
|
||||
var qescRegExp = /\\([\u0000-\u007f])/g;
|
||||
|
||||
/**
|
||||
* RegExp to match chars that must be quoted-pair in RFC 2616
|
||||
*/
|
||||
|
||||
var quoteRegExp = /([\\"])/g
|
||||
|
||||
/**
|
||||
* RegExp for various RFC 2616 grammar
|
||||
*
|
||||
* parameter = token "=" ( token | quoted-string )
|
||||
* token = 1*<any CHAR except CTLs or separators>
|
||||
* separators = "(" | ")" | "<" | ">" | "@"
|
||||
* | "," | ";" | ":" | "\" | <">
|
||||
* | "/" | "[" | "]" | "?" | "="
|
||||
* | "{" | "}" | SP | HT
|
||||
* quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
|
||||
* qdtext = <any TEXT except <">>
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
* TEXT = <any OCTET except CTLs, but including LWS>
|
||||
* LWS = [CRLF] 1*( SP | HT )
|
||||
* CRLF = CR LF
|
||||
* CR = <US-ASCII CR, carriage return (13)>
|
||||
* LF = <US-ASCII LF, linefeed (10)>
|
||||
* SP = <US-ASCII SP, space (32)>
|
||||
* HT = <US-ASCII HT, horizontal-tab (9)>
|
||||
* CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
|
||||
* OCTET = <any 8-bit sequence of data>
|
||||
*/
|
||||
|
||||
var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g
|
||||
var textRegExp = /^[\x20-\x7e\x80-\xff]+$/
|
||||
var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/
|
||||
|
||||
/**
|
||||
* RegExp for various RFC 5987 grammar
|
||||
*
|
||||
* ext-value = charset "'" [ language ] "'" value-chars
|
||||
* charset = "UTF-8" / "ISO-8859-1" / mime-charset
|
||||
* mime-charset = 1*mime-charsetc
|
||||
* mime-charsetc = ALPHA / DIGIT
|
||||
* / "!" / "#" / "$" / "%" / "&"
|
||||
* / "+" / "-" / "^" / "_" / "`"
|
||||
* / "{" / "}" / "~"
|
||||
* language = ( 2*3ALPHA [ extlang ] )
|
||||
* / 4ALPHA
|
||||
* / 5*8ALPHA
|
||||
* extlang = *3( "-" 3ALPHA )
|
||||
* value-chars = *( pct-encoded / attr-char )
|
||||
* pct-encoded = "%" HEXDIG HEXDIG
|
||||
* attr-char = ALPHA / DIGIT
|
||||
* / "!" / "#" / "$" / "&" / "+" / "-" / "."
|
||||
* / "^" / "_" / "`" / "|" / "~"
|
||||
*/
|
||||
|
||||
var extValueRegExp = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+\-\.^_`|~])+)$/
|
||||
|
||||
/**
|
||||
* RegExp for various RFC 6266 grammar
|
||||
*
|
||||
* disposition-type = "inline" | "attachment" | disp-ext-type
|
||||
* disp-ext-type = token
|
||||
* disposition-parm = filename-parm | disp-ext-parm
|
||||
* filename-parm = "filename" "=" value
|
||||
* | "filename*" "=" ext-value
|
||||
* disp-ext-parm = token "=" value
|
||||
* | ext-token "=" ext-value
|
||||
* ext-token = <the characters in token, followed by "*">
|
||||
*/
|
||||
|
||||
var dispositionTypeRegExp = /^([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *(?:$|;)/
|
||||
|
||||
/**
|
||||
* Create an attachment Content-Disposition header.
|
||||
*
|
||||
* @param {string} [filename]
|
||||
* @param {object} [options]
|
||||
* @param {string} [options.type=attachment]
|
||||
* @param {string|boolean} [options.fallback=true]
|
||||
* @return {string}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function contentDisposition(filename, options) {
|
||||
var opts = options || {}
|
||||
|
||||
// get type
|
||||
var type = opts.type || 'attachment'
|
||||
|
||||
// get parameters
|
||||
var params = createparams(filename, opts.fallback)
|
||||
|
||||
// format into string
|
||||
return format(new ContentDisposition(type, params))
|
||||
}
|
||||
|
||||
/**
|
||||
* Create parameters object from filename and fallback.
|
||||
*
|
||||
* @param {string} [filename]
|
||||
* @param {string|boolean} [fallback=true]
|
||||
* @return {object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function createparams(filename, fallback) {
|
||||
if (filename === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
var params = {}
|
||||
|
||||
if (typeof filename !== 'string') {
|
||||
throw new TypeError('filename must be a string')
|
||||
}
|
||||
|
||||
// fallback defaults to true
|
||||
if (fallback === undefined) {
|
||||
fallback = true
|
||||
}
|
||||
|
||||
if (typeof fallback !== 'string' && typeof fallback !== 'boolean') {
|
||||
throw new TypeError('fallback must be a string or boolean')
|
||||
}
|
||||
|
||||
if (typeof fallback === 'string' && nonLatin1RegExp.test(fallback)) {
|
||||
throw new TypeError('fallback must be ISO-8859-1 string')
|
||||
}
|
||||
|
||||
// restrict to file base name
|
||||
var name = basename(filename)
|
||||
|
||||
// determine if name is suitable for quoted string
|
||||
var isQuotedString = textRegExp.test(name)
|
||||
|
||||
// generate fallback name
|
||||
var fallbackName = typeof fallback !== 'string'
|
||||
? fallback && getlatin1(name)
|
||||
: basename(fallback)
|
||||
var hasFallback = typeof fallbackName === 'string' && fallbackName !== name
|
||||
|
||||
// set extended filename parameter
|
||||
if (hasFallback || !isQuotedString || hexEscapeRegExp.test(name)) {
|
||||
params['filename*'] = name
|
||||
}
|
||||
|
||||
// set filename parameter
|
||||
if (isQuotedString || hasFallback) {
|
||||
params.filename = hasFallback
|
||||
? fallbackName
|
||||
: name
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
/**
|
||||
* Format object to Content-Disposition header.
|
||||
*
|
||||
* @param {object} obj
|
||||
* @param {string} obj.type
|
||||
* @param {object} [obj.parameters]
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function format(obj) {
|
||||
var parameters = obj.parameters
|
||||
var type = obj.type
|
||||
|
||||
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
|
||||
throw new TypeError('invalid type')
|
||||
}
|
||||
|
||||
// start with normalized type
|
||||
var string = String(type).toLowerCase()
|
||||
|
||||
// append parameters
|
||||
if (parameters && typeof parameters === 'object') {
|
||||
var param
|
||||
var params = Object.keys(parameters).sort()
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
param = params[i]
|
||||
|
||||
var val = param.substr(-1) === '*'
|
||||
? ustring(parameters[param])
|
||||
: qstring(parameters[param])
|
||||
|
||||
string += '; ' + param + '=' + val
|
||||
}
|
||||
}
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a RFC 6987 field value (gracefully).
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function decodefield(str) {
|
||||
var match = extValueRegExp.exec(str)
|
||||
|
||||
if (!match) {
|
||||
throw new TypeError('invalid extended field value')
|
||||
}
|
||||
|
||||
var charset = match[1].toLowerCase()
|
||||
var encoded = match[2]
|
||||
var value
|
||||
|
||||
// to binary string
|
||||
var binary = encoded.replace(hexEscapeReplaceRegExp, pdecode)
|
||||
|
||||
switch (charset) {
|
||||
case 'iso-8859-1':
|
||||
value = getlatin1(binary)
|
||||
break
|
||||
case 'utf-8':
|
||||
value = new Buffer(binary, 'binary').toString('utf8')
|
||||
break
|
||||
default:
|
||||
throw new TypeError('unsupported charset in extended field')
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ISO-8859-1 version of string.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getlatin1(val) {
|
||||
// simple Unicode -> ISO-8859-1 transformation
|
||||
return String(val).replace(nonLatin1RegExp, '?')
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Content-Disposition header string.
|
||||
*
|
||||
* @param {string} string
|
||||
* @return {object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(string) {
|
||||
if (!string || typeof string !== 'string') {
|
||||
throw new TypeError('argument string is required')
|
||||
}
|
||||
|
||||
var match = dispositionTypeRegExp.exec(string)
|
||||
|
||||
if (!match) {
|
||||
throw new TypeError('invalid type format')
|
||||
}
|
||||
|
||||
// normalize type
|
||||
var index = match[0].length
|
||||
var type = match[1].toLowerCase()
|
||||
|
||||
var key
|
||||
var names = []
|
||||
var params = {}
|
||||
var value
|
||||
|
||||
// calculate index to start at
|
||||
index = paramRegExp.lastIndex = match[0].substr(-1) === ';'
|
||||
? index - 1
|
||||
: index
|
||||
|
||||
// match parameters
|
||||
while (match = paramRegExp.exec(string)) {
|
||||
if (match.index !== index) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
index += match[0].length
|
||||
key = match[1].toLowerCase()
|
||||
value = match[2]
|
||||
|
||||
if (names.indexOf(key) !== -1) {
|
||||
throw new TypeError('invalid duplicate parameter')
|
||||
}
|
||||
|
||||
names.push(key)
|
||||
|
||||
if (key.indexOf('*') + 1 === key.length) {
|
||||
// decode extended value
|
||||
key = key.slice(0, -1)
|
||||
value = decodefield(value)
|
||||
|
||||
// overwrite existing value
|
||||
params[key] = value
|
||||
continue
|
||||
}
|
||||
|
||||
if (typeof params[key] === 'string') {
|
||||
continue
|
||||
}
|
||||
|
||||
if (value[0] === '"') {
|
||||
// remove quotes and escapes
|
||||
value = value
|
||||
.substr(1, value.length - 2)
|
||||
.replace(qescRegExp, '$1')
|
||||
}
|
||||
|
||||
params[key] = value
|
||||
}
|
||||
|
||||
if (index !== -1 && index !== string.length) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
return new ContentDisposition(type, params)
|
||||
}
|
||||
|
||||
/**
|
||||
* Percent decode a single character.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} hex
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function pdecode(str, hex) {
|
||||
return String.fromCharCode(parseInt(hex, 16))
|
||||
}
|
||||
|
||||
/**
|
||||
* Percent encode a single character.
|
||||
*
|
||||
* @param {string} char
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function pencode(char) {
|
||||
var hex = String(char)
|
||||
.charCodeAt(0)
|
||||
.toString(16)
|
||||
.toUpperCase()
|
||||
return hex.length === 1
|
||||
? '%0' + hex
|
||||
: '%' + hex
|
||||
}
|
||||
|
||||
/**
|
||||
* Quote a string for HTTP.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function qstring(val) {
|
||||
var str = String(val)
|
||||
|
||||
return '"' + str.replace(quoteRegExp, '\\$1') + '"'
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a Unicode string for HTTP (RFC 5987).
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function ustring(val) {
|
||||
var str = String(val)
|
||||
|
||||
// percent encode as UTF-8
|
||||
var encoded = encodeURIComponent(str)
|
||||
.replace(encodeUriAttrCharRegExp, pencode)
|
||||
|
||||
return 'UTF-8\'\'' + encoded
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for parsed Content-Disposition header for v8 optimization
|
||||
*/
|
||||
|
||||
function ContentDisposition(type, parameters) {
|
||||
this.type = type
|
||||
this.parameters = parameters
|
||||
}
|
100
node_modules/content-disposition/package.json
generated
vendored
Normal file
100
node_modules/content-disposition/package.json
generated
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "content-disposition@0.5.0",
|
||||
"scope": null,
|
||||
"escapedName": "content-disposition",
|
||||
"name": "content-disposition",
|
||||
"rawSpec": "0.5.0",
|
||||
"spec": "0.5.0",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/express"
|
||||
]
|
||||
],
|
||||
"_from": "content-disposition@0.5.0",
|
||||
"_id": "content-disposition@0.5.0",
|
||||
"_inCache": true,
|
||||
"_location": "/content-disposition",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"_npmVersion": "1.4.21",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "content-disposition@0.5.0",
|
||||
"scope": null,
|
||||
"escapedName": "content-disposition",
|
||||
"name": "content-disposition",
|
||||
"rawSpec": "0.5.0",
|
||||
"spec": "0.5.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.0.tgz",
|
||||
"_shasum": "4284fe6ae0630874639e44e80a418c2934135e9e",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "content-disposition@0.5.0",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/express",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/content-disposition/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "Create and parse Content-Disposition header",
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.2",
|
||||
"mocha": "~1.21.4"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "4284fe6ae0630874639e44e80a418c2934135e9e",
|
||||
"tarball": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "f3c915f0c9d9f5ec79713dba24c8c6181b73305d",
|
||||
"homepage": "https://github.com/jshttp/content-disposition",
|
||||
"keywords": [
|
||||
"content-disposition",
|
||||
"http",
|
||||
"rfc6266",
|
||||
"res"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"name": "content-disposition",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jshttp/content-disposition.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --bail --check-leaks test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
||||
},
|
||||
"version": "0.5.0"
|
||||
}
|
4
node_modules/cookie-signature/.npmignore
generated
vendored
Normal file
4
node_modules/cookie-signature/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
support
|
||||
test
|
||||
examples
|
||||
*.sock
|
27
node_modules/cookie-signature/History.md
generated
vendored
Normal file
27
node_modules/cookie-signature/History.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
1.0.4 / 2014-06-25
|
||||
==================
|
||||
|
||||
* corrected avoidance of timing attacks (thanks @tenbits!)
|
||||
|
||||
|
||||
1.0.3 / 2014-01-28
|
||||
==================
|
||||
|
||||
* [incorrect] fix for timing attacks
|
||||
|
||||
1.0.2 / 2014-01-28
|
||||
==================
|
||||
|
||||
* fix missing repository warning
|
||||
* fix typo in test
|
||||
|
||||
1.0.1 / 2013-04-15
|
||||
==================
|
||||
|
||||
* Revert "Changed underlying HMAC algo. to sha512."
|
||||
* Revert "Fix for timing attacks on MAC verification."
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
7
node_modules/cookie-signature/Makefile
generated
vendored
Normal file
7
node_modules/cookie-signature/Makefile
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter spec
|
||||
|
||||
.PHONY: test
|
42
node_modules/cookie-signature/Readme.md
generated
vendored
Normal file
42
node_modules/cookie-signature/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
# cookie-signature
|
||||
|
||||
Sign and unsign cookies.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var cookie = require('cookie-signature');
|
||||
|
||||
var val = cookie.sign('hello', 'tobiiscool');
|
||||
val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');
|
||||
|
||||
var val = cookie.sign('hello', 'tobiiscool');
|
||||
cookie.unsign(val, 'tobiiscool').should.equal('hello');
|
||||
cookie.unsign(val, 'luna').should.be.false;
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 LearnBoost <tj@learnboost.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
51
node_modules/cookie-signature/index.js
generated
vendored
Normal file
51
node_modules/cookie-signature/index.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
/**
|
||||
* Sign the given `val` with `secret`.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {String} secret
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.sign = function(val, secret){
|
||||
if ('string' != typeof val) throw new TypeError('cookie required');
|
||||
if ('string' != typeof secret) throw new TypeError('secret required');
|
||||
return val + '.' + crypto
|
||||
.createHmac('sha256', secret)
|
||||
.update(val)
|
||||
.digest('base64')
|
||||
.replace(/\=+$/, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Unsign and decode the given `val` with `secret`,
|
||||
* returning `false` if the signature is invalid.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {String} secret
|
||||
* @return {String|Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.unsign = function(val, secret){
|
||||
if ('string' != typeof val) throw new TypeError('cookie required');
|
||||
if ('string' != typeof secret) throw new TypeError('secret required');
|
||||
var str = val.slice(0, val.lastIndexOf('.'))
|
||||
, mac = exports.sign(str, secret);
|
||||
|
||||
return sha1(mac) == sha1(val) ? str : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Private
|
||||
*/
|
||||
|
||||
function sha1(str){
|
||||
return crypto.createHash('sha1').update(str).digest('hex');
|
||||
}
|
89
node_modules/cookie-signature/package.json
generated
vendored
Normal file
89
node_modules/cookie-signature/package.json
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "cookie-signature@1.0.5",
|
||||
"scope": null,
|
||||
"escapedName": "cookie-signature",
|
||||
"name": "cookie-signature",
|
||||
"rawSpec": "1.0.5",
|
||||
"spec": "1.0.5",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/express"
|
||||
]
|
||||
],
|
||||
"_from": "cookie-signature@1.0.5",
|
||||
"_id": "cookie-signature@1.0.5",
|
||||
"_inCache": true,
|
||||
"_location": "/cookie-signature",
|
||||
"_npmUser": {
|
||||
"name": "natevw",
|
||||
"email": "natevw@yahoo.com"
|
||||
},
|
||||
"_npmVersion": "1.4.20",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "cookie-signature@1.0.5",
|
||||
"scope": null,
|
||||
"escapedName": "cookie-signature",
|
||||
"name": "cookie-signature",
|
||||
"rawSpec": "1.0.5",
|
||||
"spec": "1.0.5",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.5.tgz",
|
||||
"_shasum": "a122e3f1503eca0f5355795b0711bb2368d450f9",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "cookie-signature@1.0.5",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/express",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@learnboost.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/visionmedia/node-cookie-signature/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Sign and unsign cookies",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "a122e3f1503eca0f5355795b0711bb2368d450f9",
|
||||
"tarball": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.5.tgz"
|
||||
},
|
||||
"gitHead": "73ed69b511b3ef47555d71b4ed1deea9e5ed6e1f",
|
||||
"homepage": "https://github.com/visionmedia/node-cookie-signature",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"sign",
|
||||
"unsign"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "natevw",
|
||||
"email": "natevw@yahoo.com"
|
||||
}
|
||||
],
|
||||
"name": "cookie-signature",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/visionmedia/node-cookie-signature.git"
|
||||
},
|
||||
"scripts": {},
|
||||
"version": "1.0.5"
|
||||
}
|
2
node_modules/cookie/.npmignore
generated
vendored
Normal file
2
node_modules/cookie/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
test
|
||||
.travis.yml
|
9
node_modules/cookie/LICENSE
generated
vendored
Normal file
9
node_modules/cookie/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
// MIT License
|
||||
|
||||
Copyright (C) Roman Shtylman <shtylman@gmail.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.
|
44
node_modules/cookie/README.md
generated
vendored
Normal file
44
node_modules/cookie/README.md
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
# cookie [![Build Status](https://secure.travis-ci.org/defunctzombie/node-cookie.png?branch=master)](http://travis-ci.org/defunctzombie/node-cookie) #
|
||||
|
||||
cookie is a basic cookie parser and serializer. It doesn't make assumptions about how you are going to deal with your cookies. It basically just provides a way to read and write the HTTP cookie headers.
|
||||
|
||||
See [RFC6265](http://tools.ietf.org/html/rfc6265) for details about the http header for cookies.
|
||||
|
||||
## how?
|
||||
|
||||
```
|
||||
npm install cookie
|
||||
```
|
||||
|
||||
```javascript
|
||||
var cookie = require('cookie');
|
||||
|
||||
var hdr = cookie.serialize('foo', 'bar');
|
||||
// hdr = 'foo=bar';
|
||||
|
||||
var cookies = cookie.parse('foo=bar; cat=meow; dog=ruff');
|
||||
// cookies = { foo: 'bar', cat: 'meow', dog: 'ruff' };
|
||||
```
|
||||
|
||||
## more
|
||||
|
||||
The serialize function takes a third parameter, an object, to set cookie options. See the RFC for valid values.
|
||||
|
||||
### path
|
||||
> cookie path
|
||||
|
||||
### expires
|
||||
> absolute expiration date for the cookie (Date object)
|
||||
|
||||
### maxAge
|
||||
> relative max age of the cookie from when the client receives it (seconds)
|
||||
|
||||
### domain
|
||||
> domain for the cookie
|
||||
|
||||
### secure
|
||||
> true or false
|
||||
|
||||
### httpOnly
|
||||
> true or false
|
||||
|
75
node_modules/cookie/index.js
generated
vendored
Normal file
75
node_modules/cookie/index.js
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
|
||||
/// Serialize the a name value pair into a cookie string suitable for
|
||||
/// http headers. An optional options object specified cookie parameters
|
||||
///
|
||||
/// serialize('foo', 'bar', { httpOnly: true })
|
||||
/// => "foo=bar; httpOnly"
|
||||
///
|
||||
/// @param {String} name
|
||||
/// @param {String} val
|
||||
/// @param {Object} options
|
||||
/// @return {String}
|
||||
var serialize = function(name, val, opt){
|
||||
opt = opt || {};
|
||||
var enc = opt.encode || encode;
|
||||
var pairs = [name + '=' + enc(val)];
|
||||
|
||||
if (null != opt.maxAge) {
|
||||
var maxAge = opt.maxAge - 0;
|
||||
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
||||
pairs.push('Max-Age=' + maxAge);
|
||||
}
|
||||
|
||||
if (opt.domain) pairs.push('Domain=' + opt.domain);
|
||||
if (opt.path) pairs.push('Path=' + opt.path);
|
||||
if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString());
|
||||
if (opt.httpOnly) pairs.push('HttpOnly');
|
||||
if (opt.secure) pairs.push('Secure');
|
||||
|
||||
return pairs.join('; ');
|
||||
};
|
||||
|
||||
/// Parse the given cookie header string into an object
|
||||
/// The object has the various cookies as keys(names) => values
|
||||
/// @param {String} str
|
||||
/// @return {Object}
|
||||
var parse = function(str, opt) {
|
||||
opt = opt || {};
|
||||
var obj = {}
|
||||
var pairs = str.split(/; */);
|
||||
var dec = opt.decode || decode;
|
||||
|
||||
pairs.forEach(function(pair) {
|
||||
var eq_idx = pair.indexOf('=')
|
||||
|
||||
// skip things that don't look like key=value
|
||||
if (eq_idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var key = pair.substr(0, eq_idx).trim()
|
||||
var val = pair.substr(++eq_idx, pair.length).trim();
|
||||
|
||||
// quoted values
|
||||
if ('"' == val[0]) {
|
||||
val = val.slice(1, -1);
|
||||
}
|
||||
|
||||
// only assign once
|
||||
if (undefined == obj[key]) {
|
||||
try {
|
||||
obj[key] = dec(val);
|
||||
} catch (e) {
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var encode = encodeURIComponent;
|
||||
var decode = decodeURIComponent;
|
||||
|
||||
module.exports.serialize = serialize;
|
||||
module.exports.parse = parse;
|
86
node_modules/cookie/package.json
generated
vendored
Normal file
86
node_modules/cookie/package.json
generated
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "cookie@0.1.2",
|
||||
"scope": null,
|
||||
"escapedName": "cookie",
|
||||
"name": "cookie",
|
||||
"rawSpec": "0.1.2",
|
||||
"spec": "0.1.2",
|
||||
"type": "version"
|
||||
},
|
||||
"/home/simon/Projects/Pong/node_modules/express"
|
||||
]
|
||||
],
|
||||
"_from": "cookie@0.1.2",
|
||||
"_id": "cookie@0.1.2",
|
||||
"_inCache": true,
|
||||
"_location": "/cookie",
|
||||
"_npmUser": {
|
||||
"name": "shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
"_npmVersion": "1.4.6",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "cookie@0.1.2",
|
||||
"scope": null,
|
||||
"escapedName": "cookie",
|
||||
"name": "cookie",
|
||||
"rawSpec": "0.1.2",
|
||||
"spec": "0.1.2",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.1.2.tgz",
|
||||
"_shasum": "72fec3d24e48a3432073d90c12642005061004b1",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "cookie@0.1.2",
|
||||
"_where": "/home/simon/Projects/Pong/node_modules/express",
|
||||
"author": {
|
||||
"name": "Roman Shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/shtylman/node-cookie/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "cookie parsing and serialization",
|
||||
"devDependencies": {
|
||||
"mocha": "1.x.x"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "72fec3d24e48a3432073d90c12642005061004b1",
|
||||
"tarball": "https://registry.npmjs.org/cookie/-/cookie-0.1.2.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/shtylman/node-cookie",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"cookies"
|
||||
],
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "cookie",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/shtylman/node-cookie.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "0.1.2"
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue