Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated connect and created a readme file.

  • Loading branch information...
commit 8ea5be82b84790a7d738bfee2181909d78da22da 1 parent 7f18d0d
@TajPelc authored
Showing with 8,799 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +123 −0 README.md
  3. +142 −0 node_modules/connect/lib/middleware/compress.js
  4. +96 −0 node_modules/connect/lib/middleware/cookieSession.js
  5. +61 −0 node_modules/connect/lib/middleware/json.js
  6. +99 −0 node_modules/connect/lib/middleware/multipart.js
  7. +54 −0 node_modules/connect/lib/middleware/urlencoded.js
  8. +231 −0 node_modules/connect/lib/proto.js
  9. +3 −0  node_modules/connect/node_modules/crc/.gitmodules
  10. +27 −0 node_modules/connect/node_modules/crc/README.md
  11. +362 −0 node_modules/connect/node_modules/crc/lib/crc.js
  12. +32 −0 node_modules/connect/node_modules/crc/package.json
  13. +64 −0 node_modules/connect/node_modules/crc/tests/crc_tests.js
  14. +3 −0  node_modules/connect/node_modules/crc/tests/nodeunit/.npmignore
  15. +56 −0 node_modules/connect/node_modules/crc/tests/nodeunit/CONTRIBUTORS.md
  16. +19 −0 node_modules/connect/node_modules/crc/tests/nodeunit/LICENSE
  17. +126 −0 node_modules/connect/node_modules/crc/tests/nodeunit/Makefile
  18. +430 −0 node_modules/connect/node_modules/crc/tests/nodeunit/README.md
  19. +108 −0 node_modules/connect/node_modules/crc/tests/nodeunit/bin/nodeunit
  20. +10 −0 node_modules/connect/node_modules/crc/tests/nodeunit/bin/nodeunit.json
  21. +602 −0 node_modules/connect/node_modules/crc/tests/nodeunit/deps/async.js
  22. +125 −0 node_modules/connect/node_modules/crc/tests/nodeunit/deps/ejs.js
  23. +483 −0 node_modules/connect/node_modules/crc/tests/nodeunit/deps/json2.js
  24. +60 −0 node_modules/connect/node_modules/crc/tests/nodeunit/doc/nodeunit.md
  25. +1,757 −0 node_modules/connect/node_modules/crc/tests/nodeunit/examples/browser/nodeunit.js
  26. +12 −0 node_modules/connect/node_modules/crc/tests/nodeunit/examples/browser/suite1.js
  27. +13 −0 node_modules/connect/node_modules/crc/tests/nodeunit/examples/browser/suite2.js
  28. +16 −0 node_modules/connect/node_modules/crc/tests/nodeunit/examples/browser/test.html
  29. BIN  node_modules/connect/node_modules/crc/tests/nodeunit/img/example_fail.png
  30. BIN  node_modules/connect/node_modules/crc/tests/nodeunit/img/example_pass.png
  31. +3 −0  node_modules/connect/node_modules/crc/tests/nodeunit/index.js
  32. +316 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/assert.js
  33. +236 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/core.js
  34. +80 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/nodeunit.js
  35. +119 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/reporters/browser.js
  36. +110 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/reporters/default.js
  37. +112 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/reporters/html.js
  38. +9 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/reporters/index.js
  39. +183 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/reporters/junit.js
  40. +117 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/reporters/minimal.js
  41. +110 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/reporters/skip_passed.js
  42. +187 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/types.js
  43. +209 −0 node_modules/connect/node_modules/crc/tests/nodeunit/lib/utils.js
  44. +95 −0 node_modules/connect/node_modules/crc/tests/nodeunit/man1/nodeunit.1
  45. +4 −0 node_modules/connect/node_modules/crc/tests/nodeunit/nodelint.cfg
  46. +53 −0 node_modules/connect/node_modules/crc/tests/nodeunit/package.json
  47. +19 −0 node_modules/connect/node_modules/crc/tests/nodeunit/share/junit.xml.ejs
  48. +11 −0 node_modules/connect/node_modules/crc/tests/nodeunit/share/license.js
  49. +70 −0 node_modules/connect/node_modules/crc/tests/nodeunit/share/nodeunit.css
  50. +4 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee
  51. +1 −0  node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/dir/mock_module3.js
  52. +1 −0  node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/dir/mock_module4.js
  53. +1 −0  node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/mock_module1.js
  54. +1 −0  node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/mock_module2.js
  55. +3 −0  node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/raw_jscode1.js
  56. +3 −0  node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/raw_jscode2.js
  57. +1 −0  node_modules/connect/node_modules/crc/tests/nodeunit/test/fixtures/raw_jscode3.js
  58. +219 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-base.js
  59. +114 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-failing-callbacks.js
  60. +55 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-httputil.js
  61. +214 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-runfiles.js
  62. +125 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-runmodule.js
  63. +46 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-runtest.js
  64. +31 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-sandbox.js
  65. +234 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test-testcase.js
  66. +26 −0 node_modules/connect/node_modules/crc/tests/nodeunit/test/test.html
  67. +4 −0 node_modules/connect/node_modules/debug/.npmignore
  68. +41 −0 node_modules/connect/node_modules/debug/History.md
  69. +5 −0 node_modules/connect/node_modules/debug/Makefile
  70. +130 −0 node_modules/connect/node_modules/debug/Readme.md
  71. +122 −0 node_modules/connect/node_modules/debug/debug.js
  72. +19 −0 node_modules/connect/node_modules/debug/example/app.js
  73. +24 −0 node_modules/connect/node_modules/debug/example/browser.html
  74. +10 −0 node_modules/connect/node_modules/debug/example/wildcards.js
  75. +22 −0 node_modules/connect/node_modules/debug/example/worker.js
  76. +2 −0  node_modules/connect/node_modules/debug/index.js
  77. +147 −0 node_modules/connect/node_modules/debug/lib/debug.js
  78. +32 −0 node_modules/connect/node_modules/debug/package.json
  79. +1 −0  node_modules/connect/test/fixtures/.hidden
View
4 .gitignore
@@ -0,0 +1,4 @@
+.project
+.settings/
+.pydevproject
+.idea/
View
123 README.md 100644 → 100755
@@ -0,0 +1,123 @@
+# Chilly Framework #
+## About ##
+
+**[Chilly Framework](http://www.chillyframework.com/)** is a HTML5 game development platform running on [Node.js](http://nodejs.org/) using [Connect](http://www.senchalabs.org/connect/) middleware.
+
+It was built in response to our needs while developing a HTML5 game called TankCraft.
+
+It acts as multiplayer server which also serves static files and uses Ajax requests to transfer data between the front end and the back end. The main feature is syncing player actions or broadcasting data across multiple clients using Chilly update channels.
+
+Behind the hood requests and long-polling are handled by Chilly. We provide an interface to use these features easily.
+
+The back end logic of a game can be built using Chilly Framework methods and if needed, additional Node.js modules like MySQL support, can be added easily using [NPM modules](http://search.npmjs.org/).
+
+Chilly front end script takes care of ajax requests and broadcasting updates. And triggers updates whenever a client receives data. Developers are free to use whatever suits them to build the game. We used the [CraftyJS](http://craftyjs.com/) library for graphics and animations, jQuery for the UI and SoundManager for the sound.
+
+## Installation ##
+
+* Download and [install Node.js](https://github.com/joyent/node/wiki/Installation) on your platform of choice.
+* Download Chilly Framework
+* You are ready to go, start the server with `node server.js` from the folder where you extracted the files.
+
+## Structure ##
+This is a basic structure for a Chilly Framework project. It's separated to a back (protected) and a front end (public).
+<pre>
+framework
+ chilly-0.2.js // Chilly Framework back end script
+node_modules // additional Node.js modules
+protected // back end files
+ actions.js // define your actions
+ config.js // server and game config
+ helpers.js // define custom helper functions
+ models.js // define your models
+public // static content served by the web server
+ js
+ libraries
+ chilly-0.2.js // Chilly Framework front end script
+ css
+ img
+server.js // starts the server
+</pre>
+
+## How to use it ##
+**Front end**
+______________________________________________
+
+Start by creating an index.html file in `/public/index.html`, then run the server with `node server.js`. Navigate to `http://localhost:3000/` and you should see the contents of the file.
+
+Include the Chilly Framework front end library with `<script src="/js/libraries/chilly-0.2.js" />`. Create your own JavaScript file, for example game.js and include it.
+
+To start Chilly Framework call `Chilly.init();`. This triggers an `init` event.
+
+To bind events use:
+<pre>
+Chilly.bind('init', function(e) { ... // load assets, sprites, sounds, etc });
+</pre>
+
+To trigger custom events use:
+<pre>
+Chilly.trigger('eventName', customData);
+</pre>
+
+To issue request to the back-end use:
+<pre>
+Chilly.request('actionName', {
+ data: { // optional
+ custom1: 'a',
+ custom2: 'b'
+ },
+ success: function(data) {
+ ... // do stuff
+ },
+ error: function(data) { // optional
+ ... // display errors
+ }
+});
+</pre>
+
+Define code for every action that is transmitted over the update channel using:
+<pre>
+Chilly.onUpdate('gameOver', function(data) {
+ ... // display the score
+});
+</pre>
+
+Listen to additional channels created on the back end using:
+<pre>
+Chilly.listen('chat', function(data){
+ ... // display broadcasted message
+});
+</pre>
+
+**Back end**
+______________________________________________
+
+Open `actions.js` and define additional update channels with:
+<pre>
+Chilly.createChannel('chat');
+</pre>
+
+Open `actions.js` and define responses to requests send from the front end by `Chilly.request` with:
+<pre>
+Chilly.action('login', {
+ user: function(request) { // if user is already logged in
+ ... // respond with an error
+ request.respond.error('Already logged in.');
+ },
+ anonymous: function(request) { // (optional)
+ ... // log the user in
+ request.respond.ok('You are now logged in.');
+ }
+});
+</pre>
+
+Open `models.js` and extend Game.js and define your own models that will be used by the game.
+
+## Additional help ##
+Check the source code comments for both chilly-0.2.js files for more information. Visit [chillyframework.com](http://chillyframework.com/).
+
+## License ##
+Copyright 2012, Taj Pelc
+
+Dual licensed under the MIT or GPL Version 2 licenses.
+[http://chillyframework.org/license/](http://chillyframework.org/license/)
View
142 node_modules/connect/lib/middleware/compress.js
@@ -0,0 +1,142 @@
+
+/*!
+ * Connect - compress
+ * Copyright(c) 2010 Sencha Inc.
+ * Copyright(c) 2011 TJ Holowaychuk
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var zlib = require('zlib');
+
+/**
+ * Supported content-encoding methods.
+ */
+
+exports.methods = {
+ gzip: zlib.createGzip
+ , deflate: zlib.createDeflate
+};
+
+/**
+ * Default filter function.
+ */
+
+exports.filter = function(req, res){
+ var type = res.getHeader('Content-Type') || '';
+ return type.match(/json|text|javascript/);
+};
+
+/**
+ * Compress:
+ *
+ * Compress response data with gzip/deflate.
+ *
+ * Filter:
+ *
+ * A `filter` callback function may be passed to
+ * replace the default logic of:
+ *
+ * exports.filter = function(req, res){
+ * var type = res.getHeader('Content-Type') || '';
+ * return type.match(/json|text|javascript/);
+ * };
+ *
+ * Options:
+ *
+ * All remaining options are passed to the gzip/deflate
+ * creation functions. Consult node's docs for additional details.
+ *
+ * - `chunkSize` (default: 16*1024)
+ * - `windowBits`
+ * - `level`: 0-9 where 0 is no compression, and 9 is slow but best compression
+ * - `memLevel`: 1-9 low is slower but uses less memory, high is fast but uses more
+ * - `strategy`: compression strategy
+ *
+ * @param {Object} options
+ * @return {Function}
+ * @api public
+ */
+
+module.exports = function compress(options) {
+ var options = options || {}
+ , names = Object.keys(exports.methods)
+ , filter = options.filter || exports.filter;
+
+ return function(req, res, next){
+ var accept = req.headers['accept-encoding']
+ , write = res.write
+ , end = res.end
+ , stream
+ , method;
+
+ // vary
+ res.setHeader('Vary', 'Accept-Encoding');
+
+ // proxy
+
+ res.write = function(chunk, encoding){
+ if (!this.headerSent) this._implicitHeader();
+ return stream
+ ? stream.write(chunk, encoding)
+ : write.call(res, chunk, encoding);
+ };
+
+ res.end = function(chunk, encoding){
+ if (chunk) this.write(chunk, encoding);
+ return stream
+ ? stream.end()
+ : end.call(res);
+ };
+
+ res.on('header', function(){
+ // default request filter
+ if (!filter(req, res)) return;
+
+ // SHOULD use identity
+ if (!accept) return;
+
+ // head
+ if ('HEAD' == req.method) return;
+
+ // default to gzip
+ if ('*' == accept.trim()) method = 'gzip';
+
+ // compression method
+ if (!method) {
+ for (var i = 0, len = names.length; i < len; ++i) {
+ if (~accept.indexOf(names[i])) {
+ method = names[i];
+ break;
+ }
+ }
+ }
+
+ // compression method
+ if (!method) return;
+
+ // compression stream
+ stream = exports.methods[method](options);
+
+ // header fields
+ res.setHeader('Content-Encoding', method);
+ res.removeHeader('Content-Length');
+
+ // compression
+
+ stream.on('data', function(chunk){
+ write.call(res, chunk);
+ });
+
+ stream.on('end', function(){
+ end.call(res);
+ });
+
+ });
+
+ next();
+ };
+}
View
96 node_modules/connect/lib/middleware/cookieSession.js
@@ -0,0 +1,96 @@
+
+/*!
+ * Connect - cookieSession
+ * Copyright(c) 2011 Sencha Inc.
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var utils = require('./../utils')
+ , Cookie = require('./session/cookie')
+ , debug = require('debug')('connect:cookieSession')
+ , crc16 = require('crc').crc16;
+
+// environment
+
+var env = process.env.NODE_ENV;
+
+/**
+ * Cookie Session:
+ *
+ * Cookie session middleware.
+ *
+ * var app = connect();
+ * app.use(connect.cookieParser('tobo!'));
+ * app.use(connect.cookieSession({ cookie: { maxAge: 60 * 60 * 1000 }}));
+ *
+ * Options:
+ *
+ * - `key` cookie name defaulting to `connect.sess`
+ * - `cookie` session cookie settings, defaulting to `{ path: '/', httpOnly: true, maxAge: null }`
+ * - `proxy` trust the reverse proxy when setting secure cookies (via "x-forwarded-proto")
+ *
+ * Clearing sessions:
+ *
+ * To clear the session simply set its value to `null`,
+ * `cookieSession()` will then respond with a 1970 Set-Cookie.
+ *
+ * req.session = null;
+ *
+ * @param {Object} options
+ * @return {Function}
+ * @api public
+ */
+
+module.exports = function cookieSession(options){
+ // TODO: utilize Session/Cookie to unify API
+ var options = options || {}
+ , key = options.key || 'connect.sess'
+ , cookie = options.cookie
+ , trustProxy = options.proxy;
+
+ return function cookieSession(req, res, next) {
+ req.session = req.signedCookies[key] || {};
+ req.session.cookie = new Cookie(req, cookie);
+
+ res.on('header', function(){
+ // removed
+ if (!req.session) {
+ debug('clear session');
+ res.setHeader('Set-Cookie', key + '=; expires=' + new Date(0).toUTCString());
+ return;
+ }
+
+ var cookie = req.session.cookie;
+ delete req.session.cookie;
+
+ // check security
+ var proto = (req.headers['x-forwarded-proto'] || '').toLowerCase()
+ , tls = req.connection.encrypted || (trustProxy && 'https' == proto)
+ , secured = cookie.secure && tls;
+
+ // only send secure cookies via https
+ if (cookie.secure && !secured) return debug('not secured');
+
+ // serialize
+ debug('serializing %j', req.session);
+ var val = 'j:' + JSON.stringify(req.session);
+
+ // compare hashes
+ var originalHash = req.cookieHashes && req.cookieHashes[key];
+ var hash = crc16(val);
+ if (originalHash == hash) return debug('unmodified session');
+
+ // set-cookie
+ val = utils.sign(val, req.secret);
+ val = utils.serializeCookie(key, val, cookie);
+ debug('set-cookie %j', cookie);
+ res.setHeader('Set-Cookie', val);
+ });
+
+ next();
+ };
+};
View
61 node_modules/connect/lib/middleware/json.js
@@ -0,0 +1,61 @@
+
+/*!
+ * Connect - json
+ * Copyright(c) 2010 Sencha Inc.
+ * Copyright(c) 2011 TJ Holowaychuk
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var utils = require('../utils');
+
+/**
+ * JSON:
+ *
+ * Parse JSON request bodies, providing the
+ * parsed object as `req.body`.
+ *
+ * Options:
+ *
+ * - `strict` when `false` anything `JSON.parse()` accepts will be parsed
+ *
+ * @param {Object} options
+ * @return {Function}
+ * @api public
+ */
+
+exports = module.exports = function(options){
+ var options = options || {}
+ , strict = options.strict === false
+ ? false
+ : true;
+
+ return function json(req, res, next) {
+ if (req._body) return next();
+ req.body = req.body || {};
+
+ // check Content-Type
+ if ('application/json' != utils.mime(req)) return next();
+
+ // flag as parsed
+ req._body = true;
+
+ // parse
+ var buf = '';
+ req.setEncoding('utf8');
+ req.on('data', function(chunk){ buf += chunk });
+ req.on('end', function(){
+ if (strict && '{' != buf[0] && '[' != buf[0]) return next(utils.error(400));
+ try {
+ req.body = JSON.parse(buf);
+ next();
+ } catch (err){
+ err.status = 400;
+ next(err);
+ }
+ });
+ }
+};
View
99 node_modules/connect/lib/middleware/multipart.js
@@ -0,0 +1,99 @@
+
+/*!
+ * Connect - multipart
+ * Copyright(c) 2010 Sencha Inc.
+ * Copyright(c) 2011 TJ Holowaychuk
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var formidable = require('formidable')
+ , utils = require('../utils')
+ , qs = require('qs');
+
+/**
+ * Multipart:
+ *
+ * Parse multipart/form-data request bodies,
+ * providing the parsed object as `req.body`
+ * and `req.files`.
+ *
+ * Configuration:
+ *
+ * The options passed are merged with [formidable](https://github.com/felixge/node-formidable)'s
+ * `IncomingForm` object, allowing you to configure the upload directory,
+ * size limits, etc. For example if you wish to change the upload dir do the following.
+ *
+ * app.use(connect.multipart({ uploadDir: path }));
+ *
+ * @param {Object} options
+ * @return {Function}
+ * @api public
+ */
+
+exports = module.exports = function(options){
+ options = options || {};
+ return function multipart(req, res, next) {
+ if (req._body) return next();
+ req.body = req.body || {};
+ req.files = req.files || {};
+
+ // ignore GET
+ if ('GET' == req.method || 'HEAD' == req.method) return next();
+
+ // check Content-Type
+ if ('multipart/form-data' != utils.mime(req)) return next();
+
+ // flag as parsed
+ req._body = true;
+
+ // parse
+ var form = new formidable.IncomingForm
+ , data = {}
+ , files = {}
+ , done;
+
+ Object.keys(options).forEach(function(key){
+ form[key] = options[key];
+ });
+
+ function ondata(name, val, data){
+ if (Array.isArray(data[name])) {
+ data[name].push(val);
+ } else if (data[name]) {
+ data[name] = [data[name], val];
+ } else {
+ data[name] = val;
+ }
+ }
+
+ form.on('field', function(name, val){
+ ondata(name, val, data);
+ });
+
+ form.on('file', function(name, val){
+ ondata(name, val, files);
+ });
+
+ form.on('error', function(err){
+ next(err);
+ done = true;
+ });
+
+ form.on('end', function(){
+ if (done) return;
+ try {
+ req.body = qs.parse(data);
+ req.files = qs.parse(files);
+ next();
+ } catch (err) {
+ next(err);
+ }
+ });
+
+ form.parse(req);
+ }
+};
View
54 node_modules/connect/lib/middleware/urlencoded.js
@@ -0,0 +1,54 @@
+
+/*!
+ * Connect - urlencoded
+ * Copyright(c) 2010 Sencha Inc.
+ * Copyright(c) 2011 TJ Holowaychuk
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var utils = require('../utils')
+ , qs = require('qs');
+
+/**
+ * Urlencoded:
+ *
+ * Parse x-ww-form-urlencoded request bodies,
+ * providing the parsed object as `req.body`.
+ *
+ * @param {Object} options
+ * @return {Function}
+ * @api public
+ */
+
+exports = module.exports = function(options){
+ options = options || {};
+ return function urlencoded(req, res, next) {
+ if (req._body) return next();
+ req.body = req.body || {};
+
+ // check Content-Type
+ if ('application/x-www-form-urlencoded' != utils.mime(req)) return next();
+
+ // flag as parsed
+ req._body = true;
+
+ // parse
+ var buf = '';
+ req.setEncoding('utf8');
+ req.on('data', function(chunk){ buf += chunk });
+ req.on('end', function(){
+ try {
+ req.body = buf.length
+ ? qs.parse(buf, options)
+ : {};
+ next();
+ } catch (err){
+ next(err);
+ }
+ });
+ }
+};
View
231 node_modules/connect/lib/proto.js
@@ -0,0 +1,231 @@
+
+/*!
+ * Connect - HTTPServer
+ * Copyright(c) 2010 Sencha Inc.
+ * Copyright(c) 2011 TJ Holowaychuk
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var http = require('http')
+ , parse = require('url').parse
+ , utils = require('./utils')
+ , debug = require('debug')('connect:dispatcher');
+
+// prototype
+
+var app = module.exports = {};
+
+// environment
+
+var env = process.env.NODE_ENV || 'development';
+
+/**
+ * Utilize the given middleware `handle` to the given `route`,
+ * defaulting to _/_. This "route" is the mount-point for the
+ * middleware, when given a value other than _/_ the middleware
+ * is only effective when that segment is present in the request's
+ * pathname.
+ *
+ * For example if we were to mount a function at _/admin_, it would
+ * be invoked on _/admin_, and _/admin/settings_, however it would
+ * not be invoked for _/_, or _/posts_.
+ *
+ * Examples:
+ *
+ * var app = connect();
+ * app.use(connect.favicon());
+ * app.use(connect.logger());
+ * app.use(connect.static(__dirname + '/public'));
+ *
+ * If we wanted to prefix static files with _/public_, we could
+ * "mount" the `static()` middleware:
+ *
+ * app.use('/public', connect.static(__dirname + '/public'));
+ *
+ * This api is chainable, so the following is valid:
+ *
+ * connect
+ * .use(connect.favicon())
+ * .use(connect.logger())
+ * .use(connect.static(__dirname + '/public'))
+ * .listen(3000);
+ *
+ * @param {String|Function|Server} route, callback or server
+ * @param {Function|Server} callback or server
+ * @return {Server} for chaining
+ * @api public
+ */
+
+app.use = function(route, fn){
+ // default route to '/'
+ if ('string' != typeof route) {
+ fn = route;
+ route = '/';
+ }
+
+ // wrap sub-apps
+ if ('function' == typeof fn.handle) {
+ var server = fn;
+ fn.route = route;
+ fn = function(req, res, next){
+ server.handle(req, res, next);
+ };
+ }
+
+ // wrap vanilla http.Servers
+ if (fn instanceof http.Server) {
+ fn = fn.listeners('request')[0];
+ }
+
+ // strip trailing slash
+ if ('/' == route[route.length - 1]) {
+ route = route.slice(0, -1);
+ }
+
+ // add the middleware
+ debug('use %s %s', route || '/', fn.name || 'anonymous');
+ this.stack.push({ route: route, handle: fn });
+
+ return this;
+};
+
+/**
+ * Handle server requests, punting them down
+ * the middleware stack.
+ *
+ * @api private
+ */
+
+app.handle = function(req, res, out) {
+ var stack = this.stack
+ , fqdn = ~req.url.indexOf('://')
+ , removed = ''
+ , slashAdded = false
+ , index = 0;
+
+ function next(err) {
+ var layer, path, status, c;
+
+ if (slashAdded) {
+ req.url = req.url.substr(1);
+ slashAdded = false;
+ }
+
+ req.url = removed + req.url;
+ req.originalUrl = req.originalUrl || req.url;
+ removed = '';
+
+ // next callback
+ layer = stack[index++];
+
+ // all done
+ if (!layer || res.headerSent) {
+ // delegate to parent
+ if (out) return out(err);
+
+ // unhandled error
+ if (err) {
+ // default to 500
+ if (res.statusCode < 400) res.statusCode = 500;
+ debug('default %s', res.statusCode);
+
+ // respect err.status
+ if (err.status) res.statusCode = err.status;
+
+ // production gets a basic error message
+ var msg = 'production' == env
+ ? http.STATUS_CODES[res.statusCode]
+ : err.stack || err.toString();
+
+ // log to stderr in a non-test env
+ if ('test' != env) console.error(err.stack || err.toString());
+ if (res.headerSent) return req.socket.destroy();
+ res.setHeader('Content-Type', 'text/plain');
+ res.setHeader('Content-Length', Buffer.byteLength(msg));
+ if ('HEAD' == req.method) return res.end();
+ res.end(msg);
+ } else {
+ debug('default 404');
+ res.statusCode = 404;
+ res.setHeader('Content-Type', 'text/plain');
+ if ('HEAD' == req.method) return res.end();
+ res.end('Cannot ' + req.method + ' ' + utils.escape(req.originalUrl));
+ }
+ return;
+ }
+
+ try {
+ path = parse(req.url).pathname;
+ if (undefined == path) path = '/';
+
+ // skip this layer if the route doesn't match.
+ if (0 != path.indexOf(layer.route)) return next(err);
+
+ c = path[layer.route.length];
+ if (c && '/' != c && '.' != c) return next(err);
+
+ // Call the layer handler
+ // Trim off the part of the url that matches the route
+ removed = layer.route;
+ req.url = req.url.substr(removed.length);
+
+ // Ensure leading slash
+ if (!fqdn && '/' != req.url[0]) {
+ req.url = '/' + req.url;
+ slashAdded = true;
+ }
+
+ debug('%s', layer.handle.name || 'anonymous');
+ var arity = layer.handle.length;
+ if (err) {
+ if (arity === 4) {
+ layer.handle(err, req, res, next);
+ } else {
+ next(err);
+ }
+ } else if (arity < 4) {
+ layer.handle(req, res, next);
+ } else {
+ next();
+ }
+ } catch (e) {
+ next(e);
+ }
+ }
+ next();
+};
+
+/**
+ * Listen for connections.
+ *
+ * This method takes the same arguments
+ * as node's `http.Server#listen()`.
+ *
+ * HTTP and HTTPS:
+ *
+ * If you run your application both as HTTP
+ * and HTTPS you may wrap them individually,
+ * since your Connect "server" is really just
+ * a JavaScript `Function`.
+ *
+ * var connect = require('connect')
+ * , http = require('http')
+ * , https = require('https');
+ *
+ * var app = connect();
+ *
+ * http.createServer(app).listen(80);
+ * https.createServer(options, app).listen(443);
+ *
+ * @return {http.Server}
+ * @api public
+ */
+
+app.listen = function(){
+ var server = http.createServer(this);
+ return server.listen.apply(server, arguments);
+};
View
3  node_modules/connect/node_modules/crc/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "tests/nodeunit"]
+ path = tests/nodeunit
+ url = git://github.com/caolan/nodeunit.git
View
27 node_modules/connect/node_modules/crc/README.md
@@ -0,0 +1,27 @@
+# JavaScript CRC 8, 16 and 32.
+
+This is a basic port/copy of the JavaScript CRC implementation. The module works with any CommonJS system supporting `module.exports` notation as well as in the browser. When loaded in the browser, all functions end up under the `window.crc` "namespace".
+
+Original code is taken from http://www.digsys.se/JavaScript/CRC.aspx
+
+## Functions
+
+The following functions are implemented:
+
+ crc8(String) #=> Number
+ crcArc(String) #=> Number
+ crc16(String) #=> Number
+ fcs16(String) #=> Number
+ crc32(String) #=> Number
+ hex8(Number) #=> String
+ hex16(Number) #=> String
+ hex32(Number) #=> String
+
+## Installation
+
+ git clone git://github.com/alexgorbatchev/node-crc.git
+
+or
+
+ npm install crc
+
View
362 node_modules/connect/node_modules/crc/lib/crc.js
@@ -0,0 +1,362 @@
+(function()
+{
+ // CRC-8 in table form
+ //
+ // Copyright (c) 1989 AnDan Software. You may use this program, or
+ // code or tables extracted from it, as long as this notice is not
+ // removed or changed.
+ var CRC8_TAB = new Array(
+ // C/C++ language:
+ //
+ // unsigned char CRC8_TAB[] = {...};
+ 0x00,0x1B,0x36,0x2D,0x6C,0x77,0x5A,0x41,0xD8,0xC3,0xEE,0xF5,0xB4,0xAF,0x82,0x99,0xD3,0xC8,0xE5,
+ 0xFE,0xBF,0xA4,0x89,0x92,0x0B,0x10,0x3D,0x26,0x67,0x7C,0x51,0x4A,0xC5,0xDE,0xF3,0xE8,0xA9,0xB2,
+ 0x9F,0x84,0x1D,0x06,0x2B,0x30,0x71,0x6A,0x47,0x5C,0x16,0x0D,0x20,0x3B,0x7A,0x61,0x4C,0x57,0xCE,
+ 0xD5,0xF8,0xE3,0xA2,0xB9,0x94,0x8F,0xE9,0xF2,0xDF,0xC4,0x85,0x9E,0xB3,0xA8,0x31,0x2A,0x07,0x1C,
+ 0x5D,0x46,0x6B,0x70,0x3A,0x21,0x0C,0x17,0x56,0x4D,0x60,0x7B,0xE2,0xF9,0xD4,0xCF,0x8E,0x95,0xB8,
+ 0xA3,0x2C,0x37,0x1A,0x01,0x40,0x5B,0x76,0x6D,0xF4,0xEF,0xC2,0xD9,0x98,0x83,0xAE,0xB5,0xFF,0xE4,
+ 0xC9,0xD2,0x93,0x88,0xA5,0xBE,0x27,0x3C,0x11,0x0A,0x4B,0x50,0x7D,0x66,0xB1,0xAA,0x87,0x9C,0xDD,
+ 0xC6,0xEB,0xF0,0x69,0x72,0x5F,0x44,0x05,0x1E,0x33,0x28,0x62,0x79,0x54,0x4F,0x0E,0x15,0x38,0x23,
+ 0xBA,0xA1,0x8C,0x97,0xD6,0xCD,0xE0,0xFB,0x74,0x6F,0x42,0x59,0x18,0x03,0x2E,0x35,0xAC,0xB7,0x9A,
+ 0x81,0xC0,0xDB,0xF6,0xED,0xA7,0xBC,0x91,0x8A,0xCB,0xD0,0xFD,0xE6,0x7F,0x64,0x49,0x52,0x13,0x08,
+ 0x25,0x3E,0x58,0x43,0x6E,0x75,0x34,0x2F,0x02,0x19,0x80,0x9B,0xB6,0xAD,0xEC,0xF7,0xDA,0xC1,0x8B,
+ 0x90,0xBD,0xA6,0xE7,0xFC,0xD1,0xCA,0x53,0x48,0x65,0x7E,0x3F,0x24,0x09,0x12,0x9D,0x86,0xAB,0xB0,
+ 0xF1,0xEA,0xC7,0xDC,0x45,0x5E,0x73,0x68,0x29,0x32,0x1F,0x04,0x4E,0x55,0x78,0x63,0x22,0x39,0x14,
+ 0x0F,0x96,0x8D,0xA0,0xBB,0xFA,0xE1,0xCC,0xD7
+ );
+
+ function crc8Add(crc,c)
+ // 'crc' should be initialized to 0x00.
+ {
+ return CRC8_TAB[(crc^c)&0xFF];
+ };
+ // C/C++ language:
+ //
+ // inline unsigned char crc8Add(unsigned char crc, unsigned char c)
+ // {
+ // return CRC8_TAB[crc^c];
+ // }
+
+ // CRC-16 (as it is in SEA's ARC) in table form
+ //
+ // The logic for this method of calculating the CRC 16 bit polynomial
+ // is taken from an article by David Schwaderer in the April 1985
+ // issue of PC Tech Journal.
+ var CRC_ARC_TAB = new Array(
+ // C/C++ language:
+ //
+ // unsigned short CRC_ARC_TAB[] = {...};
+ 0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,0xC601,0x06C0,0x0780,0xC741,0x0500,
+ 0xC5C1,0xC481,0x0440,0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,0x0A00,0xCAC1,
+ 0xCB81,0x0B40,0xC901,0x09C0,0x0880,0xC841,0xD801,0x18C0,0x1980,0xD941,0x1B00,0xDBC1,0xDA81,
+ 0x1A40,0x1E00,0xDEC1,0xDF81,0x1F40,0xDD01,0x1DC0,0x1C80,0xDC41,0x1400,0xD4C1,0xD581,0x1540,
+ 0xD701,0x17C0,0x1680,0xD641,0xD201,0x12C0,0x1380,0xD341,0x1100,0xD1C1,0xD081,0x1040,0xF001,
+ 0x30C0,0x3180,0xF141,0x3300,0xF3C1,0xF281,0x3240,0x3600,0xF6C1,0xF781,0x3740,0xF501,0x35C0,
+ 0x3480,0xF441,0x3C00,0xFCC1,0xFD81,0x3D40,0xFF01,0x3FC0,0x3E80,0xFE41,0xFA01,0x3AC0,0x3B80,
+ 0xFB41,0x3900,0xF9C1,0xF881,0x3840,0x2800,0xE8C1,0xE981,0x2940,0xEB01,0x2BC0,0x2A80,0xEA41,
+ 0xEE01,0x2EC0,0x2F80,0xEF41,0x2D00,0xEDC1,0xEC81,0x2C40,0xE401,0x24C0,0x2580,0xE541,0x2700,
+ 0xE7C1,0xE681,0x2640,0x2200,0xE2C1,0xE381,0x2340,0xE101,0x21C0,0x2080,0xE041,0xA001,0x60C0,
+ 0x6180,0xA141,0x6300,0xA3C1,0xA281,0x6240,0x6600,0xA6C1,0xA781,0x6740,0xA501,0x65C0,0x6480,
+ 0xA441,0x6C00,0xACC1,0xAD81,0x6D40,0xAF01,0x6FC0,0x6E80,0xAE41,0xAA01,0x6AC0,0x6B80,0xAB41,
+ 0x6900,0xA9C1,0xA881,0x6840,0x7800,0xB8C1,0xB981,0x7940,0xBB01,0x7BC0,0x7A80,0xBA41,0xBE01,
+ 0x7EC0,0x7F80,0xBF41,0x7D00,0xBDC1,0xBC81,0x7C40,0xB401,0x74C0,0x7580,0xB541,0x7700,0xB7C1,
+ 0xB681,0x7640,0x7200,0xB2C1,0xB381,0x7340,0xB101,0x71C0,0x7080,0xB041,0x5000,0x90C1,0x9181,
+ 0x5140,0x9301,0x53C0,0x5280,0x9241,0x9601,0x56C0,0x5780,0x9741,0x5500,0x95C1,0x9481,0x5440,
+ 0x9C01,0x5CC0,0x5D80,0x9D41,0x5F00,0x9FC1,0x9E81,0x5E40,0x5A00,0x9AC1,0x9B81,0x5B40,0x9901,
+ 0x59C0,0x5880,0x9841,0x8801,0x48C0,0x4980,0x8941,0x4B00,0x8BC1,0x8A81,0x4A40,0x4E00,0x8EC1,
+ 0x8F81,0x4F40,0x8D01,0x4DC0,0x4C80,0x8C41,0x4400,0x84C1,0x8581,0x4540,0x8701,0x47C0,0x4680,
+ 0x8641,0x8201,0x42C0,0x4380,0x8341,0x4100,0x81C1,0x8081,0x4040
+ );
+
+ function crcArcAdd(crc,c)
+ // 'crc' should be initialized to 0x0000.
+ {
+ return CRC_ARC_TAB[(crc^c)&0xFF]^((crc>>8)&0xFF);
+ };
+ // C/C++ language:
+ //
+ // inline unsigned short crcArcAdd(unsigned short crc, unsigned char c)
+ // {
+ // return CRC_ARC_TAB[(unsigned char)crc^c]^(unsigned short)(crc>>8);
+ // }
+
+ // CRC-16 (as it is in ZMODEM) in table form
+ //
+ // Copyright (c) 1989 AnDan Software. You may use this program, or
+ // code or tables extracted from it, as long as this notice is not
+ // removed or changed.
+ var CRC16_TAB = new Array(
+ // C/C++ language:
+ //
+ // unsigned short CRC16_TAB[] = {...};
+ 0x0000,0x1021,0x2042,0x3063,0x4084,0x50A5,0x60C6,0x70E7,0x8108,0x9129,0xA14A,0xB16B,0xC18C,
+ 0xD1AD,0xE1CE,0xF1EF,0x1231,0x0210,0x3273,0x2252,0x52B5,0x4294,0x72F7,0x62D6,0x9339,0x8318,
+ 0xB37B,0xA35A,0xD3BD,0xC39C,0xF3FF,0xE3DE,0x2462,0x3443,0x0420,0x1401,0x64E6,0x74C7,0x44A4,
+ 0x5485,0xA56A,0xB54B,0x8528,0x9509,0xE5EE,0xF5CF,0xC5AC,0xD58D,0x3653,0x2672,0x1611,0x0630,
+ 0x76D7,0x66F6,0x5695,0x46B4,0xB75B,0xA77A,0x9719,0x8738,0xF7DF,0xE7FE,0xD79D,0xC7BC,0x48C4,
+ 0x58E5,0x6886,0x78A7,0x0840,0x1861,0x2802,0x3823,0xC9CC,0xD9ED,0xE98E,0xF9AF,0x8948,0x9969,
+ 0xA90A,0xB92B,0x5AF5,0x4AD4,0x7AB7,0x6A96,0x1A71,0x0A50,0x3A33,0x2A12,0xDBFD,0xCBDC,0xFBBF,
+ 0xEB9E,0x9B79,0x8B58,0xBB3B,0xAB1A,0x6CA6,0x7C87,0x4CE4,0x5CC5,0x2C22,0x3C03,0x0C60,0x1C41,
+ 0xEDAE,0xFD8F,0xCDEC,0xDDCD,0xAD2A,0xBD0B,0x8D68,0x9D49,0x7E97,0x6EB6,0x5ED5,0x4EF4,0x3E13,
+ 0x2E32,0x1E51,0x0E70,0xFF9F,0xEFBE,0xDFDD,0xCFFC,0xBF1B,0xAF3A,0x9F59,0x8F78,0x9188,0x81A9,
+ 0xB1CA,0xA1EB,0xD10C,0xC12D,0xF14E,0xE16F,0x1080,0x00A1,0x30C2,0x20E3,0x5004,0x4025,0x7046,
+ 0x6067,0x83B9,0x9398,0xA3FB,0xB3DA,0xC33D,0xD31C,0xE37F,0xF35E,0x02B1,0x1290,0x22F3,0x32D2,
+ 0x4235,0x5214,0x6277,0x7256,0xB5EA,0xA5CB,0x95A8,0x8589,0xF56E,0xE54F,0xD52C,0xC50D,0x34E2,
+ 0x24C3,0x14A0,0x0481,0x7466,0x6447,0x5424,0x4405,0xA7DB,0xB7FA,0x8799,0x97B8,0xE75F,0xF77E,
+ 0xC71D,0xD73C,0x26D3,0x36F2,0x0691,0x16B0,0x6657,0x7676,0x4615,0x5634,0xD94C,0xC96D,0xF90E,
+ 0xE92F,0x99C8,0x89E9,0xB98A,0xA9AB,0x5844,0x4865,0x7806,0x6827,0x18C0,0x08E1,0x3882,0x28A3,
+ 0xCB7D,0xDB5C,0xEB3F,0xFB1E,0x8BF9,0x9BD8,0xABBB,0xBB9A,0x4A75,0x5A54,0x6A37,0x7A16,0x0AF1,
+ 0x1AD0,0x2AB3,0x3A92,0xFD2E,0xED0F,0xDD6C,0xCD4D,0xBDAA,0xAD8B,0x9DE8,0x8DC9,0x7C26,0x6C07,
+ 0x5C64,0x4C45,0x3CA2,0x2C83,0x1CE0,0x0CC1,0xEF1F,0xFF3E,0xCF5D,0xDF7C,0xAF9B,0xBFBA,0x8FD9,
+ 0x9FF8,0x6E17,0x7E36,0x4E55,0x5E74,0x2E93,0x3EB2,0x0ED1,0x1EF0
+ );
+
+ function crc16Add(crc,c)
+ // 'crc' should be initialized to 0x0000.
+ {
+ return CRC16_TAB[((crc>>8)^c)&0xFF]^((crc<<8)&0xFFFF);
+ };
+ // C/C++ language:
+ //
+ // inline unsigned short crc16Add(unsigned short crc, unsigned char c)
+ // {
+ // return CRC16_TAB[(unsigned char)(crc>>8)^c]^(unsigned short)(crc<<8);
+ // }
+
+ // FCS-16 (as it is in PPP) in table form
+ //
+ // Described in RFC-1662 by William Allen Simpson, see RFC-1662 for references.
+ //
+ // Modified by Anders Danielsson, March 10, 2006.
+ var FCS_16_TAB = new Array(
+ // C/C++ language:
+ //
+ // unsigned short FCS_16_TAB[256] = {...};
+ 0x0000,0x1189,0x2312,0x329B,0x4624,0x57AD,0x6536,0x74BF,0x8C48,0x9DC1,0xAF5A,0xBED3,0xCA6C,
+ 0xDBE5,0xE97E,0xF8F7,0x1081,0x0108,0x3393,0x221A,0x56A5,0x472C,0x75B7,0x643E,0x9CC9,0x8D40,
+ 0xBFDB,0xAE52,0xDAED,0xCB64,0xF9FF,0xE876,0x2102,0x308B,0x0210,0x1399,0x6726,0x76AF,0x4434,
+ 0x55BD,0xAD4A,0xBCC3,0x8E58,0x9FD1,0xEB6E,0xFAE7,0xC87C,0xD9F5,0x3183,0x200A,0x1291,0x0318,
+ 0x77A7,0x662E,0x54B5,0x453C,0xBDCB,0xAC42,0x9ED9,0x8F50,0xFBEF,0xEA66,0xD8FD,0xC974,0x4204,
+ 0x538D,0x6116,0x709F,0x0420,0x15A9,0x2732,0x36BB,0xCE4C,0xDFC5,0xED5E,0xFCD7,0x8868,0x99E1,
+ 0xAB7A,0xBAF3,0x5285,0x430C,0x7197,0x601E,0x14A1,0x0528,0x37B3,0x263A,0xDECD,0xCF44,0xFDDF,
+ 0xEC56,0x98E9,0x8960,0xBBFB,0xAA72,0x6306,0x728F,0x4014,0x519D,0x2522,0x34AB,0x0630,0x17B9,
+ 0xEF4E,0xFEC7,0xCC5C,0xDDD5,0xA96A,0xB8E3,0x8A78,0x9BF1,0x7387,0x620E,0x5095,0x411C,0x35A3,
+ 0x242A,0x16B1,0x0738,0xFFCF,0xEE46,0xDCDD,0xCD54,0xB9EB,0xA862,0x9AF9,0x8B70,0x8408,0x9581,
+ 0xA71A,0xB693,0xC22C,0xD3A5,0xE13E,0xF0B7,0x0840,0x19C9,0x2B52,0x3ADB,0x4E64,0x5FED,0x6D76,
+ 0x7CFF,0x9489,0x8500,0xB79B,0xA612,0xD2AD,0xC324,0xF1BF,0xE036,0x18C1,0x0948,0x3BD3,0x2A5A,
+ 0x5EE5,0x4F6C,0x7DF7,0x6C7E,0xA50A,0xB483,0x8618,0x9791,0xE32E,0xF2A7,0xC03C,0xD1B5,0x2942,
+ 0x38CB,0x0A50,0x1BD9,0x6F66,0x7EEF,0x4C74,0x5DFD,0xB58B,0xA402,0x9699,0x8710,0xF3AF,0xE226,
+ 0xD0BD,0xC134,0x39C3,0x284A,0x1AD1,0x0B58,0x7FE7,0x6E6E,0x5CF5,0x4D7C,0xC60C,0xD785,0xE51E,
+ 0xF497,0x8028,0x91A1,0xA33A,0xB2B3,0x4A44,0x5BCD,0x6956,0x78DF,0x0C60,0x1DE9,0x2F72,0x3EFB,
+ 0xD68D,0xC704,0xF59F,0xE416,0x90A9,0x8120,0xB3BB,0xA232,0x5AC5,0x4B4C,0x79D7,0x685E,0x1CE1,
+ 0x0D68,0x3FF3,0x2E7A,0xE70E,0xF687,0xC41C,0xD595,0xA12A,0xB0A3,0x8238,0x93B1,0x6B46,0x7ACF,
+ 0x4854,0x59DD,0x2D62,0x3CEB,0x0E70,0x1FF9,0xF78F,0xE606,0xD49D,0xC514,0xB1AB,0xA022,0x92B9,
+ 0x8330,0x7BC7,0x6A4E,0x58D5,0x495C,0x3DE3,0x2C6A,0x1EF1,0x0F78
+ );
+
+ function fcs16Add(fcs,c)
+ // 'fcs' should be initialized to 0xFFFF and after the computation it should be
+ // complemented (inverted).
+ //
+ // If the FCS-16 is calculated over the data and over the complemented FCS-16, the
+ // result will always be 0xF0B8 (without the complementation).
+ {
+ return FCS_16_TAB[(fcs^c)&0xFF]^((fcs>>8)&0xFF);
+ };
+
+ // C/C++ language:
+ //
+ // inline unsigned short fcs16Add(unsigned short fcs, unsigned char c)
+ // {
+ // return FCS_16_TAB[(unsigned char)fcs^c]^(unsigned short)(fcs>>8);
+ // }
+
+ //
+ // CRC-32 (as it is in ZMODEM) in table form
+ //
+ // Copyright (C) 1986 Gary S. Brown. You may use this program, or
+ // code or tables extracted from it, as desired without restriction.
+ //
+ // Modified by Anders Danielsson, February 5, 1989 and March 10, 2006.
+ //
+ // This is also known as FCS-32 (as it is in PPP), described in
+ // RFC-1662 by William Allen Simpson, see RFC-1662 for references.
+ //
+ var CRC32_TAB = new Array( /* CRC polynomial 0xEDB88320 */
+ // C/C++ language:
+ //
+ // unsigned long CRC32_TAB[] = {...};
+ 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,
+ 0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,
+ 0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,
+ 0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5,
+ 0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,
+ 0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
+ 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,
+ 0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,
+ 0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,
+ 0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01,
+ 0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,
+ 0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
+ 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,
+ 0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,
+ 0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,
+ 0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD,
+ 0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,
+ 0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
+ 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,
+ 0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,
+ 0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,
+ 0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79,
+ 0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,
+ 0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
+ 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,
+ 0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,
+ 0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,
+ 0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45,
+ 0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,
+ 0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
+ 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,
+ 0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D
+ );
+
+ function crc32Add(crc,c)
+ // 'crc' should be initialized to 0xFFFFFFFF and after the computation it should be
+ // complemented (inverted).
+ //
+ // CRC-32 is also known as FCS-32.
+ //
+ // If the FCS-32 is calculated over the data and over the complemented FCS-32, the
+ // result will always be 0xDEBB20E3 (without the complementation).
+ {
+ return CRC32_TAB[(crc^c)&0xFF]^((crc>>8)&0xFFFFFF);
+ };
+ //
+ // C/C++ language:
+ //
+ // inline unsigned long crc32Add(unsigned long crc, unsigned char c)
+ // {
+ // return CRC32_TAB[(unsigned char)crc^c]^(crc>>8);
+ // }
+ //
+
+ function crc8(str)
+ {
+ var n,
+ len = str.length,
+ crc = 0
+ ;
+
+ for(i = 0; i < len; i++)
+ crc = crc8Add(crc, str.charCodeAt(i));
+
+ return crc;
+ };
+
+ function crcArc(str)
+ {
+ var i,
+ len = str.length,
+ crc = 0
+ ;
+
+ for(i = 0; i < len; i++)
+ crc = crcArcAdd(crc, str.charCodeAt(i));
+
+ return crc;
+ };
+
+ function crc16(str)
+ {
+ var i,
+ len = str.length,
+ crc = 0
+ ;
+
+ for(i = 0; i < len; i++)
+ crc = crc16Add(crc, str.charCodeAt(i));
+
+ return crc;
+ };
+
+ function fcs16(str)
+ {
+ var i,
+ len = str.length,
+ fcs = 0xFFFF
+ ;
+
+ for(i = 0; i < len; i++)
+ fcs = fcs16Add(fcs,str.charCodeAt(i));
+
+ return fcs^0xFFFF;
+ };
+
+ function crc32(str)
+ {
+ var i,
+ len = str.length,
+ crc = 0xFFFFFFFF
+ ;
+
+ for(i = 0; i < len; i++)
+ crc = crc32Add(crc, str.charCodeAt(i));
+
+ return crc^0xFFFFFFFF;
+ };
+
+ /**
+ * Convert value as 8-bit unsigned integer to 2 digit hexadecimal number.
+ */
+ function hex8(val)
+ {
+ var n = val & 0xFF,
+ str = n.toString(16).toUpperCase()
+ ;
+
+ while(str.length < 2)
+ str = "0" + str;
+
+ return str;
+ };
+
+ /**
+ * Convert value as 16-bit unsigned integer to 4 digit hexadecimal number.
+ */
+ function hex16(val)
+ {
+ return hex8(val >> 8) + hex8(val);
+ };
+
+ /**
+ * Convert value as 32-bit unsigned integer to 8 digit hexadecimal number.
+ */
+ function hex32(val)
+ {
+ return hex16(val >> 16) + hex16(val);
+ };
+
+ var target, property;
+
+ if(typeof(window) == 'undefined')
+ {
+ target = module;
+ property = 'exports';
+ }
+ else
+ {
+ target = window;
+ property = 'crc';
+ }
+
+ target[property] = {
+ 'crc8' : crc8,
+ 'crcArc' : crcArc,
+ 'crc16' : crc16,
+ 'fcs16' : fcs16,
+ 'crc32' : crc32,
+ 'hex8' : hex8,
+ 'hex16' : hex16,
+ 'hex32' : hex32
+ };
+})();
View
32 node_modules/connect/node_modules/crc/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "crc",
+ "version": "0.1.0",
+ "description": "CRC JavaScript implementation",
+ "author": {
+ "name": "Alex Gorbatchev",
+ "email": "alex.gorbatchev@gmail.com"
+ },
+ "contributors": [],
+ "main": "./lib/crc.js",
+ "scripts": {},
+ "directories": {},
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/alexgorbatchev/node-crc.git"
+ },
+ "_id": "crc@0.1.0",
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "_engineSupported": true,
+ "_npmVersion": "1.1.4",
+ "_nodeVersion": "v0.6.12",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "3f0a8083d9399349e30071b88682d0986034c79e"
+ },
+ "_from": "crc@0.1.0"
+}
View
64 node_modules/connect/node_modules/crc/tests/crc_tests.js
@@ -0,0 +1,64 @@
+#!/usr/bin/env ./nodeunit/bin/nodeunit
+
+var crc = require('../lib/crc');
+
+var fixture = {
+ 'crc8': [
+ ['hello world', 64]
+ ],
+
+ 'crc16': [
+ ['hello world', 15332]
+ ],
+
+ 'crc32': [
+ ['hello world', 222957957]
+ ],
+
+ 'crcArc': [
+ ['hello world', 14785]
+ ],
+
+ 'fcs16': [
+ ['hello world', 44550]
+ ],
+
+ 'hex8': [
+ [64, '40']
+ ],
+
+ 'hex16': [
+ [15332, '3BE4']
+ ],
+
+ 'hex32': [
+ [222957957, '0D4A1185']
+ ]
+};
+
+var suite = module.exports['crc'] = {};
+
+for(var func in fixture)
+{
+ var list = fixture[func];
+
+ for(var i = 0; i < list.length; i++)
+ {
+ var input = list[i][0],
+ output = list[i][1],
+ name = [ func, input, output ].join(' - ')
+ ;
+
+ suite[name] = (function(func, input, output)
+ {
+
+ return function(assert)
+ {
+ assert.deepEqual(crc[func](input), output);
+ assert.done();
+ };
+
+ })(func, input, output);
+ }
+};
+
View
3  node_modules/connect/node_modules/crc/tests/nodeunit/.npmignore
@@ -0,0 +1,3 @@
+dist
+stamp-build
+test/fixtures/dir2
View
56 node_modules/connect/node_modules/crc/tests/nodeunit/CONTRIBUTORS.md
@@ -0,0 +1,56 @@
+Nodeunit contributors (sorted alphabeticaly)
+============================================
+
+* **[Alex Gorbatchev](https://github.com/alexgorbatchev)**
+
+ * Deeper default object inspection
+ * Timeout to ensure flushing of console output (default reporter)
+
+* **[Alex Wolfe](https://github.com/alexkwolfe)**
+
+ * HTML test reporter
+
+* **[Caolan McMahon](https://github.com/caolan)**
+
+ * Author and maintainer
+ * Most features develpopment
+
+* **[Carl Fürstenberg](https://github.com/azatoth)**
+
+ * Debian-friendly Makefile, supports both 'node' and 'nodejs' executables
+ * Sandbox utility
+ * Minimal test reporter
+
+* **[Gerad Suyderhoud](https://github.com/gerad)**
+
+ * First comand-line tool
+
+* **[Kadir Pekel](https://github.com/coffeemate)**
+
+ * Improvements to default test reporter
+ * HTTP test utility
+
+* **[Oleg Efimov](https://github.com/Sannis)**
+
+ * Adding 'make lint' and fixing nodelint errors
+ * Option parsing, --help text and config file support
+ * Reporters option for command-line tool
+
+* **[Orlando Vazquez](https://github.com/orlandov)**
+
+ * Added jUnit XML reporter
+
+* **[Ryan Dahl](https://github.com/ry)**
+
+ * Add package.json
+
+* **[Sam Stephenson](https://github.com/sstephenson)**
+
+ * Coffee-script support
+
+* **[Thomas Mayfield](https://github.com/thegreatape)**
+
+ * Async setUp and tearDown support for testCase
+
+**[Full contributors list](https://github.com/caolan/nodeunit/contributors).**
+
View
19 node_modules/connect/node_modules/crc/tests/nodeunit/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Caolan McMahon
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
126 node_modules/connect/node_modules/crc/tests/nodeunit/Makefile
@@ -0,0 +1,126 @@
+PACKAGE = nodeunit
+NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
+
+PREFIX ?= /usr/local
+BINDIR ?= $(PREFIX)/bin
+DATADIR ?= $(PREFIX)/share
+MANDIR ?= $(PREFIX)/share/man
+LIBDIR ?= $(PREFIX)/lib
+NODEJSLIBDIR ?= $(LIBDIR)/$(NODEJS)
+
+BUILDDIR = dist
+
+DOCS = $(shell find doc -name '*.md' \
+ |sed 's|.md|.1|g' \
+ |sed 's|doc/|man1/|g' \
+ )
+
+
+$(shell if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi)
+
+all: build doc
+
+browser:
+ # super hacky build script for browser version!
+ mkdir -p $(BUILDDIR)/browser
+ rm -rf $(BUILDDIR)/browser/*
+ # build browser version of nodeunit.js
+ cat share/license.js >> $(BUILDDIR)/browser/nodeunit.js
+ echo "nodeunit = (function(){" >> $(BUILDDIR)/browser/nodeunit.js
+ cat deps/json2.js >> $(BUILDDIR)/browser/nodeunit.js
+ # make assert global
+ echo "var assert = this.assert = {};" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "var types = {};" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "var core = {};" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "var nodeunit = {};" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "var reporter = {};" >> $(BUILDDIR)/browser/nodeunit.js
+ cat deps/async.js >> $(BUILDDIR)/browser/nodeunit.js
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
+ cat lib/assert.js >> $(BUILDDIR)/browser/nodeunit.js
+ echo "})(assert);" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
+ cat lib/types.js >> $(BUILDDIR)/browser/nodeunit.js
+ echo "})(types);" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
+ cat lib/core.js >> $(BUILDDIR)/browser/nodeunit.js
+ echo "})(core);" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
+ cat lib/reporters/browser.js >> $(BUILDDIR)/browser/nodeunit.js
+ echo "})(reporter);" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "nodeunit = core;" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "nodeunit.assert = assert;" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "nodeunit.reporter = reporter;" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "nodeunit.run = reporter.run;" >> $(BUILDDIR)/browser/nodeunit.js
+ echo "return nodeunit; })();" >> $(BUILDDIR)/browser/nodeunit.js
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/nodeunit.js
+ # copy nodeunit.css
+ cp share/nodeunit.css $(BUILDDIR)/browser/nodeunit.css
+ # create nodeunit.min.js
+ uglifyjs $(BUILDDIR)/browser/nodeunit.js > $(BUILDDIR)/browser/nodeunit.min.js
+ # create test scripts
+ mkdir -p $(BUILDDIR)/browser/test
+ cp test/test.html $(BUILDDIR)/browser/test/test.html
+ # test-base.js
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-base.js
+ cat test/test-base.js >> $(BUILDDIR)/browser/test/test-base.js
+ echo "})(this.test_base = {});" >> $(BUILDDIR)/browser/test/test-base.js
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-base.js
+ # test-runmodule.js
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-runmodule.js
+ cat test/test-runmodule.js >> $(BUILDDIR)/browser/test/test-runmodule.js
+ echo "})(this.test_runmodule = {});" >> $(BUILDDIR)/browser/test/test-runmodule.js
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-runmodule.js
+ # test-runtest.js
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-runtest.js
+ cat test/test-runtest.js >> $(BUILDDIR)/browser/test/test-runtest.js
+ echo "})(this.test_runtest = {});" >> $(BUILDDIR)/browser/test/test-runtest.js
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-runtest.js
+ # test-testcase.js
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-testcase.js
+ cat test/test-testcase.js >> $(BUILDDIR)/browser/test/test-testcase.js
+ echo "})(this.test_testcase = {});" >> $(BUILDDIR)/browser/test/test-testcase.js
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-testcase.js
+ # copy nodeunit.js to dist/browser/test to make it easier for me to host and
+ # run on windows VMs with IE
+ cp $(BUILDDIR)/browser/nodeunit.js $(BUILDDIR)/browser/test/nodeunit.js
+ cp $(BUILDDIR)/browser/nodeunit.css $(BUILDDIR)/browser/test/nodeunit.css
+
+build: stamp-build
+
+stamp-build: $(wildcard deps/* lib/*.js)
+ touch $@;
+ mkdir -p $(BUILDDIR)/nodeunit
+ cp -R bin deps index.js lib package.json $(BUILDDIR)/nodeunit
+ printf '#!/bin/sh\n$(NODEJS) $(NODEJSLIBDIR)/$(PACKAGE)/bin/nodeunit $$@' > $(BUILDDIR)/nodeunit.sh
+
+test:
+ $(NODEJS) ./bin/nodeunit test
+
+install: build
+ install --directory $(NODEJSLIBDIR)
+ cp -a $(BUILDDIR)/nodeunit $(NODEJSLIBDIR)
+ install --mode=0755 $(BUILDDIR)/nodeunit.sh $(BINDIR)/nodeunit
+ install --directory $(MANDIR)/man1/
+ cp -a man1/nodeunit.1 $(MANDIR)/man1/
+
+uninstall:
+ rm -rf $(NODEJSLIBDIR)/nodeunit $(NODEJSLIBDIR)/nodeunit.js $(BINDIR)/nodeunit
+ rm -rf $(MANDIR)/man1/nodeunit.1
+
+clean:
+ rm -rf $(BUILDDIR) stamp-build
+
+lint:
+ nodelint --config nodelint.cfg ./index.js ./bin/nodeunit ./bin/nodeunit.json ./lib/*.js ./lib/reporters/*.js ./test/*.js
+
+doc: man1 $(DOCS)
+ @true
+
+man1:
+ @if ! test -d man1 ; then mkdir -p man1 ; fi
+
+# use `npm install ronn` for this to work.
+man1/%.1: doc/%.md
+ ronn --roff $< > $@
+
+.PHONY: browser test install uninstall build all
View
430 node_modules/connect/node_modules/crc/tests/nodeunit/README.md
@@ -0,0 +1,430 @@
+Nodeunit
+========
+
+Simple syntax, powerful tools. Nodeunit provides easy async unit testing for
+node.js and the browser.
+
+* Simple to use
+* Just export the tests from a module
+* Works with node.js and in the browser.
+* Helps you avoid common pitfalls when testing asynchronous code
+* Easy to add test cases with setUp and tearDown functions if you wish
+* Flexible reporters for custom output, built-in support for HTML and jUnit XML
+* Allows the use of mocks and stubs
+
+__Contributors__
+
+* [alexgorbatchev](https://github.com/alexgorbatchev)
+* [alexkwolfe](https://github.com/alexkwolfe)
+* [azatoth](https://github.com/azatoth)
+* [coffeemate](https://github.com/coffeemate)
+* [orlandov](https://github.com/orlandov)
+* [Sannis](https://github.com/Sannis)
+* [sstephenson](https://github.com/sstephenson)
+* [thegreatape](https://github.com/thegreatape)
+* and thanks to [cjohansen](https://github.com/cjohansen) for input and advice
+ on implementing setUp and tearDown functions. See
+ [cjohansen's fork](https://github.com/cjohansen/nodeunit).
+
+Also, check out gerad's [nodeunit-dsl](https://github.com/gerad/nodeunit-dsl)
+project, which implements a 'pretty dsl on top of nodeunit'.
+
+More contributor information can be found in the CONTRIBUTORS.md file.
+
+Usage
+-----
+
+Here is an example unit test module:
+
+ exports.testSomething = function(test){
+ test.expect(1);
+ test.ok(true, "this assertion should pass");
+ test.done();
+ };
+
+ exports.testSomethingElse = function(test){
+ test.ok(false, "this assertion should fail");
+ test.done();
+ };
+
+When run using the included test runner, this will output the following:
+
+<img src="https://github.com/caolan/nodeunit/raw/master/img/example_fail.png" />
+
+Installation
+------------
+
+There are two options for installing nodeunit:
+
+1. Clone / download nodeunit from [github](https://github.com/caolan/nodeunit),
+ then:
+
+ make && sudo make install
+
+2. Install via npm:
+
+ npm install nodeunit
+
+API Documentation
+-----------------
+
+Nodeunit uses the functions available in the node.js
+[assert module](http://nodejs.org/api.html#assert-280):
+
+* __ok(value, [message])__ - Tests if value is a true value.
+* __equal(actual, expected, [message])__ - Tests shallow, coercive equality
+ with the equal comparison operator ( == ).
+* __notEqual(actual, expected, [message])__ - Tests shallow, coercive
+ non-equality with the not equal comparison operator ( != ).
+* __deepEqual(actual, expected, [message])__ - Tests for deep equality.
+* __notDeepEqual(actual, expected, [message])__ - Tests for any deep
+ inequality.
+* __strictEqual(actual, expected, [message])__ - Tests strict equality, as
+ determined by the strict equality operator ( === )
+* __notStrictEqual(actual, expected, [message])__ - Tests strict non-equality,
+ as determined by the strict not equal operator ( !== )
+* __throws(block, [error], [message])__ - Expects block to throw an error.
+* __doesNotThrow(block, [error], [message])__ - Expects block not to throw an
+ error.
+* __ifError(value)__ - Tests if value is not a false value, throws if it is a
+ true value. Useful when testing the first argument, error in callbacks.
+
+Nodeunit also provides the following functions within tests:
+
+* __expect(amount)__ - Specify how many assertions are expected to run within a
+ test. Very useful for ensuring that all your callbacks and assertions are
+ run.
+* __done()__ - Finish the current test function, and move on to the next. ALL
+ tests should call this!
+
+Nodeunit aims to be simple and easy to learn. This is achieved through using
+existing structures (such as node.js modules) to maximum effect, and reducing
+the API where possible, to make it easier to digest.
+
+Tests are simply exported from a module, but they are still run in the order
+they are defined.
+
+__Note:__ Users of old nodeunit versions may remember using ok, equals and same
+in the style of qunit, instead of the assert functions above. These functions
+still exist for backwards compatibility, and are simply aliases to their assert
+module counterparts.
+
+
+Asynchronous Testing
+--------------------
+
+When testing asynchronous code, there are a number of sharp edges to watch out
+for. Thankfully, nodeunit is designed to help you avoid as many of these
+pitfalls as possible. For the most part, testing asynchronous code in nodeunit
+_just works_.
+
+
+### Tests run in series
+
+While running tests in parallel seems like a good idea for speeding up your
+test suite, in practice I've found it means writing much more complicated
+tests. Because of node's module cache, running tests in parallel means mocking
+and stubbing is pretty much impossible. One of the nicest things about testing
+in javascript is the ease of doing stubs:
+
+ var _readFile = fs.readFile;
+ fs.readFile = function(path, callback){
+ // its a stub!
+ };
+ // test function that uses fs.readFile
+
+ // we're done
+ fs.readFile = _readFile;
+
+You cannot do this when running tests in parallel. In order to keep testing as
+simple as possible, nodeunit avoids it. Thankfully, most unit-test suites run
+fast anyway.
+
+
+### Explicit ending of tests
+
+When testing async code its important that tests end at the correct point, not
+just after a given number of assertions. Otherwise your tests can run short,
+ending before all assertions have completed. Its important to detect too
+many assertions as well as too few. Combining explicit ending of tests with
+an expected number of assertions helps to avoid false test passes, so be sure
+to use the test.expect() method at the start of your test functions, and
+test.done() when finished.
+
+
+Groups, setUp and tearDown
+--------------------------
+
+Nodeunit allows the nesting of test functions:
+
+ exports.test1 = function (test) {
+ ...
+ }
+
+ exports.group = {
+ test2: function (test) {
+ ...
+ },
+ test3: function (test) {
+ ...
+ }
+ }
+
+This would be run as:
+
+ test1
+ group - test2
+ group - test3
+
+Using these groups its possible to add setUp and tearDown functions to your
+tests. Nodeunit has a utility function called testCase which allows you to
+define a setUp function, which is run before each test, and a tearDown
+function, which is run after each test calls test.done():
+
+ var testCase = require('nodeunit').testCase;
+
+ module.exports = testCase({
+ setUp: function (callback) {
+ this.foo = 'bar';
+ callback();
+ },
+ tearDown: function (callback) {
+ // clean up
+ callback();
+ },
+ test1: function (test) {
+ test.equals(this.foo, 'bar');
+ test.done();
+ }
+ });
+
+In this way, its possible to have multiple groups of tests in a module, each
+group with its own setUp and tearDown functions.
+
+
+Running Tests
+-------------
+
+Nodeunit comes with a basic command-line test runner, which can be installed
+using 'sudo make install'. Example usage:
+
+ nodeunit testmodule1.js testfolder [...]
+
+The default test reporter uses color output, because I think that's more fun :) I
+intend to add a no-color option in future. To give you a feeling of the fun you'll
+be having writing tests, lets fix the example at the start of the README:
+
+<img src="https://github.com/caolan/nodeunit/raw/master/img/example_pass.png" />
+
+Ahhh, Doesn't that feel better?
+
+When using the included test runner, it will exit using the failed number of
+assertions as the exit code. Exiting with 0 when all tests pass.
+
+
+### Command-line Options
+
+* __--reporter FILE__ - you can set the test reporter to a custom module or
+on of the modules in nodeunit/lib/reporters, when omitted, the default test runner
+is used.
+* __--list-reporters__ - list available build-in reporters.
+* __--config FILE__ - load config options from a JSON file, allows
+the customisation of color schemes for the default test reporter etc. See
+bin/nodeunit.json for current available options.
+* __--version__ or __-v__ - report nodeunit version
+* __--help__ - show nodeunit help
+
+
+Running tests in the browser
+----------------------------
+
+Nodeunit tests can also be run inside the browser. For example usage, see
+the examples/browser folder. The basic syntax is as follows:
+
+__test.html__
+
+ <html>
+ <head>
+ <title>Example Test Suite</title>
+ <link rel="stylesheet" href="nodeunit.css" type="text/css" />
+ <script src="nodeunit.js"></script>
+ <script src="suite1.js"></script>
+ <script src="suite2.js"></script>
+ </head>
+ <body>
+ <h1 id="nodeunit-header>Example Test Suite</h1>
+ <script>
+ nodeunit.run({
+ 'Suite One': suite1,
+ 'Suite Two': suite2
+ });
+ </script>
+ </body>
+ </html>
+
+Here, suite1 and suite2 are just object literals containing test functions or
+groups, as would be returned if you did require('test-suite') in node.js:
+
+__suite1.js__
+
+ this.suite1 = {
+ 'example test': function (test) {
+ test.ok(true, 'everything is ok');
+ test.done();
+ }
+ };
+
+If you wish to use a commonjs format for your test suites (using exports), it is
+up to you to define the commonjs tools for the browser. There are a number of
+alternatives and its important it fits with your existing code, which is
+why nodeunit does not currently provide this out of the box.
+
+In the example above, the tests will run when the page is loaded.
+
+The browser-version of nodeunit.js is created in dist/browser when you do, 'make
+browser'. You'll need [UglifyJS](https://github.com/mishoo/UglifyJS) installed in
+order for it to automatically create nodeunit.min.js.
+
+
+Adding nodeunit to Your Projects
+--------------------------------
+
+If you don't want people to have to install the nodeunit command-line tool,
+you'll want to create a script that runs the tests for your project with the
+correct require paths set up. Here's an example test script, with a deps
+directory containing the projects dependencies:
+
+ #!/usr/bin/env node
+ require.paths.unshift(__dirname + '/deps');
+
+ var reporter = require('nodeunit').reporters.default;
+ reporter.run(['test']);
+
+If you're using git, you might find it useful to include nodeunit as a
+submodule. Using submodules makes it easy for developers to download nodeunit
+and run your test suite, without cluttering up your repository with
+the source code. To add nodeunit as a git submodule do the following:
+
+ git submodule add git://github.com/caolan/nodeunit.git deps/nodeunit
+
+This will add nodeunit to the deps folder of your project. Now, when cloning
+the repository, nodeunit can be downloaded by doing the following:
+
+ git submodule init
+ git submodule update
+
+Let's update the test script above with a helpful hint on how to get nodeunit,
+if its missing:
+
+ #!/usr/bin/env node
+
+ require.paths.unshift(__dirname + '/deps');
+
+ try {
+ var reporter = require('nodeunit').reporters.default;
+ }
+ catch(e) {
+ var sys = require('sys');
+ sys.puts("Cannot find nodeunit module.");
+ sys.puts("You can download submodules for this project by doing:");
+ sys.puts("");
+ sys.puts(" git submodule init");
+ sys.puts(" git submodule update");
+ sys.puts("");
+ process.exit();
+ }
+
+ process.chdir(__dirname);
+ reporter.run(['test']);
+
+Now if someone attempts to run your test suite without nodeunit installed they
+will be prompted to download the submodules for your project.
+
+
+Built-in Test Reporters
+-----------------------
+
+* __default__ - The standard reporter seen in the nodeunit screenshots
+* __minimal__ - Pretty, minimal output, shows errors and progress only
+* __html__ - Outputs a HTML report to stdout
+* __junit__ - Creates jUnit compatible XML reports, which can be used with
+ continuous integration tools such as [Hudson](http://hudson-ci.org/).
+
+
+Writing a Test Reporter
+---------------------
+
+Nodeunit exports runTest(fn, options), runModule(mod, options) and
+runFiles(paths, options). You'll most likely want to run test suites from
+files, which can be done using the latter function. The _options_ argument can
+contain callbacks which run during testing. Nodeunit provides the following
+callbacks:
+
+* __moduleStart(name)__ - called before a module is tested
+* __moduleDone(name, assertions)__ - called once all test functions within the
+ module have completed (see assertions object reference below)
+ ALL tests within the module
+* __testStart(name)__ - called before a test function is run
+* __testDone(name, assertions)__ - called once a test function has completed
+ (by calling test.done())
+* __log(assertion)__ - called whenever an assertion is made (see assertion
+ object reference below)
+* __done(assertions)__ - called after all tests/modules are complete
+
+The __assertion__ object:
+
+* __passed()__ - did the assertion pass?
+* __failed()__ - did the assertion fail?
+* __error__ - the AssertionError if the assertion failed
+* __method__ - the nodeunit assertion method used (ok, same, equals...)
+* __message__ - the message the assertion method was called with (optional)
+
+The __assertionList__ object:
+
+* An array-like object with the following new attributes:
+ * __failures()__ - the number of assertions which failed
+ * __duration__ - the time taken for the test to complete in msecs
+
+For a reference implementation of a test reporter, see lib/reporters/default.js in
+the nodeunit project directory.
+
+
+Sandbox utility
+---------------
+
+This is a function which evaluates JavaScript files in a sandbox and returns the
+context. The sandbox function can be used for testing client-side code or private
+un-exported functions within a module.
+
+ var sandbox = require('nodeunit').utils.sandbox;
+ var example = sandbox('example.js');
+
+__sandbox(files, sandbox)__ - Evaluates JavaScript files in a sandbox, returning
+the context. The first argument can either be a single filename or an array of
+filenames. If multiple filenames are given their contents are concatenated before
+evalution. The second argument is an optional context to use for the sandbox.
+
+
+Running the nodeunit Tests
+--------------------------
+
+The tests for nodeunit are written using nodeunit itself as the test framework.
+However, the module test-base.js first does some basic tests using the assert
+module to ensure that test functions are actually run, and a basic level of
+nodeunit functionality is available.
+
+To run the nodeunit tests do:
+
+ make test
+
+__Note:__ There was a bug in node v0.2.0 causing the tests to hang, upgrading
+to v0.2.1 fixes this.
+
+
+Contributing
+------------
+
+Contributions to the project are most welcome, so feel free to fork and improve.
+When submitting a pull request, please run 'make lint' first to ensure
+we're following a consistent coding style.
+
View
108 node_modules/connect/node_modules/crc/tests/nodeunit/bin/nodeunit
@@ -0,0 +1,108 @@
+#!/usr/bin/env node
+
+var
+ fs = require('fs'),
+ sys = require('sys'),
+ path = require('path');
+
+require.paths.push(process.cwd());
+var args = process.ARGV.slice(2);
+
+var files = [];
+
+var testrunner,
+ config_file,
+ config_param_found = false,
+ output_param_found = false,
+ reporter_file = 'default',
+ reporter_param_found = false;
+
+var usage = "Usage: nodeunit [options] testmodule1.js testfolder [...] \n" +
+ "Options:\n\n" +
+ " --config FILE the path to a JSON file with options\n" +
+ " --reporter FILE optional path to a reporter file to customize the output\n" +
+ " --list-reporters list available build-in reporters\n" +
+ " -h, --help display this help and exit\n" +
+ " -v, --version output version information and exit";
+
+
+// load default options
+var content = fs.readFileSync(__dirname + '/nodeunit.json', 'utf8');
+var options = JSON.parse(content);
+
+// a very basic pseudo --options parser
+args.forEach(function (arg) {
+ if (arg.slice(0, 9) === "--config=") {
+ config_file = arg.slice(9);
+ } else if (arg === '--config') {
+ config_param_found = true;
+ } else if (config_param_found) {
+ config_file = arg;
+ config_param_found = false;
+ } else if (arg.slice(0, 9) === "--output=") {
+ options.output = arg.slice(9);
+ } else if (arg === '--output') {
+ output_param_found = true;
+ } else if (output_param_found) {
+ options.output = arg;
+ output_param_found = false;
+ } else if (arg.slice(0, 11) === "--reporter=") {
+ reporter_file = arg.slice(11);
+ } else if (arg === '--reporter') {
+ reporter_param_found = true;
+ } else if (reporter_param_found) {
+ reporter_file = arg;
+ reporter_param_found = false;
+ } else if (arg === '--list-reporters') {
+ var reporters = fs.readdirSync(__dirname + '/../lib/reporters');
+ reporters = reporters.filter(function (reporter_file) {
+ return (/\.js$/).test(reporter_file);
+ }).map(function (reporter_file) {
+ return reporter_file.replace(/\.js$/, '');
+ }).filter(function (reporter_file) {
+ return reporter_file !== 'index';
+ });
+ sys.puts('Build-in reporters: ');
+ reporters.forEach(function (reporter_file) {
+ var reporter = require('../lib/reporters/' + reporter_file);
+ sys.puts(' * ' + reporter_file + (reporter.info ? ': ' + reporter.info : ''));
+ });
+ process.exit(0);
+ } else if ((arg === '-v') || (arg === '--version')) {
+ var content = fs.readFileSync(__dirname + '/../package.json', 'utf8');
+ var pkg = JSON.parse(content);
+ sys.puts(pkg.version);
+ process.exit(0);
+ } else if ((arg === '-h') || (arg === '--help')) {
+ sys.puts(usage);
+ process.exit(0);
+ } else {
+ files.push(arg);
+ }
+});
+
+if (files.length === 0) {
+ sys.puts('Files required.');
+ sys.puts(usage);
+ process.exit(1);
+}
+
+if (config_file) {
+ content = fs.readFileSync(config_file, 'utf8');
+ var custom_options = JSON.parse(content);
+
+ for (var option in custom_options) {
+ if (typeof option === 'string') {
+ options[option] = custom_options[option];
+ }
+ }
+}
+
+var builtin_reporters = require(__dirname + '/../lib/reporters');
+if (reporter_file in builtin_reporters) {
+ testrunner = builtin_reporters[reporter_file];
+}
+else {
+ testrunner = require(reporter_file);
+}
+testrunner.run(files, options);
View
10 node_modules/connect/node_modules/crc/tests/nodeunit/bin/nodeunit.json
@@ -0,0 +1,10 @@
+{
+ "error_prefix": "\u001B[31m",
+ "error_suffix": "\u001B[39m",
+ "ok_prefix": "\u001B[32m",
+ "ok_suffix": "\u001B[39m",
+ "bold_prefix": "\u001B[1m",
+ "bold_suffix": "\u001B[22m",
+ "assertion_prefix": "\u001B[35m",
+ "assertion_suffix": "\u001B[39m"
+}
View
602 node_modules/connect/node_modules/crc/tests/nodeunit/deps/async.js
@@ -0,0 +1,602 @@
+/*global setTimeout: false, console: false */
+(function () {
+
+ var async = {};
+
+ // global on the server, window in the browser
+ var root = this,
+ previous_async = root.async;
+
+ if (typeof module !== 'undefined' && module.exports) {
+ module.exports = async;
+ }
+ else {
+ root.async = async;
+ }
+
+ async.noConflict = function () {
+ root.async = previous_async;
+ return async;
+ };
+
+ //// cross-browser compatiblity functions ////
+
+ var _forEach = function (arr, iterator) {
+ if (arr.forEach) {
+ return arr.forEach(iterator);
+ }
+ for (var i = 0; i < arr.length; i += 1) {
+ iterator(arr[i], i, arr);
+ }
+ };
+
+ var _map = function (arr, iterator) {
+ if (arr.map) {
+ return arr.map(iterator);
+ }
+ var results = [];
+ _forEach(arr, function (x, i, a) {
+ results.push(iterator(x, i, a));
+ });
+ return results;
+ };
+
+ var _reduce = function (arr, iterator, memo) {
+ if (arr.reduce) {
+ return arr.reduce(iterator, memo);
+ }
+ _forEach(arr, function (x, i, a) {
+ memo = iterator(memo, x, i, a);
+ });
+ return memo;
+ };
+
+ var _keys = function (obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ }
+ var keys = [];
+ for (var k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ keys.push(k);
+ }
+ }
+ return keys;
+ };
+
+ var _indexOf = function (arr, item) {
+ if (arr.indexOf) {
+ return arr.indexOf(item);
+ }
+ for (var i = 0; i < arr.length; i += 1) {
+ if (arr[i] === item) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ //// exported async module functions ////
+
+ //// nextTick implementation with browser-compatible fallback ////
+ async.nextTick = function (fn) {
+ if (typeof process === 'undefined' || !(process.nextTick)) {
+ setTimeout(fn, 0);
+ }
+ else {
+ process.nextTick(fn);
+ }
+ };
+
+ async.forEach = function (arr, iterator, callback) {
+ if (!arr.length) {
+ return callback();
+ }
+ var completed = 0;
+ _forEach(arr, function (x) {
+ iterator(x, function (err) {
+ if (err) {
+ callback(err);
+ callback = function () {};
+ }
+ else {
+ completed += 1;
+ if (completed === arr.length) {
+ callback();
+ }
+ }
+ });
+ });
+ };
+
+ async.forEachSeries = function (arr, iterator, callback) {
+ if (!arr.length) {
+ return callback();
+ }
+ var completed = 0;
+ var iterate = function () {
+ iterator(arr[completed], function (err) {
+ if (err) {
+ callback(err);
+ callback = function () {};
+ }
+ else {
+ completed += 1;
+ if (completed === arr.length) {
+ callback();
+ }
+ else {
+ iterate();
+ }
+ }
+ });
+ };
+ iterate();
+ };
+
+
+ var doParallel = function (fn) {
+ return function () {
+ var args = Array.prototype.slice.call(arguments);
+ return fn.apply(null, [async.forEach].concat(args));
+ };
+ };
+ var doSeries = function (fn) {
+ return function () {
+ var args = Array.prototype.slice.call(arguments);
+ return fn.apply(null, [async.forEachSeries].concat(args));
+ };
+ };
+
+
+ var _asyncMap = function (eachfn, arr, iterator, callback) {
+ var results = [];
+ arr = _map(arr, function (x, i) {
+ return {index: i, value: x};
+ });