diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb index 75735ea8..300498c7 100644 --- a/app/views/maps/show.html.erb +++ b/app/views/maps/show.html.erb @@ -250,11 +250,12 @@ initialize("chaotic", true); }); } - /*window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); + //window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); + window.realtime.socket = io.connect('http://metamaps.cc:5001'); window.realtime.socket.on('connect', function() { subscribeToRooms(); console.log('socket connected'); - });*/ + }); function subscribeToRooms() { window.realtime.socket.on('maps-' + mapid, function(data) { //as long as you weren't the origin of the changes, update your map diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index bd436df1..183e9128 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -10,7 +10,7 @@ Devise.setup do |config| # config.mailer = "Devise::Mailer" if Rails.env.production? - config.secret_key = 'd91ba0da95749174ee2b8922034783cbde4945409ed28b13383e18e72844beb74467f8199e9e216f0687cd2290c6e46bf74da24486d14bba3671d76c5b10c753' + #config.secret_key = 'd91ba0da95749174ee2b8922034783cbde4945409ed28b13383e18e72844beb74467f8199e9e216f0687cd2290c6e46bf74da24486d14bba3671d76c5b10c753' end # ==> ORM configuration diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb index edc3f2f2..3acdbeae 100644 --- a/config/initializers/redis.rb +++ b/config/initializers/redis.rb @@ -1,6 +1,6 @@ -if Rails.env.development? - $redis = Redis.new(:host => 'localhost', :port=> 6379) -elsif Rails.env.production? - uri = URI.parse(ENV["REDISTOGO_URL"]) - $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) -end \ No newline at end of file +#if Rails.env.development? +$redis = Redis.new(:host => 'localhost', :port=> 6379) +#elsif Rails.env.production? +# uri = URI.parse(ENV["REDISTOGO_URL"]) +# $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) +#end \ No newline at end of file diff --git a/realtime/node_modules/.bin/express b/realtime/node_modules/.bin/express new file mode 100644 index 00000000..cad5a1ef --- /dev/null +++ b/realtime/node_modules/.bin/express @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../express/bin/express" "$@" + ret=$? +else + node "$basedir/../express/bin/express" "$@" + ret=$? +fi +exit $ret diff --git a/realtime/node_modules/.bin/express.cmd b/realtime/node_modules/.bin/express.cmd new file mode 100644 index 00000000..a3ce07c4 --- /dev/null +++ b/realtime/node_modules/.bin/express.cmd @@ -0,0 +1,6 @@ +:: Created by npm, please don't edit manually. +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\express\bin\express" %* +) ELSE ( + node "%~dp0\..\express\bin\express" %* +) \ No newline at end of file diff --git a/realtime/node_modules/express/.npmignore b/realtime/node_modules/express/.npmignore new file mode 100644 index 00000000..caf574de --- /dev/null +++ b/realtime/node_modules/express/.npmignore @@ -0,0 +1,9 @@ +.git* +docs/ +examples/ +support/ +test/ +testing.js +.DS_Store +coverage.html +lib-cov diff --git a/realtime/node_modules/express/.travis.yml b/realtime/node_modules/express/.travis.yml new file mode 100644 index 00000000..a12e3f0f --- /dev/null +++ b/realtime/node_modules/express/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" \ No newline at end of file diff --git a/realtime/node_modules/express/History.md b/realtime/node_modules/express/History.md new file mode 100644 index 00000000..9d53bef4 --- /dev/null +++ b/realtime/node_modules/express/History.md @@ -0,0 +1,1274 @@ +4.0.0 / +================== + + * remove: + - express(1) - moved to [express-generator](https://github.com/expressjs/generator) + - `req.accepted*` - use `req.accepts*()` instead + - `app.configure` - use logic in your own app code + * change: + - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` + - `req.params` is now an object instead of an array + - `json spaces` no longer enabled by default in development + * refactor: + - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) + - `req.is` with [type-is](https://github.com/expressjs/type-is) + +3.4.8 / 2014-01-13 +================== + + * prevent incorrect automatic OPTIONS responses #1868 @dpatti + * update binary and examples for jade 1.0 #1876 @yossi, #1877 @reqshark, #1892 @matheusazzi + * throw 400 in case of malformed paths @rlidwka + +3.4.7 / 2013-12-10 +================== + + * update connect + +3.4.6 / 2013-12-01 +================== + + * update connect (raw-body) + +3.4.5 / 2013-11-27 +================== + + * update connect + * res.location: remove leading ./ #1802 @kapouer + * res.redirect: fix `res.redirect('toString') #1829 @michaelficarra + * res.send: always send ETag when content-length > 0 + * router: add Router.all() method + +3.4.4 / 2013-10-29 +================== + + * update connect + * update supertest + * update methods + * express(1): replace bodyParser() with urlencoded() and json() #1795 @chirag04 + +3.4.3 / 2013-10-23 +================== + + * update connect + +3.4.2 / 2013-10-18 +================== + + * update connect + * downgrade commander + +3.4.1 / 2013-10-15 +================== + + * update connect + * update commander + * jsonp: check if callback is a function + * router: wrap encodeURIComponent in a try/catch #1735 (@lxe) + * res.format: now includes chraset @1747 (@sorribas) + * res.links: allow multiple calls @1746 (@sorribas) + +3.4.0 / 2013-09-07 +================== + + * add res.vary(). Closes #1682 + * update connect + +3.3.8 / 2013-09-02 +================== + + * update connect + +3.3.7 / 2013-08-28 +================== + + * update connect + +3.3.6 / 2013-08-27 +================== + + * Revert "remove charset from json responses. Closes #1631" (causes issues in some clients) + * add: req.accepts take an argument list + +3.3.4 / 2013-07-08 +================== + + * update send and connect + +3.3.3 / 2013-07-04 +================== + + * update connect + +3.3.2 / 2013-07-03 +================== + + * update connect + * update send + * remove .version export + +3.3.1 / 2013-06-27 +================== + + * update connect + +3.3.0 / 2013-06-26 +================== + + * update connect + * add support for multiple X-Forwarded-Proto values. Closes #1646 + * change: remove charset from json responses. Closes #1631 + * change: return actual booleans from req.accept* functions + * fix jsonp callback array throw + +3.2.6 / 2013-06-02 +================== + + * update connect + +3.2.5 / 2013-05-21 +================== + + * update connect + * update node-cookie + * add: throw a meaningful error when there is no default engine + * change generation of ETags with res.send() to GET requests only. Closes #1619 + +3.2.4 / 2013-05-09 +================== + + * fix `req.subdomains` when no Host is present + * fix `req.host` when no Host is present, return undefined + +3.2.3 / 2013-05-07 +================== + + * update connect / qs + +3.2.2 / 2013-05-03 +================== + + * update qs + +3.2.1 / 2013-04-29 +================== + + * add app.VERB() paths array deprecation warning + * update connect + * update qs and remove all ~ semver crap + * fix: accept number as value of Signed Cookie + +3.2.0 / 2013-04-15 +================== + + * add "view" constructor setting to override view behaviour + * add req.acceptsEncoding(name) + * add req.acceptedEncodings + * revert cookie signature change causing session race conditions + * fix sorting of Accept values of the same quality + +3.1.2 / 2013-04-12 +================== + + * add support for custom Accept parameters + * update cookie-signature + +3.1.1 / 2013-04-01 +================== + + * add X-Forwarded-Host support to `req.host` + * fix relative redirects + * update mkdirp + * update buffer-crc32 + * remove legacy app.configure() method from app template. + +3.1.0 / 2013-01-25 +================== + + * add support for leading "." in "view engine" setting + * add array support to `res.set()` + * add node 0.8.x to travis.yml + * add "subdomain offset" setting for tweaking `req.subdomains` + * add `res.location(url)` implementing `res.redirect()`-like setting of Location + * use app.get() for x-powered-by setting for inheritance + * fix colons in passwords for `req.auth` + +3.0.6 / 2013-01-04 +================== + + * add http verb methods to Router + * update connect + * fix mangling of the `res.cookie()` options object + * fix jsonp whitespace escape. Closes #1132 + +3.0.5 / 2012-12-19 +================== + + * add throwing when a non-function is passed to a route + * fix: explicitly remove Transfer-Encoding header from 204 and 304 responses + * revert "add 'etag' option" + +3.0.4 / 2012-12-05 +================== + + * add 'etag' option to disable `res.send()` Etags + * add escaping of urls in text/plain in `res.redirect()` + for old browsers interpreting as html + * change crc32 module for a more liberal license + * update connect + +3.0.3 / 2012-11-13 +================== + + * update connect + * update cookie module + * fix cookie max-age + +3.0.2 / 2012-11-08 +================== + + * add OPTIONS to cors example. Closes #1398 + * fix route chaining regression. Closes #1397 + +3.0.1 / 2012-11-01 +================== + + * update connect + +3.0.0 / 2012-10-23 +================== + + * add `make clean` + * add "Basic" check to req.auth + * add `req.auth` test coverage + * add cb && cb(payload) to `res.jsonp()`. Closes #1374 + * add backwards compat for `res.redirect()` status. Closes #1336 + * add support for `res.json()` to retain previously defined Content-Types. Closes #1349 + * update connect + * change `res.redirect()` to utilize a pathname-relative Location again. Closes #1382 + * remove non-primitive string support for `res.send()` + * fix view-locals example. Closes #1370 + * fix route-separation example + +3.0.0rc5 / 2012-09-18 +================== + + * update connect + * add redis search example + * add static-files example + * add "x-powered-by" setting (`app.disable('x-powered-by')`) + * add "application/octet-stream" redirect Accept test case. Closes #1317 + +3.0.0rc4 / 2012-08-30 +================== + + * add `res.jsonp()`. Closes #1307 + * add "verbose errors" option to error-pages example + * add another route example to express(1) so people are not so confused + * add redis online user activity tracking example + * update connect dep + * fix etag quoting. Closes #1310 + * fix error-pages 404 status + * fix jsonp callback char restrictions + * remove old OPTIONS default response + +3.0.0rc3 / 2012-08-13 +================== + + * update connect dep + * fix signed cookies to work with `connect.cookieParser()` ("s:" prefix was missing) [tnydwrds] + * fix `res.render()` clobbering of "locals" + +3.0.0rc2 / 2012-08-03 +================== + + * add CORS example + * update connect dep + * deprecate `.createServer()` & remove old stale examples + * fix: escape `res.redirect()` link + * fix vhost example + +3.0.0rc1 / 2012-07-24 +================== + + * add more examples to view-locals + * add scheme-relative redirects (`res.redirect("//foo.com")`) support + * update cookie dep + * update connect dep + * update send dep + * fix `express(1)` -h flag, use -H for hogan. Closes #1245 + * fix `res.sendfile()` socket error handling regression + +3.0.0beta7 / 2012-07-16 +================== + + * update connect dep for `send()` root normalization regression + +3.0.0beta6 / 2012-07-13 +================== + + * add `err.view` property for view errors. Closes #1226 + * add "jsonp callback name" setting + * add support for "/foo/:bar*" non-greedy matches + * change `res.sendfile()` to use `send()` module + * change `res.send` to use "response-send" module + * remove `app.locals.use` and `res.locals.use`, use regular middleware + +3.0.0beta5 / 2012-07-03 +================== + + * add "make check" support + * add route-map example + * add `res.json(obj, status)` support back for BC + * add "methods" dep, remove internal methods module + * update connect dep + * update auth example to utilize cores pbkdf2 + * updated tests to use "supertest" + +3.0.0beta4 / 2012-06-25 +================== + + * Added `req.auth` + * Added `req.range(size)` + * Added `res.links(obj)` + * Added `res.send(body, status)` support back for backwards compat + * Added `.default()` support to `res.format()` + * Added 2xx / 304 check to `req.fresh` + * Revert "Added + support to the router" + * Fixed `res.send()` freshness check, respect res.statusCode + +3.0.0beta3 / 2012-06-15 +================== + + * Added hogan `--hjs` to express(1) [nullfirm] + * Added another example to content-negotiation + * Added `fresh` dep + * Changed: `res.send()` always checks freshness + * Fixed: expose connects mime module. Cloases #1165 + +3.0.0beta2 / 2012-06-06 +================== + + * Added `+` support to the router + * Added `req.host` + * Changed `req.param()` to check route first + * Update connect dep + +3.0.0beta1 / 2012-06-01 +================== + + * Added `res.format()` callback to override default 406 behaviour + * Fixed `res.redirect()` 406. Closes #1154 + +3.0.0alpha5 / 2012-05-30 +================== + + * Added `req.ip` + * Added `{ signed: true }` option to `res.cookie()` + * Removed `res.signedCookie()` + * Changed: dont reverse `req.ips` + * Fixed "trust proxy" setting check for `req.ips` + +3.0.0alpha4 / 2012-05-09 +================== + + * Added: allow `[]` in jsonp callback. Closes #1128 + * Added `PORT` env var support in generated template. Closes #1118 [benatkin] + * Updated: connect 2.2.2 + +3.0.0alpha3 / 2012-05-04 +================== + + * Added public `app.routes`. Closes #887 + * Added _view-locals_ example + * Added _mvc_ example + * Added `res.locals.use()`. Closes #1120 + * Added conditional-GET support to `res.send()` + * Added: coerce `res.set()` values to strings + * Changed: moved `static()` in generated apps below router + * Changed: `res.send()` only set ETag when not previously set + * Changed connect 2.2.1 dep + * Changed: `make test` now runs unit / acceptance tests + * Fixed req/res proto inheritance + +3.0.0alpha2 / 2012-04-26 +================== + + * Added `make benchmark` back + * Added `res.send()` support for `String` objects + * Added client-side data exposing example + * Added `res.header()` and `req.header()` aliases for BC + * Added `express.createServer()` for BC + * Perf: memoize parsed urls + * Perf: connect 2.2.0 dep + * Changed: make `expressInit()` middleware self-aware + * Fixed: use app.get() for all core settings + * Fixed redis session example + * Fixed session example. Closes #1105 + * Fixed generated express dep. Closes #1078 + +3.0.0alpha1 / 2012-04-15 +================== + + * Added `app.locals.use(callback)` + * Added `app.locals` object + * Added `app.locals(obj)` + * Added `res.locals` object + * Added `res.locals(obj)` + * Added `res.format()` for content-negotiation + * Added `app.engine()` + * Added `res.cookie()` JSON cookie support + * Added "trust proxy" setting + * Added `req.subdomains` + * Added `req.protocol` + * Added `req.secure` + * Added `req.path` + * Added `req.ips` + * Added `req.fresh` + * Added `req.stale` + * Added comma-delmited / array support for `req.accepts()` + * Added debug instrumentation + * Added `res.set(obj)` + * Added `res.set(field, value)` + * Added `res.get(field)` + * Added `app.get(setting)`. Closes #842 + * Added `req.acceptsLanguage()` + * Added `req.acceptsCharset()` + * Added `req.accepted` + * Added `req.acceptedLanguages` + * Added `req.acceptedCharsets` + * Added "json replacer" setting + * Added "json spaces" setting + * Added X-Forwarded-Proto support to `res.redirect()`. Closes #92 + * Added `--less` support to express(1) + * Added `express.response` prototype + * Added `express.request` prototype + * Added `express.application` prototype + * Added `app.path()` + * Added `app.render()` + * Added `res.type()` to replace `res.contentType()` + * Changed: `res.redirect()` to add relative support + * Changed: enable "jsonp callback" by default + * Changed: renamed "case sensitive routes" to "case sensitive routing" + * Rewrite of all tests with mocha + * Removed "root" setting + * Removed `res.redirect('home')` support + * Removed `req.notify()` + * Removed `app.register()` + * Removed `app.redirect()` + * Removed `app.is()` + * Removed `app.helpers()` + * Removed `app.dynamicHelpers()` + * Fixed `res.sendfile()` with non-GET. Closes #723 + * Fixed express(1) public dir for windows. Closes #866 + +2.5.9/ 2012-04-02 +================== + + * Added support for PURGE request method [pbuyle] + * Fixed `express(1)` generated app `app.address()` before `listening` [mmalecki] + +2.5.8 / 2012-02-08 +================== + + * Update mkdirp dep. Closes #991 + +2.5.7 / 2012-02-06 +================== + + * Fixed `app.all` duplicate DELETE requests [mscdex] + +2.5.6 / 2012-01-13 +================== + + * Updated hamljs dev dep. Closes #953 + +2.5.5 / 2012-01-08 +================== + + * Fixed: set `filename` on cached templates [matthewleon] + +2.5.4 / 2012-01-02 +================== + + * Fixed `express(1)` eol on 0.4.x. Closes #947 + +2.5.3 / 2011-12-30 +================== + + * Fixed `req.is()` when a charset is present + +2.5.2 / 2011-12-10 +================== + + * Fixed: express(1) LF -> CRLF for windows + +2.5.1 / 2011-11-17 +================== + + * Changed: updated connect to 1.8.x + * Removed sass.js support from express(1) + +2.5.0 / 2011-10-24 +================== + + * Added ./routes dir for generated app by default + * Added npm install reminder to express(1) app gen + * Added 0.5.x support + * Removed `make test-cov` since it wont work with node 0.5.x + * Fixed express(1) public dir for windows. Closes #866 + +2.4.7 / 2011-10-05 +================== + + * Added mkdirp to express(1). Closes #795 + * Added simple _json-config_ example + * Added shorthand for the parsed request's pathname via `req.path` + * Changed connect dep to 1.7.x to fix npm issue... + * Fixed `res.redirect()` __HEAD__ support. [reported by xerox] + * Fixed `req.flash()`, only escape args + * Fixed absolute path checking on windows. Closes #829 [reported by andrewpmckenzie] + +2.4.6 / 2011-08-22 +================== + + * Fixed multiple param callback regression. Closes #824 [reported by TroyGoode] + +2.4.5 / 2011-08-19 +================== + + * Added support for routes to handle errors. Closes #809 + * Added `app.routes.all()`. Closes #803 + * Added "basepath" setting to work in conjunction with reverse proxies etc. + * Refactored `Route` to use a single array of callbacks + * Added support for multiple callbacks for `app.param()`. Closes #801 +Closes #805 + * Changed: removed .call(self) for route callbacks + * Dependency: `qs >= 0.3.1` + * Fixed `res.redirect()` on windows due to `join()` usage. Closes #808 + +2.4.4 / 2011-08-05 +================== + + * Fixed `res.header()` intention of a set, even when `undefined` + * Fixed `*`, value no longer required + * Fixed `res.send(204)` support. Closes #771 + +2.4.3 / 2011-07-14 +================== + + * Added docs for `status` option special-case. Closes #739 + * Fixed `options.filename`, exposing the view path to template engines + +2.4.2. / 2011-07-06 +================== + + * Revert "removed jsonp stripping" for XSS + +2.4.1 / 2011-07-06 +================== + + * Added `res.json()` JSONP support. Closes #737 + * Added _extending-templates_ example. Closes #730 + * Added "strict routing" setting for trailing slashes + * Added support for multiple envs in `app.configure()` calls. Closes #735 + * Changed: `res.send()` using `res.json()` + * Changed: when cookie `path === null` don't default it + * Changed; default cookie path to "home" setting. Closes #731 + * Removed _pids/logs_ creation from express(1) + +2.4.0 / 2011-06-28 +================== + + * Added chainable `res.status(code)` + * Added `res.json()`, an explicit version of `res.send(obj)` + * Added simple web-service example + +2.3.12 / 2011-06-22 +================== + + * \#express is now on freenode! come join! + * Added `req.get(field, param)` + * Added links to Japanese documentation, thanks @hideyukisaito! + * Added; the `express(1)` generated app outputs the env + * Added `content-negotiation` example + * Dependency: connect >= 1.5.1 < 2.0.0 + * Fixed view layout bug. Closes #720 + * Fixed; ignore body on 304. Closes #701 + +2.3.11 / 2011-06-04 +================== + + * Added `npm test` + * Removed generation of dummy test file from `express(1)` + * Fixed; `express(1)` adds express as a dep + * Fixed; prune on `prepublish` + +2.3.10 / 2011-05-27 +================== + + * Added `req.route`, exposing the current route + * Added _package.json_ generation support to `express(1)` + * Fixed call to `app.param()` function for optional params. Closes #682 + +2.3.9 / 2011-05-25 +================== + + * Fixed bug-ish with `../' in `res.partial()` calls + +2.3.8 / 2011-05-24 +================== + + * Fixed `app.options()` + +2.3.7 / 2011-05-23 +================== + + * Added route `Collection`, ex: `app.get('/user/:id').remove();` + * Added support for `app.param(fn)` to define param logic + * Removed `app.param()` support for callback with return value + * Removed module.parent check from express(1) generated app. Closes #670 + * Refactored router. Closes #639 + +2.3.6 / 2011-05-20 +================== + + * Changed; using devDependencies instead of git submodules + * Fixed redis session example + * Fixed markdown example + * Fixed view caching, should not be enabled in development + +2.3.5 / 2011-05-20 +================== + + * Added export `.view` as alias for `.View` + +2.3.4 / 2011-05-08 +================== + + * Added `./examples/say` + * Fixed `res.sendfile()` bug preventing the transfer of files with spaces + +2.3.3 / 2011-05-03 +================== + + * Added "case sensitive routes" option. + * Changed; split methods supported per rfc [slaskis] + * Fixed route-specific middleware when using the same callback function several times + +2.3.2 / 2011-04-27 +================== + + * Fixed view hints + +2.3.1 / 2011-04-26 +================== + + * Added `app.match()` as `app.match.all()` + * Added `app.lookup()` as `app.lookup.all()` + * Added `app.remove()` for `app.remove.all()` + * Added `app.remove.VERB()` + * Fixed template caching collision issue. Closes #644 + * Moved router over from connect and started refactor + +2.3.0 / 2011-04-25 +================== + + * Added options support to `res.clearCookie()` + * Added `res.helpers()` as alias of `res.locals()` + * Added; json defaults to UTF-8 with `res.send()`. Closes #632. [Daniel * Dependency `connect >= 1.4.0` + * Changed; auto set Content-Type in res.attachement [Aaron Heckmann] + * Renamed "cache views" to "view cache". Closes #628 + * Fixed caching of views when using several apps. Closes #637 + * Fixed gotcha invoking `app.param()` callbacks once per route middleware. +Closes #638 + * Fixed partial lookup precedence. Closes #631 +Shaw] + +2.2.2 / 2011-04-12 +================== + + * Added second callback support for `res.download()` connection errors + * Fixed `filename` option passing to template engine + +2.2.1 / 2011-04-04 +================== + + * Added `layout(path)` helper to change the layout within a view. Closes #610 + * Fixed `partial()` collection object support. + Previously only anything with `.length` would work. + When `.length` is present one must still be aware of holes, + however now `{ collection: {foo: 'bar'}}` is valid, exposes + `keyInCollection` and `keysInCollection`. + + * Performance improved with better view caching + * Removed `request` and `response` locals + * Changed; errorHandler page title is now `Express` instead of `Connect` + +2.2.0 / 2011-03-30 +================== + + * Added `app.lookup.VERB()`, ex `app.lookup.put('/user/:id')`. Closes #606 + * Added `app.match.VERB()`, ex `app.match.put('/user/12')`. Closes #606 + * Added `app.VERB(path)` as alias of `app.lookup.VERB()`. + * Dependency `connect >= 1.2.0` + +2.1.1 / 2011-03-29 +================== + + * Added; expose `err.view` object when failing to locate a view + * Fixed `res.partial()` call `next(err)` when no callback is given [reported by aheckmann] + * Fixed; `res.send(undefined)` responds with 204 [aheckmann] + +2.1.0 / 2011-03-24 +================== + + * Added `/_?` partial lookup support. Closes #447 + * Added `request`, `response`, and `app` local variables + * Added `settings` local variable, containing the app's settings + * Added `req.flash()` exception if `req.session` is not available + * Added `res.send(bool)` support (json response) + * Fixed stylus example for latest version + * Fixed; wrap try/catch around `res.render()` + +2.0.0 / 2011-03-17 +================== + + * Fixed up index view path alternative. + * Changed; `res.locals()` without object returns the locals + +2.0.0rc3 / 2011-03-17 +================== + + * Added `res.locals(obj)` to compliment `res.local(key, val)` + * Added `res.partial()` callback support + * Fixed recursive error reporting issue in `res.render()` + +2.0.0rc2 / 2011-03-17 +================== + + * Changed; `partial()` "locals" are now optional + * Fixed `SlowBuffer` support. Closes #584 [reported by tyrda01] + * Fixed .filename view engine option [reported by drudge] + * Fixed blog example + * Fixed `{req,res}.app` reference when mounting [Ben Weaver] + +2.0.0rc / 2011-03-14 +================== + + * Fixed; expose `HTTPSServer` constructor + * Fixed express(1) default test charset. Closes #579 [reported by secoif] + * Fixed; default charset to utf-8 instead of utf8 for lame IE [reported by NickP] + +2.0.0beta3 / 2011-03-09 +================== + + * Added support for `res.contentType()` literal + The original `res.contentType('.json')`, + `res.contentType('application/json')`, and `res.contentType('json')` + will work now. + * Added `res.render()` status option support back + * Added charset option for `res.render()` + * Added `.charset` support (via connect 1.0.4) + * Added view resolution hints when in development and a lookup fails + * Added layout lookup support relative to the page view. + For example while rendering `./views/user/index.jade` if you create + `./views/user/layout.jade` it will be used in favour of the root layout. + * Fixed `res.redirect()`. RFC states absolute url [reported by unlink] + * Fixed; default `res.send()` string charset to utf8 + * Removed `Partial` constructor (not currently used) + +2.0.0beta2 / 2011-03-07 +================== + + * Added res.render() `.locals` support back to aid in migration process + * Fixed flash example + +2.0.0beta / 2011-03-03 +================== + + * Added HTTPS support + * Added `res.cookie()` maxAge support + * Added `req.header()` _Referrer_ / _Referer_ special-case, either works + * Added mount support for `res.redirect()`, now respects the mount-point + * Added `union()` util, taking place of `merge(clone())` combo + * Added stylus support to express(1) generated app + * Added secret to session middleware used in examples and generated app + * Added `res.local(name, val)` for progressive view locals + * Added default param support to `req.param(name, default)` + * Added `app.disabled()` and `app.enabled()` + * Added `app.register()` support for omitting leading ".", either works + * Added `res.partial()`, using the same interface as `partial()` within a view. Closes #539 + * Added `app.param()` to map route params to async/sync logic + * Added; aliased `app.helpers()` as `app.locals()`. Closes #481 + * Added extname with no leading "." support to `res.contentType()` + * Added `cache views` setting, defaulting to enabled in "production" env + * Added index file partial resolution, eg: partial('user') may try _views/user/index.jade_. + * Added `req.accepts()` support for extensions + * Changed; `res.download()` and `res.sendfile()` now utilize Connect's + static file server `connect.static.send()`. + * Changed; replaced `connect.utils.mime()` with npm _mime_ module + * Changed; allow `req.query` to be pre-defined (via middleware or other parent + * Changed view partial resolution, now relative to parent view + * Changed view engine signature. no longer `engine.render(str, options, callback)`, now `engine.compile(str, options) -> Function`, the returned function accepts `fn(locals)`. + * Fixed `req.param()` bug returning Array.prototype methods. Closes #552 + * Fixed; using `Stream#pipe()` instead of `sys.pump()` in `res.sendfile()` + * Fixed; using _qs_ module instead of _querystring_ + * Fixed; strip unsafe chars from jsonp callbacks + * Removed "stream threshold" setting + +1.0.8 / 2011-03-01 +================== + + * Allow `req.query` to be pre-defined (via middleware or other parent app) + * "connect": ">= 0.5.0 < 1.0.0". Closes #547 + * Removed the long deprecated __EXPRESS_ENV__ support + +1.0.7 / 2011-02-07 +================== + + * Fixed `render()` setting inheritance. + Mounted apps would not inherit "view engine" + +1.0.6 / 2011-02-07 +================== + + * Fixed `view engine` setting bug when period is in dirname + +1.0.5 / 2011-02-05 +================== + + * Added secret to generated app `session()` call + +1.0.4 / 2011-02-05 +================== + + * Added `qs` dependency to _package.json_ + * Fixed namespaced `require()`s for latest connect support + +1.0.3 / 2011-01-13 +================== + + * Remove unsafe characters from JSONP callback names [Ryan Grove] + +1.0.2 / 2011-01-10 +================== + + * Removed nested require, using `connect.router` + +1.0.1 / 2010-12-29 +================== + + * Fixed for middleware stacked via `createServer()` + previously the `foo` middleware passed to `createServer(foo)` + would not have access to Express methods such as `res.send()` + or props like `req.query` etc. + +1.0.0 / 2010-11-16 +================== + + * Added; deduce partial object names from the last segment. + For example by default `partial('forum/post', postObject)` will + give you the _post_ object, providing a meaningful default. + * Added http status code string representation to `res.redirect()` body + * Added; `res.redirect()` supporting _text/plain_ and _text/html_ via __Accept__. + * Added `req.is()` to aid in content negotiation + * Added partial local inheritance [suggested by masylum]. Closes #102 + providing access to parent template locals. + * Added _-s, --session[s]_ flag to express(1) to add session related middleware + * Added _--template_ flag to express(1) to specify the + template engine to use. + * Added _--css_ flag to express(1) to specify the + stylesheet engine to use (or just plain css by default). + * Added `app.all()` support [thanks aheckmann] + * Added partial direct object support. + You may now `partial('user', user)` providing the "user" local, + vs previously `partial('user', { object: user })`. + * Added _route-separation_ example since many people question ways + to do this with CommonJS modules. Also view the _blog_ example for + an alternative. + * Performance; caching view path derived partial object names + * Fixed partial local inheritance precedence. [reported by Nick Poulden] Closes #454 + * Fixed jsonp support; _text/javascript_ as per mailinglist discussion + +1.0.0rc4 / 2010-10-14 +================== + + * Added _NODE_ENV_ support, _EXPRESS_ENV_ is deprecated and will be removed in 1.0.0 + * Added route-middleware support (very helpful, see the [docs](http://expressjs.com/guide.html#Route-Middleware)) + * Added _jsonp callback_ setting to enable/disable jsonp autowrapping [Dav Glass] + * Added callback query check on response.send to autowrap JSON objects for simple webservice implementations [Dav Glass] + * Added `partial()` support for array-like collections. Closes #434 + * Added support for swappable querystring parsers + * Added session usage docs. Closes #443 + * Added dynamic helper caching. Closes #439 [suggested by maritz] + * Added authentication example + * Added basic Range support to `res.sendfile()` (and `res.download()` etc) + * Changed; `express(1)` generated app using 2 spaces instead of 4 + * Default env to "development" again [aheckmann] + * Removed _context_ option is no more, use "scope" + * Fixed; exposing _./support_ libs to examples so they can run without installs + * Fixed mvc example + +1.0.0rc3 / 2010-09-20 +================== + + * Added confirmation for `express(1)` app generation. Closes #391 + * Added extending of flash formatters via `app.flashFormatters` + * Added flash formatter support. Closes #411 + * Added streaming support to `res.sendfile()` using `sys.pump()` when >= "stream threshold" + * Added _stream threshold_ setting for `res.sendfile()` + * Added `res.send()` __HEAD__ support + * Added `res.clearCookie()` + * Added `res.cookie()` + * Added `res.render()` headers option + * Added `res.redirect()` response bodies + * Added `res.render()` status option support. Closes #425 [thanks aheckmann] + * Fixed `res.sendfile()` responding with 403 on malicious path + * Fixed `res.download()` bug; when an error occurs remove _Content-Disposition_ + * Fixed; mounted apps settings now inherit from parent app [aheckmann] + * Fixed; stripping Content-Length / Content-Type when 204 + * Fixed `res.send()` 204. Closes #419 + * Fixed multiple _Set-Cookie_ headers via `res.header()`. Closes #402 + * Fixed bug messing with error handlers when `listenFD()` is called instead of `listen()`. [thanks guillermo] + + +1.0.0rc2 / 2010-08-17 +================== + + * Added `app.register()` for template engine mapping. Closes #390 + * Added `res.render()` callback support as second argument (no options) + * Added callback support to `res.download()` + * Added callback support for `res.sendfile()` + * Added support for middleware access via `express.middlewareName()` vs `connect.middlewareName()` + * Added "partials" setting to docs + * Added default expresso tests to `express(1)` generated app. Closes #384 + * Fixed `res.sendfile()` error handling, defer via `next()` + * Fixed `res.render()` callback when a layout is used [thanks guillermo] + * Fixed; `make install` creating ~/.node_libraries when not present + * Fixed issue preventing error handlers from being defined anywhere. Closes #387 + +1.0.0rc / 2010-07-28 +================== + + * Added mounted hook. Closes #369 + * Added connect dependency to _package.json_ + + * Removed "reload views" setting and support code + development env never caches, production always caches. + + * Removed _param_ in route callbacks, signature is now + simply (req, res, next), previously (req, res, params, next). + Use _req.params_ for path captures, _req.query_ for GET params. + + * Fixed "home" setting + * Fixed middleware/router precedence issue. Closes #366 + * Fixed; _configure()_ callbacks called immediately. Closes #368 + +1.0.0beta2 / 2010-07-23 +================== + + * Added more examples + * Added; exporting `Server` constructor + * Added `Server#helpers()` for view locals + * Added `Server#dynamicHelpers()` for dynamic view locals. Closes #349 + * Added support for absolute view paths + * Added; _home_ setting defaults to `Server#route` for mounted apps. Closes #363 + * Added Guillermo Rauch to the contributor list + * Added support for "as" for non-collection partials. Closes #341 + * Fixed _install.sh_, ensuring _~/.node_libraries_ exists. Closes #362 [thanks jf] + * Fixed `res.render()` exceptions, now passed to `next()` when no callback is given [thanks guillermo] + * Fixed instanceof `Array` checks, now `Array.isArray()` + * Fixed express(1) expansion of public dirs. Closes #348 + * Fixed middleware precedence. Closes #345 + * Fixed view watcher, now async [thanks aheckmann] + +1.0.0beta / 2010-07-15 +================== + + * Re-write + - much faster + - much lighter + - Check [ExpressJS.com](http://expressjs.com) for migration guide and updated docs + +0.14.0 / 2010-06-15 +================== + + * Utilize relative requires + * Added Static bufferSize option [aheckmann] + * Fixed caching of view and partial subdirectories [aheckmann] + * Fixed mime.type() comments now that ".ext" is not supported + * Updated haml submodule + * Updated class submodule + * Removed bin/express + +0.13.0 / 2010-06-01 +================== + + * Added node v0.1.97 compatibility + * Added support for deleting cookies via Request#cookie('key', null) + * Updated haml submodule + * Fixed not-found page, now using using charset utf-8 + * Fixed show-exceptions page, now using using charset utf-8 + * Fixed view support due to fs.readFile Buffers + * Changed; mime.type() no longer accepts ".type" due to node extname() changes + +0.12.0 / 2010-05-22 +================== + + * Added node v0.1.96 compatibility + * Added view `helpers` export which act as additional local variables + * Updated haml submodule + * Changed ETag; removed inode, modified time only + * Fixed LF to CRLF for setting multiple cookies + * Fixed cookie complation; values are now urlencoded + * Fixed cookies parsing; accepts quoted values and url escaped cookies + +0.11.0 / 2010-05-06 +================== + + * Added support for layouts using different engines + - this.render('page.html.haml', { layout: 'super-cool-layout.html.ejs' }) + - this.render('page.html.haml', { layout: 'foo' }) // assumes 'foo.html.haml' + - this.render('page.html.haml', { layout: false }) // no layout + * Updated ext submodule + * Updated haml submodule + * Fixed EJS partial support by passing along the context. Issue #307 + +0.10.1 / 2010-05-03 +================== + + * Fixed binary uploads. + +0.10.0 / 2010-04-30 +================== + + * Added charset support via Request#charset (automatically assigned to 'UTF-8' when respond()'s + encoding is set to 'utf8' or 'utf-8'. + * Added "encoding" option to Request#render(). Closes #299 + * Added "dump exceptions" setting, which is enabled by default. + * Added simple ejs template engine support + * Added error reponse support for text/plain, application/json. Closes #297 + * Added callback function param to Request#error() + * Added Request#sendHead() + * Added Request#stream() + * Added support for Request#respond(304, null) for empty response bodies + * Added ETag support to Request#sendfile() + * Added options to Request#sendfile(), passed to fs.createReadStream() + * Added filename arg to Request#download() + * Performance enhanced due to pre-reversing plugins so that plugins.reverse() is not called on each request + * Performance enhanced by preventing several calls to toLowerCase() in Router#match() + * Changed; Request#sendfile() now streams + * Changed; Renamed Request#halt() to Request#respond(). Closes #289 + * Changed; Using sys.inspect() instead of JSON.encode() for error output + * Changed; run() returns the http.Server instance. Closes #298 + * Changed; Defaulting Server#host to null (INADDR_ANY) + * Changed; Logger "common" format scale of 0.4f + * Removed Logger "request" format + * Fixed; Catching ENOENT in view caching, preventing error when "views/partials" is not found + * Fixed several issues with http client + * Fixed Logger Content-Length output + * Fixed bug preventing Opera from retaining the generated session id. Closes #292 + +0.9.0 / 2010-04-14 +================== + + * Added DSL level error() route support + * Added DSL level notFound() route support + * Added Request#error() + * Added Request#notFound() + * Added Request#render() callback function. Closes #258 + * Added "max upload size" setting + * Added "magic" variables to collection partials (\_\_index\_\_, \_\_length\_\_, \_\_isFirst\_\_, \_\_isLast\_\_). Closes #254 + * Added [haml.js](http://github.com/visionmedia/haml.js) submodule; removed haml-js + * Added callback function support to Request#halt() as 3rd/4th arg + * Added preprocessing of route param wildcards using param(). Closes #251 + * Added view partial support (with collections etc) + * Fixed bug preventing falsey params (such as ?page=0). Closes #286 + * Fixed setting of multiple cookies. Closes #199 + * Changed; view naming convention is now NAME.TYPE.ENGINE (for example page.html.haml) + * Changed; session cookie is now httpOnly + * Changed; Request is no longer global + * Changed; Event is no longer global + * Changed; "sys" module is no longer global + * Changed; moved Request#download to Static plugin where it belongs + * Changed; Request instance created before body parsing. Closes #262 + * Changed; Pre-caching views in memory when "cache view contents" is enabled. Closes #253 + * Changed; Pre-caching view partials in memory when "cache view partials" is enabled + * Updated support to node --version 0.1.90 + * Updated dependencies + * Removed set("session cookie") in favour of use(Session, { cookie: { ... }}) + * Removed utils.mixin(); use Object#mergeDeep() + +0.8.0 / 2010-03-19 +================== + + * Added coffeescript example app. Closes #242 + * Changed; cache api now async friendly. Closes #240 + * Removed deprecated 'express/static' support. Use 'express/plugins/static' + +0.7.6 / 2010-03-19 +================== + + * Added Request#isXHR. Closes #229 + * Added `make install` (for the executable) + * Added `express` executable for setting up simple app templates + * Added "GET /public/*" to Static plugin, defaulting to /public + * Added Static plugin + * Fixed; Request#render() only calls cache.get() once + * Fixed; Namespacing View caches with "view:" + * Fixed; Namespacing Static caches with "static:" + * Fixed; Both example apps now use the Static plugin + * Fixed set("views"). Closes #239 + * Fixed missing space for combined log format + * Deprecated Request#sendfile() and 'express/static' + * Removed Server#running + +0.7.5 / 2010-03-16 +================== + + * Added Request#flash() support without args, now returns all flashes + * Updated ext submodule + +0.7.4 / 2010-03-16 +================== + + * Fixed session reaper + * Changed; class.js replacing js-oo Class implementation (quite a bit faster, no browser cruft) + +0.7.3 / 2010-03-16 +================== + + * Added package.json + * Fixed requiring of haml / sass due to kiwi removal + +0.7.2 / 2010-03-16 +================== + + * Fixed GIT submodules (HAH!) + +0.7.1 / 2010-03-16 +================== + + * Changed; Express now using submodules again until a PM is adopted + * Changed; chat example using millisecond conversions from ext + +0.7.0 / 2010-03-15 +================== + + * Added Request#pass() support (finds the next matching route, or the given path) + * Added Logger plugin (default "common" format replaces CommonLogger) + * Removed Profiler plugin + * Removed CommonLogger plugin + +0.6.0 / 2010-03-11 +================== + + * Added seed.yml for kiwi package management support + * Added HTTP client query string support when method is GET. Closes #205 + + * Added support for arbitrary view engines. + For example "foo.engine.html" will now require('engine'), + the exports from this module are cached after the first require(). + + * Added async plugin support + + * Removed usage of RESTful route funcs as http client + get() etc, use http.get() and friends + + * Removed custom exceptions + +0.5.0 / 2010-03-10 +================== + + * Added ext dependency (library of js extensions) + * Removed extname() / basename() utils. Use path module + * Removed toArray() util. Use arguments.values + * Removed escapeRegexp() util. Use RegExp.escape() + * Removed process.mixin() dependency. Use utils.mixin() + * Removed Collection + * Removed ElementCollection + * Shameless self promotion of ebook "Advanced JavaScript" (http://dev-mag.com) ;) + +0.4.0 / 2010-02-11 +================== + + * Added flash() example to sample upload app + * Added high level restful http client module (express/http) + * Changed; RESTful route functions double as HTTP clients. Closes #69 + * Changed; throwing error when routes are added at runtime + * Changed; defaulting render() context to the current Request. Closes #197 + * Updated haml submodule + +0.3.0 / 2010-02-11 +================== + + * Updated haml / sass submodules. Closes #200 + * Added flash message support. Closes #64 + * Added accepts() now allows multiple args. fixes #117 + * Added support for plugins to halt. Closes #189 + * Added alternate layout support. Closes #119 + * Removed Route#run(). Closes #188 + * Fixed broken specs due to use(Cookie) missing + +0.2.1 / 2010-02-05 +================== + + * Added "plot" format option for Profiler (for gnuplot processing) + * Added request number to Profiler plugin + * Fixed binary encoding for multi-part file uploads, was previously defaulting to UTF8 + * Fixed issue with routes not firing when not files are present. Closes #184 + * Fixed process.Promise -> events.Promise + +0.2.0 / 2010-02-03 +================== + + * Added parseParam() support for name[] etc. (allows for file inputs with "multiple" attr) Closes #180 + * Added Both Cache and Session option "reapInterval" may be "reapEvery". Closes #174 + * Added expiration support to cache api with reaper. Closes #133 + * Added cache Store.Memory#reap() + * Added Cache; cache api now uses first class Cache instances + * Added abstract session Store. Closes #172 + * Changed; cache Memory.Store#get() utilizing Collection + * Renamed MemoryStore -> Store.Memory + * Fixed use() of the same plugin several time will always use latest options. Closes #176 + +0.1.0 / 2010-02-03 +================== + + * Changed; Hooks (before / after) pass request as arg as well as evaluated in their context + * Updated node support to 0.1.27 Closes #169 + * Updated dirname(__filename) -> __dirname + * Updated libxmljs support to v0.2.0 + * Added session support with memory store / reaping + * Added quick uid() helper + * Added multi-part upload support + * Added Sass.js support / submodule + * Added production env caching view contents and static files + * Added static file caching. Closes #136 + * Added cache plugin with memory stores + * Added support to StaticFile so that it works with non-textual files. + * Removed dirname() helper + * Removed several globals (now their modules must be required) + +0.0.2 / 2010-01-10 +================== + + * Added view benchmarks; currently haml vs ejs + * Added Request#attachment() specs. Closes #116 + * Added use of node's parseQuery() util. Closes #123 + * Added `make init` for submodules + * Updated Haml + * Updated sample chat app to show messages on load + * Updated libxmljs parseString -> parseHtmlString + * Fixed `make init` to work with older versions of git + * Fixed specs can now run independant specs for those who cant build deps. Closes #127 + * Fixed issues introduced by the node url module changes. Closes 126. + * Fixed two assertions failing due to Collection#keys() returning strings + * Fixed faulty Collection#toArray() spec due to keys() returning strings + * Fixed `make test` now builds libxmljs.node before testing + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/realtime/node_modules/express/LICENSE b/realtime/node_modules/express/LICENSE new file mode 100644 index 00000000..d23e93ce --- /dev/null +++ b/realtime/node_modules/express/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2009-2013 TJ Holowaychuk + +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. \ No newline at end of file diff --git a/realtime/node_modules/express/Makefile b/realtime/node_modules/express/Makefile new file mode 100644 index 00000000..a1f33a70 --- /dev/null +++ b/realtime/node_modules/express/Makefile @@ -0,0 +1,34 @@ + +MOCHA_OPTS= --check-leaks +REPORTER = dot + +check: test + +test: test-unit test-acceptance + +test-unit: + @NODE_ENV=test ./node_modules/.bin/mocha \ + --reporter $(REPORTER) \ + --globals setImmediate,clearImmediate \ + $(MOCHA_OPTS) + +test-acceptance: + @NODE_ENV=test ./node_modules/.bin/mocha \ + --reporter $(REPORTER) \ + --bail \ + test/acceptance/*.js + +test-cov: lib-cov + @EXPRESS_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html + +lib-cov: + @jscoverage lib lib-cov + +bench: + @$(MAKE) -C benchmarks + +clean: + rm -f coverage.html + rm -fr lib-cov + +.PHONY: test test-unit test-acceptance bench clean diff --git a/realtime/node_modules/express/Readme.md b/realtime/node_modules/express/Readme.md new file mode 100644 index 00000000..e1e3f7e9 --- /dev/null +++ b/realtime/node_modules/express/Readme.md @@ -0,0 +1,126 @@ +[![express logo](http://f.cl.ly/items/0V2S1n0K1i3y1c122g04/Screen%20Shot%202012-04-11%20at%209.59.42%20AM.png)](http://expressjs.com/) + + Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). + + [![Build Status](https://secure.travis-ci.org/visionmedia/express.png)](http://travis-ci.org/visionmedia/express) [![Gittip](http://img.shields.io/gittip/visionmedia.png)](https://www.gittip.com/visionmedia/) + +```js +var express = require('express'); +var app = express(); + +app.get('/', function(req, res){ + res.send('Hello World'); +}); + +app.listen(3000); +``` + +## Installation + + $ npm install -g express + +## Quick Start + + The quickest way to get started with express is to utilize the executable `express(1)` to generate an application as shown below: + + Create the app: + + $ npm install -g express + $ express /tmp/foo && cd /tmp/foo + + Install dependencies: + + $ npm install + + Start the server: + + $ node app + +## Features + + * Built on [Connect](http://github.com/senchalabs/connect) + * Robust routing + * HTTP helpers (redirection, caching, etc) + * View system supporting 14+ template engines + * Content negotiation + * Focus on high performance + * Environment based configuration + * Executable for generating applications quickly + * High test coverage + +## Philosophy + + The Express philosophy is to provide small, robust tooling for HTTP servers, making + it a great solution for single page applications, web sites, hybrids, or public + HTTP APIs. + + Built on Connect, you can use _only_ what you need, and nothing more. Applications + can be as big or as small as you like, even a single file. Express does + not force you to use any specific ORM or template engine. With support for over + 14 template engines via [Consolidate.js](http://github.com/visionmedia/consolidate.js), + you can quickly craft your perfect framework. + +## More Information + + * [Website and Documentation](http://expressjs.com/) stored at [visionmedia/expressjs.com](https://github.com/visionmedia/expressjs.com) + * Join #express on freenode + * [Google Group](http://groups.google.com/group/express-js) for discussion + * Follow [tjholowaychuk](http://twitter.com/tjholowaychuk) on twitter for updates + * Visit the [Wiki](http://github.com/visionmedia/express/wiki) + * [Русскоязычная документация](http://jsman.ru/express/) + * Run express examples [online](https://runnable.com/express) + +## Viewing Examples + +Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies: + + $ git clone git://github.com/visionmedia/express.git --depth 1 + $ cd express + $ npm install + +Then run whichever tests you want: + + $ node examples/content-negotiation + +You can also view live examples here: + + + +## Running Tests + +To run the test suite, first invoke the following command within the repo, installing the development dependencies: + + $ npm install + +Then run the tests: + + $ make test + +## Contributors + + https://github.com/visionmedia/express/graphs/contributors + +## License + +(The MIT License) + +Copyright (c) 2009-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. diff --git a/realtime/node_modules/express/benchmarks/Makefile b/realtime/node_modules/express/benchmarks/Makefile new file mode 100644 index 00000000..baf0d6fc --- /dev/null +++ b/realtime/node_modules/express/benchmarks/Makefile @@ -0,0 +1,13 @@ + +all: + @./run 1 middleware + @./run 5 middleware + @./run 10 middleware + @./run 15 middleware + @./run 20 middleware + @./run 30 middleware + @./run 50 middleware + @./run 100 middleware + @echo + +.PHONY: all diff --git a/realtime/node_modules/express/benchmarks/middleware.js b/realtime/node_modules/express/benchmarks/middleware.js new file mode 100644 index 00000000..3aa7a8b4 --- /dev/null +++ b/realtime/node_modules/express/benchmarks/middleware.js @@ -0,0 +1,23 @@ + +var http = require('http'); +var express = require('..'); +var app = express(); + +// number of middleware + +var n = parseInt(process.env.MW || '1', 10); +console.log(' %s middleware', n); + +while (n--) { + app.use(function(req, res, next){ + next(); + }); +} + +var body = new Buffer('Hello World'); + +app.use(function(req, res, next){ + res.send(body); +}); + +app.listen(3333); diff --git a/realtime/node_modules/express/benchmarks/run b/realtime/node_modules/express/benchmarks/run new file mode 100644 index 00000000..93b5bc52 --- /dev/null +++ b/realtime/node_modules/express/benchmarks/run @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +echo +MW=$1 node $2 & +pid=$! + +sleep 2 + +wrk 'http://localhost:3333/?foo[bar]=baz' \ + -d 3 \ + -c 50 \ + -t 8 \ + | grep 'Requests/sec' \ + | awk '{ print " " $2 }' + +kill $pid diff --git a/realtime/node_modules/express/bin/express b/realtime/node_modules/express/bin/express new file mode 100644 index 00000000..cb979288 --- /dev/null +++ b/realtime/node_modules/express/bin/express @@ -0,0 +1,423 @@ +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var program = require('commander') + , mkdirp = require('mkdirp') + , pkg = require('../package.json') + , version = pkg.version + , os = require('os') + , fs = require('fs'); + +// CLI + +program + .version(version) + .usage('[options] [dir]') + .option('-s, --sessions', 'add session support') + .option('-e, --ejs', 'add ejs engine support (defaults to jade)') + .option('-J, --jshtml', 'add jshtml engine support (defaults to jade)') + .option('-H, --hogan', 'add hogan.js engine support') + .option('-c, --css ', 'add stylesheet support (less|stylus) (defaults to plain css)') + .option('-f, --force', 'force on non-empty directory') + .parse(process.argv); + +// Path + +var path = program.args.shift() || '.'; + +// end-of-line code + +var eol = os.EOL + +// Template engine + +program.template = 'jade'; +if (program.ejs) program.template = 'ejs'; +if (program.jshtml) program.template = 'jshtml'; +if (program.hogan) program.template = 'hjs'; + +/** + * Routes index template. + */ + +var index = [ + '' + , '/*' + , ' * GET home page.' + , ' */' + , '' + , 'exports.index = function(req, res){' + , ' res.render(\'index\', { title: \'Express\' });' + , '};' +].join(eol); + +/** + * Routes users template. + */ + +var users = [ + '' + , '/*' + , ' * GET users listing.' + , ' */' + , '' + , 'exports.list = function(req, res){' + , ' res.send("respond with a resource");' + , '};' +].join(eol); + +/** + * Jade layout template. + */ + +var jadeLayout = [ + 'doctype html' + , 'html' + , ' head' + , ' title= title' + , ' link(rel=\'stylesheet\', href=\'/stylesheets/style.css\')' + , ' body' + , ' block content' +].join(eol); + +/** + * Jade index template. + */ + +var jadeIndex = [ + 'extends layout' + , '' + , 'block content' + , ' h1= title' + , ' p Welcome to #{title}' +].join(eol); + +/** + * EJS index template. + */ + +var ejsIndex = [ + '' + , '' + , ' ' + , ' <%= title %>' + , ' ' + , ' ' + , ' ' + , '

<%= title %>

' + , '

Welcome to <%= title %>

' + , ' ' + , '' +].join(eol); + +/** + * JSHTML layout template. + */ + +var jshtmlLayout = [ + '' + , '' + , ' ' + , ' @write(title) ' + , ' ' + , ' ' + , ' ' + , ' @write(body)' + , ' ' + , '' +].join(eol); + +/** + * JSHTML index template. + */ + +var jshtmlIndex = [ + '

@write(title)

' + , '

Welcome to @write(title)

' +].join(eol); + +/** + * Hogan.js index template. + */ +var hoganIndex = [ + '' + , '' + , ' ' + , ' {{ title }}' + , ' ' + , ' ' + , ' ' + , '

{{ title }}

' + , '

Welcome to {{ title }}

' + , ' ' + , '' +].join(eol); + +/** + * Default css template. + */ + +var css = [ + 'body {' + , ' padding: 50px;' + , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;' + , '}' + , '' + , 'a {' + , ' color: #00B7FF;' + , '}' +].join(eol); + +/** + * Default less template. + */ + +var less = [ + 'body {' + , ' padding: 50px;' + , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;' + , '}' + , '' + , 'a {' + , ' color: #00B7FF;' + , '}' +].join(eol); + +/** + * Default stylus template. + */ + +var stylus = [ + 'body' + , ' padding: 50px' + , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif' + , 'a' + , ' color: #00B7FF' +].join(eol); + +/** + * App template. + */ + +var app = [ + '' + , '/**' + , ' * Module dependencies.' + , ' */' + , '' + , 'var express = require(\'express\');' + , 'var routes = require(\'./routes\');' + , 'var user = require(\'./routes/user\');' + , 'var http = require(\'http\');' + , 'var path = require(\'path\');' + , '' + , 'var app = express();' + , '' + , '// all environments' + , 'app.set(\'port\', process.env.PORT || 3000);' + , 'app.set(\'views\', path.join(__dirname, \'views\'));' + , 'app.set(\'view engine\', \':TEMPLATE\');' + , 'app.use(express.favicon());' + , 'app.use(express.logger(\'dev\'));' + , 'app.use(express.json());' + , 'app.use(express.urlencoded());' + , 'app.use(express.methodOverride());{sess}' + , 'app.use(app.router);{css}' + , 'app.use(express.static(path.join(__dirname, \'public\')));' + , '' + , '// development only' + , 'if (\'development\' == app.get(\'env\')) {' + , ' app.use(express.errorHandler());' + , '}' + , '' + , 'app.get(\'/\', routes.index);' + , 'app.get(\'/users\', user.list);' + , '' + , 'http.createServer(app).listen(app.get(\'port\'), function(){' + , ' console.log(\'Express server listening on port \' + app.get(\'port\'));' + , '});' + , '' +].join(eol); + +// Generate application + +(function createApplication(path) { + emptyDirectory(path, function(empty){ + if (empty || program.force) { + createApplicationAt(path); + } else { + program.confirm('destination is not empty, continue? ', function(ok){ + if (ok) { + process.stdin.destroy(); + createApplicationAt(path); + } else { + abort('aborting'); + } + }); + } + }); +})(path); + +/** + * Create application at the given directory `path`. + * + * @param {String} path + */ + +function createApplicationAt(path) { + console.log(); + process.on('exit', function(){ + console.log(); + console.log(' install dependencies:'); + console.log(' $ cd %s && npm install', path); + console.log(); + console.log(' run the app:'); + console.log(' $ node app'); + console.log(); + }); + + mkdir(path, function(){ + mkdir(path + '/public'); + mkdir(path + '/public/javascripts'); + mkdir(path + '/public/images'); + mkdir(path + '/public/stylesheets', function(){ + switch (program.css) { + case 'less': + write(path + '/public/stylesheets/style.less', less); + break; + case 'stylus': + write(path + '/public/stylesheets/style.styl', stylus); + break; + default: + write(path + '/public/stylesheets/style.css', css); + } + }); + + mkdir(path + '/routes', function(){ + write(path + '/routes/index.js', index); + write(path + '/routes/user.js', users); + }); + + mkdir(path + '/views', function(){ + switch (program.template) { + case 'ejs': + write(path + '/views/index.ejs', ejsIndex); + break; + case 'jade': + write(path + '/views/layout.jade', jadeLayout); + write(path + '/views/index.jade', jadeIndex); + break; + case 'jshtml': + write(path + '/views/layout.jshtml', jshtmlLayout); + write(path + '/views/index.jshtml', jshtmlIndex); + break; + case 'hjs': + write(path + '/views/index.hjs', hoganIndex); + break; + + } + }); + + // CSS Engine support + switch (program.css) { + case 'less': + app = app.replace('{css}', eol + 'app.use(require(\'less-middleware\')({ src: path.join(__dirname, \'public\') }));'); + break; + case 'stylus': + app = app.replace('{css}', eol + 'app.use(require(\'stylus\').middleware(path.join(__dirname, \'public\')));'); + break; + default: + app = app.replace('{css}', ''); + } + + // Session support + app = app.replace('{sess}', program.sessions + ? eol + 'app.use(express.cookieParser(\'your secret here\'));' + eol + 'app.use(express.session());' + : ''); + + // Template support + app = app.replace(':TEMPLATE', program.template); + + // package.json + var pkg = { + name: 'application-name' + , version: '0.0.1' + , private: true + , scripts: { start: 'node app.js' } + , dependencies: { + express: version + } + } + + if (program.template) pkg.dependencies[program.template] = '*'; + + // CSS Engine support + switch (program.css) { + case 'less': + pkg.dependencies['less-middleware'] = '*'; + break; + default: + if (program.css) { + pkg.dependencies[program.css] = '*'; + } + } + + write(path + '/package.json', JSON.stringify(pkg, null, 2)); + write(path + '/app.js', app); + }); +} + +/** + * Check if the given directory `path` is empty. + * + * @param {String} path + * @param {Function} fn + */ + +function emptyDirectory(path, fn) { + fs.readdir(path, function(err, files){ + if (err && 'ENOENT' != err.code) throw err; + fn(!files || !files.length); + }); +} + +/** + * echo str > path. + * + * @param {String} path + * @param {String} str + */ + +function write(path, str) { + fs.writeFile(path, str); + console.log(' \x1b[36mcreate\x1b[0m : ' + path); +} + +/** + * Mkdir -p. + * + * @param {String} path + * @param {Function} fn + */ + +function mkdir(path, fn) { + mkdirp(path, 0755, function(err){ + if (err) throw err; + console.log(' \033[36mcreate\033[0m : ' + path); + fn && fn(); + }); +} + +/** + * Exit with the given `str`. + * + * @param {String} str + */ + +function abort(str) { + console.error(str); + process.exit(1); +} diff --git a/realtime/node_modules/express/index.js b/realtime/node_modules/express/index.js new file mode 100644 index 00000000..bfe99345 --- /dev/null +++ b/realtime/node_modules/express/index.js @@ -0,0 +1,4 @@ + +module.exports = process.env.EXPRESS_COV + ? require('./lib-cov/express') + : require('./lib/express'); \ No newline at end of file diff --git a/realtime/node_modules/express/lib/application.js b/realtime/node_modules/express/lib/application.js new file mode 100644 index 00000000..865e1e02 --- /dev/null +++ b/realtime/node_modules/express/lib/application.js @@ -0,0 +1,534 @@ +/** + * Module dependencies. + */ + +var connect = require('connect') + , Router = require('./router') + , methods = require('methods') + , middleware = require('./middleware') + , debug = require('debug')('express:application') + , locals = require('./utils').locals + , View = require('./view') + , utils = connect.utils + , http = require('http'); + +/** + * Application prototype. + */ + +var app = exports = module.exports = {}; + +/** + * Initialize the server. + * + * - setup default configuration + * - setup default middleware + * - setup route reflection methods + * + * @api private + */ + +app.init = function(){ + this.cache = {}; + this.settings = {}; + this.engines = {}; + this.defaultConfiguration(); +}; + +/** + * Initialize application configuration. + * + * @api private + */ + +app.defaultConfiguration = function(){ + // default settings + this.enable('x-powered-by'); + this.enable('etag'); + this.set('env', process.env.NODE_ENV || 'development'); + this.set('subdomain offset', 2); + debug('booting in %s mode', this.get('env')); + + // implicit middleware + this.use(connect.query()); + this.use(middleware.init(this)); + + // inherit protos + this.on('mount', function(parent){ + this.request.__proto__ = parent.request; + this.response.__proto__ = parent.response; + this.engines.__proto__ = parent.engines; + this.settings.__proto__ = parent.settings; + }); + + // router + this._router = new Router(this); + this.routes = this._router.map; + this.__defineGetter__('router', function(){ + this._usedRouter = true; + this._router.caseSensitive = this.enabled('case sensitive routing'); + this._router.strict = this.enabled('strict routing'); + return this._router.middleware; + }); + + // setup locals + this.locals = locals(this); + + // default locals + this.locals.settings = this.settings; + + // default configuration + this.set('view', View); + this.set('views', process.cwd() + '/views'); + this.set('jsonp callback name', 'callback'); + + this.configure('development', function(){ + this.set('json spaces', 2); + }); + + this.configure('production', function(){ + this.enable('view cache'); + }); +}; + +/** + * Proxy `connect#use()` to apply settings to + * mounted applications. + * + * @param {String|Function|Server} route + * @param {Function|Server} fn + * @return {app} for chaining + * @api public + */ + +app.use = function(route, fn){ + var app; + + // default route to '/' + if ('string' != typeof route) fn = route, route = '/'; + + // express app + if (fn.handle && fn.set) app = fn; + + // restore .app property on req and res + if (app) { + app.route = route; + fn = function(req, res, next) { + var orig = req.app; + app.handle(req, res, function(err){ + req.__proto__ = orig.request; + res.__proto__ = orig.response; + next(err); + }); + }; + } + + connect.proto.use.call(this, route, fn); + + // mounted an app + if (app) { + app.parent = this; + app.emit('mount', this); + } + + return this; +}; + +/** + * Register the given template engine callback `fn` + * as `ext`. + * + * By default will `require()` the engine based on the + * file extension. For example if you try to render + * a "foo.jade" file Express will invoke the following internally: + * + * app.engine('jade', require('jade').__express); + * + * For engines that do not provide `.__express` out of the box, + * or if you wish to "map" a different extension to the template engine + * you may use this method. For example mapping the EJS template engine to + * ".html" files: + * + * app.engine('html', require('ejs').renderFile); + * + * In this case EJS provides a `.renderFile()` method with + * the same signature that Express expects: `(path, options, callback)`, + * though note that it aliases this method as `ejs.__express` internally + * so if you're using ".ejs" extensions you dont need to do anything. + * + * Some template engines do not follow this convention, the + * [Consolidate.js](https://github.com/visionmedia/consolidate.js) + * library was created to map all of node's popular template + * engines to follow this convention, thus allowing them to + * work seamlessly within Express. + * + * @param {String} ext + * @param {Function} fn + * @return {app} for chaining + * @api public + */ + +app.engine = function(ext, fn){ + if ('function' != typeof fn) throw new Error('callback function required'); + if ('.' != ext[0]) ext = '.' + ext; + this.engines[ext] = fn; + return this; +}; + +/** + * Map the given param placeholder `name`(s) to the given callback(s). + * + * Parameter mapping is used to provide pre-conditions to routes + * which use normalized placeholders. For example a _:user_id_ parameter + * could automatically load a user's information from the database without + * any additional code, + * + * The callback uses the same signature as middleware, the only difference + * being that the value of the placeholder is passed, in this case the _id_ + * of the user. Once the `next()` function is invoked, just like middleware + * it will continue on to execute the route, or subsequent parameter functions. + * + * app.param('user_id', function(req, res, next, id){ + * User.find(id, function(err, user){ + * if (err) { + * next(err); + * } else if (user) { + * req.user = user; + * next(); + * } else { + * next(new Error('failed to load user')); + * } + * }); + * }); + * + * @param {String|Array} name + * @param {Function} fn + * @return {app} for chaining + * @api public + */ + +app.param = function(name, fn){ + var self = this + , fns = [].slice.call(arguments, 1); + + // array + if (Array.isArray(name)) { + name.forEach(function(name){ + fns.forEach(function(fn){ + self.param(name, fn); + }); + }); + // param logic + } else if ('function' == typeof name) { + this._router.param(name); + // single + } else { + if (':' == name[0]) name = name.substr(1); + fns.forEach(function(fn){ + self._router.param(name, fn); + }); + } + + return this; +}; + +/** + * Assign `setting` to `val`, or return `setting`'s value. + * + * app.set('foo', 'bar'); + * app.get('foo'); + * // => "bar" + * + * Mounted servers inherit their parent server's settings. + * + * @param {String} setting + * @param {String} val + * @return {Server} for chaining + * @api public + */ + +app.set = function(setting, val){ + if (1 == arguments.length) { + return this.settings[setting]; + } else { + this.settings[setting] = val; + return this; + } +}; + +/** + * Return the app's absolute pathname + * based on the parent(s) that have + * mounted it. + * + * For example if the application was + * mounted as "/admin", which itself + * was mounted as "/blog" then the + * return value would be "/blog/admin". + * + * @return {String} + * @api private + */ + +app.path = function(){ + return this.parent + ? this.parent.path() + this.route + : ''; +}; + +/** + * Check if `setting` is enabled (truthy). + * + * app.enabled('foo') + * // => false + * + * app.enable('foo') + * app.enabled('foo') + * // => true + * + * @param {String} setting + * @return {Boolean} + * @api public + */ + +app.enabled = function(setting){ + return !!this.set(setting); +}; + +/** + * Check if `setting` is disabled. + * + * app.disabled('foo') + * // => true + * + * app.enable('foo') + * app.disabled('foo') + * // => false + * + * @param {String} setting + * @return {Boolean} + * @api public + */ + +app.disabled = function(setting){ + return !this.set(setting); +}; + +/** + * Enable `setting`. + * + * @param {String} setting + * @return {app} for chaining + * @api public + */ + +app.enable = function(setting){ + return this.set(setting, true); +}; + +/** + * Disable `setting`. + * + * @param {String} setting + * @return {app} for chaining + * @api public + */ + +app.disable = function(setting){ + return this.set(setting, false); +}; + +/** + * Configure callback for zero or more envs, + * when no `env` is specified that callback will + * be invoked for all environments. Any combination + * can be used multiple times, in any order desired. + * + * Examples: + * + * app.configure(function(){ + * // executed for all envs + * }); + * + * app.configure('stage', function(){ + * // executed staging env + * }); + * + * app.configure('stage', 'production', function(){ + * // executed for stage and production + * }); + * + * Note: + * + * These callbacks are invoked immediately, and + * are effectively sugar for the following: + * + * var env = process.env.NODE_ENV || 'development'; + * + * switch (env) { + * case 'development': + * ... + * break; + * case 'stage': + * ... + * break; + * case 'production': + * ... + * break; + * } + * + * @param {String} env... + * @param {Function} fn + * @return {app} for chaining + * @api public + */ + +app.configure = function(env, fn){ + var envs = 'all' + , args = [].slice.call(arguments); + fn = args.pop(); + if (args.length) envs = args; + if ('all' == envs || ~envs.indexOf(this.settings.env)) fn.call(this); + return this; +}; + +/** + * Delegate `.VERB(...)` calls to `router.VERB(...)`. + */ + +methods.forEach(function(method){ + app[method] = function(path){ + if ('get' == method && 1 == arguments.length) return this.set(path); + + // deprecated + if (Array.isArray(path)) { + console.trace('passing an array to app.VERB() is deprecated and will be removed in 4.0'); + } + + // if no router attached yet, attach the router + if (!this._usedRouter) this.use(this.router); + + // setup route + this._router[method].apply(this._router, arguments); + return this; + }; +}); + +/** + * Special-cased "all" method, applying the given route `path`, + * middleware, and callback to _every_ HTTP method. + * + * @param {String} path + * @param {Function} ... + * @return {app} for chaining + * @api public + */ + +app.all = function(path){ + var args = arguments; + methods.forEach(function(method){ + app[method].apply(this, args); + }, this); + return this; +}; + +// del -> delete alias + +app.del = app.delete; + +/** + * Render the given view `name` name with `options` + * and a callback accepting an error and the + * rendered template string. + * + * Example: + * + * app.render('email', { name: 'Tobi' }, function(err, html){ + * // ... + * }) + * + * @param {String} name + * @param {String|Function} options or fn + * @param {Function} fn + * @api public + */ + +app.render = function(name, options, fn){ + var opts = {} + , cache = this.cache + , engines = this.engines + , view; + + // support callback function as second arg + if ('function' == typeof options) { + fn = options, options = {}; + } + + // merge app.locals + utils.merge(opts, this.locals); + + // merge options._locals + if (options._locals) utils.merge(opts, options._locals); + + // merge options + utils.merge(opts, options); + + // set .cache unless explicitly provided + opts.cache = null == opts.cache + ? this.enabled('view cache') + : opts.cache; + + // primed cache + if (opts.cache) view = cache[name]; + + // view + if (!view) { + view = new (this.get('view'))(name, { + defaultEngine: this.get('view engine'), + root: this.get('views'), + engines: engines + }); + + if (!view.path) { + var err = new Error('Failed to lookup view "' + name + '" in views directory "' + view.root + '"'); + err.view = view; + return fn(err); + } + + // prime the cache + if (opts.cache) cache[name] = view; + } + + // render + try { + view.render(opts, fn); + } catch (err) { + fn(err); + } +}; + +/** + * Listen for connections. + * + * A node `http.Server` is returned, with this + * application (which is a `Function`) as its + * callback. If you wish to create both an HTTP + * and HTTPS server you may do so with the "http" + * and "https" modules as shown here: + * + * var http = require('http') + * , https = require('https') + * , express = require('express') + * , app = express(); + * + * http.createServer(app).listen(80); + * https.createServer({ ... }, app).listen(443); + * + * @return {http.Server} + * @api public + */ + +app.listen = function(){ + var server = http.createServer(this); + return server.listen.apply(server, arguments); +}; diff --git a/realtime/node_modules/express/lib/express.js b/realtime/node_modules/express/lib/express.js new file mode 100644 index 00000000..4f61cdbd --- /dev/null +++ b/realtime/node_modules/express/lib/express.js @@ -0,0 +1,82 @@ +/** + * Module dependencies. + */ + +var merge = require('merge-descriptors'); +var connect = require('connect') + , proto = require('./application') + , Route = require('./router/route') + , Router = require('./router') + , req = require('./request') + , res = require('./response') + , utils = connect.utils; + +/** + * Expose `createApplication()`. + */ + +exports = module.exports = createApplication; + +/** + * Expose mime. + */ + +exports.mime = connect.mime; + +/** + * Create an express application. + * + * @return {Function} + * @api public + */ + +function createApplication() { + var app = connect(); + utils.merge(app, proto); + app.request = { __proto__: req, app: app }; + app.response = { __proto__: res, app: app }; + app.init(); + return app; +} + +/** + * Expose connect.middleware as express.* + * for example `express.logger` etc. + */ + +merge(exports, connect.middleware); + +/** + * Error on createServer(). + */ + +exports.createServer = function(){ + console.warn('Warning: express.createServer() is deprecated, express'); + console.warn('applications no longer inherit from http.Server,'); + console.warn('please use:'); + console.warn(''); + console.warn(' var express = require("express");'); + console.warn(' var app = express();'); + console.warn(''); + return createApplication(); +}; + +/** + * Expose the prototypes. + */ + +exports.application = proto; +exports.request = req; +exports.response = res; + +/** + * Expose constructors. + */ + +exports.Route = Route; +exports.Router = Router; + +// Error handler title + +exports.errorHandler.title = 'Express'; + diff --git a/realtime/node_modules/express/lib/middleware.js b/realtime/node_modules/express/lib/middleware.js new file mode 100644 index 00000000..e07dd4cd --- /dev/null +++ b/realtime/node_modules/express/lib/middleware.js @@ -0,0 +1,32 @@ + +/** + * Module dependencies. + */ + +var utils = require('./utils'); + +/** + * Initialization middleware, exposing the + * request and response to eachother, as well + * as defaulting the X-Powered-By header field. + * + * @param {Function} app + * @return {Function} + * @api private + */ + +exports.init = function(app){ + return function expressInit(req, res, next){ + if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express'); + req.res = res; + res.req = req; + req.next = next; + + req.__proto__ = app.request; + res.__proto__ = app.response; + + res.locals = res.locals || utils.locals(res); + + next(); + } +}; diff --git a/realtime/node_modules/express/lib/request.js b/realtime/node_modules/express/lib/request.js new file mode 100644 index 00000000..3d41617e --- /dev/null +++ b/realtime/node_modules/express/lib/request.js @@ -0,0 +1,529 @@ + +/** + * Module dependencies. + */ + +var http = require('http') + , utils = require('./utils') + , connect = require('connect') + , fresh = require('fresh') + , parseRange = require('range-parser') + , parse = connect.utils.parseUrl + , mime = connect.mime; + +/** + * Request prototype. + */ + +var req = exports = module.exports = { + __proto__: http.IncomingMessage.prototype +}; + +/** + * Return request header. + * + * The `Referrer` header field is special-cased, + * both `Referrer` and `Referer` are interchangeable. + * + * Examples: + * + * req.get('Content-Type'); + * // => "text/plain" + * + * req.get('content-type'); + * // => "text/plain" + * + * req.get('Something'); + * // => undefined + * + * Aliased as `req.header()`. + * + * @param {String} name + * @return {String} + * @api public + */ + +req.get = +req.header = function(name){ + switch (name = name.toLowerCase()) { + case 'referer': + case 'referrer': + return this.headers.referrer + || this.headers.referer; + default: + return this.headers[name]; + } +}; + +/** + * 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", a comma-delimted list such as "json, html, text/plain", + * an argument list such as `"json", "html", "text/plain"`, + * 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 + * req.accepts('html'); + * // => "html" + * + * // Accept: text/*, application/json + * req.accepts('html'); + * // => "html" + * req.accepts('text/html'); + * // => "text/html" + * req.accepts('json, text'); + * // => "json" + * req.accepts('application/json'); + * // => "application/json" + * + * // Accept: text/*, application/json + * req.accepts('image/png'); + * req.accepts('png'); + * // => undefined + * + * // Accept: text/*;q=.5, application/json + * req.accepts(['html', 'json']); + * req.accepts('html', 'json'); + * req.accepts('html, json'); + * // => "json" + * + * @param {String|Array} type(s) + * @return {String} + * @api public + */ + +req.accepts = function(type){ + var args = arguments.length > 1 ? [].slice.apply(arguments) : type; + return utils.accepts(args, this.get('Accept')); +}; + +/** + * Check if the given `encoding` is accepted. + * + * @param {String} encoding + * @return {Boolean} + * @api public + */ + +req.acceptsEncoding = function(encoding){ + return !! ~this.acceptedEncodings.indexOf(encoding); +}; + +/** + * Check if the given `charset` is acceptable, + * otherwise you should respond with 406 "Not Acceptable". + * + * @param {String} charset + * @return {Boolean} + * @api public + */ + +req.acceptsCharset = function(charset){ + var accepted = this.acceptedCharsets; + return accepted.length + ? !! ~accepted.indexOf(charset) + : true; +}; + +/** + * Check if the given `lang` is acceptable, + * otherwise you should respond with 406 "Not Acceptable". + * + * @param {String} lang + * @return {Boolean} + * @api public + */ + +req.acceptsLanguage = function(lang){ + var accepted = this.acceptedLanguages; + return accepted.length + ? !! ~accepted.indexOf(lang) + : true; +}; + +/** + * Parse Range header field, + * capping to the given `size`. + * + * Unspecified ranges such as "0-" require + * knowledge of your resource length. In + * the case of a byte range this is of course + * the total number of bytes. If the Range + * header field is not given `null` is returned, + * `-1` when unsatisfiable, `-2` when syntactically invalid. + * + * NOTE: remember that ranges are inclusive, so + * for example "Range: users=0-3" should respond + * with 4 users when available, not 3. + * + * @param {Number} size + * @return {Array} + * @api public + */ + +req.range = function(size){ + var range = this.get('Range'); + if (!range) return; + return parseRange(size, range); +}; + +/** + * Return an array of encodings. + * + * Examples: + * + * ['gzip', 'deflate'] + * + * @return {Array} + * @api public + */ + +req.__defineGetter__('acceptedEncodings', function(){ + var accept = this.get('Accept-Encoding'); + return accept + ? accept.trim().split(/ *, */) + : []; +}); + +/** + * Return an array of Accepted media types + * ordered from highest quality to lowest. + * + * Examples: + * + * [ { value: 'application/json', + * quality: 1, + * type: 'application', + * subtype: 'json' }, + * { value: 'text/html', + * quality: 0.5, + * type: 'text', + * subtype: 'html' } ] + * + * @return {Array} + * @api public + */ + +req.__defineGetter__('accepted', function(){ + var accept = this.get('Accept'); + return accept + ? utils.parseAccept(accept) + : []; +}); + +/** + * Return an array of Accepted languages + * ordered from highest quality to lowest. + * + * Examples: + * + * Accept-Language: en;q=.5, en-us + * ['en-us', 'en'] + * + * @return {Array} + * @api public + */ + +req.__defineGetter__('acceptedLanguages', function(){ + var accept = this.get('Accept-Language'); + return accept + ? utils + .parseParams(accept) + .map(function(obj){ + return obj.value; + }) + : []; +}); + +/** + * Return an array of Accepted charsets + * ordered from highest quality to lowest. + * + * Examples: + * + * Accept-Charset: iso-8859-5;q=.2, unicode-1-1;q=0.8 + * ['unicode-1-1', 'iso-8859-5'] + * + * @return {Array} + * @api public + */ + +req.__defineGetter__('acceptedCharsets', function(){ + var accept = this.get('Accept-Charset'); + return accept + ? utils + .parseParams(accept) + .map(function(obj){ + return obj.value; + }) + : []; +}); + +/** + * Return the value of param `name` when present or `defaultValue`. + * + * - Checks route placeholders, ex: _/user/:id_ + * - Checks body params, ex: id=12, {"id":12} + * - Checks query string params, ex: ?id=12 + * + * To utilize request bodies, `req.body` + * should be an object. This can be done by using + * the `connect.bodyParser()` middleware. + * + * @param {String} name + * @param {Mixed} [defaultValue] + * @return {String} + * @api public + */ + +req.param = function(name, defaultValue){ + var params = this.params || {}; + var body = this.body || {}; + var query = this.query || {}; + if (null != params[name] && params.hasOwnProperty(name)) return params[name]; + if (null != body[name]) return body[name]; + if (null != query[name]) return query[name]; + return defaultValue; +}; + +/** + * Check if the incoming request contains the "Content-Type" + * header field, and it contains the give mime `type`. + * + * Examples: + * + * // With Content-Type: text/html; charset=utf-8 + * req.is('html'); + * req.is('text/html'); + * req.is('text/*'); + * // => true + * + * // When Content-Type is application/json + * req.is('json'); + * req.is('application/json'); + * req.is('application/*'); + * // => true + * + * req.is('html'); + * // => false + * + * @param {String} type + * @return {Boolean} + * @api public + */ + +req.is = function(type){ + var ct = this.get('Content-Type'); + if (!ct) return false; + ct = ct.split(';')[0]; + if (!~type.indexOf('/')) type = mime.lookup(type); + if (~type.indexOf('*')) { + type = type.split('/'); + ct = ct.split('/'); + if ('*' == type[0] && type[1] == ct[1]) return true; + if ('*' == type[1] && type[0] == ct[0]) return true; + return false; + } + return !! ~ct.indexOf(type); +}; + +/** + * Return the protocol string "http" or "https" + * when requested with TLS. When the "trust proxy" + * setting is enabled the "X-Forwarded-Proto" header + * field will be trusted. If you're running behind + * a reverse proxy that supplies https for you this + * may be enabled. + * + * @return {String} + * @api public + */ + +req.__defineGetter__('protocol', function(){ + var trustProxy = this.app.get('trust proxy'); + if (this.connection.encrypted) return 'https'; + if (!trustProxy) return 'http'; + var proto = this.get('X-Forwarded-Proto') || 'http'; + return proto.split(/\s*,\s*/)[0]; +}); + +/** + * Short-hand for: + * + * req.protocol == 'https' + * + * @return {Boolean} + * @api public + */ + +req.__defineGetter__('secure', function(){ + return 'https' == this.protocol; +}); + +/** + * Return the remote address, or when + * "trust proxy" is `true` return + * the upstream addr. + * + * @return {String} + * @api public + */ + +req.__defineGetter__('ip', function(){ + return this.ips[0] || this.connection.remoteAddress; +}); + +/** + * When "trust proxy" is `true`, parse + * the "X-Forwarded-For" ip address list. + * + * For example if the value were "client, proxy1, proxy2" + * you would receive the array `["client", "proxy1", "proxy2"]` + * where "proxy2" is the furthest down-stream. + * + * @return {Array} + * @api public + */ + +req.__defineGetter__('ips', function(){ + var trustProxy = this.app.get('trust proxy'); + var val = this.get('X-Forwarded-For'); + return trustProxy && val + ? val.split(/ *, */) + : []; +}); + +/** + * Return basic auth credentials. + * + * Examples: + * + * // http://tobi:hello@example.com + * req.auth + * // => { username: 'tobi', password: 'hello' } + * + * @return {Object} or undefined + * @api public + */ + +req.__defineGetter__('auth', function(){ + // missing + var auth = this.get('Authorization'); + if (!auth) return; + + // malformed + var parts = auth.split(' '); + if ('basic' != parts[0].toLowerCase()) return; + if (!parts[1]) return; + auth = parts[1]; + + // credentials + auth = new Buffer(auth, 'base64').toString().match(/^([^:]*):(.*)$/); + if (!auth) return; + return { username: auth[1], password: auth[2] }; +}); + +/** + * Return subdomains as an array. + * + * Subdomains are the dot-separated parts of the host before the main domain of + * the app. By default, the domain of the app is assumed to be the last two + * parts of the host. This can be changed by setting "subdomain offset". + * + * For example, if the domain is "tobi.ferrets.example.com": + * If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`. + * If "subdomain offset" is 3, req.subdomains is `["tobi"]`. + * + * @return {Array} + * @api public + */ + +req.__defineGetter__('subdomains', function(){ + var offset = this.app.get('subdomain offset'); + return (this.host || '') + .split('.') + .reverse() + .slice(offset); +}); + +/** + * Short-hand for `url.parse(req.url).pathname`. + * + * @return {String} + * @api public + */ + +req.__defineGetter__('path', function(){ + return parse(this).pathname; +}); + +/** + * Parse the "Host" header field hostname. + * + * @return {String} + * @api public + */ + +req.__defineGetter__('host', function(){ + var trustProxy = this.app.get('trust proxy'); + var host = trustProxy && this.get('X-Forwarded-Host'); + host = host || this.get('Host'); + if (!host) return; + return host.split(':')[0]; +}); + +/** + * Check if the request is fresh, aka + * Last-Modified and/or the ETag + * still match. + * + * @return {Boolean} + * @api public + */ + +req.__defineGetter__('fresh', function(){ + var method = this.method; + var s = this.res.statusCode; + + // GET or HEAD for weak freshness validation only + if ('GET' != method && 'HEAD' != method) return false; + + // 2xx or 304 as per rfc2616 14.26 + if ((s >= 200 && s < 300) || 304 == s) { + return fresh(this.headers, this.res._headers); + } + + return false; +}); + +/** + * Check if the request is stale, aka + * "Last-Modified" and / or the "ETag" for the + * resource has changed. + * + * @return {Boolean} + * @api public + */ + +req.__defineGetter__('stale', function(){ + return !this.fresh; +}); + +/** + * Check if the request was an _XMLHttpRequest_. + * + * @return {Boolean} + * @api public + */ + +req.__defineGetter__('xhr', function(){ + var val = this.get('X-Requested-With') || ''; + return 'xmlhttprequest' == val.toLowerCase(); +}); diff --git a/realtime/node_modules/express/lib/response.js b/realtime/node_modules/express/lib/response.js new file mode 100644 index 00000000..31c79c0d --- /dev/null +++ b/realtime/node_modules/express/lib/response.js @@ -0,0 +1,799 @@ +/** + * Module dependencies. + */ + +var http = require('http') + , path = require('path') + , connect = require('connect') + , utils = connect.utils + , sign = require('cookie-signature').sign + , normalizeType = require('./utils').normalizeType + , normalizeTypes = require('./utils').normalizeTypes + , etag = require('./utils').etag + , statusCodes = http.STATUS_CODES + , cookie = require('cookie') + , send = require('send') + , mime = connect.mime + , resolve = require('url').resolve + , basename = path.basename + , extname = path.extname; + +/** + * Response prototype. + */ + +var res = module.exports = { + __proto__: http.ServerResponse.prototype +}; + +/** + * Set status `code`. + * + * @param {Number} code + * @return {ServerResponse} + * @api public + */ + +res.status = function(code){ + this.statusCode = code; + return this; +}; + +/** + * Set Link header field with the given `links`. + * + * Examples: + * + * res.links({ + * next: 'http://api.example.com/users?page=2', + * last: 'http://api.example.com/users?page=5' + * }); + * + * @param {Object} links + * @return {ServerResponse} + * @api public + */ + +res.links = function(links){ + var link = this.get('Link') || ''; + if (link) link += ', '; + return this.set('Link', link + Object.keys(links).map(function(rel){ + return '<' + links[rel] + '>; rel="' + rel + '"'; + }).join(', ')); +}; + +/** + * Send a response. + * + * Examples: + * + * res.send(new Buffer('wahoo')); + * res.send({ some: 'json' }); + * res.send('

some html

'); + * res.send(404, 'Sorry, cant find that'); + * res.send(404); + * + * @param {Mixed} body or status + * @param {Mixed} body + * @return {ServerResponse} + * @api public + */ + +res.send = function(body){ + var req = this.req; + var head = 'HEAD' == req.method; + var len; + + // settings + var app = this.app; + + // allow status / body + if (2 == arguments.length) { + // res.send(body, status) backwards compat + if ('number' != typeof body && 'number' == typeof arguments[1]) { + this.statusCode = arguments[1]; + } else { + this.statusCode = body; + body = arguments[1]; + } + } + + switch (typeof body) { + // response status + case 'number': + this.get('Content-Type') || this.type('txt'); + this.statusCode = body; + body = http.STATUS_CODES[body]; + break; + // string defaulting to html + case 'string': + if (!this.get('Content-Type')) { + this.charset = this.charset || 'utf-8'; + this.type('html'); + } + break; + case 'boolean': + case 'object': + if (null == body) { + body = ''; + } else if (Buffer.isBuffer(body)) { + this.get('Content-Type') || this.type('bin'); + } else { + return this.json(body); + } + break; + } + + // populate Content-Length + if (undefined !== body && !this.get('Content-Length')) { + this.set('Content-Length', len = Buffer.isBuffer(body) + ? body.length + : Buffer.byteLength(body)); + } + + // ETag support + // TODO: W/ support + if (app.settings.etag && len && 'GET' == req.method) { + if (!this.get('ETag')) { + this.set('ETag', etag(body)); + } + } + + // freshness + if (req.fresh) this.statusCode = 304; + + // strip irrelevant headers + if (204 == this.statusCode || 304 == this.statusCode) { + this.removeHeader('Content-Type'); + this.removeHeader('Content-Length'); + this.removeHeader('Transfer-Encoding'); + body = ''; + } + + // respond + this.end(head ? null : body); + return this; +}; + +/** + * Send JSON response. + * + * Examples: + * + * res.json(null); + * res.json({ user: 'tj' }); + * res.json(500, 'oh noes!'); + * res.json(404, 'I dont have that'); + * + * @param {Mixed} obj or status + * @param {Mixed} obj + * @return {ServerResponse} + * @api public + */ + +res.json = function(obj){ + // allow status / body + if (2 == arguments.length) { + // res.json(body, status) backwards compat + if ('number' == typeof arguments[1]) { + this.statusCode = arguments[1]; + } else { + this.statusCode = obj; + obj = arguments[1]; + } + } + + // settings + var app = this.app; + var replacer = app.get('json replacer'); + var spaces = app.get('json spaces'); + var body = JSON.stringify(obj, replacer, spaces); + + // content-type + this.charset = this.charset || 'utf-8'; + this.get('Content-Type') || this.set('Content-Type', 'application/json'); + + return this.send(body); +}; + +/** + * Send JSON response with JSONP callback support. + * + * Examples: + * + * res.jsonp(null); + * res.jsonp({ user: 'tj' }); + * res.jsonp(500, 'oh noes!'); + * res.jsonp(404, 'I dont have that'); + * + * @param {Mixed} obj or status + * @param {Mixed} obj + * @return {ServerResponse} + * @api public + */ + +res.jsonp = function(obj){ + // allow status / body + if (2 == arguments.length) { + // res.json(body, status) backwards compat + if ('number' == typeof arguments[1]) { + this.statusCode = arguments[1]; + } else { + this.statusCode = obj; + obj = arguments[1]; + } + } + + // settings + var app = this.app; + var replacer = app.get('json replacer'); + var spaces = app.get('json spaces'); + var body = JSON.stringify(obj, replacer, spaces) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029'); + var callback = this.req.query[app.get('jsonp callback name')]; + + // content-type + this.charset = this.charset || 'utf-8'; + this.set('Content-Type', 'application/json'); + + // jsonp + if (callback) { + if (Array.isArray(callback)) callback = callback[0]; + this.set('Content-Type', 'text/javascript'); + var cb = callback.replace(/[^\[\]\w$.]/g, ''); + body = 'typeof ' + cb + ' === \'function\' && ' + cb + '(' + body + ');'; + } + + return this.send(body); +}; + +/** + * Transfer the file at the given `path`. + * + * Automatically sets the _Content-Type_ response header field. + * The callback `fn(err)` is invoked when the transfer is complete + * or when an error occurs. Be sure to check `res.sentHeader` + * if you wish to attempt responding, as the header and some data + * may have already been transferred. + * + * Options: + * + * - `maxAge` defaulting to 0 + * - `root` root directory for relative filenames + * + * Examples: + * + * The following example illustrates how `res.sendfile()` may + * be used as an alternative for the `static()` middleware for + * dynamic situations. The code backing `res.sendfile()` is actually + * the same code, so HTTP cache support etc is identical. + * + * app.get('/user/:uid/photos/:file', function(req, res){ + * var uid = req.params.uid + * , file = req.params.file; + * + * req.user.mayViewFilesFrom(uid, function(yes){ + * if (yes) { + * res.sendfile('/uploads/' + uid + '/' + file); + * } else { + * res.send(403, 'Sorry! you cant see that.'); + * } + * }); + * }); + * + * @param {String} path + * @param {Object|Function} options or fn + * @param {Function} fn + * @api public + */ + +res.sendfile = function(path, options, fn){ + var self = this + , req = self.req + , next = this.req.next + , options = options || {} + , done; + + // support function as second arg + if ('function' == typeof options) { + fn = options; + options = {}; + } + + // socket errors + req.socket.on('error', error); + + // errors + function error(err) { + if (done) return; + done = true; + + // clean up + cleanup(); + if (!self.headerSent) self.removeHeader('Content-Disposition'); + + // callback available + if (fn) return fn(err); + + // list in limbo if there's no callback + if (self.headerSent) return; + + // delegate + next(err); + } + + // streaming + function stream(stream) { + if (done) return; + cleanup(); + if (fn) stream.on('end', fn); + } + + // cleanup + function cleanup() { + req.socket.removeListener('error', error); + } + + // transfer + var file = send(req, path); + if (options.root) file.root(options.root); + file.maxage(options.maxAge || 0); + file.on('error', error); + file.on('directory', next); + file.on('stream', stream); + file.pipe(this); + this.on('finish', cleanup); +}; + +/** + * Transfer the file at the given `path` as an attachment. + * + * Optionally providing an alternate attachment `filename`, + * and optional callback `fn(err)`. The callback is invoked + * when the data transfer is complete, or when an error has + * ocurred. Be sure to check `res.headerSent` if you plan to respond. + * + * This method uses `res.sendfile()`. + * + * @param {String} path + * @param {String|Function} filename or fn + * @param {Function} fn + * @api public + */ + +res.download = function(path, filename, fn){ + // support function as second arg + if ('function' == typeof filename) { + fn = filename; + filename = null; + } + + filename = filename || path; + this.set('Content-Disposition', 'attachment; filename="' + basename(filename) + '"'); + return this.sendfile(path, fn); +}; + +/** + * Set _Content-Type_ response header with `type` through `mime.lookup()` + * when it does not contain "/", or set the Content-Type to `type` otherwise. + * + * Examples: + * + * res.type('.html'); + * res.type('html'); + * res.type('json'); + * res.type('application/json'); + * res.type('png'); + * + * @param {String} type + * @return {ServerResponse} for chaining + * @api public + */ + +res.contentType = +res.type = function(type){ + return this.set('Content-Type', ~type.indexOf('/') + ? type + : mime.lookup(type)); +}; + +/** + * Respond to the Acceptable formats using an `obj` + * of mime-type callbacks. + * + * This method uses `req.accepted`, an array of + * acceptable types ordered by their quality values. + * When "Accept" is not present the _first_ callback + * is invoked, otherwise the first match is used. When + * no match is performed the server responds with + * 406 "Not Acceptable". + * + * Content-Type is set for you, however if you choose + * you may alter this within the callback using `res.type()` + * or `res.set('Content-Type', ...)`. + * + * res.format({ + * 'text/plain': function(){ + * res.send('hey'); + * }, + * + * 'text/html': function(){ + * res.send('

hey

'); + * }, + * + * 'appliation/json': function(){ + * res.send({ message: 'hey' }); + * } + * }); + * + * In addition to canonicalized MIME types you may + * also use extnames mapped to these types: + * + * res.format({ + * text: function(){ + * res.send('hey'); + * }, + * + * html: function(){ + * res.send('

hey

'); + * }, + * + * json: function(){ + * res.send({ message: 'hey' }); + * } + * }); + * + * By default Express passes an `Error` + * with a `.status` of 406 to `next(err)` + * if a match is not made. If you provide + * a `.default` callback it will be invoked + * instead. + * + * @param {Object} obj + * @return {ServerResponse} for chaining + * @api public + */ + +res.format = function(obj){ + var req = this.req + , next = req.next; + + var fn = obj.default; + if (fn) delete obj.default; + var keys = Object.keys(obj); + + var key = req.accepts(keys); + + this.vary("Accept"); + + if (key) { + var type = normalizeType(key).value; + var charset = mime.charsets.lookup(type); + if (charset) type += '; charset=' + charset; + this.set('Content-Type', type); + obj[key](req, this, next); + } else if (fn) { + fn(); + } else { + var err = new Error('Not Acceptable'); + err.status = 406; + err.types = normalizeTypes(keys).map(function(o){ return o.value }); + next(err); + } + + return this; +}; + +/** + * Set _Content-Disposition_ header to _attachment_ with optional `filename`. + * + * @param {String} filename + * @return {ServerResponse} + * @api public + */ + +res.attachment = function(filename){ + if (filename) this.type(extname(filename)); + this.set('Content-Disposition', filename + ? 'attachment; filename="' + basename(filename) + '"' + : 'attachment'); + return this; +}; + +/** + * Set header `field` to `val`, or pass + * an object of header fields. + * + * Examples: + * + * res.set('Foo', ['bar', 'baz']); + * res.set('Accept', 'application/json'); + * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' }); + * + * Aliased as `res.header()`. + * + * @param {String|Object|Array} field + * @param {String} val + * @return {ServerResponse} for chaining + * @api public + */ + +res.set = +res.header = function(field, val){ + if (2 == arguments.length) { + if (Array.isArray(val)) val = val.map(String); + else val = String(val); + this.setHeader(field, val); + } else { + for (var key in field) { + this.set(key, field[key]); + } + } + return this; +}; + +/** + * Get value for header `field`. + * + * @param {String} field + * @return {String} + * @api public + */ + +res.get = function(field){ + return this.getHeader(field); +}; + +/** + * Clear cookie `name`. + * + * @param {String} name + * @param {Object} options + * @param {ServerResponse} for chaining + * @api public + */ + +res.clearCookie = function(name, options){ + var opts = { expires: new Date(1), path: '/' }; + return this.cookie(name, '', options + ? utils.merge(opts, options) + : opts); +}; + +/** + * Set cookie `name` to `val`, with the given `options`. + * + * Options: + * + * - `maxAge` max-age in milliseconds, converted to `expires` + * - `signed` sign the cookie + * - `path` defaults to "/" + * + * Examples: + * + * // "Remember Me" for 15 minutes + * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true }); + * + * // save as above + * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true }) + * + * @param {String} name + * @param {String|Object} val + * @param {Options} options + * @api public + */ + +res.cookie = function(name, val, options){ + options = utils.merge({}, options); + var secret = this.req.secret; + var signed = options.signed; + if (signed && !secret) throw new Error('connect.cookieParser("secret") required for signed cookies'); + if ('number' == typeof val) val = val.toString(); + if ('object' == typeof val) val = 'j:' + JSON.stringify(val); + if (signed) val = 's:' + sign(val, secret); + if ('maxAge' in options) { + options.expires = new Date(Date.now() + options.maxAge); + options.maxAge /= 1000; + } + if (null == options.path) options.path = '/'; + this.set('Set-Cookie', cookie.serialize(name, String(val), options)); + return this; +}; + + +/** + * Set the location header to `url`. + * + * The given `url` can also be "back", which redirects + * to the _Referrer_ or _Referer_ headers or "/". + * + * Examples: + * + * res.location('/foo/bar').; + * res.location('http://example.com'); + * res.location('../login'); // /blog/post/1 -> /blog/login + * + * Mounting: + * + * When an application is mounted and `res.location()` + * is given a path that does _not_ lead with "/" it becomes + * relative to the mount-point. For example if the application + * is mounted at "/blog", the following would become "/blog/login". + * + * res.location('login'); + * + * While the leading slash would result in a location of "/login": + * + * res.location('/login'); + * + * @param {String} url + * @api public + */ + +res.location = function(url){ + var app = this.app + , req = this.req + , path; + + // "back" is an alias for the referrer + if ('back' == url) url = req.get('Referrer') || '/'; + + // relative + if (!~url.indexOf('://') && 0 != url.indexOf('//')) { + // relative to path + if ('.' == url[0]) { + path = req.originalUrl.split('?')[0]; + path = path + ('/' == path[path.length - 1] ? '' : '/'); + url = resolve(path, url); + // relative to mount-point + } else if ('/' != url[0]) { + path = app.path(); + url = path + '/' + url; + } + } + + // Respond + this.set('Location', url); + return this; +}; + +/** + * Redirect to the given `url` with optional response `status` + * defaulting to 302. + * + * The resulting `url` is determined by `res.location()`, so + * it will play nicely with mounted apps, relative paths, + * `"back"` etc. + * + * Examples: + * + * res.redirect('/foo/bar'); + * res.redirect('http://example.com'); + * res.redirect(301, 'http://example.com'); + * res.redirect('http://example.com', 301); + * res.redirect('../login'); // /blog/post/1 -> /blog/login + * + * @param {String} url + * @param {Number} code + * @api public + */ + +res.redirect = function(url){ + var head = 'HEAD' == this.req.method + , status = 302 + , body; + + // allow status / url + if (2 == arguments.length) { + if ('number' == typeof url) { + status = url; + url = arguments[1]; + } else { + status = arguments[1]; + } + } + + // Set location header + this.location(url); + url = this.get('Location'); + + // Support text/{plain,html} by default + this.format({ + text: function(){ + body = statusCodes[status] + '. Redirecting to ' + encodeURI(url); + }, + + html: function(){ + var u = utils.escape(url); + body = '

' + statusCodes[status] + '. Redirecting to ' + u + '

'; + }, + + default: function(){ + body = ''; + } + }); + + // Respond + this.statusCode = status; + this.set('Content-Length', Buffer.byteLength(body)); + this.end(head ? null : body); +}; + +/** + * Add `field` to Vary. If already present in the Vary set, then + * this call is simply ignored. + * + * @param {Array|String} field + * @param {ServerResponse} for chaining + * @api public + */ + +res.vary = function(field){ + var self = this; + + // nothing + if (!field) return this; + + // array + if (Array.isArray(field)) { + field.forEach(function(field){ + self.vary(field); + }); + return; + } + + var vary = this.get('Vary'); + + // append + if (vary) { + vary = vary.split(/ *, */); + if (!~vary.indexOf(field)) vary.push(field); + this.set('Vary', vary.join(', ')); + return this; + } + + // set + this.set('Vary', field); + return this; +}; + +/** + * Render `view` with the given `options` and optional callback `fn`. + * When a callback function is given a response will _not_ be made + * automatically, otherwise a response of _200_ and _text/html_ is given. + * + * Options: + * + * - `cache` boolean hinting to the engine it should cache + * - `filename` filename of the view being rendered + * + * @param {String} view + * @param {Object|Function} options or callback function + * @param {Function} fn + * @api public + */ + +res.render = function(view, options, fn){ + var self = this + , options = options || {} + , req = this.req + , app = req.app; + + // support callback function as second arg + if ('function' == typeof options) { + fn = options, options = {}; + } + + // merge res.locals + options._locals = self.locals; + + // default callback to respond + fn = fn || function(err, str){ + if (err) return req.next(err); + self.send(str); + }; + + // render + app.render(view, options, fn); +}; diff --git a/realtime/node_modules/express/lib/router/index.js b/realtime/node_modules/express/lib/router/index.js new file mode 100644 index 00000000..cd2f2693 --- /dev/null +++ b/realtime/node_modules/express/lib/router/index.js @@ -0,0 +1,321 @@ +/** + * Module dependencies. + */ + +var Route = require('./route') + , utils = require('../utils') + , methods = require('methods') + , debug = require('debug')('express:router') + , parse = require('connect').utils.parseUrl; + +/** + * Expose `Router` constructor. + */ + +exports = module.exports = Router; + +/** + * Initialize a new `Router` with the given `options`. + * + * @param {Object} options + * @api private + */ + +function Router(options) { + options = options || {}; + var self = this; + this.map = {}; + this.params = {}; + this._params = []; + this.caseSensitive = options.caseSensitive; + this.strict = options.strict; + this.middleware = function router(req, res, next){ + self._dispatch(req, res, next); + }; +} + +/** + * Register a param callback `fn` for the given `name`. + * + * @param {String|Function} name + * @param {Function} fn + * @return {Router} for chaining + * @api public + */ + +Router.prototype.param = function(name, fn){ + // param logic + if ('function' == typeof name) { + this._params.push(name); + return; + } + + // apply param functions + var params = this._params + , len = params.length + , ret; + + for (var i = 0; i < len; ++i) { + if (ret = params[i](name, fn)) { + fn = ret; + } + } + + // ensure we end up with a + // middleware function + if ('function' != typeof fn) { + throw new Error('invalid param() call for ' + name + ', got ' + fn); + } + + (this.params[name] = this.params[name] || []).push(fn); + return this; +}; + +/** + * Route dispatcher aka the route "middleware". + * + * @param {IncomingMessage} req + * @param {ServerResponse} res + * @param {Function} next + * @api private + */ + +Router.prototype._dispatch = function(req, res, next){ + var params = this.params + , self = this; + + debug('dispatching %s %s (%s)', req.method, req.url, req.originalUrl); + + // route dispatch + (function pass(i, err){ + var paramCallbacks + , paramIndex = 0 + , paramVal + , route + , keys + , key; + + // match next route + function nextRoute(err) { + pass(req._route_index + 1, err); + } + + // match route + req.route = route = self.matchRequest(req, i); + + // implied OPTIONS + if (!route && 'OPTIONS' == req.method) return self._options(req, res, next); + + // no route + if (!route) return next(err); + debug('matched %s %s', route.method, route.path); + + // we have a route + // start at param 0 + req.params = route.params; + keys = route.keys; + i = 0; + + // param callbacks + function param(err) { + paramIndex = 0; + key = keys[i++]; + paramVal = key && req.params[key.name]; + paramCallbacks = key && params[key.name]; + + try { + if ('route' == err) { + nextRoute(); + } else if (err) { + i = 0; + callbacks(err); + } else if (paramCallbacks && undefined !== paramVal) { + paramCallback(); + } else if (key) { + param(); + } else { + i = 0; + callbacks(); + } + } catch (err) { + param(err); + } + }; + + param(err); + + // single param callbacks + function paramCallback(err) { + var fn = paramCallbacks[paramIndex++]; + if (err || !fn) return param(err); + fn(req, res, paramCallback, paramVal, key.name); + } + + // invoke route callbacks + function callbacks(err) { + var fn = route.callbacks[i++]; + try { + if ('route' == err) { + nextRoute(); + } else if (err && fn) { + if (fn.length < 4) return callbacks(err); + fn(err, req, res, callbacks); + } else if (fn) { + if (fn.length < 4) return fn(req, res, callbacks); + callbacks(); + } else { + nextRoute(err); + } + } catch (err) { + callbacks(err); + } + } + })(0); +}; + +/** + * Respond to __OPTIONS__ method. + * + * @param {IncomingMessage} req + * @param {ServerResponse} res + * @api private + */ + +Router.prototype._options = function(req, res, next){ + var path = parse(req).pathname + , body = this._optionsFor(path).join(','); + if (!body) return next(); + res.set('Allow', body).send(body); +}; + +/** + * Return an array of HTTP verbs or "options" for `path`. + * + * @param {String} path + * @return {Array} + * @api private + */ + +Router.prototype._optionsFor = function(path){ + var self = this; + return methods.filter(function(method){ + var routes = self.map[method]; + if (!routes || 'options' == method) return; + for (var i = 0, len = routes.length; i < len; ++i) { + if (routes[i].match(path)) return true; + } + }).map(function(method){ + return method.toUpperCase(); + }); +}; + +/** + * Attempt to match a route for `req` + * with optional starting index of `i` + * defaulting to 0. + * + * @param {IncomingMessage} req + * @param {Number} i + * @return {Route} + * @api private + */ + +Router.prototype.matchRequest = function(req, i, head){ + var method = req.method.toLowerCase() + , url = parse(req) + , path = url.pathname + , routes = this.map + , i = i || 0 + , route; + + // HEAD support + if (!head && 'head' == method) { + route = this.matchRequest(req, i, true); + if (route) return route; + method = 'get'; + } + + // routes for this method + if (routes = routes[method]) { + + // matching routes + for (var len = routes.length; i < len; ++i) { + route = routes[i]; + if (route.match(path)) { + req._route_index = i; + return route; + } + } + } +}; + +/** + * Attempt to match a route for `method` + * and `url` with optional starting + * index of `i` defaulting to 0. + * + * @param {String} method + * @param {String} url + * @param {Number} i + * @return {Route} + * @api private + */ + +Router.prototype.match = function(method, url, i, head){ + var req = { method: method, url: url }; + return this.matchRequest(req, i, head); +}; + +/** + * Route `method`, `path`, and one or more callbacks. + * + * @param {String} method + * @param {String} path + * @param {Function} callback... + * @return {Router} for chaining + * @api private + */ + +Router.prototype.route = function(method, path, callbacks){ + var method = method.toLowerCase() + , callbacks = utils.flatten([].slice.call(arguments, 2)); + + // ensure path was given + if (!path) throw new Error('Router#' + method + '() requires a path'); + + // ensure all callbacks are functions + callbacks.forEach(function(fn){ + if ('function' == typeof fn) return; + var type = {}.toString.call(fn); + var msg = '.' + method + '() requires callback functions but got a ' + type; + throw new Error(msg); + }); + + // create the route + debug('defined %s %s', method, path); + var route = new Route(method, path, callbacks, { + sensitive: this.caseSensitive, + strict: this.strict + }); + + // add it + (this.map[method] = this.map[method] || []).push(route); + return this; +}; + +Router.prototype.all = function(path) { + var self = this; + var args = [].slice.call(arguments); + methods.forEach(function(method){ + self.route.apply(self, [method].concat(args)); + }); + return this; +}; + +methods.forEach(function(method){ + Router.prototype[method] = function(path){ + var args = [method].concat([].slice.call(arguments)); + this.route.apply(this, args); + return this; + }; +}); diff --git a/realtime/node_modules/express/lib/router/route.js b/realtime/node_modules/express/lib/router/route.js new file mode 100644 index 00000000..d7ec88d2 --- /dev/null +++ b/realtime/node_modules/express/lib/router/route.js @@ -0,0 +1,78 @@ + +/** + * Module dependencies. + */ + +var utils = require('../utils'); + +/** + * Expose `Route`. + */ + +module.exports = Route; + +/** + * Initialize `Route` with the given HTTP `method`, `path`, + * and an array of `callbacks` and `options`. + * + * Options: + * + * - `sensitive` enable case-sensitive routes + * - `strict` enable strict matching for trailing slashes + * + * @param {String} method + * @param {String} path + * @param {Array} callbacks + * @param {Object} options. + * @api private + */ + +function Route(method, path, callbacks, options) { + options = options || {}; + this.path = path; + this.method = method; + this.callbacks = callbacks; + this.regexp = utils.pathRegexp(path + , this.keys = [] + , options.sensitive + , options.strict); +} + +/** + * Check if this route matches `path`, if so + * populate `.params`. + * + * @param {String} path + * @return {Boolean} + * @api private + */ + +Route.prototype.match = function(path){ + var keys = this.keys + , params = this.params = [] + , m = this.regexp.exec(path); + + if (!m) return false; + + for (var i = 1, len = m.length; i < len; ++i) { + var key = keys[i - 1]; + + try { + var val = 'string' == typeof m[i] + ? decodeURIComponent(m[i]) + : m[i]; + } catch(e) { + var err = new Error("Failed to decode param '" + m[i] + "'"); + err.status = 400; + throw err; + } + + if (key) { + params[key.name] = val; + } else { + params.push(val); + } + } + + return true; +}; diff --git a/realtime/node_modules/express/lib/utils.js b/realtime/node_modules/express/lib/utils.js new file mode 100644 index 00000000..b30873a8 --- /dev/null +++ b/realtime/node_modules/express/lib/utils.js @@ -0,0 +1,314 @@ + +/** + * Module dependencies. + */ + +var mime = require('connect').mime + , crc32 = require('buffer-crc32'); + +/** + * toString ref. + */ + +var toString = {}.toString; + +/** + * Return ETag for `body`. + * + * @param {String|Buffer} body + * @return {String} + * @api private + */ + +exports.etag = function(body){ + return '"' + crc32.signed(body) + '"'; +}; + +/** + * Make `locals()` bound to the given `obj`. + * + * This is used for `app.locals` and `res.locals`. + * + * @param {Object} obj + * @return {Function} + * @api private + */ + +exports.locals = function(){ + function locals(obj){ + for (var key in obj) locals[key] = obj[key]; + return obj; + }; + + return locals; +}; + +/** + * Check if `path` looks absolute. + * + * @param {String} path + * @return {Boolean} + * @api private + */ + +exports.isAbsolute = function(path){ + if ('/' == path[0]) return true; + if (':' == path[1] && '\\' == path[2]) return true; + if ('\\\\' == path.substring(0, 2)) return true; // Microsoft Azure absolute path +}; + +/** + * Flatten the given `arr`. + * + * @param {Array} arr + * @return {Array} + * @api private + */ + +exports.flatten = function(arr, ret){ + var ret = ret || [] + , len = arr.length; + for (var i = 0; i < len; ++i) { + if (Array.isArray(arr[i])) { + exports.flatten(arr[i], ret); + } else { + ret.push(arr[i]); + } + } + return ret; +}; + +/** + * Normalize the given `type`, for example "html" becomes "text/html". + * + * @param {String} type + * @return {Object} + * @api private + */ + +exports.normalizeType = function(type){ + return ~type.indexOf('/') + ? acceptParams(type) + : { value: mime.lookup(type), params: {} }; +}; + +/** + * Normalize `types`, for example "html" becomes "text/html". + * + * @param {Array} types + * @return {Array} + * @api private + */ + +exports.normalizeTypes = function(types){ + var ret = []; + + for (var i = 0; i < types.length; ++i) { + ret.push(exports.normalizeType(types[i])); + } + + return ret; +}; + +/** + * Return the acceptable type in `types`, if any. + * + * @param {Array} types + * @param {String} str + * @return {String} + * @api private + */ + +exports.acceptsArray = function(types, str){ + // accept anything when Accept is not present + if (!str) return types[0]; + + // parse + var accepted = exports.parseAccept(str) + , normalized = exports.normalizeTypes(types) + , len = accepted.length; + + for (var i = 0; i < len; ++i) { + for (var j = 0, jlen = types.length; j < jlen; ++j) { + if (exports.accept(normalized[j], accepted[i])) { + return types[j]; + } + } + } +}; + +/** + * Check if `type(s)` are acceptable based on + * the given `str`. + * + * @param {String|Array} type(s) + * @param {String} str + * @return {Boolean|String} + * @api private + */ + +exports.accepts = function(type, str){ + if ('string' == typeof type) type = type.split(/ *, */); + return exports.acceptsArray(type, str); +}; + +/** + * Check if `type` array is acceptable for `other`. + * + * @param {Object} type + * @param {Object} other + * @return {Boolean} + * @api private + */ + +exports.accept = function(type, other){ + var t = type.value.split('/'); + return (t[0] == other.type || '*' == other.type) + && (t[1] == other.subtype || '*' == other.subtype) + && paramsEqual(type.params, other.params); +}; + +/** + * Check if accept params are equal. + * + * @param {Object} a + * @param {Object} b + * @return {Boolean} + * @api private + */ + +function paramsEqual(a, b){ + return !Object.keys(a).some(function(k) { + return a[k] != b[k]; + }); +} + +/** + * Parse accept `str`, returning + * an array objects containing + * `.type` and `.subtype` along + * with the values provided by + * `parseQuality()`. + * + * @param {Type} name + * @return {Type} + * @api private + */ + +exports.parseAccept = function(str){ + return exports + .parseParams(str) + .map(function(obj){ + var parts = obj.value.split('/'); + obj.type = parts[0]; + obj.subtype = parts[1]; + return obj; + }); +}; + +/** + * Parse quality `str`, returning an + * array of objects with `.value`, + * `.quality` and optional `.params` + * + * @param {String} str + * @return {Array} + * @api private + */ + +exports.parseParams = function(str){ + return str + .split(/ *, */) + .map(acceptParams) + .filter(function(obj){ + return obj.quality; + }) + .sort(function(a, b){ + if (a.quality === b.quality) { + return a.originalIndex - b.originalIndex; + } else { + return b.quality - a.quality; + } + }); +}; + +/** + * Parse accept params `str` returning an + * object with `.value`, `.quality` and `.params`. + * also includes `.originalIndex` for stable sorting + * + * @param {String} str + * @return {Object} + * @api private + */ + +function acceptParams(str, index) { + var parts = str.split(/ *; */); + var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index }; + + for (var i = 1; i < parts.length; ++i) { + var pms = parts[i].split(/ *= */); + if ('q' == pms[0]) { + ret.quality = parseFloat(pms[1]); + } else { + ret.params[pms[0]] = pms[1]; + } + } + + return ret; +} + +/** + * Escape special characters in the given string of html. + * + * @param {String} html + * @return {String} + * @api private + */ + +exports.escape = function(html) { + return String(html) + .replace(/&/g, '&') + .replace(/"/g, '"') + .replace(//g, '>'); +}; + +/** + * Normalize the given path string, + * returning a regular expression. + * + * An empty array should be passed, + * which will contain the placeholder + * key names. For example "/user/:id" will + * then contain ["id"]. + * + * @param {String|RegExp|Array} path + * @param {Array} keys + * @param {Boolean} sensitive + * @param {Boolean} strict + * @return {RegExp} + * @api private + */ + +exports.pathRegexp = function(path, keys, sensitive, strict) { + if (toString.call(path) == '[object RegExp]') return path; + if (Array.isArray(path)) path = '(' + path.join('|') + ')'; + path = path + .concat(strict ? '' : '/?') + .replace(/\/\(/g, '(?:/') + .replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?(\*)?/g, function(_, slash, format, key, capture, optional, star){ + keys.push({ name: key, optional: !! optional }); + slash = slash || ''; + return '' + + (optional ? '' : slash) + + '(?:' + + (optional ? slash : '') + + (format || '') + (capture || (format && '([^/.]+?)' || '([^/]+?)')) + ')' + + (optional || '') + + (star ? '(/*)?' : ''); + }) + .replace(/([\/.])/g, '\\$1') + .replace(/\*/g, '(.*)'); + return new RegExp('^' + path + '$', sensitive ? '' : 'i'); +} diff --git a/realtime/node_modules/express/lib/view.js b/realtime/node_modules/express/lib/view.js new file mode 100644 index 00000000..b9dc69e0 --- /dev/null +++ b/realtime/node_modules/express/lib/view.js @@ -0,0 +1,77 @@ +/** + * Module dependencies. + */ + +var path = require('path') + , fs = require('fs') + , utils = require('./utils') + , dirname = path.dirname + , basename = path.basename + , extname = path.extname + , exists = fs.existsSync || path.existsSync + , join = path.join; + +/** + * Expose `View`. + */ + +module.exports = View; + +/** + * Initialize a new `View` with the given `name`. + * + * Options: + * + * - `defaultEngine` the default template engine name + * - `engines` template engine require() cache + * - `root` root path for view lookup + * + * @param {String} name + * @param {Object} options + * @api private + */ + +function View(name, options) { + options = options || {}; + this.name = name; + this.root = options.root; + var engines = options.engines; + this.defaultEngine = options.defaultEngine; + var ext = this.ext = extname(name); + if (!ext && !this.defaultEngine) throw new Error('No default engine was specified and no extension was provided.'); + if (!ext) name += (ext = this.ext = ('.' != this.defaultEngine[0] ? '.' : '') + this.defaultEngine); + this.engine = engines[ext] || (engines[ext] = require(ext.slice(1)).__express); + this.path = this.lookup(name); +} + +/** + * Lookup view by the given `path` + * + * @param {String} path + * @return {String} + * @api private + */ + +View.prototype.lookup = function(path){ + var ext = this.ext; + + // . + if (!utils.isAbsolute(path)) path = join(this.root, path); + if (exists(path)) return path; + + // /index. + path = join(dirname(path), basename(path, ext), 'index' + ext); + if (exists(path)) return path; +}; + +/** + * Render with the given `options` and callback `fn(err, str)`. + * + * @param {Object} options + * @param {Function} fn + * @api private + */ + +View.prototype.render = function(options, fn){ + this.engine(this.path, options, fn); +}; diff --git a/realtime/node_modules/express/node_modules/buffer-crc32/.npmignore b/realtime/node_modules/express/node_modules/buffer-crc32/.npmignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/realtime/node_modules/express/node_modules/buffer-crc32/.npmignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/buffer-crc32/.travis.yml b/realtime/node_modules/express/node_modules/buffer-crc32/.travis.yml new file mode 100644 index 00000000..7a902e8c --- /dev/null +++ b/realtime/node_modules/express/node_modules/buffer-crc32/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - 0.6 + - 0.8 +notifications: + email: + recipients: + - brianloveswords@gmail.com \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/buffer-crc32/README.md b/realtime/node_modules/express/node_modules/buffer-crc32/README.md new file mode 100644 index 00000000..0d9d8b83 --- /dev/null +++ b/realtime/node_modules/express/node_modules/buffer-crc32/README.md @@ -0,0 +1,47 @@ +# buffer-crc32 + +[![Build Status](https://secure.travis-ci.org/brianloveswords/buffer-crc32.png?branch=master)](http://travis-ci.org/brianloveswords/buffer-crc32) + +crc32 that works with binary data and fancy character sets, outputs +buffer, signed or unsigned data and has tests. + +Derived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix + +# install +``` +npm install buffer-crc32 +``` + +# example +```js +var crc32 = require('buffer-crc32'); +// works with buffers +var buf = Buffer([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00]) +crc32(buf) // -> + +// has convenience methods for getting signed or unsigned ints +crc32.signed(buf) // -> -1805997238 +crc32.unsigned(buf) // -> 2488970058 + +// will cast to buffer if given a string, so you can +// directly use foreign characters safely +crc32('自動販売機') // -> + +// and works in append mode too +var partialCrc = crc32('hey'); +var partialCrc = crc32(' ', partialCrc); +var partialCrc = crc32('sup', partialCrc); +var partialCrc = crc32(' ', partialCrc); +var finalCrc = crc32('bros', partialCrc); // -> +``` + +# tests +This was tested against the output of zlib's crc32 method. You can run +the tests with`npm test` (requires tap) + +# see also +https://github.com/alexgorbatchev/node-crc, `crc.buffer.crc32` also +supports buffer inputs and return unsigned ints (thanks @tjholowaychuk). + +# license +MIT/X11 diff --git a/realtime/node_modules/express/node_modules/buffer-crc32/index.js b/realtime/node_modules/express/node_modules/buffer-crc32/index.js new file mode 100644 index 00000000..e29ce3eb --- /dev/null +++ b/realtime/node_modules/express/node_modules/buffer-crc32/index.js @@ -0,0 +1,88 @@ +var Buffer = require('buffer').Buffer; + +var CRC_TABLE = [ + 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 bufferizeInt(num) { + var tmp = Buffer(4); + tmp.writeInt32BE(num, 0); + return tmp; +} + +function _crc32(buf, previous) { + if (!Buffer.isBuffer(buf)) { + buf = Buffer(buf); + } + if (Buffer.isBuffer(previous)) { + previous = previous.readUInt32BE(0); + } + var crc = ~~previous ^ -1; + for (var n = 0; n < buf.length; n++) { + crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8); + } + return (crc ^ -1); +} + +function crc32() { + return bufferizeInt(_crc32.apply(null, arguments)); +} +crc32.signed = function () { + return _crc32.apply(null, arguments); +}; +crc32.unsigned = function () { + return _crc32.apply(null, arguments) >>> 0; +}; + +module.exports = crc32; diff --git a/realtime/node_modules/express/node_modules/buffer-crc32/package.json b/realtime/node_modules/express/node_modules/buffer-crc32/package.json new file mode 100644 index 00000000..cd07ea63 --- /dev/null +++ b/realtime/node_modules/express/node_modules/buffer-crc32/package.json @@ -0,0 +1,40 @@ +{ + "author": { + "name": "Brian J. Brennan", + "email": "brianloveswords@gmail.com", + "url": "http://bjb.io" + }, + "name": "buffer-crc32", + "description": "A pure javascript CRC32 algorithm that plays nice with binary data", + "version": "0.2.1", + "contributors": [ + { + "name": "Vladimir Kuznetsov" + } + ], + "homepage": "https://github.com/brianloveswords/buffer-crc32", + "repository": { + "type": "git", + "url": "git://github.com/brianloveswords/buffer-crc32.git" + }, + "main": "index.js", + "scripts": { + "test": "./node_modules/.bin/tap tests/*.test.js" + }, + "dependencies": {}, + "devDependencies": { + "tap": "~0.2.5" + }, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "readme": "# buffer-crc32\n\n[![Build Status](https://secure.travis-ci.org/brianloveswords/buffer-crc32.png?branch=master)](http://travis-ci.org/brianloveswords/buffer-crc32)\n\ncrc32 that works with binary data and fancy character sets, outputs\nbuffer, signed or unsigned data and has tests.\n\nDerived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix\n\n# install\n```\nnpm install buffer-crc32\n```\n\n# example\n```js\nvar crc32 = require('buffer-crc32');\n// works with buffers\nvar buf = Buffer([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00])\ncrc32(buf) // -> \n\n// has convenience methods for getting signed or unsigned ints\ncrc32.signed(buf) // -> -1805997238\ncrc32.unsigned(buf) // -> 2488970058\n\n// will cast to buffer if given a string, so you can\n// directly use foreign characters safely\ncrc32('自動販売機') // -> \n\n// and works in append mode too\nvar partialCrc = crc32('hey');\nvar partialCrc = crc32(' ', partialCrc);\nvar partialCrc = crc32('sup', partialCrc);\nvar partialCrc = crc32(' ', partialCrc);\nvar finalCrc = crc32('bros', partialCrc); // -> \n```\n\n# tests\nThis was tested against the output of zlib's crc32 method. You can run\nthe tests with`npm test` (requires tap)\n\n# see also\nhttps://github.com/alexgorbatchev/node-crc, `crc.buffer.crc32` also\nsupports buffer inputs and return unsigned ints (thanks @tjholowaychuk).\n\n# license\nMIT/X11\n", + "readmeFilename": "README.md", + "_id": "buffer-crc32@0.2.1", + "dist": { + "shasum": "1481647097358eba59b54a3a1e57ea5531016e58" + }, + "_from": "buffer-crc32@0.2.1", + "_resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz" +} diff --git a/realtime/node_modules/express/node_modules/buffer-crc32/tests/crc.test.js b/realtime/node_modules/express/node_modules/buffer-crc32/tests/crc.test.js new file mode 100644 index 00000000..bb0f9efc --- /dev/null +++ b/realtime/node_modules/express/node_modules/buffer-crc32/tests/crc.test.js @@ -0,0 +1,89 @@ +var crc32 = require('..'); +var test = require('tap').test; + +test('simple crc32 is no problem', function (t) { + var input = Buffer('hey sup bros'); + var expected = Buffer([0x47, 0xfa, 0x55, 0x70]); + t.same(crc32(input), expected); + t.end(); +}); + +test('another simple one', function (t) { + var input = Buffer('IEND'); + var expected = Buffer([0xae, 0x42, 0x60, 0x82]); + t.same(crc32(input), expected); + t.end(); +}); + +test('slightly more complex', function (t) { + var input = Buffer([0x00, 0x00, 0x00]); + var expected = Buffer([0xff, 0x41, 0xd9, 0x12]); + t.same(crc32(input), expected); + t.end(); +}); + +test('complex crc32 gets calculated like a champ', function (t) { + var input = Buffer('शीर्षक'); + var expected = Buffer([0x17, 0xb8, 0xaf, 0xf1]); + t.same(crc32(input), expected); + t.end(); +}); + +test('casts to buffer if necessary', function (t) { + var input = 'शीर्षक'; + var expected = Buffer([0x17, 0xb8, 0xaf, 0xf1]); + t.same(crc32(input), expected); + t.end(); +}); + +test('can do signed', function (t) { + var input = 'ham sandwich'; + var expected = -1891873021; + t.same(crc32.signed(input), expected); + t.end(); +}); + +test('can do unsigned', function (t) { + var input = 'bear sandwich'; + var expected = 3711466352; + t.same(crc32.unsigned(input), expected); + t.end(); +}); + + +test('simple crc32 in append mode', function (t) { + var input = [Buffer('hey'), Buffer(' '), Buffer('sup'), Buffer(' '), Buffer('bros')]; + var expected = Buffer([0x47, 0xfa, 0x55, 0x70]); + for (var crc = 0, i = 0; i < input.length; i++) { + crc = crc32(input[i], crc); + } + t.same(crc, expected); + t.end(); +}); + + +test('can do signed in append mode', function (t) { + var input1 = 'ham'; + var input2 = ' '; + var input3 = 'sandwich'; + var expected = -1891873021; + + var crc = crc32.signed(input1); + crc = crc32.signed(input2, crc); + crc = crc32.signed(input3, crc); + + t.same(crc, expected); + t.end(); +}); + +test('can do unsigned in append mode', function (t) { + var input1 = 'bear san'; + var input2 = 'dwich'; + var expected = 3711466352; + + var crc = crc32.unsigned(input1); + crc = crc32.unsigned(input2, crc); + t.same(crc, expected); + t.end(); +}); + diff --git a/realtime/node_modules/express/node_modules/commander/History.md b/realtime/node_modules/express/node_modules/commander/History.md new file mode 100644 index 00000000..ce046f6f --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/History.md @@ -0,0 +1,174 @@ + +1.3.2 / 2013-07-18 +================== + + * add support for sub-commands to co-exist with the original command + +1.3.1 / 2013-07-18 +================== + + * add quick .runningCommand hack so you can opt-out of other logic when running a sub command + +1.3.0 / 2013-07-09 +================== + + * add EACCES error handling + * fix sub-command --help + +1.2.0 / 2013-06-13 +================== + + * allow "-" hyphen as an option argument + * support for RegExp coercion + +1.1.1 / 2012-11-20 +================== + + * add more sub-command padding + * fix .usage() when args are present. Closes #106 + +1.1.0 / 2012-11-16 +================== + + * add git-style executable subcommand support. Closes #94 + +1.0.5 / 2012-10-09 +================== + + * fix `--name` clobbering. Closes #92 + * fix examples/help. Closes #89 + +1.0.4 / 2012-09-03 +================== + + * add `outputHelp()` method. + +1.0.3 / 2012-08-30 +================== + + * remove invalid .version() defaulting + +1.0.2 / 2012-08-24 +================== + + * add `--foo=bar` support [arv] + * fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus] + +1.0.1 / 2012-08-03 +================== + + * fix issue #56 + * fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode()) + +1.0.0 / 2012-07-05 +================== + + * add support for optional option descriptions + * add defaulting of `.version()` to package.json's version + +0.6.1 / 2012-06-01 +================== + + * Added: append (yes or no) on confirmation + * Added: allow node.js v0.7.x + +0.6.0 / 2012-04-10 +================== + + * Added `.prompt(obj, callback)` support. Closes #49 + * Added default support to .choose(). Closes #41 + * Fixed the choice example + +0.5.1 / 2011-12-20 +================== + + * Fixed `password()` for recent nodes. Closes #36 + +0.5.0 / 2011-12-04 +================== + + * Added sub-command option support [itay] + +0.4.3 / 2011-12-04 +================== + + * Fixed custom help ordering. Closes #32 + +0.4.2 / 2011-11-24 +================== + + * Added travis support + * Fixed: line-buffered input automatically trimmed. Closes #31 + +0.4.1 / 2011-11-18 +================== + + * Removed listening for "close" on --help + +0.4.0 / 2011-11-15 +================== + + * Added support for `--`. Closes #24 + +0.3.3 / 2011-11-14 +================== + + * Fixed: wait for close event when writing help info [Jerry Hamlet] + +0.3.2 / 2011-11-01 +================== + + * Fixed long flag definitions with values [felixge] + +0.3.1 / 2011-10-31 +================== + + * Changed `--version` short flag to `-V` from `-v` + * Changed `.version()` so it's configurable [felixge] + +0.3.0 / 2011-10-31 +================== + + * Added support for long flags only. Closes #18 + +0.2.1 / 2011-10-24 +================== + + * "node": ">= 0.4.x < 0.7.0". Closes #20 + +0.2.0 / 2011-09-26 +================== + + * Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs] + +0.1.0 / 2011-08-24 +================== + + * Added support for custom `--help` output + +0.0.5 / 2011-08-18 +================== + + * Changed: when the user enters nothing prompt for password again + * Fixed issue with passwords beginning with numbers [NuckChorris] + +0.0.4 / 2011-08-15 +================== + + * Fixed `Commander#args` + +0.0.3 / 2011-08-15 +================== + + * Added default option value support + +0.0.2 / 2011-08-15 +================== + + * Added mask support to `Command#password(str[, mask], fn)` + * Added `Command#password(str, fn)` + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/realtime/node_modules/express/node_modules/commander/Readme.md b/realtime/node_modules/express/node_modules/commander/Readme.md new file mode 100644 index 00000000..ed0aeb2c --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/Readme.md @@ -0,0 +1,276 @@ +# Commander.js + + The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/visionmedia/commander). + + [![Build Status](https://secure.travis-ci.org/visionmedia/commander.js.png)](http://travis-ci.org/visionmedia/commander.js) + +## Installation + + $ npm install commander + +## Option parsing + + Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options. + +```js +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var program = require('commander'); + +program + .version('0.0.1') + .option('-p, --peppers', 'Add peppers') + .option('-P, --pineapple', 'Add pineapple') + .option('-b, --bbq', 'Add bbq sauce') + .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble') + .parse(process.argv); + +console.log('you ordered a pizza with:'); +if (program.peppers) console.log(' - peppers'); +if (program.pineapple) console.log(' - pineapple'); +if (program.bbq) console.log(' - bbq'); +console.log(' - %s cheese', program.cheese); +``` + + Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. + +## Automated --help + + The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free: + +``` + $ ./examples/pizza --help + + Usage: pizza [options] + + Options: + + -V, --version output the version number + -p, --peppers Add peppers + -P, --pineapple Add pineapple + -b, --bbq Add bbq sauce + -c, --cheese Add the specified type of cheese [marble] + -h, --help output usage information + +``` + +## Coercion + +```js +function range(val) { + return val.split('..').map(Number); +} + +function list(val) { + return val.split(','); +} + +program + .version('0.0.1') + .usage('[options] ') + .option('-i, --integer ', 'An integer argument', parseInt) + .option('-f, --float ', 'A float argument', parseFloat) + .option('-r, --range ..', 'A range', range) + .option('-l, --list ', 'A list', list) + .option('-o, --optional [value]', 'An optional value') + .parse(process.argv); + +console.log(' int: %j', program.integer); +console.log(' float: %j', program.float); +console.log(' optional: %j', program.optional); +program.range = program.range || []; +console.log(' range: %j..%j', program.range[0], program.range[1]); +console.log(' list: %j', program.list); +console.log(' args: %j', program.args); +``` + +## Custom help + + You can display arbitrary `-h, --help` information + by listening for "--help". Commander will automatically + exit once you are done so that the remainder of your program + does not execute causing undesired behaviours, for example + in the following executable "stuff" will not output when + `--help` is used. + +```js +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var program = require('../'); + +function list(val) { + return val.split(',').map(Number); +} + +program + .version('0.0.1') + .option('-f, --foo', 'enable some foo') + .option('-b, --bar', 'enable some bar') + .option('-B, --baz', 'enable some baz'); + +// must be before .parse() since +// node's emit() is immediate + +program.on('--help', function(){ + console.log(' Examples:'); + console.log(''); + console.log(' $ custom-help --help'); + console.log(' $ custom-help -h'); + console.log(''); +}); + +program.parse(process.argv); + +console.log('stuff'); +``` + +yielding the following help output: + +``` + +Usage: custom-help [options] + +Options: + + -h, --help output usage information + -V, --version output the version number + -f, --foo enable some foo + -b, --bar enable some bar + -B, --baz enable some baz + +Examples: + + $ custom-help --help + $ custom-help -h + +``` + +## .prompt(msg, fn) + + Single-line prompt: + +```js +program.prompt('name: ', function(name){ + console.log('hi %s', name); +}); +``` + + Multi-line prompt: + +```js +program.prompt('description:', function(name){ + console.log('hi %s', name); +}); +``` + + Coercion: + +```js +program.prompt('Age: ', Number, function(age){ + console.log('age: %j', age); +}); +``` + +```js +program.prompt('Birthdate: ', Date, function(date){ + console.log('date: %s', date); +}); +``` + +```js +program.prompt('Email: ', /^.+@.+\..+$/, function(email){ + console.log('email: %j', email); +}); +``` + +## .password(msg[, mask], fn) + +Prompt for password without echoing: + +```js +program.password('Password: ', function(pass){ + console.log('got "%s"', pass); + process.stdin.destroy(); +}); +``` + +Prompt for password with mask char "*": + +```js +program.password('Password: ', '*', function(pass){ + console.log('got "%s"', pass); + process.stdin.destroy(); +}); +``` + +## .confirm(msg, fn) + + Confirm with the given `msg`: + +```js +program.confirm('continue? ', function(ok){ + console.log(' got %j', ok); +}); +``` + +## .choose(list, fn) + + Let the user choose from a `list`: + +```js +var list = ['tobi', 'loki', 'jane', 'manny', 'luna']; + +console.log('Choose the coolest pet:'); +program.choose(list, function(i){ + console.log('you chose %d "%s"', i, list[i]); +}); +``` + +## .outputHelp() + + Output help information without exiting. + +## .help() + + Output help information and exit immediately. + +## Links + + - [API documentation](http://visionmedia.github.com/commander.js/) + - [ascii tables](https://github.com/LearnBoost/cli-table) + - [progress bars](https://github.com/visionmedia/node-progress) + - [more progress bars](https://github.com/substack/node-multimeter) + - [examples](https://github.com/visionmedia/commander.js/tree/master/examples) + +## License + +(The MIT License) + +Copyright (c) 2011 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. diff --git a/realtime/node_modules/express/node_modules/commander/index.js b/realtime/node_modules/express/node_modules/commander/index.js new file mode 100644 index 00000000..d9634e34 --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/index.js @@ -0,0 +1,1160 @@ +/*! + * commander + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var EventEmitter = require('events').EventEmitter + , spawn = require('child_process').spawn + , keypress = require('keypress') + , fs = require('fs') + , exists = fs.existsSync + , path = require('path') + , tty = require('tty') + , dirname = path.dirname + , basename = path.basename; + +/** + * Expose the root command. + */ + +exports = module.exports = new Command; + +/** + * Expose `Command`. + */ + +exports.Command = Command; + +/** + * Expose `Option`. + */ + +exports.Option = Option; + +/** + * Initialize a new `Option` with the given `flags` and `description`. + * + * @param {String} flags + * @param {String} description + * @api public + */ + +function Option(flags, description) { + this.flags = flags; + this.required = ~flags.indexOf('<'); + this.optional = ~flags.indexOf('['); + this.bool = !~flags.indexOf('-no-'); + flags = flags.split(/[ ,|]+/); + if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift(); + this.long = flags.shift(); + this.description = description || ''; +} + +/** + * Return option name. + * + * @return {String} + * @api private + */ + +Option.prototype.name = function(){ + return this.long + .replace('--', '') + .replace('no-', ''); +}; + +/** + * Check if `arg` matches the short or long flag. + * + * @param {String} arg + * @return {Boolean} + * @api private + */ + +Option.prototype.is = function(arg){ + return arg == this.short + || arg == this.long; +}; + +/** + * Initialize a new `Command`. + * + * @param {String} name + * @api public + */ + +function Command(name) { + this.commands = []; + this.options = []; + this._execs = []; + this._args = []; + this._name = name; +} + +/** + * Inherit from `EventEmitter.prototype`. + */ + +Command.prototype.__proto__ = EventEmitter.prototype; + +/** + * Add command `name`. + * + * The `.action()` callback is invoked when the + * command `name` is specified via __ARGV__, + * and the remaining arguments are applied to the + * function for access. + * + * When the `name` is "*" an un-matched command + * will be passed as the first arg, followed by + * the rest of __ARGV__ remaining. + * + * Examples: + * + * program + * .version('0.0.1') + * .option('-C, --chdir ', 'change the working directory') + * .option('-c, --config ', 'set config path. defaults to ./deploy.conf') + * .option('-T, --no-tests', 'ignore test hook') + * + * program + * .command('setup') + * .description('run remote setup commands') + * .action(function(){ + * console.log('setup'); + * }); + * + * program + * .command('exec ') + * .description('run the given remote command') + * .action(function(cmd){ + * console.log('exec "%s"', cmd); + * }); + * + * program + * .command('*') + * .description('deploy the given env') + * .action(function(env){ + * console.log('deploying "%s"', env); + * }); + * + * program.parse(process.argv); + * + * @param {String} name + * @param {String} [desc] + * @return {Command} the new command + * @api public + */ + +Command.prototype.command = function(name, desc){ + var args = name.split(/ +/); + var cmd = new Command(args.shift()); + if (desc) cmd.description(desc); + if (desc) this.executables = true; + if (desc) this._execs[cmd._name] = true; + this.commands.push(cmd); + cmd.parseExpectedArgs(args); + cmd.parent = this; + if (desc) return this; + return cmd; +}; + +/** + * Add an implicit `help [cmd]` subcommand + * which invokes `--help` for the given command. + * + * @api private + */ + +Command.prototype.addImplicitHelpCommand = function() { + this.command('help [cmd]', 'display help for [cmd]'); +}; + +/** + * Parse expected `args`. + * + * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`. + * + * @param {Array} args + * @return {Command} for chaining + * @api public + */ + +Command.prototype.parseExpectedArgs = function(args){ + if (!args.length) return; + var self = this; + args.forEach(function(arg){ + switch (arg[0]) { + case '<': + self._args.push({ required: true, name: arg.slice(1, -1) }); + break; + case '[': + self._args.push({ required: false, name: arg.slice(1, -1) }); + break; + } + }); + return this; +}; + +/** + * Register callback `fn` for the command. + * + * Examples: + * + * program + * .command('help') + * .description('display verbose help') + * .action(function(){ + * // output help here + * }); + * + * @param {Function} fn + * @return {Command} for chaining + * @api public + */ + +Command.prototype.action = function(fn){ + var self = this; + this.parent.on(this._name, function(args, unknown){ + // Parse any so-far unknown options + unknown = unknown || []; + var parsed = self.parseOptions(unknown); + + // Output help if necessary + outputHelpIfNecessary(self, parsed.unknown); + + // If there are still any unknown options, then we simply + // die, unless someone asked for help, in which case we give it + // to them, and then we die. + if (parsed.unknown.length > 0) { + self.unknownOption(parsed.unknown[0]); + } + + // Leftover arguments need to be pushed back. Fixes issue #56 + if (parsed.args.length) args = parsed.args.concat(args); + + self._args.forEach(function(arg, i){ + if (arg.required && null == args[i]) { + self.missingArgument(arg.name); + } + }); + + // Always append ourselves to the end of the arguments, + // to make sure we match the number of arguments the user + // expects + if (self._args.length) { + args[self._args.length] = self; + } else { + args.push(self); + } + + fn.apply(this, args); + }); + return this; +}; + +/** + * Define option with `flags`, `description` and optional + * coercion `fn`. + * + * The `flags` string should contain both the short and long flags, + * separated by comma, a pipe or space. The following are all valid + * all will output this way when `--help` is used. + * + * "-p, --pepper" + * "-p|--pepper" + * "-p --pepper" + * + * Examples: + * + * // simple boolean defaulting to false + * program.option('-p, --pepper', 'add pepper'); + * + * --pepper + * program.pepper + * // => Boolean + * + * // simple boolean defaulting to false + * program.option('-C, --no-cheese', 'remove cheese'); + * + * program.cheese + * // => true + * + * --no-cheese + * program.cheese + * // => true + * + * // required argument + * program.option('-C, --chdir ', 'change the working directory'); + * + * --chdir /tmp + * program.chdir + * // => "/tmp" + * + * // optional argument + * program.option('-c, --cheese [type]', 'add cheese [marble]'); + * + * @param {String} flags + * @param {String} description + * @param {Function|Mixed} fn or default + * @param {Mixed} defaultValue + * @return {Command} for chaining + * @api public + */ + +Command.prototype.option = function(flags, description, fn, defaultValue){ + var self = this + , option = new Option(flags, description) + , oname = option.name() + , name = camelcase(oname); + + // default as 3rd arg + if ('function' != typeof fn) defaultValue = fn, fn = null; + + // preassign default value only for --no-*, [optional], or + if (false == option.bool || option.optional || option.required) { + // when --no-* we make sure default is true + if (false == option.bool) defaultValue = true; + // preassign only if we have a default + if (undefined !== defaultValue) self[name] = defaultValue; + } + + // register the option + this.options.push(option); + + // when it's passed assign the value + // and conditionally invoke the callback + this.on(oname, function(val){ + // coercion + if (null != val && fn) val = fn(val); + + // unassigned or bool + if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) { + // if no value, bool true, and we have a default, then use it! + if (null == val) { + self[name] = option.bool + ? defaultValue || true + : false; + } else { + self[name] = val; + } + } else if (null !== val) { + // reassign + self[name] = val; + } + }); + + return this; +}; + +/** + * Parse `argv`, settings options and invoking commands when defined. + * + * @param {Array} argv + * @return {Command} for chaining + * @api public + */ + +Command.prototype.parse = function(argv){ + // implicit help + if (this.executables) this.addImplicitHelpCommand(); + + // store raw args + this.rawArgs = argv; + + // guess name + this._name = this._name || basename(argv[1]); + + // process argv + var parsed = this.parseOptions(this.normalize(argv.slice(2))); + var args = this.args = parsed.args; + + var result = this.parseArgs(this.args, parsed.unknown); + + // executable sub-commands + var name = result.args[0]; + if (this._execs[name]) return this.executeSubCommand(argv, args, parsed.unknown); + + return result; +}; + +/** + * Execute a sub-command executable. + * + * @param {Array} argv + * @param {Array} args + * @param {Array} unknown + * @api private + */ + +Command.prototype.executeSubCommand = function(argv, args, unknown) { + args = args.concat(unknown); + + if (!args.length) this.help(); + if ('help' == args[0] && 1 == args.length) this.help(); + + // --help + if ('help' == args[0]) { + args[0] = args[1]; + args[1] = '--help'; + } + + // executable + var dir = dirname(argv[1]); + var bin = basename(argv[1]) + '-' + args[0]; + + // check for ./ first + var local = path.join(dir, bin); + + // run it + args = args.slice(1); + var proc = spawn(local, args, { stdio: 'inherit', customFds: [0, 1, 2] }); + proc.on('error', function(err){ + if (err.code == "ENOENT") { + console.error('\n %s(1) does not exist, try --help\n', bin); + } else if (err.code == "EACCES") { + console.error('\n %s(1) not executable. try chmod or run with root\n', bin); + } + }); + + this.runningCommand = proc; +}; + +/** + * Normalize `args`, splitting joined short flags. For example + * the arg "-abc" is equivalent to "-a -b -c". + * This also normalizes equal sign and splits "--abc=def" into "--abc def". + * + * @param {Array} args + * @return {Array} + * @api private + */ + +Command.prototype.normalize = function(args){ + var ret = [] + , arg + , index; + + for (var i = 0, len = args.length; i < len; ++i) { + arg = args[i]; + if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) { + arg.slice(1).split('').forEach(function(c){ + ret.push('-' + c); + }); + } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) { + ret.push(arg.slice(0, index), arg.slice(index + 1)); + } else { + ret.push(arg); + } + } + + return ret; +}; + +/** + * Parse command `args`. + * + * When listener(s) are available those + * callbacks are invoked, otherwise the "*" + * event is emitted and those actions are invoked. + * + * @param {Array} args + * @return {Command} for chaining + * @api private + */ + +Command.prototype.parseArgs = function(args, unknown){ + var cmds = this.commands + , len = cmds.length + , name; + + if (args.length) { + name = args[0]; + if (this.listeners(name).length) { + this.emit(args.shift(), args, unknown); + } else { + this.emit('*', args); + } + } else { + outputHelpIfNecessary(this, unknown); + + // If there were no args and we have unknown options, + // then they are extraneous and we need to error. + if (unknown.length > 0) { + this.unknownOption(unknown[0]); + } + } + + return this; +}; + +/** + * Return an option matching `arg` if any. + * + * @param {String} arg + * @return {Option} + * @api private + */ + +Command.prototype.optionFor = function(arg){ + for (var i = 0, len = this.options.length; i < len; ++i) { + if (this.options[i].is(arg)) { + return this.options[i]; + } + } +}; + +/** + * Parse options from `argv` returning `argv` + * void of these options. + * + * @param {Array} argv + * @return {Array} + * @api public + */ + +Command.prototype.parseOptions = function(argv){ + var args = [] + , len = argv.length + , literal + , option + , arg; + + var unknownOptions = []; + + // parse options + for (var i = 0; i < len; ++i) { + arg = argv[i]; + + // literal args after -- + if ('--' == arg) { + literal = true; + continue; + } + + if (literal) { + args.push(arg); + continue; + } + + // find matching Option + option = this.optionFor(arg); + + // option is defined + if (option) { + // requires arg + if (option.required) { + arg = argv[++i]; + if (null == arg) return this.optionMissingArgument(option); + if ('-' == arg[0] && '-' != arg) return this.optionMissingArgument(option, arg); + this.emit(option.name(), arg); + // optional arg + } else if (option.optional) { + arg = argv[i+1]; + if (null == arg || ('-' == arg[0] && '-' != arg)) { + arg = null; + } else { + ++i; + } + this.emit(option.name(), arg); + // bool + } else { + this.emit(option.name()); + } + continue; + } + + // looks like an option + if (arg.length > 1 && '-' == arg[0]) { + unknownOptions.push(arg); + + // If the next argument looks like it might be + // an argument for this option, we pass it on. + // If it isn't, then it'll simply be ignored + if (argv[i+1] && '-' != argv[i+1][0]) { + unknownOptions.push(argv[++i]); + } + continue; + } + + // arg + args.push(arg); + } + + return { args: args, unknown: unknownOptions }; +}; + +/** + * Argument `name` is missing. + * + * @param {String} name + * @api private + */ + +Command.prototype.missingArgument = function(name){ + console.error(); + console.error(" error: missing required argument `%s'", name); + console.error(); + process.exit(1); +}; + +/** + * `Option` is missing an argument, but received `flag` or nothing. + * + * @param {String} option + * @param {String} flag + * @api private + */ + +Command.prototype.optionMissingArgument = function(option, flag){ + console.error(); + if (flag) { + console.error(" error: option `%s' argument missing, got `%s'", option.flags, flag); + } else { + console.error(" error: option `%s' argument missing", option.flags); + } + console.error(); + process.exit(1); +}; + +/** + * Unknown option `flag`. + * + * @param {String} flag + * @api private + */ + +Command.prototype.unknownOption = function(flag){ + console.error(); + console.error(" error: unknown option `%s'", flag); + console.error(); + process.exit(1); +}; + + +/** + * Set the program version to `str`. + * + * This method auto-registers the "-V, --version" flag + * which will print the version number when passed. + * + * @param {String} str + * @param {String} flags + * @return {Command} for chaining + * @api public + */ + +Command.prototype.version = function(str, flags){ + if (0 == arguments.length) return this._version; + this._version = str; + flags = flags || '-V, --version'; + this.option(flags, 'output the version number'); + this.on('version', function(){ + console.log(str); + process.exit(0); + }); + return this; +}; + +/** + * Set the description `str`. + * + * @param {String} str + * @return {String|Command} + * @api public + */ + +Command.prototype.description = function(str){ + if (0 == arguments.length) return this._description; + this._description = str; + return this; +}; + +/** + * Set / get the command usage `str`. + * + * @param {String} str + * @return {String|Command} + * @api public + */ + +Command.prototype.usage = function(str){ + var args = this._args.map(function(arg){ + return arg.required + ? '<' + arg.name + '>' + : '[' + arg.name + ']'; + }); + + var usage = '[options' + + (this.commands.length ? '] [command' : '') + + ']' + + (this._args.length ? ' ' + args : ''); + + if (0 == arguments.length) return this._usage || usage; + this._usage = str; + + return this; +}; + +/** + * Return the largest option length. + * + * @return {Number} + * @api private + */ + +Command.prototype.largestOptionLength = function(){ + return this.options.reduce(function(max, option){ + return Math.max(max, option.flags.length); + }, 0); +}; + +/** + * Return help for options. + * + * @return {String} + * @api private + */ + +Command.prototype.optionHelp = function(){ + var width = this.largestOptionLength(); + + // Prepend the help information + return [pad('-h, --help', width) + ' ' + 'output usage information'] + .concat(this.options.map(function(option){ + return pad(option.flags, width) + + ' ' + option.description; + })) + .join('\n'); +}; + +/** + * Return command help documentation. + * + * @return {String} + * @api private + */ + +Command.prototype.commandHelp = function(){ + if (!this.commands.length) return ''; + return [ + '' + , ' Commands:' + , '' + , this.commands.map(function(cmd){ + var args = cmd._args.map(function(arg){ + return arg.required + ? '<' + arg.name + '>' + : '[' + arg.name + ']'; + }).join(' '); + + return pad(cmd._name + + (cmd.options.length + ? ' [options]' + : '') + ' ' + args, 22) + + (cmd.description() + ? ' ' + cmd.description() + : ''); + }).join('\n').replace(/^/gm, ' ') + , '' + ].join('\n'); +}; + +/** + * Return program help documentation. + * + * @return {String} + * @api private + */ + +Command.prototype.helpInformation = function(){ + return [ + '' + , ' Usage: ' + this._name + ' ' + this.usage() + , '' + this.commandHelp() + , ' Options:' + , '' + , '' + this.optionHelp().replace(/^/gm, ' ') + , '' + , '' + ].join('\n'); +}; + +/** + * Prompt for a `Number`. + * + * @param {String} str + * @param {Function} fn + * @api private + */ + +Command.prototype.promptForNumber = function(str, fn){ + var self = this; + this.promptSingleLine(str, function parseNumber(val){ + val = Number(val); + if (isNaN(val)) return self.promptSingleLine(str + '(must be a number) ', parseNumber); + fn(val); + }); +}; + +/** + * Prompt for a `Date`. + * + * @param {String} str + * @param {Function} fn + * @api private + */ + +Command.prototype.promptForDate = function(str, fn){ + var self = this; + this.promptSingleLine(str, function parseDate(val){ + val = new Date(val); + if (isNaN(val.getTime())) return self.promptSingleLine(str + '(must be a date) ', parseDate); + fn(val); + }); +}; + + +/** + * Prompt for a `Regular Expression`. + * + * @param {String} str + * @param {Object} pattern regular expression object to test + * @param {Function} fn + * @api private + */ + +Command.prototype.promptForRegexp = function(str, pattern, fn){ + var self = this; + this.promptSingleLine(str, function parseRegexp(val){ + if(!pattern.test(val)) return self.promptSingleLine(str + '(regular expression mismatch) ', parseRegexp); + fn(val); + }); +}; + + +/** + * Single-line prompt. + * + * @param {String} str + * @param {Function} fn + * @api private + */ + +Command.prototype.promptSingleLine = function(str, fn){ + // determine if the 2nd argument is a regular expression + if (arguments[1].global !== undefined && arguments[1].multiline !== undefined) { + return this.promptForRegexp(str, arguments[1], arguments[2]); + } else if ('function' == typeof arguments[2]) { + return this['promptFor' + (fn.name || fn)](str, arguments[2]); + } + + process.stdout.write(str); + process.stdin.setEncoding('utf8'); + process.stdin.once('data', function(val){ + fn(val.trim()); + }).resume(); +}; + +/** + * Multi-line prompt. + * + * @param {String} str + * @param {Function} fn + * @api private + */ + +Command.prototype.promptMultiLine = function(str, fn){ + var buf = []; + console.log(str); + process.stdin.setEncoding('utf8'); + process.stdin.on('data', function(val){ + if ('\n' == val || '\r\n' == val) { + process.stdin.removeAllListeners('data'); + fn(buf.join('\n')); + } else { + buf.push(val.trimRight()); + } + }).resume(); +}; + +/** + * Prompt `str` and callback `fn(val)` + * + * Commander supports single-line and multi-line prompts. + * To issue a single-line prompt simply add white-space + * to the end of `str`, something like "name: ", whereas + * for a multi-line prompt omit this "description:". + * + * + * Examples: + * + * program.prompt('Username: ', function(name){ + * console.log('hi %s', name); + * }); + * + * program.prompt('Description:', function(desc){ + * console.log('description was "%s"', desc.trim()); + * }); + * + * @param {String|Object} str + * @param {Function} fn + * @api public + */ + +Command.prototype.prompt = function(str, fn){ + var self = this; + if ('string' == typeof str) { + if (/ $/.test(str)) return this.promptSingleLine.apply(this, arguments); + this.promptMultiLine(str, fn); + } else { + var keys = Object.keys(str) + , obj = {}; + + function next() { + var key = keys.shift() + , label = str[key]; + + if (!key) return fn(obj); + self.prompt(label, function(val){ + obj[key] = val; + next(); + }); + } + + next(); + } +}; + +/** + * Prompt for password with `str`, `mask` char and callback `fn(val)`. + * + * The mask string defaults to '', aka no output is + * written while typing, you may want to use "*" etc. + * + * Examples: + * + * program.password('Password: ', function(pass){ + * console.log('got "%s"', pass); + * process.stdin.destroy(); + * }); + * + * program.password('Password: ', '*', function(pass){ + * console.log('got "%s"', pass); + * process.stdin.destroy(); + * }); + * + * @param {String} str + * @param {String} mask + * @param {Function} fn + * @api public + */ + +Command.prototype.password = function(str, mask, fn){ + var self = this + , buf = ''; + + // default mask + if ('function' == typeof mask) { + fn = mask; + mask = ''; + } + + keypress(process.stdin); + + function setRawMode(mode) { + if (process.stdin.setRawMode) { + process.stdin.setRawMode(mode); + } else { + tty.setRawMode(mode); + } + }; + setRawMode(true); + process.stdout.write(str); + + // keypress + process.stdin.on('keypress', function(c, key){ + if (key && 'enter' == key.name) { + console.log(); + process.stdin.pause(); + process.stdin.removeAllListeners('keypress'); + setRawMode(false); + if (!buf.trim().length) return self.password(str, mask, fn); + fn(buf); + return; + } + + if (key && key.ctrl && 'c' == key.name) { + console.log('%s', buf); + process.exit(); + } + + process.stdout.write(mask); + buf += c; + }).resume(); +}; + +/** + * Confirmation prompt with `str` and callback `fn(bool)` + * + * Examples: + * + * program.confirm('continue? ', function(ok){ + * console.log(' got %j', ok); + * process.stdin.destroy(); + * }); + * + * @param {String} str + * @param {Function} fn + * @api public + */ + + +Command.prototype.confirm = function(str, fn, verbose){ + var self = this; + this.prompt(str, function(ok){ + if (!ok.trim()) { + if (!verbose) str += '(yes or no) '; + return self.confirm(str, fn, true); + } + fn(parseBool(ok)); + }); +}; + +/** + * Choice prompt with `list` of items and callback `fn(index, item)` + * + * Examples: + * + * var list = ['tobi', 'loki', 'jane', 'manny', 'luna']; + * + * console.log('Choose the coolest pet:'); + * program.choose(list, function(i){ + * console.log('you chose %d "%s"', i, list[i]); + * process.stdin.destroy(); + * }); + * + * @param {Array} list + * @param {Number|Function} index or fn + * @param {Function} fn + * @api public + */ + +Command.prototype.choose = function(list, index, fn){ + var self = this + , hasDefault = 'number' == typeof index; + + if (!hasDefault) { + fn = index; + index = null; + } + + list.forEach(function(item, i){ + if (hasDefault && i == index) { + console.log('* %d) %s', i + 1, item); + } else { + console.log(' %d) %s', i + 1, item); + } + }); + + function again() { + self.prompt(' : ', function(val){ + val = parseInt(val, 10) - 1; + if (hasDefault && isNaN(val)) val = index; + + if (null == list[val]) { + again(); + } else { + fn(val, list[val]); + } + }); + } + + again(); +}; + + +/** + * Output help information for this command + * + * @api public + */ + +Command.prototype.outputHelp = function(){ + process.stdout.write(this.helpInformation()); + this.emit('--help'); +}; + +/** + * Output help information and exit. + * + * @api public + */ + +Command.prototype.help = function(){ + this.outputHelp(); + process.exit(); +}; + +/** + * Camel-case the given `flag` + * + * @param {String} flag + * @return {String} + * @api private + */ + +function camelcase(flag) { + return flag.split('-').reduce(function(str, word){ + return str + word[0].toUpperCase() + word.slice(1); + }); +} + +/** + * Parse a boolean `str`. + * + * @param {String} str + * @return {Boolean} + * @api private + */ + +function parseBool(str) { + return /^y|yes|ok|true$/i.test(str); +} + +/** + * Pad `str` to `width`. + * + * @param {String} str + * @param {Number} width + * @return {String} + * @api private + */ + +function pad(str, width) { + var len = Math.max(0, width - str.length); + return str + Array(len + 1).join(' '); +} + +/** + * Output help information if necessary + * + * @param {Command} command to output help for + * @param {Array} array of options to search for -h or --help + * @api private + */ + +function outputHelpIfNecessary(cmd, options) { + options = options || []; + for (var i = 0; i < options.length; i++) { + if (options[i] == '--help' || options[i] == '-h') { + cmd.outputHelp(); + process.exit(0); + } + } +} diff --git a/realtime/node_modules/express/node_modules/commander/node_modules/keypress/README.md b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/README.md new file mode 100644 index 00000000..a768e8f5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/README.md @@ -0,0 +1,101 @@ +keypress +======== +### Make any Node ReadableStream emit "keypress" events + + +Previous to Node `v0.8.x`, there was an undocumented `"keypress"` event that +`process.stdin` would emit when it was a TTY. Some people discovered this hidden +gem, and started using it in their own code. + +Now in Node `v0.8.x`, this `"keypress"` event does not get emitted by default, +but rather only when it is being used in conjuction with the `readline` (or by +extension, the `repl`) module. + +This module is the exact logic from the node `v0.8.x` releases ripped out into its +own module. + +__Bonus:__ Now with mouse support! + +Installation +------------ + +Install with `npm`: + +``` bash +$ npm install keypress +``` + +Or add it to the `"dependencies"` section of your _package.json_ file. + + +Example +------- + +#### Listening for "keypress" events + +``` js +var keypress = require('keypress'); + +// make `process.stdin` begin emitting "keypress" events +keypress(process.stdin); + +// listen for the "keypress" event +process.stdin.on('keypress', function (ch, key) { + console.log('got "keypress"', key); + if (key && key.ctrl && key.name == 'c') { + process.stdin.pause(); + } +}); + +process.stdin.setRawMode(true); +process.stdin.resume(); +``` + +#### Listening for "mousepress" events + +``` js +var keypress = require('keypress'); + +// make `process.stdin` begin emitting "mousepress" (and "keypress") events +keypress(process.stdin); + +// you must enable the mouse events before they will begin firing +keypress.enableMouse(process.stdout); + +process.stdin.on('mousepress', function (info) { + console.log('got "mousepress" event at %d x %d', info.x, info.y); +}); + +process.on('exit', function () { + // disable mouse on exit, so that the state + // is back to normal for the terminal + keypress.disableMouse(process.stdout); +}); +``` + + +License +------- + +(The MIT License) + +Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net> + +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. diff --git a/realtime/node_modules/express/node_modules/commander/node_modules/keypress/index.js b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/index.js new file mode 100644 index 00000000..c2ba488b --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/index.js @@ -0,0 +1,346 @@ + +/** + * This module offers the internal "keypress" functionality from node-core's + * `readline` module, for your own programs and modules to use. + * + * Usage: + * + * require('keypress')(process.stdin); + * + * process.stdin.on('keypress', function (ch, key) { + * console.log(ch, key); + * if (key.ctrl && key.name == 'c') { + * process.stdin.pause(); + * } + * }); + * proces.stdin.resume(); + */ +var exports = module.exports = keypress; + +exports.enableMouse = function (stream) { + stream.write('\x1b' +'[?1000h') +} + +exports.disableMouse = function (stream) { + stream.write('\x1b' +'[?1000l') +} + + +/** + * accepts a readable Stream instance and makes it emit "keypress" events + */ + +function keypress(stream) { + if (isEmittingKeypress(stream)) return; + stream._emitKeypress = true; + + function onData(b) { + if (stream.listeners('keypress').length > 0) { + emitKey(stream, b); + } else { + // Nobody's watching anyway + stream.removeListener('data', onData); + stream.on('newListener', onNewListener); + } + } + + function onNewListener(event) { + if (event == 'keypress') { + stream.on('data', onData); + stream.removeListener('newListener', onNewListener); + } + } + + if (stream.listeners('keypress').length > 0) { + stream.on('data', onData); + } else { + stream.on('newListener', onNewListener); + } +} + +/** + * Returns `true` if the stream is already emitting "keypress" events. + * `false` otherwise. + */ + +function isEmittingKeypress(stream) { + var rtn = stream._emitKeypress; + if (!rtn) { + // hack: check for the v0.6.x "data" event + stream.listeners('data').forEach(function (l) { + if (l.name == 'onData' && /emitKey/.test(l.toString())) { + rtn = true; + stream._emitKeypress = true; + } + }); + } + if (!rtn) { + // hack: check for the v0.6.x "newListener" event + stream.listeners('newListener').forEach(function (l) { + if (l.name == 'onNewListener' && /keypress/.test(l.toString())) { + rtn = true; + stream._emitKeypress = true; + } + }); + } + return rtn; +} + + +/* + Some patterns seen in terminal key escape codes, derived from combos seen + at http://www.midnight-commander.org/browser/lib/tty/key.c + + ESC letter + ESC [ letter + ESC [ modifier letter + ESC [ 1 ; modifier letter + ESC [ num char + ESC [ num ; modifier char + ESC O letter + ESC O modifier letter + ESC O 1 ; modifier letter + ESC N letter + ESC [ [ num ; modifier char + ESC [ [ 1 ; modifier letter + ESC ESC [ num char + ESC ESC O letter + + - char is usually ~ but $ and ^ also happen with rxvt + - modifier is 1 + + (shift * 1) + + (left_alt * 2) + + (ctrl * 4) + + (right_alt * 8) + - two leading ESCs apparently mean the same as one leading ESC +*/ + +// Regexes used for ansi escape code splitting +var metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/; +var functionKeyCodeRe = + /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/; + +function emitKey(stream, s) { + var ch, + key = { + name: undefined, + ctrl: false, + meta: false, + shift: false + }, + parts; + + if (Buffer.isBuffer(s)) { + if (s[0] > 127 && s[1] === undefined) { + s[0] -= 128; + s = '\x1b' + s.toString(stream.encoding || 'utf-8'); + } else { + s = s.toString(stream.encoding || 'utf-8'); + } + } + + key.sequence = s; + + if (s === '\r' || s === '\n') { + // enter + key.name = 'enter'; + + } else if (s === '\t') { + // tab + key.name = 'tab'; + + } else if (s === '\b' || s === '\x7f' || + s === '\x1b\x7f' || s === '\x1b\b') { + // backspace or ctrl+h + key.name = 'backspace'; + key.meta = (s.charAt(0) === '\x1b'); + + } else if (s === '\x1b' || s === '\x1b\x1b') { + // escape key + key.name = 'escape'; + key.meta = (s.length === 2); + + } else if (s === ' ' || s === '\x1b ') { + key.name = 'space'; + key.meta = (s.length === 2); + + } else if (s <= '\x1a') { + // ctrl+letter + key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1); + key.ctrl = true; + + } else if (s.length === 1 && s >= 'a' && s <= 'z') { + // lowercase letter + key.name = s; + + } else if (s.length === 1 && s >= 'A' && s <= 'Z') { + // shift+letter + key.name = s.toLowerCase(); + key.shift = true; + + } else if (parts = metaKeyCodeRe.exec(s)) { + // meta+character key + key.name = parts[1].toLowerCase(); + key.meta = true; + key.shift = /^[A-Z]$/.test(parts[1]); + + } else if (parts = functionKeyCodeRe.exec(s)) { + // ansi escape sequence + + // reassemble the key code leaving out leading \x1b's, + // the modifier key bitflag and any meaningless "1;" sequence + var code = (parts[1] || '') + (parts[2] || '') + + (parts[4] || '') + (parts[6] || ''), + modifier = (parts[3] || parts[5] || 1) - 1; + + // Parse the key modifier + key.ctrl = !!(modifier & 4); + key.meta = !!(modifier & 10); + key.shift = !!(modifier & 1); + key.code = code; + + // Parse the key itself + switch (code) { + /* xterm/gnome ESC O letter */ + case 'OP': key.name = 'f1'; break; + case 'OQ': key.name = 'f2'; break; + case 'OR': key.name = 'f3'; break; + case 'OS': key.name = 'f4'; break; + + /* xterm/rxvt ESC [ number ~ */ + case '[11~': key.name = 'f1'; break; + case '[12~': key.name = 'f2'; break; + case '[13~': key.name = 'f3'; break; + case '[14~': key.name = 'f4'; break; + + /* from Cygwin and used in libuv */ + case '[[A': key.name = 'f1'; break; + case '[[B': key.name = 'f2'; break; + case '[[C': key.name = 'f3'; break; + case '[[D': key.name = 'f4'; break; + case '[[E': key.name = 'f5'; break; + + /* common */ + case '[15~': key.name = 'f5'; break; + case '[17~': key.name = 'f6'; break; + case '[18~': key.name = 'f7'; break; + case '[19~': key.name = 'f8'; break; + case '[20~': key.name = 'f9'; break; + case '[21~': key.name = 'f10'; break; + case '[23~': key.name = 'f11'; break; + case '[24~': key.name = 'f12'; break; + + /* xterm ESC [ letter */ + case '[A': key.name = 'up'; break; + case '[B': key.name = 'down'; break; + case '[C': key.name = 'right'; break; + case '[D': key.name = 'left'; break; + case '[E': key.name = 'clear'; break; + case '[F': key.name = 'end'; break; + case '[H': key.name = 'home'; break; + + /* xterm/gnome ESC O letter */ + case 'OA': key.name = 'up'; break; + case 'OB': key.name = 'down'; break; + case 'OC': key.name = 'right'; break; + case 'OD': key.name = 'left'; break; + case 'OE': key.name = 'clear'; break; + case 'OF': key.name = 'end'; break; + case 'OH': key.name = 'home'; break; + + /* xterm/rxvt ESC [ number ~ */ + case '[1~': key.name = 'home'; break; + case '[2~': key.name = 'insert'; break; + case '[3~': key.name = 'delete'; break; + case '[4~': key.name = 'end'; break; + case '[5~': key.name = 'pageup'; break; + case '[6~': key.name = 'pagedown'; break; + + /* putty */ + case '[[5~': key.name = 'pageup'; break; + case '[[6~': key.name = 'pagedown'; break; + + /* rxvt */ + case '[7~': key.name = 'home'; break; + case '[8~': key.name = 'end'; break; + + /* rxvt keys with modifiers */ + case '[a': key.name = 'up'; key.shift = true; break; + case '[b': key.name = 'down'; key.shift = true; break; + case '[c': key.name = 'right'; key.shift = true; break; + case '[d': key.name = 'left'; key.shift = true; break; + case '[e': key.name = 'clear'; key.shift = true; break; + + case '[2$': key.name = 'insert'; key.shift = true; break; + case '[3$': key.name = 'delete'; key.shift = true; break; + case '[5$': key.name = 'pageup'; key.shift = true; break; + case '[6$': key.name = 'pagedown'; key.shift = true; break; + case '[7$': key.name = 'home'; key.shift = true; break; + case '[8$': key.name = 'end'; key.shift = true; break; + + case 'Oa': key.name = 'up'; key.ctrl = true; break; + case 'Ob': key.name = 'down'; key.ctrl = true; break; + case 'Oc': key.name = 'right'; key.ctrl = true; break; + case 'Od': key.name = 'left'; key.ctrl = true; break; + case 'Oe': key.name = 'clear'; key.ctrl = true; break; + + case '[2^': key.name = 'insert'; key.ctrl = true; break; + case '[3^': key.name = 'delete'; key.ctrl = true; break; + case '[5^': key.name = 'pageup'; key.ctrl = true; break; + case '[6^': key.name = 'pagedown'; key.ctrl = true; break; + case '[7^': key.name = 'home'; key.ctrl = true; break; + case '[8^': key.name = 'end'; key.ctrl = true; break; + + /* misc. */ + case '[Z': key.name = 'tab'; key.shift = true; break; + default: key.name = 'undefined'; break; + + } + } else if (s.length > 1 && s[0] !== '\x1b') { + // Got a longer-than-one string of characters. + // Probably a paste, since it wasn't a control sequence. + Array.prototype.forEach.call(s, function(c) { + emitKey(stream, c); + }); + return; + } + + if (key.code == '[M') { + key.name = 'mouse'; + var s = key.sequence; + var b = s.charCodeAt(3); + key.x = s.charCodeAt(4) - 040; + key.y = s.charCodeAt(5) - 040; + + key.scroll = 0; + + key.ctrl = !!(1<<4 & b); + key.meta = !!(1<<3 & b); + key.shift = !!(1<<2 & b); + + key.release = (3 & b) === 3; + + if (1<<6 & b) { //scroll + key.scroll = 1 & b ? 1 : -1; + } + + if (!key.release && !key.scroll) { + key.button = b & 3; + } + } + + // Don't emit a key if no name was found + if (key.name === undefined) { + key = undefined; + } + + if (s.length === 1) { + ch = s; + } + + if (key && key.name == 'mouse') { + stream.emit('mousepress', key) + } else if (key || ch) { + stream.emit('keypress', ch, key); + } +} diff --git a/realtime/node_modules/express/node_modules/commander/node_modules/keypress/package.json b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/package.json new file mode 100644 index 00000000..6cdf0856 --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/package.json @@ -0,0 +1,28 @@ +{ + "name": "keypress", + "version": "0.1.0", + "description": "Make any Node ReadableStream emit \"keypress\" events", + "author": { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "http://tootallnate.net" + }, + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/keypress.git" + }, + "keywords": [ + "keypress", + "readline", + "core" + ], + "license": "MIT", + "readme": "keypress\n========\n### Make any Node ReadableStream emit \"keypress\" events\n\n\nPrevious to Node `v0.8.x`, there was an undocumented `\"keypress\"` event that\n`process.stdin` would emit when it was a TTY. Some people discovered this hidden\ngem, and started using it in their own code.\n\nNow in Node `v0.8.x`, this `\"keypress\"` event does not get emitted by default,\nbut rather only when it is being used in conjuction with the `readline` (or by\nextension, the `repl`) module.\n\nThis module is the exact logic from the node `v0.8.x` releases ripped out into its\nown module.\n\n__Bonus:__ Now with mouse support!\n\nInstallation\n------------\n\nInstall with `npm`:\n\n``` bash\n$ npm install keypress\n```\n\nOr add it to the `\"dependencies\"` section of your _package.json_ file.\n\n\nExample\n-------\n\n#### Listening for \"keypress\" events\n\n``` js\nvar keypress = require('keypress');\n\n// make `process.stdin` begin emitting \"keypress\" events\nkeypress(process.stdin);\n\n// listen for the \"keypress\" event\nprocess.stdin.on('keypress', function (ch, key) {\n console.log('got \"keypress\"', key);\n if (key && key.ctrl && key.name == 'c') {\n process.stdin.pause();\n }\n});\n\nprocess.stdin.setRawMode(true);\nprocess.stdin.resume();\n```\n\n#### Listening for \"mousepress\" events\n\n``` js\nvar keypress = require('keypress');\n\n// make `process.stdin` begin emitting \"mousepress\" (and \"keypress\") events\nkeypress(process.stdin);\n\n// you must enable the mouse events before they will begin firing\nkeypress.enableMouse(process.stdout);\n\nprocess.stdin.on('mousepress', function (info) {\n console.log('got \"mousepress\" event at %d x %d', info.x, info.y);\n});\n\nprocess.on('exit', function () {\n // disable mouse on exit, so that the state\n // is back to normal for the terminal\n keypress.disableMouse(process.stdout);\n});\n```\n\n\nLicense\n-------\n\n(The MIT License)\n\nCopyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "README.md", + "_id": "keypress@0.1.0", + "_from": "keypress@0.1.x" +} diff --git a/realtime/node_modules/express/node_modules/commander/node_modules/keypress/test.js b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/test.js new file mode 100644 index 00000000..c3f61d79 --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/node_modules/keypress/test.js @@ -0,0 +1,28 @@ + +var keypress = require('./') +keypress(process.stdin) + +if (process.stdin.setRawMode) + process.stdin.setRawMode(true) +else + require('tty').setRawMode(true) + +process.stdin.on('keypress', function (c, key) { + console.log(0, c, key) + if (key && key.ctrl && key.name == 'c') { + process.stdin.pause() + } +}) +process.stdin.on('mousepress', function (mouse) { + console.log(mouse) +}) + +keypress.enableMouse(process.stdout) +process.on('exit', function () { + //disable mouse on exit, so that the state is back to normal + //for the terminal. + keypress.disableMouse(process.stdout) +}) + +process.stdin.resume() + diff --git a/realtime/node_modules/express/node_modules/commander/package.json b/realtime/node_modules/express/node_modules/commander/package.json new file mode 100644 index 00000000..7085bf2a --- /dev/null +++ b/realtime/node_modules/express/node_modules/commander/package.json @@ -0,0 +1,41 @@ +{ + "name": "commander", + "version": "1.3.2", + "description": "the complete solution for node.js command-line programs", + "keywords": [ + "command", + "option", + "parser", + "prompt", + "stdin" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "repository": { + "type": "git", + "url": "https://github.com/visionmedia/commander.js.git" + }, + "dependencies": { + "keypress": "0.1.x" + }, + "devDependencies": { + "should": ">= 0.0.1" + }, + "scripts": { + "test": "make test" + }, + "main": "index", + "engines": { + "node": ">= 0.6.x" + }, + "readme": "# Commander.js\n\n The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/visionmedia/commander).\n\n [![Build Status](https://secure.travis-ci.org/visionmedia/commander.js.png)](http://travis-ci.org/visionmedia/commander.js)\n\n## Installation\n\n $ npm install commander\n\n## Option parsing\n\n Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('commander');\n\nprogram\n .version('0.0.1')\n .option('-p, --peppers', 'Add peppers')\n .option('-P, --pineapple', 'Add pineapple')\n .option('-b, --bbq', 'Add bbq sauce')\n .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')\n .parse(process.argv);\n\nconsole.log('you ordered a pizza with:');\nif (program.peppers) console.log(' - peppers');\nif (program.pineapple) console.log(' - pineapple');\nif (program.bbq) console.log(' - bbq');\nconsole.log(' - %s cheese', program.cheese);\n```\n\n Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as \"--template-engine\" are camel-cased, becoming `program.templateEngine` etc.\n\n## Automated --help\n\n The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:\n\n``` \n $ ./examples/pizza --help\n\n Usage: pizza [options]\n\n Options:\n\n -V, --version output the version number\n -p, --peppers Add peppers\n -P, --pineapple Add pineapple\n -b, --bbq Add bbq sauce\n -c, --cheese Add the specified type of cheese [marble]\n -h, --help output usage information\n\n```\n\n## Coercion\n\n```js\nfunction range(val) {\n return val.split('..').map(Number);\n}\n\nfunction list(val) {\n return val.split(',');\n}\n\nprogram\n .version('0.0.1')\n .usage('[options] ')\n .option('-i, --integer ', 'An integer argument', parseInt)\n .option('-f, --float ', 'A float argument', parseFloat)\n .option('-r, --range ..', 'A range', range)\n .option('-l, --list ', 'A list', list)\n .option('-o, --optional [value]', 'An optional value')\n .parse(process.argv);\n\nconsole.log(' int: %j', program.integer);\nconsole.log(' float: %j', program.float);\nconsole.log(' optional: %j', program.optional);\nprogram.range = program.range || [];\nconsole.log(' range: %j..%j', program.range[0], program.range[1]);\nconsole.log(' list: %j', program.list);\nconsole.log(' args: %j', program.args);\n```\n\n## Custom help\n\n You can display arbitrary `-h, --help` information\n by listening for \"--help\". Commander will automatically\n exit once you are done so that the remainder of your program\n does not execute causing undesired behaviours, for example\n in the following executable \"stuff\" will not output when\n `--help` is used.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('../');\n\nfunction list(val) {\n return val.split(',').map(Number);\n}\n\nprogram\n .version('0.0.1')\n .option('-f, --foo', 'enable some foo')\n .option('-b, --bar', 'enable some bar')\n .option('-B, --baz', 'enable some baz');\n\n// must be before .parse() since\n// node's emit() is immediate\n\nprogram.on('--help', function(){\n console.log(' Examples:');\n console.log('');\n console.log(' $ custom-help --help');\n console.log(' $ custom-help -h');\n console.log('');\n});\n\nprogram.parse(process.argv);\n\nconsole.log('stuff');\n```\n\nyielding the following help output:\n\n```\n\nUsage: custom-help [options]\n\nOptions:\n\n -h, --help output usage information\n -V, --version output the version number\n -f, --foo enable some foo\n -b, --bar enable some bar\n -B, --baz enable some baz\n\nExamples:\n\n $ custom-help --help\n $ custom-help -h\n\n```\n\n## .prompt(msg, fn)\n\n Single-line prompt:\n\n```js\nprogram.prompt('name: ', function(name){\n console.log('hi %s', name);\n});\n```\n\n Multi-line prompt:\n\n```js\nprogram.prompt('description:', function(name){\n console.log('hi %s', name);\n});\n```\n\n Coercion:\n\n```js\nprogram.prompt('Age: ', Number, function(age){\n console.log('age: %j', age);\n});\n```\n\n```js\nprogram.prompt('Birthdate: ', Date, function(date){\n console.log('date: %s', date);\n});\n```\n\n```js\nprogram.prompt('Email: ', /^.+@.+\\..+$/, function(email){\n console.log('email: %j', email);\n});\n```\n\n## .password(msg[, mask], fn)\n\nPrompt for password without echoing:\n\n```js\nprogram.password('Password: ', function(pass){\n console.log('got \"%s\"', pass);\n process.stdin.destroy();\n});\n```\n\nPrompt for password with mask char \"*\":\n\n```js\nprogram.password('Password: ', '*', function(pass){\n console.log('got \"%s\"', pass);\n process.stdin.destroy();\n});\n```\n\n## .confirm(msg, fn)\n\n Confirm with the given `msg`:\n\n```js\nprogram.confirm('continue? ', function(ok){\n console.log(' got %j', ok);\n});\n```\n\n## .choose(list, fn)\n\n Let the user choose from a `list`:\n\n```js\nvar list = ['tobi', 'loki', 'jane', 'manny', 'luna'];\n\nconsole.log('Choose the coolest pet:');\nprogram.choose(list, function(i){\n console.log('you chose %d \"%s\"', i, list[i]);\n});\n```\n\n## .outputHelp()\n\n Output help information without exiting.\n\n## .help()\n\n Output help information and exit immediately.\n\n## Links\n\n - [API documentation](http://visionmedia.github.com/commander.js/)\n - [ascii tables](https://github.com/LearnBoost/cli-table)\n - [progress bars](https://github.com/visionmedia/node-progress)\n - [more progress bars](https://github.com/substack/node-multimeter)\n - [examples](https://github.com/visionmedia/commander.js/tree/master/examples)\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "Readme.md", + "_id": "commander@1.3.2", + "dist": { + "shasum": "2dcc593d1983f411896193000f018b047694e50b" + }, + "_from": "commander@1.3.2", + "_resolved": "https://registry.npmjs.org/commander/-/commander-1.3.2.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/.npmignore b/realtime/node_modules/express/node_modules/connect/.npmignore new file mode 100644 index 00000000..9046dde5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/.npmignore @@ -0,0 +1,12 @@ +*.markdown +*.md +.git* +Makefile +benchmarks/ +docs/ +examples/ +install.sh +support/ +test/ +.DS_Store +coverage.html diff --git a/realtime/node_modules/express/node_modules/connect/.travis.yml b/realtime/node_modules/express/node_modules/connect/.travis.yml new file mode 100644 index 00000000..a12e3f0f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/LICENSE b/realtime/node_modules/express/node_modules/connect/LICENSE new file mode 100644 index 00000000..0c5d22d9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/LICENSE @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2010 Sencha Inc. +Copyright (c) 2011 LearnBoost +Copyright (c) 2011 TJ Holowaychuk + +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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/Readme.md b/realtime/node_modules/express/node_modules/connect/Readme.md new file mode 100644 index 00000000..e38a3263 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/Readme.md @@ -0,0 +1,84 @@ +# Connect [![build status](https://secure.travis-ci.org/senchalabs/connect.png)](http://travis-ci.org/senchalabs/connect) + + Connect is an extensible HTTP server framework for [node](http://nodejs.org), providing high performance "plugins" known as _middleware_. + + Connect is bundled with over _20_ commonly used middleware, including + a logger, session support, cookie parser, and [more](http://senchalabs.github.com/connect). Be sure to view the 2.x [documentation](http://senchalabs.github.com/connect/). + +```js +var connect = require('connect') + , http = require('http'); + +var app = connect() + .use(connect.favicon()) + .use(connect.logger('dev')) + .use(connect.static('public')) + .use(connect.directory('public')) + .use(connect.cookieParser()) + .use(connect.session({ secret: 'my secret here' })) + .use(function(req, res){ + res.end('Hello from Connect!\n'); + }); + +http.createServer(app).listen(3000); +``` + +## Middleware + + - [basicAuth](http://www.senchalabs.org/connect/basicAuth.html) + - [bodyParser](http://www.senchalabs.org/connect/bodyParser.html) + - [compress](http://www.senchalabs.org/connect/compress.html) + - [cookieParser](http://www.senchalabs.org/connect/cookieParser.html) + - [cookieSession](http://www.senchalabs.org/connect/cookieSession.html) + - [csrf](http://www.senchalabs.org/connect/csrf.html) + - [directory](http://www.senchalabs.org/connect/directory.html) + - [errorHandler](http://www.senchalabs.org/connect/errorHandler.html) + - [favicon](http://www.senchalabs.org/connect/favicon.html) + - [json](http://www.senchalabs.org/connect/json.html) + - [limit](http://www.senchalabs.org/connect/limit.html) + - [logger](http://www.senchalabs.org/connect/logger.html) + - [methodOverride](http://www.senchalabs.org/connect/methodOverride.html) + - [multipart](http://www.senchalabs.org/connect/multipart.html) + - [urlencoded](http://www.senchalabs.org/connect/urlencoded.html) + - [query](http://www.senchalabs.org/connect/query.html) + - [responseTime](http://www.senchalabs.org/connect/responseTime.html) + - [session](http://www.senchalabs.org/connect/session.html) + - [static](http://www.senchalabs.org/connect/static.html) + - [staticCache](http://www.senchalabs.org/connect/staticCache.html) + - [subdomains](http://www.senchalabs.org/connect/subdomains.html) + - [vhost](http://www.senchalabs.org/connect/vhost.html) + +## Running Tests + +first: + + $ npm install -d + +then: + + $ make test + +## Contributors + + https://github.com/senchalabs/connect/graphs/contributors + +## Node Compatibility + + Connect `< 1.x` is compatible with node 0.2.x + + + Connect `1.x` is compatible with node 0.4.x + + + Connect `2.x` is compatible with node 0.6.x + + + Connect (_master_) is compatible with node 0.8.x + +## CLA + + [http://sencha.com/cla](http://sencha.com/cla) + +## License + +View the [LICENSE](https://github.com/senchalabs/connect/blob/master/LICENSE) file. The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons used by the `directory` middleware created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/). diff --git a/realtime/node_modules/express/node_modules/connect/index.js b/realtime/node_modules/express/node_modules/connect/index.js new file mode 100644 index 00000000..23240eed --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/index.js @@ -0,0 +1,4 @@ + +module.exports = process.env.CONNECT_COV + ? require('./lib-cov/connect') + : require('./lib/connect'); \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/lib/cache.js b/realtime/node_modules/express/node_modules/connect/lib/cache.js new file mode 100644 index 00000000..052fcdb3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/cache.js @@ -0,0 +1,81 @@ + +/*! + * Connect - Cache + * Copyright(c) 2011 Sencha Inc. + * MIT Licensed + */ + +/** + * Expose `Cache`. + */ + +module.exports = Cache; + +/** + * LRU cache store. + * + * @param {Number} limit + * @api private + */ + +function Cache(limit) { + this.store = {}; + this.keys = []; + this.limit = limit; +} + +/** + * Touch `key`, promoting the object. + * + * @param {String} key + * @param {Number} i + * @api private + */ + +Cache.prototype.touch = function(key, i){ + this.keys.splice(i,1); + this.keys.push(key); +}; + +/** + * Remove `key`. + * + * @param {String} key + * @api private + */ + +Cache.prototype.remove = function(key){ + delete this.store[key]; +}; + +/** + * Get the object stored for `key`. + * + * @param {String} key + * @return {Array} + * @api private + */ + +Cache.prototype.get = function(key){ + return this.store[key]; +}; + +/** + * Add a cache `key`. + * + * @param {String} key + * @return {Array} + * @api private + */ + +Cache.prototype.add = function(key){ + // initialize store + var len = this.keys.push(key); + + // limit reached, invalidate LRU + if (len > this.limit) this.remove(this.keys.shift()); + + var arr = this.store[key] = []; + arr.createdAt = new Date; + return arr; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/connect.js b/realtime/node_modules/express/node_modules/connect/lib/connect.js new file mode 100644 index 00000000..72961dca --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/connect.js @@ -0,0 +1,92 @@ +/*! + * Connect + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var EventEmitter = require('events').EventEmitter + , proto = require('./proto') + , utils = require('./utils') + , path = require('path') + , basename = path.basename + , fs = require('fs'); + +// node patches + +require('./patch'); + +// expose createServer() as the module + +exports = module.exports = createServer; + +/** + * Framework version. + */ + +exports.version = '2.7.11'; + +/** + * Expose mime module. + */ + +exports.mime = require('./middleware/static').mime; + +/** + * Expose the prototype. + */ + +exports.proto = proto; + +/** + * Auto-load middleware getters. + */ + +exports.middleware = {}; + +/** + * Expose utilities. + */ + +exports.utils = utils; + +/** + * Create a new connect server. + * + * @return {Function} + * @api public + */ + +function createServer() { + function app(req, res, next){ app.handle(req, res, next); } + utils.merge(app, proto); + utils.merge(app, EventEmitter.prototype); + app.route = '/'; + app.stack = []; + for (var i = 0; i < arguments.length; ++i) { + app.use(arguments[i]); + } + return app; +}; + +/** + * Support old `.createServer()` method. + */ + +createServer.createServer = createServer; + +/** + * Auto-load bundled middleware with getters. + */ + +fs.readdirSync(__dirname + '/middleware').forEach(function(filename){ + if (!/\.js$/.test(filename)) return; + var name = basename(filename, '.js'); + function load(){ return require('./middleware/' + name); } + exports.middleware.__defineGetter__(name, load); + exports.__defineGetter__(name, load); +}); diff --git a/realtime/node_modules/express/node_modules/connect/lib/index.js b/realtime/node_modules/express/node_modules/connect/lib/index.js new file mode 100644 index 00000000..5938c753 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/index.js @@ -0,0 +1,50 @@ + +/** + * Connect is a middleware framework for node, + * shipping with over 18 bundled middleware and a rich selection of + * 3rd-party middleware. + * + * var app = connect() + * .use(connect.logger('dev')) + * .use(connect.static('public')) + * .use(function(req, res){ + * res.end('hello world\n'); + * }) + * + * http.createServer(app).listen(3000); + * + * Installation: + * + * $ npm install connect + * + * Middleware: + * + * - [logger](logger.html) request logger with custom format support + * - [csrf](csrf.html) Cross-site request forgery protection + * - [compress](compress.html) Gzip compression middleware + * - [basicAuth](basicAuth.html) basic http authentication + * - [bodyParser](bodyParser.html) extensible request body parser + * - [json](json.html) application/json parser + * - [urlencoded](urlencoded.html) application/x-www-form-urlencoded parser + * - [multipart](multipart.html) multipart/form-data parser + * - [timeout](timeout.html) request timeouts + * - [cookieParser](cookieParser.html) cookie parser + * - [session](session.html) session management support with bundled MemoryStore + * - [cookieSession](cookieSession.html) cookie-based session support + * - [methodOverride](methodOverride.html) faux HTTP method support + * - [responseTime](responseTime.html) calculates response-time and exposes via X-Response-Time + * - [staticCache](staticCache.html) memory cache layer for the static() middleware + * - [static](static.html) streaming static file server supporting `Range` and more + * - [directory](directory.html) directory listing middleware + * - [vhost](vhost.html) virtual host sub-domain mapping middleware + * - [favicon](favicon.html) efficient favicon server (with default icon) + * - [limit](limit.html) limit the bytesize of request bodies + * - [query](query.html) automatic querystring parser, populating `req.query` + * - [errorHandler](errorHandler.html) flexible error handler + * + * Links: + * + * - list of [3rd-party](https://github.com/senchalabs/connect/wiki) middleware + * - GitHub [repository](http://github.com/senchalabs/connect) + * + */ \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/basicAuth.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/basicAuth.js new file mode 100644 index 00000000..8af07ca0 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/basicAuth.js @@ -0,0 +1,106 @@ +/*! + * Connect - basicAuth + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../utils') + , unauthorized = utils.unauthorized; + +/** + * Basic Auth: + * + * Status: Deprecated. No bug reports or pull requests are welcomed + * for this middleware. However, this middleware will not be removed. + * Instead, you should use [basic-auth](https://github.com/visionmedia/node-basic-auth). + * + * Enfore basic authentication by providing a `callback(user, pass)`, + * which must return `true` in order to gain access. Alternatively an async + * method is provided as well, invoking `callback(user, pass, callback)`. Populates + * `req.user`. The final alternative is simply passing username / password + * strings. + * + * Simple username and password + * + * connect(connect.basicAuth('username', 'password')); + * + * Callback verification + * + * connect() + * .use(connect.basicAuth(function(user, pass){ + * return 'tj' == user && 'wahoo' == pass; + * })) + * + * Async callback verification, accepting `fn(err, user)`. + * + * connect() + * .use(connect.basicAuth(function(user, pass, fn){ + * User.authenticate({ user: user, pass: pass }, fn); + * })) + * + * @param {Function|String} callback or username + * @param {String} realm + * @api public + */ + +module.exports = function basicAuth(callback, realm) { + var username, password; + + // user / pass strings + if ('string' == typeof callback) { + username = callback; + password = realm; + if ('string' != typeof password) throw new Error('password argument required'); + realm = arguments[2]; + callback = function(user, pass){ + return user == username && pass == password; + } + } + + realm = realm || 'Authorization Required'; + + return function(req, res, next) { + var authorization = req.headers.authorization; + + if (req.user) return next(); + if (!authorization) return unauthorized(res, realm); + + var parts = authorization.split(' '); + + if (parts.length !== 2) return next(utils.error(400)); + + var scheme = parts[0] + , credentials = new Buffer(parts[1], 'base64').toString() + , index = credentials.indexOf(':'); + + if ('Basic' != scheme || index < 0) return next(utils.error(400)); + + var user = credentials.slice(0, index) + , pass = credentials.slice(index + 1); + + // async + if (callback.length >= 3) { + var pause = utils.pause(req); + callback(user, pass, function(err, user){ + if (err || !user) return unauthorized(res, realm); + req.user = req.remoteUser = user; + next(); + pause.resume(); + }); + // sync + } else { + if (callback(user, pass)) { + req.user = req.remoteUser = user; + next(); + } else { + unauthorized(res, realm); + } + } + } +}; + diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js new file mode 100644 index 00000000..14481f56 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js @@ -0,0 +1,68 @@ + +/*! + * Connect - bodyParser + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var multipart = require('./multipart') + , urlencoded = require('./urlencoded') + , json = require('./json'); + +/** + * Body parser: + * + * Status: the multipart body parser will be removed in Connect 3. + * + * Parse request bodies, supports _application/json_, + * _application/x-www-form-urlencoded_, and _multipart/form-data_. + * + * This is equivalent to: + * + * app.use(connect.json()); + * app.use(connect.urlencoded()); + * app.use(connect.multipart()); + * + * Examples: + * + * connect() + * .use(connect.bodyParser()) + * .use(function(req, res) { + * res.end('viewing user ' + req.body.user.name); + * }); + * + * $ curl -d 'user[name]=tj' http://local/ + * $ curl -d '{"user":{"name":"tj"}}' -H "Content-Type: application/json" http://local/ + * + * View [json](json.html), [urlencoded](urlencoded.html), and [multipart](multipart.html) for more info. + * + * If you wish to create your own body parser, you may be interested in: + * + * - [raw-body](https://github.com/stream-utils/raw-body) + * - [body](https://github.com/raynos/body) + * + * @param {Object} options + * @return {Function} + * @api public + */ + +exports = module.exports = function bodyParser(options){ + var _urlencoded = urlencoded(options) + , _multipart = multipart(options) + , _json = json(options); + + return function bodyParser(req, res, next) { + _json(req, res, function(err){ + if (err) return next(err); + _urlencoded(req, res, function(err){ + if (err) return next(err); + _multipart(req, res, next); + }); + }); + } +}; \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/compress.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/compress.js new file mode 100644 index 00000000..a300e530 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/compress.js @@ -0,0 +1,192 @@ +/*! + * Connect - compress + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var zlib = require('zlib'); +var utils = require('../utils'); +var Negotiator = require('negotiator'); + +/** + * Supported content-encoding methods. + */ + +exports.methods = { + gzip: zlib.createGzip + , deflate: zlib.createDeflate +}; + +/** + * Default filter function. + */ + +exports.filter = function(req, res){ + return /json|text|javascript|dart|image\/svg\+xml|application\/x-font-ttf|application\/vnd\.ms-opentype|application\/vnd\.ms-fontobject/.test(res.getHeader('Content-Type')); +}; + +/** + * 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){ + * return /json|text|javascript/.test(res.getHeader('Content-Type')); + * }; + * + * Threshold: + * + * Only compress the response if the byte size is at or above a threshold. + * Always compress while streaming. + * + * - `threshold` - string representation of size or bytes as an integer. + * + * 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) { + options = options || {}; + var filter = options.filter || exports.filter; + var threshold; + + if (false === options.threshold || 0 === options.threshold) { + threshold = 0 + } else if ('string' === typeof options.threshold) { + threshold = utils.parseBytes(options.threshold) + } else { + threshold = options.threshold || 1024 + } + + return function compress(req, res, next){ + var accept = req.headers['accept-encoding'] + , write = res.write + , end = res.end + , compress = true + , stream; + + // see #724 + req.on('close', function(){ + res.write = res.end = function(){}; + }); + + // flush is noop by default + res.flush = noop; + + // proxy + + res.write = function(chunk, encoding){ + if (!this.headerSent) { + // if content-length is set and is lower + // than the threshold, don't compress + var length = res.getHeader('content-length'); + if (!isNaN(length) && length < threshold) compress = false; + this._implicitHeader(); + } + return stream + ? stream.write(new Buffer(chunk, encoding)) + : write.call(res, chunk, encoding); + }; + + res.end = function(chunk, encoding){ + if (chunk) { + if (!this.headerSent && getSize(chunk) < threshold) compress = false; + this.write(chunk, encoding); + } else if (!this.headerSent) { + // response size === 0 + compress = false; + } + return stream + ? stream.end() + : end.call(res); + }; + + res.on('header', function(){ + // default request filter + if (!filter(req, res)) return; + + // vary + var vary = res.getHeader('Vary'); + if (!vary) { + res.setHeader('Vary', 'Accept-Encoding'); + } else if (!~vary.indexOf('Accept-Encoding')) { + res.setHeader('Vary', vary + ', Accept-Encoding'); + } + + if (!compress) return; + + var encoding = res.getHeader('Content-Encoding') || 'identity'; + + // already encoded + if ('identity' != encoding) return; + + // SHOULD use identity + if (!accept) return; + + // head + if ('HEAD' == req.method) return; + + // compression method + var method = new Negotiator(req).preferredEncoding(['gzip', 'deflate', 'identity']); + // negotiation failed + if (method === 'identity') return; + + // compression stream + stream = exports.methods[method](options); + + // overwrite the flush method + res.flush = function(){ + stream.flush(); + } + + // 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); + }); + + stream.on('drain', function() { + res.emit('drain'); + }); + }); + + next(); + }; +}; + +function getSize(chunk) { + return Buffer.isBuffer(chunk) + ? chunk.length + : Buffer.byteLength(chunk); +} + +function noop(){} diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js new file mode 100644 index 00000000..665226c4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js @@ -0,0 +1,67 @@ + +/*! + * Connect - cookieParser + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('./../utils') + , cookie = require('cookie'); + +/** + * Cookie parser: + * + * Status: Deprecated. This middleware will be removed in + * Connect 3.0 and will be replaced by a `cookies` middleware, + * which will use [cookies](http://github.com/jed/cookies) + * and [keygrip](https://github.com/jed/keygrip). + * + * Parse _Cookie_ header and populate `req.cookies` + * with an object keyed by the cookie names. Optionally + * you may enabled signed cookie support by passing + * a `secret` string, which assigns `req.secret` so + * it may be used by other middleware. + * + * Examples: + * + * connect() + * .use(connect.cookieParser('optional secret string')) + * .use(function(req, res, next){ + * res.end(JSON.stringify(req.cookies)); + * }) + * + * @param {String} secret + * @return {Function} + * @api public + */ + +module.exports = function cookieParser(secret, opt){ + return function cookieParser(req, res, next) { + if (req.cookies) return next(); + var cookies = req.headers.cookie; + + req.secret = secret; + req.cookies = {}; + req.signedCookies = {}; + + if (cookies) { + try { + req.cookies = cookie.parse(cookies, opt); + if (secret) { + req.signedCookies = utils.parseSignedCookies(req.cookies, secret); + req.signedCookies = utils.parseJSONCookies(req.signedCookies); + } + req.cookies = utils.parseJSONCookies(req.cookies); + } catch (err) { + err.status = 400; + return next(err); + } + } + next(); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/cookieSession.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/cookieSession.js new file mode 100644 index 00000000..663f2b97 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/cookieSession.js @@ -0,0 +1,122 @@ +/*! + * Connect - cookieSession + * Copyright(c) 2011 Sencha Inc. + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('./../utils') + , Cookie = require('./session/cookie') + , debug = require('debug')('connect:cookieSession') + , signature = require('cookie-signature') + , crc32 = require('buffer-crc32') + , url = require('url'); + +/** + * Cookie Session: + * + * Cookie session middleware. + * + * var app = connect(); + * app.use(connect.cookieParser()); + * app.use(connect.cookieSession({ secret: 'tobo!', cookie: { maxAge: 60 * 60 * 1000 }})); + * + * Options: + * + * - `key` cookie name defaulting to `connect.sess` + * - `secret` prevents cookie tampering + * - `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; + * + * If you are interested in more sophisticated solutions, + * you may be interested in: + * + * - [client-sessions](https://github.com/mozilla/node-client-sessions) + * + * @param {Object} options + * @return {Function} + * @api public + */ + +module.exports = function cookieSession(options){ + // TODO: utilize Session/Cookie to unify API + options = options || {}; + var key = options.key || 'connect.sess' + , trustProxy = options.proxy; + + return function cookieSession(req, res, next) { + + // req.secret is for backwards compatibility + var secret = options.secret || req.secret; + if (!secret) throw new Error('`secret` option required for cookie sessions'); + + // default session + req.session = {}; + var cookie = req.session.cookie = new Cookie(options.cookie); + + // pathname mismatch + var originalPath = url.parse(req.originalUrl).pathname; + if (0 != originalPath.indexOf(cookie.path)) return next(); + + // cookieParser secret + if (!options.secret && req.secret) { + req.session = req.signedCookies[key] || {}; + req.session.cookie = cookie; + } else { + // TODO: refactor + var rawCookie = req.cookies[key]; + if (rawCookie) { + var unsigned = utils.parseSignedCookie(rawCookie, secret); + if (unsigned) { + var originalHash = crc32.signed(unsigned); + req.session = utils.parseJSONCookie(unsigned) || {}; + req.session.cookie = cookie; + } + } + } + + res.on('header', function(){ + // removed + if (!req.session) { + debug('clear session'); + cookie.expires = new Date(0); + res.setHeader('Set-Cookie', cookie.serialize(key, '')); + return; + } + + delete req.session.cookie; + + // check security + var proto = (req.headers['x-forwarded-proto'] || '').toLowerCase() + , tls = req.connection.encrypted || (trustProxy && 'https' == proto.split(/\s*,\s*/)[0]); + + // only send secure cookies via https + if (cookie.secure && !tls) return debug('not secured'); + + // serialize + debug('serializing %j', req.session); + var val = 'j:' + JSON.stringify(req.session); + + // compare hashes, no need to set-cookie if unchanged + if (originalHash == crc32.signed(val)) return debug('unmodified session'); + + // set-cookie + val = 's:' + signature.sign(val, secret); + val = cookie.serialize(key, val); + debug('set-cookie %j', cookie); + res.setHeader('Set-Cookie', val); + }); + + next(); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/csrf.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/csrf.js new file mode 100644 index 00000000..1c3854b4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/csrf.js @@ -0,0 +1,163 @@ +/*! + * Connect - csrf + * Copyright(c) 2011 Sencha Inc. + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../utils'); +var uid = require('uid2'); +var crypto = require('crypto'); + +/** + * Anti CSRF: + * + * CSRF protection middleware. + * + * This middleware adds a `req.csrfToken()` function to make a token + * which should be added to requests which mutate + * state, within a hidden form field, query-string etc. This + * token is validated against the visitor's session. + * + * The default `value` function checks `req.body` generated + * by the `bodyParser()` middleware, `req.query` generated + * by `query()`, and the "X-CSRF-Token" header field. + * + * This middleware requires session support, thus should be added + * somewhere _below_ `session()` and `cookieParser()`. + * + * Options: + * + * - `value` a function accepting the request, returning the token + * + * @param {Object} options + * @api public + */ + +module.exports = function csrf(options) { + options = options || {}; + var value = options.value || defaultValue; + + return function(req, res, next){ + + // already have one + var secret = req.session._csrfSecret; + if (secret) return createToken(secret); + + // generate secret + uid(24, function(err, secret){ + if (err) return next(err); + req.session._csrfSecret = secret; + createToken(secret); + }); + + // generate the token + function createToken(secret) { + var token; + + // lazy-load token + req.csrfToken = function csrfToken() { + return token || (token = saltedToken(secret)); + }; + + // compatibility with old middleware + Object.defineProperty(req.session, '_csrf', { + configurable: true, + get: function() { + console.warn('req.session._csrf is deprecated, use req.csrfToken() instead'); + return req.csrfToken(); + } + }); + + // ignore these methods + if ('GET' == req.method || 'HEAD' == req.method || 'OPTIONS' == req.method) return next(); + + // determine user-submitted value + var val = value(req); + + // check + if (!checkToken(val, secret)) return next(utils.error(403)); + + next(); + } + } +}; + +/** + * Default value function, checking the `req.body` + * and `req.query` for the CSRF token. + * + * @param {IncomingMessage} req + * @return {String} + * @api private + */ + +function defaultValue(req) { + return (req.body && req.body._csrf) + || (req.query && req.query._csrf) + || (req.headers['x-csrf-token']) + || (req.headers['x-xsrf-token']); +} + +/** + * Return salted token. + * + * @param {String} secret + * @return {String} + * @api private + */ + +function saltedToken(secret) { + return createToken(generateSalt(10), secret); +} + +/** + * Creates a CSRF token from a given salt and secret. + * + * @param {String} salt (should be 10 characters) + * @param {String} secret + * @return {String} + * @api private + */ + +function createToken(salt, secret) { + return salt + crypto + .createHash('sha1') + .update(salt + secret) + .digest('base64'); +} + +/** + * Checks if a given CSRF token matches the given secret. + * + * @param {String} token + * @param {String} secret + * @return {Boolean} + * @api private + */ + +function checkToken(token, secret) { + if ('string' != typeof token) return false; + return token === createToken(token.slice(0, 10), secret); +} + +/** + * Generates a random salt, using a fast non-blocking PRNG (Math.random()). + * + * @param {Number} length + * @return {String} + * @api private + */ + +function generateSalt(length) { + var i, r = []; + for (i = 0; i < length; ++i) { + r.push(SALTCHARS[Math.floor(Math.random() * SALTCHARS.length)]); + } + return r.join(''); +} + +var SALTCHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/directory.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/directory.js new file mode 100644 index 00000000..ac8ea7a5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/directory.js @@ -0,0 +1,330 @@ + +/*! + * Connect - directory + * Copyright(c) 2011 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +// TODO: arrow key navigation +// TODO: make icons extensible + +/** + * Module dependencies. + */ + +var fs = require('fs') + , parse = require('url').parse + , utils = require('../utils') + , path = require('path') + , normalize = path.normalize + , sep = path.sep + , extname = path.extname + , join = path.join; +var Batch = require('batch'); +var Negotiator = require('negotiator'); + +/*! + * Icon cache. + */ + +var cache = {}; + +/** + * Media types and the map for content negotiation. + */ + +var mediaTypes = [ + 'text/html', + 'text/plain', + 'application/json' +]; + +var mediaType = { + 'text/html': 'html', + 'text/plain': 'plain', + 'application/json': 'json' +}; + +/** + * Directory: + * + * Serve directory listings with the given `root` path. + * + * Options: + * + * - `hidden` display hidden (dot) files. Defaults to false. + * - `icons` display icons. Defaults to false. + * - `filter` Apply this filter function to files. Defaults to false. + * + * @param {String} root + * @param {Object} options + * @return {Function} + * @api public + */ + +exports = module.exports = function directory(root, options){ + options = options || {}; + + // root required + if (!root) throw new Error('directory() root path required'); + var hidden = options.hidden + , icons = options.icons + , view = options.view || 'tiles' + , filter = options.filter + , root = normalize(root + sep); + + return function directory(req, res, next) { + if ('GET' != req.method && 'HEAD' != req.method) return next(); + + var url = parse(req.url) + , dir = decodeURIComponent(url.pathname) + , path = normalize(join(root, dir)) + , originalUrl = parse(req.originalUrl) + , originalDir = decodeURIComponent(originalUrl.pathname) + , showUp = path != root; + + // null byte(s), bad request + if (~path.indexOf('\0')) return next(utils.error(400)); + + // malicious path, forbidden + if (0 != path.indexOf(root)) return next(utils.error(403)); + + // check if we have a directory + fs.stat(path, function(err, stat){ + if (err) return 'ENOENT' == err.code + ? next() + : next(err); + + if (!stat.isDirectory()) return next(); + + // fetch files + fs.readdir(path, function(err, files){ + if (err) return next(err); + if (!hidden) files = removeHidden(files); + if (filter) files = files.filter(filter); + files.sort(); + + // content-negotiation + var type = new Negotiator(req).preferredMediaType(mediaTypes); + + // not acceptable + if (!type) return next(utils.error(406)); + exports[mediaType[type]](req, res, files, next, originalDir, showUp, icons, path, view); + }); + }); + }; +}; + +/** + * Respond with text/html. + */ + +exports.html = function(req, res, files, next, dir, showUp, icons, path, view){ + fs.readFile(__dirname + '/../public/directory.html', 'utf8', function(err, str){ + if (err) return next(err); + fs.readFile(__dirname + '/../public/style.css', 'utf8', function(err, style){ + if (err) return next(err); + stat(path, files, function(err, stats){ + if (err) return next(err); + files = files.map(function(file, i){ return { name: file, stat: stats[i] }; }); + files.sort(fileSort); + if (showUp) files.unshift({ name: '..' }); + str = str + .replace('{style}', style.concat(iconStyle(files, icons))) + .replace('{files}', html(files, dir, icons, view)) + .replace('{directory}', dir) + .replace('{linked-path}', htmlPath(dir)); + res.setHeader('Content-Type', 'text/html'); + res.setHeader('Content-Length', str.length); + res.end(str); + }); + }); + }); +}; + +/** + * Respond with application/json. + */ + +exports.json = function(req, res, files){ + files = JSON.stringify(files); + res.setHeader('Content-Type', 'application/json'); + res.setHeader('Content-Length', files.length); + res.end(files); +}; + +/** + * Respond with text/plain. + */ + +exports.plain = function(req, res, files){ + files = files.join('\n') + '\n'; + res.setHeader('Content-Type', 'text/plain'); + res.setHeader('Content-Length', files.length); + res.end(files); +}; + +/** + * Sort function for with directories first. + */ + +function fileSort(a, b) { + return Number(b.stat && b.stat.isDirectory()) - Number(a.stat && a.stat.isDirectory()) || + String(a.name).toLocaleLowerCase().localeCompare(String(b.name).toLocaleLowerCase()); +} + +/** + * Map html `dir`, returning a linked path. + */ + +function htmlPath(dir) { + var curr = []; + return dir.split('/').map(function(part){ + curr.push(encodeURIComponent(part)); + return part ? '' + part + '' : ''; + }).join(' / '); +} + +/** + * Load icon images, return css string. + */ + +function iconStyle (files, useIcons) { + if (!useIcons) return ''; + var data = {}; + var views = { tiles: [], details: [], mobile: [] }; + + for (var i=0; i < files.length; i++) { + var file = files[i]; + if (file.name == '..') continue; + + var isDir = '..' == file.name || (file.stat && file.stat.isDirectory()); + var icon = isDir ? icons.folder : icons[extname(file.name)] || icons.default; + + var ext = extname(file.name); + ext = isDir ? '.directory' : (icons[ext] ? ext : '.default'); + + if (data[icon]) continue; + data[icon] = ext + ' .name{background-image: url(data:image/png;base64,' + load(icon)+');}'; + views.tiles.push('.view-tiles ' + data[icon]); + views.details.push('.view-details ' + data[icon]); + views.mobile.push('#files ' + data[icon]); + } + + var style = views.tiles.join('\n') + + '\n'+views.details.join('\n') + + '\n@media (max-width: 768px) {\n\t' + + views.mobile.join('\n\t') + + '\n}'; + return style; +} + +/** + * Map html `files`, returning an html unordered list. + */ + +function html(files, dir, useIcons, view) { + return '
    ' + + (view == 'details' ? ( + '
  • ' + + 'Name' + + 'Size' + + 'Modified' + + '
  • ') : '') + + files.map(function(file){ + var isDir + , classes = [] + , path = dir.split('/').map(function (c) { return encodeURIComponent(c); }); + + if (useIcons) { + var ext = extname(file.name); + isDir = '..' == file.name || (file.stat && file.stat.isDirectory()); + ext = isDir ? '.directory' : (icons[ext] ? ext : '.default'); + classes.push('icon'); + classes.push(ext.replace('.','')); + } + + path.push(encodeURIComponent(file.name)); + + var date = file.name == '..' ? '' + : file.stat.mtime.toDateString()+' '+file.stat.mtime.toLocaleTimeString(); + var size = file.name == '..' ? '' : file.stat.size; + + return '
  • ' + + ''+file.name+'' + + ''+size+'' + + ''+date+'' + + '
  • '; + + }).join('\n') + '
'; +} + +/** + * Load and cache the given `icon`. + * + * @param {String} icon + * @return {String} + * @api private + */ + +function load(icon) { + if (cache[icon]) return cache[icon]; + return cache[icon] = fs.readFileSync(__dirname + '/../public/icons/' + icon, 'base64'); +} + +/** + * Filter "hidden" `files`, aka files + * beginning with a `.`. + * + * @param {Array} files + * @return {Array} + * @api private + */ + +function removeHidden(files) { + return files.filter(function(file){ + return '.' != file[0]; + }); +} + +/** + * Stat all files and return array of stat + * in same order. + */ + +function stat(dir, files, cb) { + var batch = new Batch(); + + batch.concurrency(10); + + files.forEach(function(file, i){ + batch.push(function(done){ + fs.stat(join(dir, file), done); + }); + }); + + batch.end(cb); +} + +/** + * Icon map. + */ + +var icons = { + '.js': 'page_white_code_red.png' + , '.c': 'page_white_c.png' + , '.h': 'page_white_h.png' + , '.cc': 'page_white_cplusplus.png' + , '.php': 'page_white_php.png' + , '.rb': 'page_white_ruby.png' + , '.cpp': 'page_white_cplusplus.png' + , '.swf': 'page_white_flash.png' + , '.pdf': 'page_white_acrobat.png' + , 'folder': 'folder.png' + , 'default': 'page_white.png' +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/errorHandler.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/errorHandler.js new file mode 100644 index 00000000..56e96830 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/errorHandler.js @@ -0,0 +1,86 @@ +/*! + * Connect - errorHandler + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../utils') + , fs = require('fs'); + +// environment + +var env = process.env.NODE_ENV || 'development'; + +/** + * Error handler: + * + * Development error handler, providing stack traces + * and error message responses for requests accepting text, html, + * or json. + * + * Text: + * + * By default, and when _text/plain_ is accepted a simple stack trace + * or error message will be returned. + * + * JSON: + * + * When _application/json_ is accepted, connect will respond with + * an object in the form of `{ "error": error }`. + * + * HTML: + * + * When accepted connect will output a nice html stack trace. + * + * @return {Function} + * @api public + */ + +exports = module.exports = function errorHandler(){ + return function errorHandler(err, req, res, next){ + if (err.status) res.statusCode = err.status; + if (res.statusCode < 400) res.statusCode = 500; + if ('test' != env) console.error(err.stack); + var accept = req.headers.accept || ''; + // html + if (~accept.indexOf('html')) { + fs.readFile(__dirname + '/../public/style.css', 'utf8', function(e, style){ + fs.readFile(__dirname + '/../public/error.html', 'utf8', function(e, html){ + var stack = (err.stack || '') + .split('\n').slice(1) + .map(function(v){ return '
  • ' + v + '
  • '; }).join(''); + html = html + .replace('{style}', style) + .replace('{stack}', stack) + .replace('{title}', exports.title) + .replace('{statusCode}', res.statusCode) + .replace(/\{error\}/g, utils.escape(err.toString().replace(/\n/g, '
    '))); + res.setHeader('Content-Type', 'text/html; charset=utf-8'); + res.end(html); + }); + }); + // json + } else if (~accept.indexOf('json')) { + var error = { message: err.message, stack: err.stack }; + for (var prop in err) error[prop] = err[prop]; + var json = JSON.stringify({ error: error }); + res.setHeader('Content-Type', 'application/json'); + res.end(json); + // plain text + } else { + res.setHeader('Content-Type', 'text/plain'); + res.end(err.stack); + } + }; +}; + +/** + * Template title, framework authors may override this value. + */ + +exports.title = 'Connect'; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/favicon.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/favicon.js new file mode 100644 index 00000000..ef543544 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/favicon.js @@ -0,0 +1,80 @@ +/*! + * Connect - favicon + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var fs = require('fs') + , utils = require('../utils'); + +/** + * Favicon: + * + * By default serves the connect favicon, or the favicon + * located by the given `path`. + * + * Options: + * + * - `maxAge` cache-control max-age directive, defaulting to 1 day + * + * Examples: + * + * Serve default favicon: + * + * connect() + * .use(connect.favicon()) + * + * Serve favicon before logging for brevity: + * + * connect() + * .use(connect.favicon()) + * .use(connect.logger('dev')) + * + * Serve custom favicon: + * + * connect() + * .use(connect.favicon('public/favicon.ico')) + * + * @param {String} path + * @param {Object} options + * @return {Function} + * @api public + */ + +module.exports = function favicon(path, options){ + var options = options || {} + , path = path || __dirname + '/../public/favicon.ico' + , maxAge = options.maxAge || 86400000 + , icon; // favicon cache + + return function favicon(req, res, next){ + if ('/favicon.ico' == req.url) { + if (icon) { + res.writeHead(200, icon.headers); + res.end(icon.body); + } else { + fs.readFile(path, function(err, buf){ + if (err) return next(err); + icon = { + headers: { + 'Content-Type': 'image/x-icon' + , 'Content-Length': buf.length + , 'ETag': '"' + utils.md5(buf) + '"' + , 'Cache-Control': 'public, max-age=' + (maxAge / 1000) + }, + body: buf + }; + res.writeHead(200, icon.headers); + res.end(icon.body); + }); + } + } else { + next(); + } + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/json.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/json.js new file mode 100644 index 00000000..ef489852 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/json.js @@ -0,0 +1,87 @@ + +/*! + * Connect - json + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../utils'); +var getBody = require('raw-body'); + +/** + * JSON: + * + * Parse JSON request bodies, providing the + * parsed object as `req.body`. + * + * Options: + * + * - `strict` when `false` anything `JSON.parse()` accepts will be parsed + * - `reviver` used as the second "reviver" argument for JSON.parse + * - `limit` byte limit [1mb] + * + * @param {Object} options + * @return {Function} + * @api public + */ + +exports = module.exports = function(options){ + options = options || {}; + var strict = options.strict !== false; + var verify = typeof options.verify === 'function' && options.verify; + + return function json(req, res, next) { + if (req._body) return next(); + req.body = req.body || {}; + + if (!utils.hasBody(req)) return next(); + + // check Content-Type + if (!exports.regexp.test(utils.mime(req))) return next(); + + // flag as parsed + req._body = true; + + // parse + getBody(req, { + limit: options.limit || '1mb', + length: req.headers['content-length'], + encoding: 'utf8' + }, function (err, buf) { + if (err) return next(err); + + if (verify) { + try { + verify(req, res, buf) + } catch (err) { + if (!err.status) err.status = 403; + return next(err); + } + } + + var first = buf.trim()[0]; + + if (0 == buf.length) { + return next(utils.error(400, 'invalid json, empty body')); + } + + if (strict && '{' != first && '[' != first) return next(utils.error(400, 'invalid json')); + try { + req.body = JSON.parse(buf, options.reviver); + } catch (err){ + err.body = buf; + err.status = 400; + return next(err); + } + next(); + }) + }; +}; + +exports.regexp = /^application\/([\w!#\$%&\*`\-\.\^~]*\+)?json$/i; + diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/limit.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/limit.js new file mode 100644 index 00000000..2b895f97 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/limit.js @@ -0,0 +1,89 @@ + +/*! + * Connect - limit + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../utils'), + brokenPause = utils.brokenPause; + +/** + * Limit: + * + * Status: Deprecated. This middleware will be removed in Connect 3.0. + * If you still wish to use some type of limit middleware, + * you may be interested in: + * + * - [raw-body](https://github.com/stream-utils/raw-body) + * + * Limit request bodies to the given size in `bytes`. + * + * A string representation of the bytesize may also be passed, + * for example "5mb", "200kb", "1gb", etc. + * + * connect() + * .use(connect.limit('5.5mb')) + * .use(handleImageUpload) + * + * @param {Number|String} bytes + * @return {Function} + * @api public + */ + +module.exports = function limit(bytes){ + if ('string' == typeof bytes) bytes = utils.parseBytes(bytes); + if ('number' != typeof bytes) throw new Error('limit() bytes required'); + + if (process.env.NODE_ENV !== 'test') { + console.warn('connect.limit() will be removed in connect 3.0'); + } + + return function limit(req, res, next){ + var received = 0 + , len = req.headers['content-length'] + ? parseInt(req.headers['content-length'], 10) + : null; + + // self-awareness + if (req._limit) return next(); + req._limit = true; + + // limit by content-length + if (len && len > bytes) return next(utils.error(413)); + + // limit + if (brokenPause) { + listen(); + } else { + req.on('newListener', function handler(event) { + if (event !== 'data') return; + + req.removeListener('newListener', handler); + // Start listening at the end of the current loop + // otherwise the request will be consumed too early. + // Sideaffect is `limit` will miss the first chunk, + // but that's not a big deal. + // Unfortunately, the tests don't have large enough + // request bodies to test this. + process.nextTick(listen); + }); + }; + + next(); + + function listen() { + req.on('data', function(chunk) { + received += Buffer.isBuffer(chunk) + ? chunk.length : + Buffer.byteLength(chunk); + + if (received > bytes) req.destroy(); + }); + }; + }; +}; \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/logger.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/logger.js new file mode 100644 index 00000000..fba43e41 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/logger.js @@ -0,0 +1,342 @@ +/*! + * Connect - logger + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var bytes = require('bytes'); + +/*! + * Log buffer. + */ + +var buf = []; + +/*! + * Default log buffer duration. + */ + +var defaultBufferDuration = 1000; + +/** + * Logger: + * + * Log requests with the given `options` or a `format` string. + * + * Options: + * + * - `format` Format string, see below for tokens + * - `stream` Output stream, defaults to _stdout_ + * - `buffer` Buffer duration, defaults to 1000ms when _true_ + * - `immediate` Write log line on request instead of response (for response times) + * + * Tokens: + * + * - `:req[header]` ex: `:req[Accept]` + * - `:res[header]` ex: `:res[Content-Length]` + * - `:http-version` + * - `:response-time` + * - `:remote-addr` + * - `:date` + * - `:method` + * - `:url` + * - `:referrer` + * - `:user-agent` + * - `:status` + * + * Formats: + * + * Pre-defined formats that ship with connect: + * + * - `default` ':remote-addr - - [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"' + * - `short` ':remote-addr - :method :url HTTP/:http-version :status :res[content-length] - :response-time ms' + * - `tiny` ':method :url :status :res[content-length] - :response-time ms' + * - `dev` concise output colored by response status for development use + * + * Examples: + * + * connect.logger() // default + * connect.logger('short') + * connect.logger('tiny') + * connect.logger({ immediate: true, format: 'dev' }) + * connect.logger(':method :url - :referrer') + * connect.logger(':req[content-type] -> :res[content-type]') + * connect.logger(function(tokens, req, res){ return 'some format string' }) + * + * Defining Tokens: + * + * To define a token, simply invoke `connect.logger.token()` with the + * name and a callback function. The value returned is then available + * as ":type" in this case. + * + * connect.logger.token('type', function(req, res){ return req.headers['content-type']; }) + * + * Defining Formats: + * + * All default formats are defined this way, however it's public API as well: + * + * connect.logger.format('name', 'string or function') + * + * @param {String|Function|Object} format or options + * @return {Function} + * @api public + */ + +exports = module.exports = function logger(options) { + if ('object' == typeof options) { + options = options || {}; + } else if (options) { + options = { format: options }; + } else { + options = {}; + } + + // output on request instead of response + var immediate = options.immediate; + + // format name + var fmt = exports[options.format] || options.format || exports.default; + + // compile format + if ('function' != typeof fmt) fmt = compile(fmt); + + // options + var stream = options.stream || process.stdout + , buffer = options.buffer; + + // buffering support + if (buffer) { + var realStream = stream + , interval = 'number' == typeof buffer + ? buffer + : defaultBufferDuration; + + // flush interval + setInterval(function(){ + if (buf.length) { + realStream.write(buf.join('')); + buf.length = 0; + } + }, interval); + + // swap the stream + stream = { + write: function(str){ + buf.push(str); + } + }; + } + + return function logger(req, res, next) { + var sock = req.socket; + req._startTime = new Date; + req._remoteAddress = sock.socket ? sock.socket.remoteAddress : sock.remoteAddress; + + function logRequest(){ + res.removeListener('finish', logRequest); + res.removeListener('close', logRequest); + var line = fmt(exports, req, res); + if (null == line) return; + stream.write(line + '\n'); + }; + + // immediate + if (immediate) { + logRequest(); + // proxy end to output logging + } else { + res.on('finish', logRequest); + res.on('close', logRequest); + } + + + next(); + }; +}; + +/** + * Compile `fmt` into a function. + * + * @param {String} fmt + * @return {Function} + * @api private + */ + +function compile(fmt) { + fmt = fmt.replace(/"/g, '\\"'); + var js = ' return "' + fmt.replace(/:([-\w]{2,})(?:\[([^\]]+)\])?/g, function(_, name, arg){ + return '"\n + (tokens["' + name + '"](req, res, "' + arg + '") || "-") + "'; + }) + '";' + return new Function('tokens, req, res', js); +}; + +/** + * Define a token function with the given `name`, + * and callback `fn(req, res)`. + * + * @param {String} name + * @param {Function} fn + * @return {Object} exports for chaining + * @api public + */ + +exports.token = function(name, fn) { + exports[name] = fn; + return this; +}; + +/** + * Define a `fmt` with the given `name`. + * + * @param {String} name + * @param {String|Function} fmt + * @return {Object} exports for chaining + * @api public + */ + +exports.format = function(name, str){ + exports[name] = str; + return this; +}; + +/** + * Default format. + */ + +exports.format('default', ':remote-addr - - [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"'); + +/** + * Short format. + */ + +exports.format('short', ':remote-addr - :method :url HTTP/:http-version :status :res[content-length] - :response-time ms'); + +/** + * Tiny format. + */ + +exports.format('tiny', ':method :url :status :res[content-length] - :response-time ms'); + +/** + * dev (colored) + */ + +exports.format('dev', function(tokens, req, res){ + var status = res.statusCode + , len = parseInt(res.getHeader('Content-Length'), 10) + , color = 32; + + if (status >= 500) color = 31 + else if (status >= 400) color = 33 + else if (status >= 300) color = 36; + + len = isNaN(len) + ? '' + : len = ' - ' + bytes(len); + + return '\x1b[90m' + req.method + + ' ' + req.originalUrl + ' ' + + '\x1b[' + color + 'm' + res.statusCode + + ' \x1b[90m' + + (new Date - req._startTime) + + 'ms' + len + + '\x1b[0m'; +}); + +/** + * request url + */ + +exports.token('url', function(req){ + return req.originalUrl || req.url; +}); + +/** + * request method + */ + +exports.token('method', function(req){ + return req.method; +}); + +/** + * response time in milliseconds + */ + +exports.token('response-time', function(req){ + return String(Date.now() - req._startTime); +}); + +/** + * UTC date + */ + +exports.token('date', function(){ + return new Date().toUTCString(); +}); + +/** + * response status code + */ + +exports.token('status', function(req, res){ + return res.headerSent ? res.statusCode : null; +}); + +/** + * normalized referrer + */ + +exports.token('referrer', function(req){ + return req.headers['referer'] || req.headers['referrer']; +}); + +/** + * remote address + */ + +exports.token('remote-addr', function(req){ + if (req.ip) return req.ip; + if (req._remoteAddress) return req._remoteAddress; + var sock = req.socket; + if (sock.socket) return sock.socket.remoteAddress; + return sock.remoteAddress; +}); + +/** + * HTTP version + */ + +exports.token('http-version', function(req){ + return req.httpVersionMajor + '.' + req.httpVersionMinor; +}); + +/** + * UA string + */ + +exports.token('user-agent', function(req){ + return req.headers['user-agent']; +}); + +/** + * request header + */ + +exports.token('req', function(req, res, field){ + return req.headers[field.toLowerCase()]; +}); + +/** + * response header + */ + +exports.token('res', function(req, res, field){ + return (res._headers || {})[field.toLowerCase()]; +}); + diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js new file mode 100644 index 00000000..a729d136 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js @@ -0,0 +1,58 @@ +/*! + * Connect - methodOverride + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var methods = require('methods'); + +/** + * Method Override: + * + * Provides faux HTTP method support. + * + * Pass an optional `key` to use when checking for + * a method override, otherwise defaults to _\_method_. + * The original method is available via `req.originalMethod`. + * + * @param {String} key + * @return {Function} + * @api public + */ + +module.exports = function methodOverride(key){ + key = key || "_method"; + return function methodOverride(req, res, next) { + var method; + req.originalMethod = req.originalMethod || req.method; + + // req.body + if (req.body && typeof req.body === 'object' && key in req.body) { + method = req.body[key].toLowerCase(); + delete req.body[key]; + } + + // check X-HTTP-Method-Override + if (req.headers['x-http-method-override']) { + method = req.headers['x-http-method-override'].toLowerCase(); + } + + // replace + if (supports(method)) req.method = method.toUpperCase(); + + next(); + }; +}; + +/** + * Check if node supports `method`. + */ + +function supports(method) { + return ~methods.indexOf(method); +} diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/multipart.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/multipart.js new file mode 100644 index 00000000..8bf66389 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/multipart.js @@ -0,0 +1,171 @@ +/*! + * Connect - multipart + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var multiparty = require('multiparty') + , _limit = require('./limit') + , utils = require('../utils') + , qs = require('qs'); + +/** + * Multipart: + * + * Status: Deprecated. The multipart parser will be removed in Connect 3.0. + * Please use one of the following parsers/middleware directly: + * + * - [formidable](https://github.com/felixge/node-formidable) + * - [connect-multiparty](https://github.com/superjoe30/connect-multiparty) or [multiparty] + * - [connect-busboy](https://github.com/mscdex/connect-busboy) or [busboy](https://github.com/mscdex/busboy) + * + * Parse multipart/form-data request bodies, + * providing the parsed object as `req.body` + * and `req.files`. + * + * Configuration: + * + * The options passed are merged with [multiparty](https://github.com/superjoe30/node-multiparty)'s + * `Form` 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 })); + * + * Options: + * + * - `limit` byte limit defaulting to [100mb] + * - `defer` defers processing and exposes the multiparty form object as `req.form`. + * `next()` is called without waiting for the form's "end" event. + * This option is useful if you need to bind to the "progress" or "part" events, for example. + * + * Temporary Files: + * + * By default temporary files are used, stored in `os.tmpDir()`. These + * are not automatically garbage collected, you are in charge of moving them + * or deleting them. When `defer` is not used and these files are created you + * may refernce them via the `req.files` object. + * + * req.files.images.forEach(function(file){ + * console.log(' uploaded : %s %skb : %s', file.originalFilename, file.size / 1024 | 0, file.path); + * }); + * + * It is highly recommended to monitor and clean up tempfiles in any production + * environment, you may use tools like [reap](https://github.com/visionmedia/reap) + * to do so. + * + * Streaming: + * + * When `defer` is used files are _not_ streamed to tmpfiles, you may + * access them via the "part" events and stream them accordingly: + * + * req.form.on('part', function(part){ + * // transfer to s3 etc + * console.log('upload %s %s', part.name, part.filename); + * var out = fs.createWriteStream('/tmp/' + part.filename); + * part.pipe(out); + * }); + * + * req.form.on('close', function(){ + * res.end('uploaded!'); + * }); + * + * @param {Object} options + * @return {Function} + * @api public + */ + +exports = module.exports = function(options){ + options = options || {}; + + if (process.env.NODE_ENV !== 'test') { + console.warn('connect.multipart() will be removed in connect 3.0'); + console.warn('visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives'); + } + + var limit = _limit(options.limit || '100mb'); + + return function multipart(req, res, next) { + if (req._body) return next(); + req.body = req.body || {}; + req.files = req.files || {}; + + if (!utils.hasBody(req)) return next(); + + // 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 + limit(req, res, function(err){ + if (err) return next(err); + + var form = new multiparty.Form(options) + , 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); + }); + + if (!options.defer) { + form.on('file', function(name, val){ + val.name = val.originalFilename; + val.type = val.headers['content-type'] || null; + ondata(name, val, files); + }); + } + + form.on('error', function(err){ + if (!options.defer) { + err.status = 400; + next(err); + } + done = true; + }); + + form.on('close', function(){ + if (done) return; + try { + req.body = qs.parse(data); + req.files = qs.parse(files); + } catch (err) { + form.emit('error', err); + return; + } + if (!options.defer) next(); + }); + + form.parse(req); + + if (options.defer) { + req.form = form; + next(); + } + }); + } +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/query.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/query.js new file mode 100644 index 00000000..f0fb50fc --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/query.js @@ -0,0 +1,47 @@ +/*! + * Connect - query + * Copyright(c) 2011 TJ Holowaychuk + * Copyright(c) 2011 Sencha Inc. + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var qs = require('qs') + , parse = require('../utils').parseUrl; + +/** + * Query: + * + * Automatically parse the query-string when available, + * populating the `req.query` object using + * [qs](https://github.com/visionmedia/node-querystring). + * + * Examples: + * + * connect() + * .use(connect.query()) + * .use(function(req, res){ + * res.end(JSON.stringify(req.query)); + * }); + * + * The `options` passed are provided to qs.parse function. + * + * @param {Object} options + * @return {Function} + * @api public + */ + +module.exports = function query(options){ + return function query(req, res, next){ + if (!req.query) { + req.query = ~req.url.indexOf('?') + ? qs.parse(parse(req).query, options) + : {}; + } + + next(); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/responseTime.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/responseTime.js new file mode 100644 index 00000000..62abc049 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/responseTime.js @@ -0,0 +1,32 @@ + +/*! + * Connect - responseTime + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Reponse time: + * + * Adds the `X-Response-Time` header displaying the response + * duration in milliseconds. + * + * @return {Function} + * @api public + */ + +module.exports = function responseTime(){ + return function(req, res, next){ + var start = new Date; + + if (res._responseTime) return next(); + res._responseTime = true; + + res.on('header', function(){ + var duration = new Date - start; + res.setHeader('X-Response-Time', duration + 'ms'); + }); + + next(); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/session.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/session.js new file mode 100644 index 00000000..128bc591 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/session.js @@ -0,0 +1,358 @@ +/*! + * Connect - session + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var Session = require('./session/session') + , debug = require('debug')('connect:session') + , MemoryStore = require('./session/memory') + , signature = require('cookie-signature') + , Cookie = require('./session/cookie') + , Store = require('./session/store') + , utils = require('./../utils') + , uid = require('uid2') + , crc32 = require('buffer-crc32') + , parse = require('url').parse; + +// environment + +var env = process.env.NODE_ENV; + +/** + * Expose the middleware. + */ + +exports = module.exports = session; + +/** + * Expose constructors. + */ + +exports.Store = Store; +exports.Cookie = Cookie; +exports.Session = Session; +exports.MemoryStore = MemoryStore; + +/** + * Warning message for `MemoryStore` usage in production. + */ + +var warning = 'Warning: connection.session() MemoryStore is not\n' + + 'designed for a production environment, as it will leak\n' + + 'memory, and will not scale past a single process.'; + +/** + * Session: + * + * Setup session store with the given `options`. + * + * Session data is _not_ saved in the cookie itself, however + * cookies are used, so we must use the [cookieParser()](cookieParser.html) + * middleware _before_ `session()`. + * + * Examples: + * + * connect() + * .use(connect.cookieParser()) + * .use(connect.session({ secret: 'keyboard cat', key: 'sid', cookie: { secure: true }})) + * + * Options: + * + * - `key` cookie name defaulting to `connect.sid` + * - `store` session store instance + * - `secret` session cookie is signed with this secret to prevent tampering + * - `cookie` session cookie settings, defaulting to `{ path: '/', httpOnly: true, maxAge: null }` + * - `proxy` trust the reverse proxy when setting secure cookies (via "x-forwarded-proto") + * + * Cookie option: + * + * By default `cookie.maxAge` is `null`, meaning no "expires" parameter is set + * so the cookie becomes a browser-session cookie. When the user closes the + * browser the cookie (and session) will be removed. + * + * ## req.session + * + * To store or access session data, simply use the request property `req.session`, + * which is (generally) serialized as JSON by the store, so nested objects + * are typically fine. For example below is a user-specific view counter: + * + * connect() + * .use(connect.favicon()) + * .use(connect.cookieParser()) + * .use(connect.session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }})) + * .use(function(req, res, next){ + * var sess = req.session; + * if (sess.views) { + * res.setHeader('Content-Type', 'text/html'); + * res.write('

    views: ' + sess.views + '

    '); + * res.write('

    expires in: ' + (sess.cookie.maxAge / 1000) + 's

    '); + * res.end(); + * sess.views++; + * } else { + * sess.views = 1; + * res.end('welcome to the session demo. refresh!'); + * } + * } + * )).listen(3000); + * + * ## Session#regenerate() + * + * To regenerate the session simply invoke the method, once complete + * a new SID and `Session` instance will be initialized at `req.session`. + * + * req.session.regenerate(function(err){ + * // will have a new session here + * }); + * + * ## Session#destroy() + * + * Destroys the session, removing `req.session`, will be re-generated next request. + * + * req.session.destroy(function(err){ + * // cannot access session here + * }); + * + * ## Session#reload() + * + * Reloads the session data. + * + * req.session.reload(function(err){ + * // session updated + * }); + * + * ## Session#save() + * + * Save the session. + * + * req.session.save(function(err){ + * // session saved + * }); + * + * ## Session#touch() + * + * Updates the `.maxAge` property. Typically this is + * not necessary to call, as the session middleware does this for you. + * + * ## Session#cookie + * + * Each session has a unique cookie object accompany it. This allows + * you to alter the session cookie per visitor. For example we can + * set `req.session.cookie.expires` to `false` to enable the cookie + * to remain for only the duration of the user-agent. + * + * ## Session#maxAge + * + * Alternatively `req.session.cookie.maxAge` will return the time + * remaining in milliseconds, which we may also re-assign a new value + * to adjust the `.expires` property appropriately. The following + * are essentially equivalent + * + * var hour = 3600000; + * req.session.cookie.expires = new Date(Date.now() + hour); + * req.session.cookie.maxAge = hour; + * + * For example when `maxAge` is set to `60000` (one minute), and 30 seconds + * has elapsed it will return `30000` until the current request has completed, + * at which time `req.session.touch()` is called to reset `req.session.maxAge` + * to its original value. + * + * req.session.cookie.maxAge; + * // => 30000 + * + * Session Store Implementation: + * + * Every session store _must_ implement the following methods + * + * - `.get(sid, callback)` + * - `.set(sid, session, callback)` + * - `.destroy(sid, callback)` + * + * Recommended methods include, but are not limited to: + * + * - `.length(callback)` + * - `.clear(callback)` + * + * For an example implementation view the [connect-redis](http://github.com/visionmedia/connect-redis) repo. + * + * @param {Object} options + * @return {Function} + * @api public + */ + +function session(options){ + var options = options || {} + , key = options.key || 'connect.sid' + , store = options.store || new MemoryStore + , cookie = options.cookie || {} + , trustProxy = options.proxy + , storeReady = true + , rollingSessions = options.rolling || false; + + // notify user that this store is not + // meant for a production environment + if ('production' == env && store instanceof MemoryStore) { + console.warn(warning); + } + + // generates the new session + store.generate = function(req){ + req.sessionID = uid(24); + req.session = new Session(req); + req.session.cookie = new Cookie(cookie); + }; + + store.on('disconnect', function(){ storeReady = false; }); + store.on('connect', function(){ storeReady = true; }); + + return function session(req, res, next) { + // self-awareness + if (req.session) return next(); + + // Handle connection as if there is no session if + // the store has temporarily disconnected etc + if (!storeReady) return debug('store is disconnected'), next(); + + // pathname mismatch + var originalPath = parse(req.originalUrl).pathname; + if (0 != originalPath.indexOf(cookie.path || '/')) return next(); + + // backwards compatibility for signed cookies + // req.secret is passed from the cookie parser middleware + var secret = options.secret || req.secret; + + // ensure secret is available or bail + if (!secret) throw new Error('`secret` option required for sessions'); + + var originalHash + , originalId; + + // expose store + req.sessionStore = store; + + // grab the session cookie value and check the signature + var rawCookie = req.cookies[key]; + + // get signedCookies for backwards compat with signed cookies + var unsignedCookie = req.signedCookies[key]; + + if (!unsignedCookie && rawCookie) { + unsignedCookie = utils.parseSignedCookie(rawCookie, secret); + } + + // set-cookie + res.on('header', function(){ + if (!req.session) return; + var cookie = req.session.cookie + , proto = (req.headers['x-forwarded-proto'] || '').split(',')[0].toLowerCase().trim() + , tls = req.connection.encrypted || (trustProxy && 'https' == proto) + , isNew = unsignedCookie != req.sessionID; + + // only send secure cookies via https + if (cookie.secure && !tls) return debug('not secured'); + + // in case of rolling session, always reset the cookie + if (!rollingSessions) { + + // browser-session length cookie + if (null == cookie.expires) { + if (!isNew) return debug('already set browser-session cookie'); + // compare hashes and ids + } else if (originalHash == hash(req.session) && originalId == req.session.id) { + return debug('unmodified session'); + } + + } + + var val = 's:' + signature.sign(req.sessionID, secret); + val = cookie.serialize(key, val); + debug('set-cookie %s', val); + res.setHeader('Set-Cookie', val); + }); + + // proxy end() to commit the session + var end = res.end; + res.end = function(data, encoding){ + res.end = end; + if (!req.session) return res.end(data, encoding); + debug('saving'); + req.session.resetMaxAge(); + req.session.save(function(err){ + if (err) console.error(err.stack); + debug('saved'); + res.end(data, encoding); + }); + }; + + // generate the session + function generate() { + store.generate(req); + } + + // get the sessionID from the cookie + req.sessionID = unsignedCookie; + + // generate a session if the browser doesn't send a sessionID + if (!req.sessionID) { + debug('no SID sent, generating session'); + generate(); + next(); + return; + } + + // generate the session object + var pause = utils.pause(req); + debug('fetching %s', req.sessionID); + store.get(req.sessionID, function(err, sess){ + // proxy to resume() events + var _next = next; + next = function(err){ + _next(err); + pause.resume(); + }; + + // error handling + if (err) { + debug('error %j', err); + if ('ENOENT' == err.code) { + generate(); + next(); + } else { + next(err); + } + // no session + } else if (!sess) { + debug('no session found'); + generate(); + next(); + // populate req.session + } else { + debug('session found'); + store.createSession(req, sess); + originalId = req.sessionID; + originalHash = hash(sess); + next(); + } + }); + }; +}; + +/** + * Hash the given `sess` object omitting changes + * to `.cookie`. + * + * @param {Object} sess + * @return {String} + * @api private + */ + +function hash(sess) { + return crc32.signed(JSON.stringify(sess, function(key, val){ + if ('cookie' != key) return val; + })); +} diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/session/cookie.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/cookie.js new file mode 100644 index 00000000..3125410d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/cookie.js @@ -0,0 +1,128 @@ + +/*! + * Connect - session - Cookie + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../../utils') + , cookie = require('cookie'); + +/** + * Initialize a new `Cookie` with the given `options`. + * + * @param {IncomingMessage} req + * @param {Object} options + * @api private + */ + +var Cookie = module.exports = function Cookie(options) { + this.path = '/'; + this.maxAge = null; + this.httpOnly = true; + if (options) utils.merge(this, options); + this.originalMaxAge = undefined == this.originalMaxAge + ? this.maxAge + : this.originalMaxAge; +}; + +/*! + * Prototype. + */ + +Cookie.prototype = { + + /** + * Set expires `date`. + * + * @param {Date} date + * @api public + */ + + set expires(date) { + this._expires = date; + this.originalMaxAge = this.maxAge; + }, + + /** + * Get expires `date`. + * + * @return {Date} + * @api public + */ + + get expires() { + return this._expires; + }, + + /** + * Set expires via max-age in `ms`. + * + * @param {Number} ms + * @api public + */ + + set maxAge(ms) { + this.expires = 'number' == typeof ms + ? new Date(Date.now() + ms) + : ms; + }, + + /** + * Get expires max-age in `ms`. + * + * @return {Number} + * @api public + */ + + get maxAge() { + return this.expires instanceof Date + ? this.expires.valueOf() - Date.now() + : this.expires; + }, + + /** + * Return cookie data object. + * + * @return {Object} + * @api private + */ + + get data() { + return { + originalMaxAge: this.originalMaxAge + , expires: this._expires + , secure: this.secure + , httpOnly: this.httpOnly + , domain: this.domain + , path: this.path + } + }, + + /** + * Return a serialized cookie string. + * + * @return {String} + * @api public + */ + + serialize: function(name, val){ + return cookie.serialize(name, val, this.data); + }, + + /** + * Return JSON representation of this cookie. + * + * @return {Object} + * @api private + */ + + toJSON: function(){ + return this.data; + } +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/session/memory.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/memory.js new file mode 100644 index 00000000..fb939392 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/memory.js @@ -0,0 +1,129 @@ + +/*! + * Connect - session - MemoryStore + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var Store = require('./store'); + +/** + * Initialize a new `MemoryStore`. + * + * @api public + */ + +var MemoryStore = module.exports = function MemoryStore() { + this.sessions = {}; +}; + +/** + * Inherit from `Store.prototype`. + */ + +MemoryStore.prototype.__proto__ = Store.prototype; + +/** + * Attempt to fetch session by the given `sid`. + * + * @param {String} sid + * @param {Function} fn + * @api public + */ + +MemoryStore.prototype.get = function(sid, fn){ + var self = this; + process.nextTick(function(){ + var expires + , sess = self.sessions[sid]; + if (sess) { + sess = JSON.parse(sess); + expires = 'string' == typeof sess.cookie.expires + ? new Date(sess.cookie.expires) + : sess.cookie.expires; + if (!expires || new Date < expires) { + fn(null, sess); + } else { + self.destroy(sid, fn); + } + } else { + fn(); + } + }); +}; + +/** + * Commit the given `sess` object associated with the given `sid`. + * + * @param {String} sid + * @param {Session} sess + * @param {Function} fn + * @api public + */ + +MemoryStore.prototype.set = function(sid, sess, fn){ + var self = this; + process.nextTick(function(){ + self.sessions[sid] = JSON.stringify(sess); + fn && fn(); + }); +}; + +/** + * Destroy the session associated with the given `sid`. + * + * @param {String} sid + * @api public + */ + +MemoryStore.prototype.destroy = function(sid, fn){ + var self = this; + process.nextTick(function(){ + delete self.sessions[sid]; + fn && fn(); + }); +}; + +/** + * Invoke the given callback `fn` with all active sessions. + * + * @param {Function} fn + * @api public + */ + +MemoryStore.prototype.all = function(fn){ + var arr = [] + , keys = Object.keys(this.sessions); + for (var i = 0, len = keys.length; i < len; ++i) { + arr.push(this.sessions[keys[i]]); + } + fn(null, arr); +}; + +/** + * Clear all sessions. + * + * @param {Function} fn + * @api public + */ + +MemoryStore.prototype.clear = function(fn){ + this.sessions = {}; + fn && fn(); +}; + +/** + * Fetch number of sessions. + * + * @param {Function} fn + * @api public + */ + +MemoryStore.prototype.length = function(fn){ + fn(null, Object.keys(this.sessions).length); +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/session/session.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/session.js new file mode 100644 index 00000000..0dd4b400 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/session.js @@ -0,0 +1,116 @@ + +/*! + * Connect - session - Session + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../../utils'); + +/** + * Create a new `Session` with the given request and `data`. + * + * @param {IncomingRequest} req + * @param {Object} data + * @api private + */ + +var Session = module.exports = function Session(req, data) { + Object.defineProperty(this, 'req', { value: req }); + Object.defineProperty(this, 'id', { value: req.sessionID }); + if ('object' == typeof data) utils.merge(this, data); +}; + +/** + * Update reset `.cookie.maxAge` to prevent + * the cookie from expiring when the + * session is still active. + * + * @return {Session} for chaining + * @api public + */ + +Session.prototype.touch = function(){ + return this.resetMaxAge(); +}; + +/** + * Reset `.maxAge` to `.originalMaxAge`. + * + * @return {Session} for chaining + * @api public + */ + +Session.prototype.resetMaxAge = function(){ + this.cookie.maxAge = this.cookie.originalMaxAge; + return this; +}; + +/** + * Save the session data with optional callback `fn(err)`. + * + * @param {Function} fn + * @return {Session} for chaining + * @api public + */ + +Session.prototype.save = function(fn){ + this.req.sessionStore.set(this.id, this, fn || function(){}); + return this; +}; + +/** + * Re-loads the session data _without_ altering + * the maxAge properties. Invokes the callback `fn(err)`, + * after which time if no exception has occurred the + * `req.session` property will be a new `Session` object, + * although representing the same session. + * + * @param {Function} fn + * @return {Session} for chaining + * @api public + */ + +Session.prototype.reload = function(fn){ + var req = this.req + , store = this.req.sessionStore; + store.get(this.id, function(err, sess){ + if (err) return fn(err); + if (!sess) return fn(new Error('failed to load session')); + store.createSession(req, sess); + fn(); + }); + return this; +}; + +/** + * Destroy `this` session. + * + * @param {Function} fn + * @return {Session} for chaining + * @api public + */ + +Session.prototype.destroy = function(fn){ + delete this.req.session; + this.req.sessionStore.destroy(this.id, fn); + return this; +}; + +/** + * Regenerate this request's session. + * + * @param {Function} fn + * @return {Session} for chaining + * @api public + */ + +Session.prototype.regenerate = function(fn){ + this.req.sessionStore.regenerate(this.req, fn); + return this; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/session/store.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/store.js new file mode 100644 index 00000000..54294cbd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/session/store.js @@ -0,0 +1,84 @@ + +/*! + * Connect - session - Store + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var EventEmitter = require('events').EventEmitter + , Session = require('./session') + , Cookie = require('./cookie'); + +/** + * Initialize abstract `Store`. + * + * @api private + */ + +var Store = module.exports = function Store(options){}; + +/** + * Inherit from `EventEmitter.prototype`. + */ + +Store.prototype.__proto__ = EventEmitter.prototype; + +/** + * Re-generate the given requests's session. + * + * @param {IncomingRequest} req + * @return {Function} fn + * @api public + */ + +Store.prototype.regenerate = function(req, fn){ + var self = this; + this.destroy(req.sessionID, function(err){ + self.generate(req); + fn(err); + }); +}; + +/** + * Load a `Session` instance via the given `sid` + * and invoke the callback `fn(err, sess)`. + * + * @param {String} sid + * @param {Function} fn + * @api public + */ + +Store.prototype.load = function(sid, fn){ + var self = this; + this.get(sid, function(err, sess){ + if (err) return fn(err); + if (!sess) return fn(); + var req = { sessionID: sid, sessionStore: self }; + sess = self.createSession(req, sess); + fn(null, sess); + }); +}; + +/** + * Create session from JSON `sess` data. + * + * @param {IncomingRequest} req + * @param {Object} sess + * @return {Session} + * @api private + */ + +Store.prototype.createSession = function(req, sess){ + var expires = sess.cookie.expires + , orig = sess.cookie.originalMaxAge; + sess.cookie = new Cookie(sess.cookie); + if ('string' == typeof expires) sess.cookie.expires = new Date(expires); + sess.cookie.originalMaxAge = orig; + req.session = new Session(req, sess); + return req.session; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/static.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/static.js new file mode 100644 index 00000000..67970dab --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/static.js @@ -0,0 +1,102 @@ +/*! + * Connect - static + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var send = require('send') + , utils = require('../utils') + , parse = utils.parseUrl + , url = require('url'); + +/** + * Static: + * + * Static file server with the given `root` path. + * + * Examples: + * + * var oneDay = 86400000; + * + * connect() + * .use(connect.static(__dirname + '/public')) + * + * connect() + * .use(connect.static(__dirname + '/public', { maxAge: oneDay })) + * + * Options: + * + * - `maxAge` Browser cache maxAge in milliseconds. defaults to 0 + * - `hidden` Allow transfer of hidden files. defaults to false + * - `redirect` Redirect to trailing "/" when the pathname is a dir. defaults to true + * - `index` Default file name, defaults to 'index.html' + * + * @param {String} root + * @param {Object} options + * @return {Function} + * @api public + */ + +exports = module.exports = function(root, options){ + options = options || {}; + + // root required + if (!root) throw new Error('static() root path required'); + + // default redirect + var redirect = false !== options.redirect; + + return function staticMiddleware(req, res, next) { + if ('GET' != req.method && 'HEAD' != req.method) return next(); + var originalUrl = url.parse(req.originalUrl); + var path = parse(req).pathname; + var pause = utils.pause(req); + + if (path == '/' && originalUrl.pathname[originalUrl.pathname.length - 1] != '/') { + return directory(); + } + + function resume() { + next(); + pause.resume(); + } + + function directory() { + if (!redirect) return resume(); + var target; + originalUrl.pathname += '/'; + target = url.format(originalUrl); + res.statusCode = 303; + res.setHeader('Location', target); + res.end('Redirecting to ' + utils.escape(target)); + } + + function error(err) { + if (404 == err.status) return resume(); + next(err); + } + + send(req, path) + .maxage(options.maxAge || 0) + .root(root) + .index(options.index || 'index.html') + .hidden(options.hidden) + .on('error', error) + .on('directory', directory) + .pipe(res); + }; +}; + +/** + * Expose mime module. + * + * If you wish to extend the mime table use this + * reference to the "mime" module in the npm registry. + */ + +exports.mime = send.mime; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/staticCache.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/staticCache.js new file mode 100644 index 00000000..66d3c1f6 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/staticCache.js @@ -0,0 +1,238 @@ + +/*! + * Connect - staticCache + * Copyright(c) 2011 Sencha Inc. + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../utils') + , Cache = require('../cache') + , fresh = require('fresh'); + +/** + * Static cache: + * + * Status: Deprecated. This middleware will be removed in + * Connect 3.0. You may be interested in: + * + * - [st](https://github.com/isaacs/st) + * + * Enables a memory cache layer on top of + * the `static()` middleware, serving popular + * static files. + * + * By default a maximum of 128 objects are + * held in cache, with a max of 256k each, + * totalling ~32mb. + * + * A Least-Recently-Used (LRU) cache algo + * is implemented through the `Cache` object, + * simply rotating cache objects as they are + * hit. This means that increasingly popular + * objects maintain their positions while + * others get shoved out of the stack and + * garbage collected. + * + * Benchmarks: + * + * static(): 2700 rps + * node-static: 5300 rps + * static() + staticCache(): 7500 rps + * + * Options: + * + * - `maxObjects` max cache objects [128] + * - `maxLength` max cache object length 256kb + * + * @param {Object} options + * @return {Function} + * @api public + */ + +module.exports = function staticCache(options){ + var options = options || {} + , cache = new Cache(options.maxObjects || 128) + , maxlen = options.maxLength || 1024 * 256; + + if (process.env.NODE_ENV !== 'test') { + console.warn('connect.staticCache() is deprecated and will be removed in 3.0'); + console.warn('use varnish or similar reverse proxy caches.'); + } + + return function staticCache(req, res, next){ + var key = cacheKey(req) + , ranges = req.headers.range + , hasCookies = req.headers.cookie + , hit = cache.get(key); + + // cache static + // TODO: change from staticCache() -> cache() + // and make this work for any request + req.on('static', function(stream){ + var headers = res._headers + , cc = utils.parseCacheControl(headers['cache-control'] || '') + , contentLength = headers['content-length'] + , hit; + + // dont cache set-cookie responses + if (headers['set-cookie']) return hasCookies = true; + + // dont cache when cookies are present + if (hasCookies) return; + + // ignore larger files + if (!contentLength || contentLength > maxlen) return; + + // don't cache partial files + if (headers['content-range']) return; + + // dont cache items we shouldn't be + // TODO: real support for must-revalidate / no-cache + if ( cc['no-cache'] + || cc['no-store'] + || cc['private'] + || cc['must-revalidate']) return; + + // if already in cache then validate + if (hit = cache.get(key)){ + if (headers.etag == hit[0].etag) { + hit[0].date = new Date; + return; + } else { + cache.remove(key); + } + } + + // validation notifiactions don't contain a steam + if (null == stream) return; + + // add the cache object + var arr = []; + + // store the chunks + stream.on('data', function(chunk){ + arr.push(chunk); + }); + + // flag it as complete + stream.on('end', function(){ + var cacheEntry = cache.add(key); + delete headers['x-cache']; // Clean up (TODO: others) + cacheEntry.push(200); + cacheEntry.push(headers); + cacheEntry.push.apply(cacheEntry, arr); + }); + }); + + if (req.method == 'GET' || req.method == 'HEAD') { + if (ranges) { + next(); + } else if (!hasCookies && hit && !mustRevalidate(req, hit)) { + res.setHeader('X-Cache', 'HIT'); + respondFromCache(req, res, hit); + } else { + res.setHeader('X-Cache', 'MISS'); + next(); + } + } else { + next(); + } + } +}; + +/** + * Respond with the provided cached value. + * TODO: Assume 200 code, that's iffy. + * + * @param {Object} req + * @param {Object} res + * @param {Object} cacheEntry + * @return {String} + * @api private + */ + +function respondFromCache(req, res, cacheEntry) { + var status = cacheEntry[0] + , headers = utils.merge({}, cacheEntry[1]) + , content = cacheEntry.slice(2); + + headers.age = (new Date - new Date(headers.date)) / 1000 || 0; + + switch (req.method) { + case 'HEAD': + res.writeHead(status, headers); + res.end(); + break; + case 'GET': + if (utils.conditionalGET(req) && fresh(req.headers, headers)) { + headers['content-length'] = 0; + res.writeHead(304, headers); + res.end(); + } else { + res.writeHead(status, headers); + + function write() { + while (content.length) { + if (false === res.write(content.shift())) { + res.once('drain', write); + return; + } + } + res.end(); + } + + write(); + } + break; + default: + // This should never happen. + res.writeHead(500, ''); + res.end(); + } +} + +/** + * Determine whether or not a cached value must be revalidated. + * + * @param {Object} req + * @param {Object} cacheEntry + * @return {String} + * @api private + */ + +function mustRevalidate(req, cacheEntry) { + var cacheHeaders = cacheEntry[1] + , reqCC = utils.parseCacheControl(req.headers['cache-control'] || '') + , cacheCC = utils.parseCacheControl(cacheHeaders['cache-control'] || '') + , cacheAge = (new Date - new Date(cacheHeaders.date)) / 1000 || 0; + + if ( cacheCC['no-cache'] + || cacheCC['must-revalidate'] + || cacheCC['proxy-revalidate']) return true; + + if (reqCC['no-cache']) return true; + + if (null != reqCC['max-age']) return reqCC['max-age'] < cacheAge; + + if (null != cacheCC['max-age']) return cacheCC['max-age'] < cacheAge; + + return false; +} + +/** + * The key to use in the cache. For now, this is the URL path and query. + * + * 'http://example.com?key=value' -> '/?key=value' + * + * @param {Object} req + * @return {String} + * @api private + */ + +function cacheKey(req) { + return utils.parseUrl(req).path; +} diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/timeout.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/timeout.js new file mode 100644 index 00000000..5496c024 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/timeout.js @@ -0,0 +1,55 @@ +/*! + * Connect - timeout + * Ported from https://github.com/LearnBoost/connect-timeout + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var debug = require('debug')('connect:timeout'); + +/** + * Timeout: + * + * Times out the request in `ms`, defaulting to `5000`. The + * method `req.clearTimeout()` is added to revert this behaviour + * programmatically within your application's middleware, routes, etc. + * + * The timeout error is passed to `next()` so that you may customize + * the response behaviour. This error has the `.timeout` property as + * well as `.status == 503`. + * + * @param {Number} ms + * @return {Function} + * @api public + */ + +module.exports = function timeout(ms) { + ms = ms || 5000; + + return function(req, res, next) { + var id = setTimeout(function(){ + req.emit('timeout', ms); + }, ms); + + req.on('timeout', function(){ + if (res.headerSent) return debug('response started, cannot timeout'); + var err = new Error('Response timeout'); + err.timeout = ms; + err.status = 503; + next(err); + }); + + req.clearTimeout = function(){ + clearTimeout(id); + }; + + res.on('header', function(){ + clearTimeout(id); + }); + + next(); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js new file mode 100644 index 00000000..ebc6f5fc --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js @@ -0,0 +1,77 @@ + +/*! + * Connect - urlencoded + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('../utils'); +var getBody = require('raw-body'); +var qs = require('qs'); + +/** + * Urlencoded: + * + * Parse x-ww-form-urlencoded request bodies, + * providing the parsed object as `req.body` using + * [qs](https://github.com/visionmedia/node-querystring). + * + * Options: + * + * - `limit` byte limit [1mb] + * + * @param {Object} options + * @return {Function} + * @api public + */ + +exports = module.exports = function(options){ + options = options || {}; + var verify = typeof options.verify === 'function' && options.verify; + + return function urlencoded(req, res, next) { + if (req._body) return next(); + req.body = req.body || {}; + + if (!utils.hasBody(req)) return next(); + + // check Content-Type + if ('application/x-www-form-urlencoded' != utils.mime(req)) return next(); + + // flag as parsed + req._body = true; + + // parse + getBody(req, { + limit: options.limit || '1mb', + length: req.headers['content-length'], + encoding: 'utf8' + }, function (err, buf) { + if (err) return next(err); + + if (verify) { + try { + verify(req, res, buf) + } catch (err) { + if (!err.status) err.status = 403; + return next(err); + } + } + + try { + req.body = buf.length + ? qs.parse(buf, options) + : {}; + } catch (err){ + err.body = buf; + return next(err); + } + next(); + }) + } +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/middleware/vhost.js b/realtime/node_modules/express/node_modules/connect/lib/middleware/vhost.js new file mode 100644 index 00000000..abbb0500 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/middleware/vhost.js @@ -0,0 +1,40 @@ + +/*! + * Connect - vhost + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Vhost: + * + * Setup vhost for the given `hostname` and `server`. + * + * connect() + * .use(connect.vhost('foo.com', fooApp)) + * .use(connect.vhost('bar.com', barApp)) + * .use(connect.vhost('*.com', mainApp)) + * + * The `server` may be a Connect server or + * a regular Node `http.Server`. + * + * @param {String} hostname + * @param {Server} server + * @return {Function} + * @api public + */ + +module.exports = function vhost(hostname, server){ + if (!hostname) throw new Error('vhost hostname required'); + if (!server) throw new Error('vhost server required'); + var regexp = new RegExp('^' + hostname.replace(/[^*\w]/g, '\\$&').replace(/[*]/g, '(?:.*?)') + '$', 'i'); + if (server.onvhost) server.onvhost(hostname); + return function vhost(req, res, next){ + if (!req.headers.host) return next(); + var host = req.headers.host.split(':')[0]; + if (!regexp.test(host)) return next(); + if ('function' == typeof server) return server(req, res, next); + server.emit('request', req, res); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/patch.js b/realtime/node_modules/express/node_modules/connect/lib/patch.js new file mode 100644 index 00000000..22bcbc62 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/patch.js @@ -0,0 +1,89 @@ + +/*! + * Connect + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var http = require('http') + , res = http.ServerResponse.prototype + , setHeader = res.setHeader + , _renderHeaders = res._renderHeaders + , writeHead = res.writeHead; + +// apply only once + +if (!res._hasConnectPatch) { + + /** + * Provide a public "header sent" flag + * until node does. + * + * @return {Boolean} + * @api public + */ + + res.__defineGetter__('headerSent', function(){ + return this._header; + }); + + /** + * Set header `field` to `val`, special-casing + * the `Set-Cookie` field for multiple support. + * + * @param {String} field + * @param {String} val + * @api public + */ + + res.setHeader = function(field, val){ + var key = field.toLowerCase() + , prev; + + // special-case Set-Cookie + if (this._headers && 'set-cookie' == key) { + if (prev = this.getHeader(field)) { + if (Array.isArray(prev)) { + val = prev.concat(val); + } else if (Array.isArray(val)) { + val = val.concat(prev); + } else { + val = [prev, val]; + } + } + // charset + } else if ('content-type' == key && this.charset) { + val += '; charset=' + this.charset; + } + + return setHeader.call(this, field, val); + }; + + /** + * Proxy to emit "header" event. + */ + + res._renderHeaders = function(){ + if (!this._emittedHeader) this.emit('header'); + this._emittedHeader = true; + return _renderHeaders.call(this); + }; + + res.writeHead = function(statusCode, reasonPhrase, headers){ + if (typeof reasonPhrase === 'object') headers = reasonPhrase; + if (typeof headers === 'object') { + Object.keys(headers).forEach(function(key){ + this.setHeader(key, headers[key]); + }, this); + } + if (!this._emittedHeader) this.emit('header'); + this._emittedHeader = true; + return writeHead.call(this, statusCode, reasonPhrase); + }; + + res._hasConnectPatch = true; +} diff --git a/realtime/node_modules/express/node_modules/connect/lib/proto.js b/realtime/node_modules/express/node_modules/connect/lib/proto.js new file mode 100644 index 00000000..a945bc28 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/proto.js @@ -0,0 +1,233 @@ +/*! + * Connect - HTTPServer + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var http = require('http') + , 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 + , search = 1 + req.url.indexOf('?') + , pathlength = search ? search - 1 : req.url.length + , fqdn = 1 + req.url.substr(0, pathlength).indexOf('://') + , protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : '' + , removed = '' + , slashAdded = false + , index = 0; + + function next(err) { + var layer, path, c; + + if (slashAdded) { + req.url = req.url.substr(1); + slashAdded = false; + } + + req.url = protohost + removed + req.url.substr(protohost.length); + 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(); + msg = utils.escape(msg); + + // 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/html'); + 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/html'); + if ('HEAD' == req.method) return res.end(); + res.end('Cannot ' + utils.escape(req.method) + ' ' + utils.escape(req.originalUrl) + '\n'); + } + return; + } + + try { + path = utils.parseUrl(req).pathname; + if (undefined == path) path = '/'; + + // skip this layer if the route doesn't match. + if (0 != path.toLowerCase().indexOf(layer.route.toLowerCase())) 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 = protohost + req.url.substr(protohost.length + removed.length); + + // Ensure leading slash + if (!fqdn && '/' != req.url[0]) { + req.url = '/' + req.url; + slashAdded = true; + } + + debug('%s %s : %s', layer.handle.name || 'anonymous', layer.route, req.originalUrl); + 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); +}; diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/directory.html b/realtime/node_modules/express/node_modules/connect/lib/public/directory.html new file mode 100644 index 00000000..8ed8b4ae --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/public/directory.html @@ -0,0 +1,82 @@ + + + + + + listing directory {directory} + + + + + +
    +

    {linked-path}

    + {files} +
    + + \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/error.html b/realtime/node_modules/express/node_modules/connect/lib/public/error.html new file mode 100644 index 00000000..a6d3fafd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/public/error.html @@ -0,0 +1,14 @@ + + + + {error} + + + +
    +

    {title}

    +

    {statusCode} {error}

    +
      {stack}
    +
    + + diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/favicon.ico b/realtime/node_modules/express/node_modules/connect/lib/public/favicon.ico new file mode 100644 index 00000000..895fc96a Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/favicon.ico differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/folder.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/folder.png new file mode 100644 index 00000000..698f3d30 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/folder.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page.png new file mode 100644 index 00000000..03ddd799 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_add.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_add.png new file mode 100644 index 00000000..d5bfa071 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_add.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_attach.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_attach.png new file mode 100644 index 00000000..89ee2da0 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_attach.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_code.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_code.png new file mode 100644 index 00000000..f7ea9041 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_code.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_copy.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_copy.png new file mode 100644 index 00000000..195dc6d6 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_copy.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_delete.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_delete.png new file mode 100644 index 00000000..3141467c Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_delete.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_edit.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_edit.png new file mode 100644 index 00000000..046811ed Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_edit.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_error.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_error.png new file mode 100644 index 00000000..f07f449a Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_error.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_excel.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_excel.png new file mode 100644 index 00000000..eb6158eb Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_excel.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_find.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_find.png new file mode 100644 index 00000000..2f193889 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_find.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_gear.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_gear.png new file mode 100644 index 00000000..8e83281c Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_gear.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_go.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_go.png new file mode 100644 index 00000000..80fe1ed0 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_go.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_green.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_green.png new file mode 100644 index 00000000..de8e003f Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_green.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_key.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_key.png new file mode 100644 index 00000000..d6626cb0 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_key.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_lightning.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_lightning.png new file mode 100644 index 00000000..7e568703 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_lightning.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_link.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_link.png new file mode 100644 index 00000000..312eab09 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_link.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_paintbrush.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_paintbrush.png new file mode 100644 index 00000000..246a2f0b Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_paintbrush.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_paste.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_paste.png new file mode 100644 index 00000000..968f073f Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_paste.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_red.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_red.png new file mode 100644 index 00000000..0b18247d Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_red.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_refresh.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_refresh.png new file mode 100644 index 00000000..cf347c7d Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_refresh.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_save.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_save.png new file mode 100644 index 00000000..caea546a Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_save.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white.png new file mode 100644 index 00000000..8b8b1ca0 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_acrobat.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_acrobat.png new file mode 100644 index 00000000..8f8095e4 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_acrobat.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_actionscript.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_actionscript.png new file mode 100644 index 00000000..159b2407 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_actionscript.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_add.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_add.png new file mode 100644 index 00000000..aa23dde3 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_add.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_c.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_c.png new file mode 100644 index 00000000..34a05ccc Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_c.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_camera.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_camera.png new file mode 100644 index 00000000..f501a593 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_camera.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cd.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cd.png new file mode 100644 index 00000000..848bdaf3 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cd.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_code.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_code.png new file mode 100644 index 00000000..0c76bd12 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_code.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_code_red.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_code_red.png new file mode 100644 index 00000000..87a69145 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_code_red.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_coldfusion.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_coldfusion.png new file mode 100644 index 00000000..c66011fb Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_coldfusion.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_compressed.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_compressed.png new file mode 100644 index 00000000..2b6b1007 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_compressed.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_copy.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_copy.png new file mode 100644 index 00000000..a9f31a27 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_copy.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cplusplus.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cplusplus.png new file mode 100644 index 00000000..a87cf847 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cplusplus.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_csharp.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_csharp.png new file mode 100644 index 00000000..ffb8fc93 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_csharp.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cup.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cup.png new file mode 100644 index 00000000..0a7d6f4a Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_cup.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_database.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_database.png new file mode 100644 index 00000000..bddba1f9 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_database.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_delete.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_delete.png new file mode 100644 index 00000000..af1ecaf2 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_delete.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_dvd.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_dvd.png new file mode 100644 index 00000000..4cc537af Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_dvd.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_edit.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_edit.png new file mode 100644 index 00000000..b93e7760 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_edit.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_error.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_error.png new file mode 100644 index 00000000..9fc5a0a1 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_error.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_excel.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_excel.png new file mode 100644 index 00000000..b977d7e5 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_excel.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_find.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_find.png new file mode 100644 index 00000000..58184363 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_find.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_flash.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_flash.png new file mode 100644 index 00000000..5769120b Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_flash.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_freehand.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_freehand.png new file mode 100644 index 00000000..8d719df5 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_freehand.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_gear.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_gear.png new file mode 100644 index 00000000..106f5aa3 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_gear.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_get.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_get.png new file mode 100644 index 00000000..e4a1ecba Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_get.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_go.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_go.png new file mode 100644 index 00000000..7e62a924 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_go.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_h.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_h.png new file mode 100644 index 00000000..e902abb0 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_h.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_horizontal.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_horizontal.png new file mode 100644 index 00000000..1d2d0a49 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_horizontal.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_key.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_key.png new file mode 100644 index 00000000..d6164845 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_key.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_lightning.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_lightning.png new file mode 100644 index 00000000..7215d1e8 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_lightning.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_link.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_link.png new file mode 100644 index 00000000..bf7bd1c9 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_link.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_magnify.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_magnify.png new file mode 100644 index 00000000..f6b74cc4 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_magnify.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_medal.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_medal.png new file mode 100644 index 00000000..d3fffb6d Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_medal.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_office.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_office.png new file mode 100644 index 00000000..a65bcb3e Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_office.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paint.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paint.png new file mode 100644 index 00000000..23a37b89 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paint.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paintbrush.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paintbrush.png new file mode 100644 index 00000000..f907e44b Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paintbrush.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paste.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paste.png new file mode 100644 index 00000000..5b2cbb3f Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_paste.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_php.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_php.png new file mode 100644 index 00000000..7868a259 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_php.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_picture.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_picture.png new file mode 100644 index 00000000..134b6693 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_picture.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_powerpoint.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_powerpoint.png new file mode 100644 index 00000000..c4eff038 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_powerpoint.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_put.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_put.png new file mode 100644 index 00000000..884ffd6f Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_put.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_ruby.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_ruby.png new file mode 100644 index 00000000..f59b7c43 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_ruby.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_stack.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_stack.png new file mode 100644 index 00000000..44084add Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_stack.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_star.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_star.png new file mode 100644 index 00000000..3a1441c9 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_star.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_swoosh.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_swoosh.png new file mode 100644 index 00000000..e7708292 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_swoosh.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_text.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_text.png new file mode 100644 index 00000000..813f712f Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_text.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_text_width.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_text_width.png new file mode 100644 index 00000000..d9cf1325 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_text_width.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_tux.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_tux.png new file mode 100644 index 00000000..52699bfe Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_tux.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_vector.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_vector.png new file mode 100644 index 00000000..4a05955b Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_vector.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_visualstudio.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_visualstudio.png new file mode 100644 index 00000000..a0a433df Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_visualstudio.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_width.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_width.png new file mode 100644 index 00000000..1eb88094 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_width.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_word.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_word.png new file mode 100644 index 00000000..ae8ecbf4 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_word.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_world.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_world.png new file mode 100644 index 00000000..6ed2490e Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_world.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_wrench.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_wrench.png new file mode 100644 index 00000000..fecadd08 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_wrench.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_zip.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_zip.png new file mode 100644 index 00000000..fd4bbccd Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_white_zip.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_word.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_word.png new file mode 100644 index 00000000..834cdfaf Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_word.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_world.png b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_world.png new file mode 100644 index 00000000..b8895dde Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/lib/public/icons/page_world.png differ diff --git a/realtime/node_modules/express/node_modules/connect/lib/public/style.css b/realtime/node_modules/express/node_modules/connect/lib/public/style.css new file mode 100644 index 00000000..0709908a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/public/style.css @@ -0,0 +1,257 @@ +* { + margin: 0; + padding: 0; + outline: 0; +} + +body { + padding: 80px 100px; + font: 13px "Helvetica Neue", "Lucida Grande", "Arial"; + background: #ECE9E9 -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#ECE9E9)); + background: #ECE9E9 -moz-linear-gradient(top, #fff, #ECE9E9); + background-repeat: no-repeat; + color: #555; + -webkit-font-smoothing: antialiased; +} +h1, h2, h3 { + font-size: 22px; + color: #343434; +} +h1 em, h2 em { + padding: 0 5px; + font-weight: normal; +} +h1 { + font-size: 60px; +} +h2 { + margin-top: 10px; +} +h3 { + margin: 5px 0 10px 0; + padding-bottom: 5px; + border-bottom: 1px solid #eee; + font-size: 18px; +} +ul li { + list-style: none; +} +ul li:hover { + cursor: pointer; + color: #2e2e2e; +} +ul li .path { + padding-left: 5px; + font-weight: bold; +} +ul li .line { + padding-right: 5px; + font-style: italic; +} +ul li:first-child .path { + padding-left: 0; +} +p { + line-height: 1.5; +} +a { + color: #555; + text-decoration: none; +} +a:hover { + color: #303030; +} +#stacktrace { + margin-top: 15px; +} +.directory h1 { + margin-bottom: 15px; + font-size: 18px; +} +ul#files { + width: 100%; + height: 100%; + overflow: hidden; +} +ul#files li { + float: left; + width: 30%; + line-height: 25px; + margin: 1px; +} +ul#files li a { + display: block; + height: 25px; + border: 1px solid transparent; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + overflow: hidden; + white-space: nowrap; +} +ul#files li a:focus, +ul#files li a:hover { + background: rgba(255,255,255,0.65); + border: 1px solid #ececec; +} +ul#files li a.highlight { + -webkit-transition: background .4s ease-in-out; + background: #ffff4f; + border-color: #E9DC51; +} +#search { + display: block; + position: fixed; + top: 20px; + right: 20px; + width: 90px; + -webkit-transition: width ease 0.2s, opacity ease 0.4s; + -moz-transition: width ease 0.2s, opacity ease 0.4s; + -webkit-border-radius: 32px; + -moz-border-radius: 32px; + -webkit-box-shadow: inset 0px 0px 3px rgba(0, 0, 0, 0.25), inset 0px 1px 3px rgba(0, 0, 0, 0.7), 0px 1px 0px rgba(255, 255, 255, 0.03); + -moz-box-shadow: inset 0px 0px 3px rgba(0, 0, 0, 0.25), inset 0px 1px 3px rgba(0, 0, 0, 0.7), 0px 1px 0px rgba(255, 255, 255, 0.03); + -webkit-font-smoothing: antialiased; + text-align: left; + font: 13px "Helvetica Neue", Arial, sans-serif; + padding: 4px 10px; + border: none; + background: transparent; + margin-bottom: 0; + outline: none; + opacity: 0.7; + color: #888; +} +#search:focus { + width: 120px; + opacity: 1.0; +} + +/*views*/ +#files span { + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + text-indent: 10px; +} +#files .name { + background-repeat: no-repeat; +} +#files .icon .name { + text-indent: 28px; +} + +/*tiles*/ +.view-tiles .name { + width: 100%; + background-position: 8px 5px; +} +.view-tiles .size, +.view-tiles .date { + display: none; +} + +/*details*/ +ul#files.view-details li { + float: none; + display: block; + width: 90%; +} +ul#files.view-details li.header { + height: 25px; + background: #000; + color: #fff; + font-weight: bold; +} +.view-details .header { + border-radius: 5px; +} +.view-details .name { + width: 60%; + background-position: 8px 5px; +} +.view-details .size { + width: 10%; +} +.view-details .date { + width: 30%; +} +.view-details .size, +.view-details .date { + text-align: right; + direction: rtl; +} + +/*mobile*/ +@media (max-width: 768px) { + body { + font-size: 13px; + line-height: 16px; + padding: 0; + } + #search { + position: static; + width: 100%; + font-size: 2em; + line-height: 1.8em; + text-indent: 10px; + border: 0; + border-radius: 0; + padding: 10px 0; + margin: 0; + } + #search:focus { + width: 100%; + border: 0; + opacity: 1; + } + .directory h1 { + font-size: 2em; + line-height: 1.5em; + color: #fff; + background: #000; + padding: 15px 10px; + margin: 0; + } + ul#files { + border-top: 1px solid #cacaca; + } + ul#files li { + float: none; + width: auto !important; + display: block; + border-bottom: 1px solid #cacaca; + font-size: 2em; + line-height: 1.2em; + text-indent: 0; + margin: 0; + } + ul#files li:nth-child(odd) { + background: #e0e0e0; + } + ul#files li a { + height: auto; + border: 0; + border-radius: 0; + padding: 15px 10px; + } + ul#files li a:focus, + ul#files li a:hover { + border: 0; + } + #files .header, + #files .size, + #files .date { + display: none !important; + } + #files .name { + float: none; + display: inline-block; + width: 100%; + text-indent: 0; + background-position: 0 0; + } + #files .icon .name { + text-indent: 41px; + } +} diff --git a/realtime/node_modules/express/node_modules/connect/lib/utils.js b/realtime/node_modules/express/node_modules/connect/lib/utils.js new file mode 100644 index 00000000..9839bc33 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/lib/utils.js @@ -0,0 +1,408 @@ + +/*! + * Connect - utils + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var http = require('http') + , crypto = require('crypto') + , parse = require('url').parse + , sep = require('path').sep + , signature = require('cookie-signature') + , nodeVersion = process.versions.node.split('.'); + +// pause is broken in node < 0.10 +exports.brokenPause = parseInt(nodeVersion[0], 10) === 0 + && parseInt(nodeVersion[1], 10) < 10; + +/** + * Return `true` if the request has a body, otherwise return `false`. + * + * @param {IncomingMessage} req + * @return {Boolean} + * @api private + */ + +exports.hasBody = function(req) { + var encoding = 'transfer-encoding' in req.headers; + var length = 'content-length' in req.headers && req.headers['content-length'] !== '0'; + return encoding || length; +}; + +/** + * Extract the mime type from the given request's + * _Content-Type_ header. + * + * @param {IncomingMessage} req + * @return {String} + * @api private + */ + +exports.mime = function(req) { + var str = req.headers['content-type'] || ''; + return str.split(';')[0]; +}; + +/** + * Generate an `Error` from the given status `code` + * and optional `msg`. + * + * @param {Number} code + * @param {String} msg + * @return {Error} + * @api private + */ + +exports.error = function(code, msg){ + var err = new Error(msg || http.STATUS_CODES[code]); + err.status = code; + return err; +}; + +/** + * Return md5 hash of the given string and optional encoding, + * defaulting to hex. + * + * utils.md5('wahoo'); + * // => "e493298061761236c96b02ea6aa8a2ad" + * + * @param {String} str + * @param {String} encoding + * @return {String} + * @api private + */ + +exports.md5 = function(str, encoding){ + return crypto + .createHash('md5') + .update(str, 'utf8') + .digest(encoding || 'hex'); +}; + +/** + * Merge object b with object a. + * + * var a = { foo: 'bar' } + * , b = { bar: 'baz' }; + * + * utils.merge(a, b); + * // => { foo: 'bar', bar: 'baz' } + * + * @param {Object} a + * @param {Object} b + * @return {Object} + * @api private + */ + +exports.merge = function(a, b){ + if (a && b) { + for (var key in b) { + a[key] = b[key]; + } + } + return a; +}; + +/** + * Escape the given string of `html`. + * + * @param {String} html + * @return {String} + * @api private + */ + +exports.escape = function(html){ + return String(html) + .replace(/&(?!\w+;)/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); +}; + +/** + * Sign the given `val` with `secret`. + * + * @param {String} val + * @param {String} secret + * @return {String} + * @api private + */ + +exports.sign = function(val, secret){ + console.warn('do not use utils.sign(), use https://github.com/visionmedia/node-cookie-signature') + 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){ + console.warn('do not use utils.unsign(), use https://github.com/visionmedia/node-cookie-signature') + var str = val.slice(0, val.lastIndexOf('.')); + return exports.sign(str, secret) == val + ? str + : false; +}; + +/** + * Parse signed cookies, returning an object + * containing the decoded key/value pairs, + * while removing the signed key from `obj`. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +exports.parseSignedCookies = function(obj, secret){ + var ret = {}; + Object.keys(obj).forEach(function(key){ + var val = obj[key]; + if (0 == val.indexOf('s:')) { + val = signature.unsign(val.slice(2), secret); + if (val) { + ret[key] = val; + delete obj[key]; + } + } + }); + return ret; +}; + +/** + * Parse a signed cookie string, return the decoded value + * + * @param {String} str signed cookie string + * @param {String} secret + * @return {String} decoded value + * @api private + */ + +exports.parseSignedCookie = function(str, secret){ + return 0 == str.indexOf('s:') + ? signature.unsign(str.slice(2), secret) + : str; +}; + +/** + * Parse JSON cookies. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +exports.parseJSONCookies = function(obj){ + Object.keys(obj).forEach(function(key){ + var val = obj[key]; + var res = exports.parseJSONCookie(val); + if (res) obj[key] = res; + }); + return obj; +}; + +/** + * Parse JSON cookie string + * + * @param {String} str + * @return {Object} Parsed object or null if not json cookie + * @api private + */ + +exports.parseJSONCookie = function(str) { + if (0 == str.indexOf('j:')) { + try { + return JSON.parse(str.slice(2)); + } catch (err) { + // no op + } + } +}; + +/** + * Pause `data` and `end` events on the given `obj`. + * Middleware performing async tasks _should_ utilize + * this utility (or similar), to re-emit data once + * the async operation has completed, otherwise these + * events may be lost. Pause is only required for + * node versions less than 10, and is replaced with + * noop's otherwise. + * + * var pause = utils.pause(req); + * fs.readFile(path, function(){ + * next(); + * pause.resume(); + * }); + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +exports.pause = exports.brokenPause + ? require('pause') + : function () { + return { + end: noop, + resume: noop + } + } + +/** + * Strip `Content-*` headers from `res`. + * + * @param {ServerResponse} res + * @api private + */ + +exports.removeContentHeaders = function(res){ + if (!res._headers) return; + Object.keys(res._headers).forEach(function(field){ + if (0 == field.indexOf('content')) { + res.removeHeader(field); + } + }); +}; + +/** + * Check if `req` is a conditional GET request. + * + * @param {IncomingMessage} req + * @return {Boolean} + * @api private + */ + +exports.conditionalGET = function(req) { + return req.headers['if-modified-since'] + || req.headers['if-none-match']; +}; + +/** + * Respond with 401 "Unauthorized". + * + * @param {ServerResponse} res + * @param {String} realm + * @api private + */ + +exports.unauthorized = function(res, realm) { + res.statusCode = 401; + res.setHeader('WWW-Authenticate', 'Basic realm="' + realm + '"'); + res.end('Unauthorized'); +}; + +/** + * Respond with 304 "Not Modified". + * + * @param {ServerResponse} res + * @param {Object} headers + * @api private + */ + +exports.notModified = function(res) { + exports.removeContentHeaders(res); + res.statusCode = 304; + res.end(); +}; + +/** + * Return an ETag in the form of `"-"` + * from the given `stat`. + * + * @param {Object} stat + * @return {String} + * @api private + */ + +exports.etag = function(stat) { + return '"' + stat.size + '-' + Number(stat.mtime) + '"'; +}; + +/** + * Parse the given Cache-Control `str`. + * + * @param {String} str + * @return {Object} + * @api private + */ + +exports.parseCacheControl = function(str){ + var directives = str.split(',') + , obj = {}; + + for(var i = 0, len = directives.length; i < len; i++) { + var parts = directives[i].split('=') + , key = parts.shift().trim() + , val = parseInt(parts.shift(), 10); + + obj[key] = isNaN(val) ? true : val; + } + + return obj; +}; + +/** + * Parse the `req` url with memoization. + * + * @param {ServerRequest} req + * @return {Object} + * @api private + */ + +exports.parseUrl = function(req){ + var parsed = req._parsedUrl; + if (parsed && parsed.href == req.url) { + return parsed; + } else { + parsed = parse(req.url); + + if (parsed.auth && !parsed.protocol && ~parsed.href.indexOf('//')) { + // This parses pathnames, and a strange pathname like //r@e should work + parsed = parse(req.url.replace(/@/g, '%40')); + } + + return req._parsedUrl = parsed; + } +}; + +/** + * Parse byte `size` string. + * + * @param {String} size + * @return {Number} + * @api private + */ + +exports.parseBytes = require('bytes'); + +/** + * Normalizes the path separator from system separator + * to URL separator, aka `/`. + * + * @param {String} path + * @return {String} + * @api private + */ + +exports.normalizeSlashes = function normalizeSlashes(path) { + return path.split(sep).join('/'); +}; + +function noop() {} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/batch/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/batch/.npmignore new file mode 100644 index 00000000..f1250e58 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/batch/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/batch/History.md b/realtime/node_modules/express/node_modules/connect/node_modules/batch/History.md new file mode 100644 index 00000000..b1b77526 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/batch/History.md @@ -0,0 +1,66 @@ + +0.5.0 / 2013-07-29 +================== + + * add `.throws(true)` to opt-in to responding with an array of error objects + * make `new` optional + +0.4.0 / 2013-06-05 +================== + + * add catching of immediate callback errors + +0.3.2 / 2013-03-15 +================== + + * remove Emitter call in constructor + +0.3.1 / 2013-03-13 +================== + + * add Emitter() mixin for client. Closes #8 + +0.3.0 / 2013-03-13 +================== + + * add component.json + * add result example + * add .concurrency support + * add concurrency example + * add parallel example + +0.2.1 / 2012-11-08 +================== + + * add .start, .end, and .duration properties + * change dependencies to devDependencies + +0.2.0 / 2012-10-04 +================== + + * add progress events. Closes #5 (__BREAKING CHANGE__) + +0.1.1 / 2012-07-03 +================== + + * change "complete" event to "progress" + +0.1.0 / 2012-07-03 +================== + + * add Emitter inheritance and emit "complete" [burcu] + +0.0.3 / 2012-06-02 +================== + + * Callback results should be in the order of the queued functions. + +0.0.2 / 2012-02-12 +================== + + * any node + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/batch/Makefile b/realtime/node_modules/express/node_modules/connect/node_modules/batch/Makefile new file mode 100644 index 00000000..634e3721 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/batch/Makefile @@ -0,0 +1,6 @@ + +test: + @./node_modules/.bin/mocha \ + --require should + +.PHONY: test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/batch/Readme.md b/realtime/node_modules/express/node_modules/connect/node_modules/batch/Readme.md new file mode 100644 index 00000000..f2345c67 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/batch/Readme.md @@ -0,0 +1,74 @@ + +# batch + + Simple async batch with concurrency control and progress reporting. + +## Installation + +``` +$ npm install batch +``` + +## API + +```js +var Batch = require('batch') + , batch = new Batch; + +batch.concurrency(4); + +ids.forEach(function(id){ + batch.push(function(done){ + User.get(id, done); + }); +}); + +batch.on('progress', function(e){ + +}); + +batch.end(function(err, users){ + +}); +``` + +### Progress events + + Contain the "job" index, response value, duration information, and completion data. + +```js +{ index: 1, + value: 'bar', + pending: 2, + total: 3, + complete: 2, + percent: 66, + start: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT), + end: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT), + duration: 0 } +``` + +## License + +(The MIT License) + +Copyright (c) 2013 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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/batch/component.json b/realtime/node_modules/express/node_modules/connect/node_modules/batch/component.json new file mode 100644 index 00000000..0ea7e582 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/batch/component.json @@ -0,0 +1,14 @@ +{ + "name": "batch", + "repo": "visionmedia/batch", + "description": "Async task batching", + "version": "0.5.0", + "keywords": ["batch", "async", "utility", "concurrency", "concurrent"], + "dependencies": { + "component/emitter": "*" + }, + "development": {}, + "scripts": [ + "index.js" + ] +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/batch/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/batch/index.js new file mode 100644 index 00000000..932d4045 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/batch/index.js @@ -0,0 +1,158 @@ +/** + * Module dependencies. + */ + +try { + var EventEmitter = require('events').EventEmitter; +} catch (err) { + var Emitter = require('emitter'); +} + +/** + * Noop. + */ + +function noop(){} + +/** + * Expose `Batch`. + */ + +module.exports = Batch; + +/** + * Create a new Batch. + */ + +function Batch() { + if (!(this instanceof Batch)) return new Batch; + this.fns = []; + this.concurrency(Infinity); + this.throws(true); + for (var i = 0, len = arguments.length; i < len; ++i) { + this.push(arguments[i]); + } +} + +/** + * Inherit from `EventEmitter.prototype`. + */ + +if (EventEmitter) { + Batch.prototype.__proto__ = EventEmitter.prototype; +} else { + Emitter(Batch.prototype); +} + +/** + * Set concurrency to `n`. + * + * @param {Number} n + * @return {Batch} + * @api public + */ + +Batch.prototype.concurrency = function(n){ + this.n = n; + return this; +}; + +/** + * Queue a function. + * + * @param {Function} fn + * @return {Batch} + * @api public + */ + +Batch.prototype.push = function(fn){ + this.fns.push(fn); + return this; +}; + +/** + * Set wether Batch will or will not throw up. + * + * @param {Boolean} throws + * @return {Batch} + * @api public + */ +Batch.prototype.throws = function(throws) { + this.e = !!throws; + return this; +}; + +/** + * Execute all queued functions in parallel, + * executing `cb(err, results)`. + * + * @param {Function} cb + * @return {Batch} + * @api public + */ + +Batch.prototype.end = function(cb){ + var self = this + , total = this.fns.length + , pending = total + , results = [] + , errors = [] + , cb = cb || noop + , fns = this.fns + , max = this.n + , throws = this.e + , index = 0 + , done; + + // empty + if (!fns.length) return cb(null, results); + + // process + function next() { + var i = index++; + var fn = fns[i]; + if (!fn) return; + var start = new Date; + + try { + fn(callback); + } catch (err) { + callback(err); + } + + function callback(err, res){ + if (done) return; + if (err && throws) return done = true, cb(err); + var complete = total - pending + 1; + var end = new Date; + + results[i] = res; + errors[i] = err; + + self.emit('progress', { + index: i, + value: res, + error: err, + pending: pending, + total: total, + complete: complete, + percent: complete / total * 100 | 0, + start: start, + end: end, + duration: end - start + }); + + if (--pending) next() + else if(!throws) cb(errors, results); + else cb(null, results); + } + } + + // concurrency + for (var i = 0; i < fns.length; i++) { + if (i == max) break; + next(); + } + + return this; +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/batch/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/batch/package.json new file mode 100644 index 00000000..a0a17319 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/batch/package.json @@ -0,0 +1,22 @@ +{ + "name": "batch", + "version": "0.5.0", + "description": "Simple async batch", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "main": "index", + "readme": "\n# batch\n\n Simple async batch with concurrency control and progress reporting.\n\n## Installation\n\n```\n$ npm install batch\n```\n\n## API\n\n```js\nvar Batch = require('batch')\n , batch = new Batch;\n\nbatch.concurrency(4);\n\nids.forEach(function(id){\n batch.push(function(done){\n User.get(id, done);\n });\n});\n\nbatch.on('progress', function(e){\n\n});\n\nbatch.end(function(err, users){\n\n});\n```\n\n### Progress events\n\n Contain the \"job\" index, response value, duration information, and completion data.\n\n```js\n{ index: 1,\n value: 'bar',\n pending: 2,\n total: 3,\n complete: 2,\n percent: 66,\n start: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),\n end: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),\n duration: 0 }\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "Readme.md", + "_id": "batch@0.5.0", + "dist": { + "shasum": "ee99813cfbd9be318019bbe6d87217ef186e460c" + }, + "_from": "batch@0.5.0", + "_resolved": "https://registry.npmjs.org/batch/-/batch-0.5.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/bytes/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/.npmignore new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/.npmignore @@ -0,0 +1 @@ +test diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/bytes/History.md b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/History.md new file mode 100644 index 00000000..f233ed16 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/History.md @@ -0,0 +1,15 @@ + +0.2.1 / 2013-04-01 +================== + + * add .component + +0.2.0 / 2012-10-28 +================== + + * bytes(200).should.eql('200b') + +0.1.0 / 2012-07-04 +================== + + * add bytes to string conversion [yields] diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/bytes/Makefile b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/Makefile new file mode 100644 index 00000000..8e8640f2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/Makefile @@ -0,0 +1,7 @@ + +test: + @./node_modules/.bin/mocha \ + --reporter spec \ + --require should + +.PHONY: test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/bytes/Readme.md b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/Readme.md new file mode 100644 index 00000000..9325d5bf --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/Readme.md @@ -0,0 +1,51 @@ +# node-bytes + + Byte string parser / formatter. + +## Example: + +```js +bytes('1kb') +// => 1024 + +bytes('2mb') +// => 2097152 + +bytes('1gb') +// => 1073741824 + +bytes(1073741824) +// => 1gb +``` + +## Installation + +``` +$ npm install bytes +$ component install visionmedia/bytes.js +``` + +## 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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/bytes/component.json b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/component.json new file mode 100644 index 00000000..2929c25d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/component.json @@ -0,0 +1,7 @@ +{ + "name": "bytes", + "description": "byte size string parser / serializer", + "keywords": ["bytes", "utility"], + "version": "0.2.1", + "scripts": ["index.js"] +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/bytes/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/index.js new file mode 100644 index 00000000..70b2e01a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/index.js @@ -0,0 +1,39 @@ + +/** + * Parse byte `size` string. + * + * @param {String} size + * @return {Number} + * @api public + */ + +module.exports = function(size) { + if ('number' == typeof size) return convert(size); + var parts = size.match(/^(\d+(?:\.\d+)?) *(kb|mb|gb)$/) + , n = parseFloat(parts[1]) + , type = parts[2]; + + var map = { + kb: 1 << 10 + , mb: 1 << 20 + , gb: 1 << 30 + }; + + return map[type] * n; +}; + +/** + * convert bytes into string. + * + * @param {Number} b - bytes to convert + * @return {String} + * @api public + */ + +function convert (b) { + var gb = 1 << 30, mb = 1 << 20, kb = 1 << 10; + if (b >= gb) return (Math.round(b / gb * 100) / 100) + 'gb'; + if (b >= mb) return (Math.round(b / mb * 100) / 100) + 'mb'; + if (b >= kb) return (Math.round(b / kb * 100) / 100) + 'kb'; + return b + 'b'; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/bytes/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/package.json new file mode 100644 index 00000000..3eed0ec4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/bytes/package.json @@ -0,0 +1,29 @@ +{ + "name": "bytes", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + }, + "description": "byte size string parser / serializer", + "version": "0.2.1", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "component": { + "scripts": { + "bytes/index.js": "index.js" + } + }, + "readme": "# node-bytes\n\n Byte string parser / formatter.\n\n## Example:\n\n```js\nbytes('1kb')\n// => 1024\n\nbytes('2mb')\n// => 2097152\n\nbytes('1gb')\n// => 1073741824\n\nbytes(1073741824)\n// => 1gb\n```\n\n## Installation\n\n```\n$ npm install bytes\n$ component install visionmedia/bytes.js\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "Readme.md", + "_id": "bytes@0.2.1", + "dist": { + "shasum": "61bcb30d55a7c8512ac77f38ee20b0fc6ee2c33f" + }, + "_from": "bytes@0.2.1", + "_resolved": "https://registry.npmjs.org/bytes/-/bytes-0.2.1.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.jshintrc b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.jshintrc new file mode 100644 index 00000000..a93b50cf --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.jshintrc @@ -0,0 +1,70 @@ +{ + // Settings + "passfail" : false, // Stop on first error. + "maxerr" : 100, // Maximum errors before stopping. + + + // Predefined globals whom JSHint will ignore. + "browser" : false, // Standard browser globals e.g. `window`, `document`. + + "node" : true, + "rhino" : false, + "couch" : false, + "wsh" : false, // Windows Scripting Host. + + "jquery" : false, + "prototypejs" : false, + "mootools" : false, + "dojo" : false, + + + "predef" : [ + "describe", "it", "before", "after" + ], + + // Development. + "debug" : true, // Allow debugger statements e.g. browser breakpoints. + "devel" : true, // Allow development statements e.g. `console.log();`. + + + // EcmaScript 5. + "es5" : true, // Allow EcmaScript 5 syntax. + "strict" : false, // Require `use strict` pragma in every file. + "globalstrict" : true, // Allow global "use strict" (also enables 'strict'). + + + // The Good Parts. + "asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons). + "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. + "laxcomma" : true, + "bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.). + "boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. + "curly" : false, // Require {} for every new block or scope. + "eqeqeq" : true, // Require triple equals i.e. `===`. + "eqnull" : true, // Tolerate use of `== null`. + "evil" : false, // Tolerate use of `eval`. + "expr" : false, // Tolerate `ExpressionStatement` as Programs. + "forin" : false, // Prohibt `for in` loops without `hasOwnProperty`. + "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` + "latedef" : false, // Prohibit variable use before definition. + "loopfunc" : false, // Allow functions to be defined within loops. + "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. + "regexp" : false, // Prohibit `.` and `[^...]` in regular expressions. + "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. + "scripturl" : false, // Tolerate script-targeted URLs. + "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. + "supernew" : false, // Tolerate `new function () { ... };` and `new Object;`. + "undef" : true, // Require all non-global variables be declared before they are used. + + + // Persone styling prefrences. + "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. + "noempty" : true, // Prohibit use of empty blocks. + "nonew" : true, // Prohibit use of constructors for side-effects. + "nomen" : false, // Prohibit use of initial or trailing underbars in names. + "onevar" : false, // Allow only one `var` statement per function. + "plusplus" : false, // Prohibit use of `++` & `--`. + "sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. + "trailing" : true, // Prohibit trailing whitespaces. + "white" : false // Check against strict whitespace and indentation rules. +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.npmignore new file mode 100644 index 00000000..07e6e472 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.npmignore @@ -0,0 +1 @@ +/node_modules diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.travis.yml new file mode 100644 index 00000000..b1fc4b01 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.8" + - "0.10" +before_script: + - ulimit -n 500 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/CHANGELOG.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/CHANGELOG.md new file mode 100644 index 00000000..ea54d9a1 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/CHANGELOG.md @@ -0,0 +1,191 @@ +### 2.2.0 + + * additional callback API to support multiple files with same field name + * fix assertion crash when max field count is exceeded + * fix assertion crash when client aborts an invalid request + * (>=v0.10 only) unpipe the request when an error occurs to save resources. + * update readable-stream to ~1.1.9 + * fix assertion crash when EMFILE occurrs + * (no more assertions - only 'error' events) + +### 2.1.9 + + * relax content-type detection regex. (thanks amitaibu) + +### 2.1.8 + + * replace deprecated Buffer.write(). (thanks hueniverse) + +### 2.1.7 + + * add repository field to package.json + +### 2.1.6 + + * expose `hash` as an option to `Form`. (thanks wookiehangover) + +### 2.1.5 + + * fix possible 'close' event before all temp files are done + +### 2.1.4 + + * fix crash for invalid requests + +### 2.1.3 + + * add `file.size` + +### 2.1.2 + + * proper backpressure support + * update s3 example + +### 2.1.1 + + * fix uploads larger than 2KB + * fix both s3 and upload example + * add part.byteCount and part.byteOffset + +### 2.1.0 (recalled) + + * Complete rewrite. See README for changes and new API. + +### v1.0.13 + +* Only update hash if update method exists (Sven Lito) +* According to travis v0.10 needs to go quoted (Sven Lito) +* Bumping build node versions (Sven Lito) +* Additional fix for empty requests (Eugene Girshov) +* Change the default to 1000, to match the new Node behaviour. (OrangeDog) +* Add ability to control maxKeys in the querystring parser. (OrangeDog) +* Adjust test case to work with node 0.9.x (Eugene Girshov) +* Update package.json (Sven Lito) +* Path adjustment according to eb4468b (Markus Ast) + +### v1.0.12 + +* Emit error on aborted connections (Eugene Girshov) +* Add support for empty requests (Eugene Girshov) +* Fix name/filename handling in Content-Disposition (jesperp) +* Tolerate malformed closing boundary in multipart (Eugene Girshov) +* Ignore preamble in multipart messages (Eugene Girshov) +* Add support for application/json (Mike Frey, Carlos Rodriguez) +* Add support for Base64 encoding (Elmer Bulthuis) +* Add File#toJSON (TJ Holowaychuk) +* Remove support for Node.js 0.4 & 0.6 (Andrew Kelley) +* Documentation improvements (Sven Lito, Andre Azevedo) +* Add support for application/octet-stream (Ion Lupascu, Chris Scribner) +* Use os.tmpDir() to get tmp directory (Andrew Kelley) +* Improve package.json (Andrew Kelley, Sven Lito) +* Fix benchmark script (Andrew Kelley) +* Fix scope issue in incoming_forms (Sven Lito) +* Fix file handle leak on error (OrangeDog) + +### v1.0.11 + +* Calculate checksums for incoming files (sreuter) +* Add definition parameters to "IncomingForm" as an argument (Math-) + +### v1.0.10 + +* Make parts to be proper Streams (Matt Robenolt) + +### v1.0.9 + +* Emit progress when content length header parsed (Tim Koschützki) +* Fix Readme syntax due to GitHub changes (goob) +* Replace references to old 'sys' module in Readme with 'util' (Peter Sugihara) + +### v1.0.8 + +* Strip potentially unsafe characters when using `keepExtensions: true`. +* Switch to utest / urun for testing +* Add travis build + +### v1.0.7 + +* Remove file from package that was causing problems when installing on windows. (#102) +* Fix typos in Readme (Jason Davies). + +### v1.0.6 + +* Do not default to the default to the field name for file uploads where + filename="". + +### v1.0.5 + +* Support filename="" in multipart parts +* Explain unexpected end() errors in parser better + +**Note:** Starting with this version, formidable emits 'file' events for empty +file input fields. Previously those were incorrectly emitted as regular file +input fields with value = "". + +### v1.0.4 + +* Detect a good default tmp directory regardless of platform. (#88) + +### v1.0.3 + +* Fix problems with utf8 characters (#84) / semicolons in filenames (#58) +* Small performance improvements +* New test suite and fixture system + +### v1.0.2 + +* Exclude node\_modules folder from git +* Implement new `'aborted'` event +* Fix files in example folder to work with recent node versions +* Make gently a devDependency + +[See Commits](https://github.com/felixge/node-formidable/compare/v1.0.1...v1.0.2) + +### v1.0.1 + +* Fix package.json to refer to proper main directory. (#68, Dean Landolt) + +[See Commits](https://github.com/felixge/node-formidable/compare/v1.0.0...v1.0.1) + +### v1.0.0 + +* Add support for multipart boundaries that are quoted strings. (Jeff Craig) + +This marks the beginning of development on version 2.0 which will include +several architectural improvements. + +[See Commits](https://github.com/felixge/node-formidable/compare/v0.9.11...v1.0.0) + +### v0.9.11 + +* Emit `'progress'` event when receiving data, regardless of parsing it. (Tim Koschützki) +* Use [W3C FileAPI Draft](http://dev.w3.org/2006/webapi/FileAPI/) properties for File class + +**Important:** The old property names of the File class will be removed in a +future release. + +[See Commits](https://github.com/felixge/node-formidable/compare/v0.9.10...v0.9.11) + +### Older releases + +These releases were done before starting to maintain the above Changelog: + +* [v0.9.10](https://github.com/felixge/node-formidable/compare/v0.9.9...v0.9.10) +* [v0.9.9](https://github.com/felixge/node-formidable/compare/v0.9.8...v0.9.9) +* [v0.9.8](https://github.com/felixge/node-formidable/compare/v0.9.7...v0.9.8) +* [v0.9.7](https://github.com/felixge/node-formidable/compare/v0.9.6...v0.9.7) +* [v0.9.6](https://github.com/felixge/node-formidable/compare/v0.9.5...v0.9.6) +* [v0.9.5](https://github.com/felixge/node-formidable/compare/v0.9.4...v0.9.5) +* [v0.9.4](https://github.com/felixge/node-formidable/compare/v0.9.3...v0.9.4) +* [v0.9.3](https://github.com/felixge/node-formidable/compare/v0.9.2...v0.9.3) +* [v0.9.2](https://github.com/felixge/node-formidable/compare/v0.9.1...v0.9.2) +* [v0.9.1](https://github.com/felixge/node-formidable/compare/v0.9.0...v0.9.1) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) +* [v0.1.0](https://github.com/felixge/node-formidable/commits/v0.1.0) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/LICENSE new file mode 100644 index 00000000..8488a405 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/LICENSE @@ -0,0 +1,7 @@ +Copyright (C) 2011-2013 Felix Geisendörfer, Andrew Kelley + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/README.md new file mode 100644 index 00000000..f149ac04 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/README.md @@ -0,0 +1,177 @@ +[![Build Status](https://travis-ci.org/superjoe30/node-multiparty.png?branch=master)](https://travis-ci.org/superjoe30/node-multiparty) +# multiparty + +Parse http requests with content-type `multipart/form-data`, also known as file uploads. + +See also [busboy](https://github.com/mscdex/busboy) - a +[faster](https://github.com/mscdex/dicer/wiki/Benchmarks) alternative +which may be worth looking into. + +### Why the fork? + + * This module uses the Node.js v0.10 streams properly, *even in Node.js v0.8* + * It will not create a temp file for you unless you want it to. + * Counts bytes and does math to help you figure out the `Content-Length` of + each part. + * You can easily stream uploads to s3 with + [knox](https://github.com/LearnBoost/knox), for [example](examples/s3.js). + * Less bugs. This code is simpler, has all deprecated functionality removed, + has cleaner tests, and does not try to do anything beyond multipart stream + parsing. + +## Installation + +``` +npm install multiparty +``` + +## Usage + + * See [examples](examples). + +Parse an incoming `multipart/form-data` request. + +```js +var multiparty = require('multiparty') + , http = require('http') + , util = require('util') + +http.createServer(function(req, res) { + if (req.url === '/upload' && req.method === 'POST') { + // parse a file upload + var form = new multiparty.Form(); + + form.parse(req, function(err, fields, files) { + res.writeHead(200, {'content-type': 'text/plain'}); + res.write('received upload:\n\n'); + res.end(util.inspect({fields: fields, files: files})); + }); + + return; + } + + // show a file upload form + res.writeHead(200, {'content-type': 'text/html'}); + res.end( + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    ' + ); +}).listen(8080); +``` + +## API + +### multiparty.Form +```js +var form = new multiparty.Form(options) +``` +Creates a new form. Options: + + * `encoding` - sets encoding for the incoming form fields. Defaults to `utf8`. + * `maxFieldSize` - Limits the amount of memory a field (not a file) can + allocate in bytes. If this value is exceeded, an `error` event is emitted. + The default size is 2MB. + * `maxFields` - Limits the number of fields that will be parsed before + emitting an `error` event. A file counts as a field in this case. + Defaults to 1000. + * `autoFields` - Enables `field` events. This is automatically set to `true` + if you add a `field` listener. + * `autoFiles` - Enables `file` events. This is automatically set to `true` + if you add a `file` listener. + * `uploadDir` - Only relevant when `autoFiles` is `true`. The directory for + placing file uploads in. You can move them later using `fs.rename()`. + Defaults to `os.tmpDir()`. + * `hash` - Only relevant when `autoFiles` is `true`. If you want checksums + calculated for incoming files, set this to either `sha1` or `md5`. + Defaults to off. + +#### form.parse(request, [cb]) + +Parses an incoming node.js `request` containing form data. If `cb` is +provided, `autoFields` and `autoFiles` are set to `true` and all fields and +files are collected and passed to the callback: + +```js +form.parse(req, function(err, fieldsObject, filesObject, fieldsList, filesList) { + // ... +}); +``` + +It is often convenient to access a field or file by name. In this situation, +use `fieldsObject` or `filesObject`. However sometimes, as in the case of a +`` the multipart stream will contain +multiple files of the same input name, and you are interested in all of them. +In this case, use `filesList`. + +Another example is when you do not care what the field name of a file is; you +are merely interested in a single upload. In this case, set `maxFields` to 1 +(assuming no other fields expected besides the file) and use `filesList[0]`. + +#### form.bytesReceived + +The amount of bytes received for this form so far. + +#### form.bytesExpected + +The expected number of bytes in this form. + +### Events + +#### 'error' (err) + +You definitely want to handle this event. If not your server *will* crash when +users submit bogus multipart requests! + +#### 'part' (part) + +Emitted when a part is encountered in the request. `part` is a +`ReadableStream`. It also has the following properties: + + * `headers` - the headers for this part. For example, you may be interested + in `content-type`. + * `name` - the field name for this part + * `filename` - only if the part is an incoming file + * `byteOffset` - the byte offset of this part in the request body + * `byteCount` - assuming that this is the last part in the request, + this is the size of this part in bytes. You could use this, for + example, to set the `Content-Length` header if uploading to S3. + If the part had a `Content-Length` header then that value is used + here instead. + +#### 'aborted' + +Emitted when the request is aborted. This event will be followed shortly +by an `error` event. In practice you do not need to handle this event. + +#### 'progress' (bytesReceived, bytesExpected) + +#### 'close' + +Emitted after all parts have been parsed and emitted. Not emitted if an `error` +event is emitted. This is typically when you would send your response. + +#### 'file' (name, file) + +**By default multiparty will not touch your hard drive.** But if you add this +listener, multiparty automatically sets `form.autoFiles` to `true` and will +stream uploads to disk for you. + + * `name` - the field name for this file + * `file` - an object with these properties: + - `fieldName` - same as `name` - the field name for this file + - `originalFilename` - the filename that the user reports for the file + - `path` - the absolute path of the uploaded file on disk + - `headers` - the HTTP headers that were sent along with this file + - `size` - size of the file in bytes + +If you set the `form.hash` option, then `file` will also contain a `hash` +property which is the checksum of the file. + +#### 'field' (name, value) + + * `name` - field name + * `value` - string field value + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/azureblobstorage.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/azureblobstorage.js new file mode 100644 index 00000000..273c3321 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/azureblobstorage.js @@ -0,0 +1,41 @@ +var http = require('http') + , util = require('util') + , multiparty = require('../') + , azure = require('azure') + , PORT = process.env.PORT || 27372 + +var server = http.createServer(function(req, res) { + if (req.url === '/') { + res.writeHead(200, {'content-type': 'text/html'}); + res.end( + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    ' + ); + } else if (req.url === '/upload') { + + var blobService = azure.createBlobService(); + var form = new multiparty.Form(); + form.on('part', function(part) { + if (!part.filename) return; + + var size = part.byteCount - part.byteOffset; + var name = part.filename; + var container = 'blobContainerName'; + + blobService.createBlockBlobFromStream(container, name, part, size, function(error) { + if (error) { + // error handling + } + }); + }); + form.parse(req); + + res.send('File uploaded successfully'); + } +}); +server.listen(PORT, function() { + console.info('listening on http://0.0.0.0:'+PORT+'/'); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/s3.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/s3.js new file mode 100644 index 00000000..60617ba2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/s3.js @@ -0,0 +1,74 @@ +var http = require('http') + , util = require('util') + , multiparty = require('../') + , knox = require('knox') + , Batch = require('batch') + , PORT = process.env.PORT || 27372 + +var s3Client = knox.createClient({ + secure: false, + key: process.env.S3_KEY, + secret: process.env.S3_SECRET, + bucket: process.env.S3_BUCKET, +}); + +var server = http.createServer(function(req, res) { + if (req.url === '/') { + res.writeHead(200, {'content-type': 'text/html'}); + res.end( + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    ' + ); + } else if (req.url === '/upload') { + var headers = { + 'x-amz-acl': 'public-read', + }; + var form = new multiparty.Form(); + var batch = new Batch(); + batch.push(function(cb) { + form.on('field', function(name, value) { + if (name === 'path') { + var destPath = value; + if (destPath[0] !== '/') destPath = '/' + destPath; + cb(null, destPath); + } + }); + }); + batch.push(function(cb) { + form.on('part', function(part) { + if (! part.filename) return; + cb(null, part); + }); + }); + batch.end(function(err, results) { + if (err) throw err; + form.removeListener('close', onEnd); + var destPath = results[0] + , part = results[1]; + + headers['Content-Length'] = part.byteCount; + s3Client.putStream(part, destPath, headers, function(err, s3Response) { + if (err) throw err; + res.statusCode = s3Response.statusCode; + s3Response.pipe(res); + console.log("https://s3.amazonaws.com/" + process.env.S3_BUCKET + destPath); + }); + }); + form.on('close', onEnd); + form.parse(req); + + } else { + res.writeHead(404, {'content-type': 'text/plain'}); + res.end('404'); + } + + function onEnd() { + throw new Error("no uploaded file"); + } +}); +server.listen(PORT, function() { + console.info('listening on http://0.0.0.0:'+PORT+'/'); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/upload.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/upload.js new file mode 100644 index 00000000..5dd39268 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/examples/upload.js @@ -0,0 +1,37 @@ +var http = require('http') + , util = require('util') + , multiparty = require('../') + , PORT = process.env.PORT || 27372 + +var server = http.createServer(function(req, res) { + if (req.url === '/') { + res.writeHead(200, {'content-type': 'text/html'}); + res.end( + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    ' + ); + } else if (req.url === '/upload') { + var form = new multiparty.Form(); + + form.parse(req, function(err, fields, files) { + if (err) { + res.writeHead(400, {'content-type': 'text/plain'}); + res.end("invalid request: " + err.message); + return; + } + res.writeHead(200, {'content-type': 'text/plain'}); + res.write('received fields:\n\n '+util.inspect(fields)); + res.write('\n\n'); + res.end('received files:\n\n '+util.inspect(files)); + }); + } else { + res.writeHead(404, {'content-type': 'text/plain'}); + res.end('404'); + } +}); +server.listen(PORT, function() { + console.info('listening on http://0.0.0.0:'+PORT+'/'); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/index.js new file mode 100644 index 00000000..71c88ae3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/index.js @@ -0,0 +1,618 @@ +exports.Form = Form; + +var stream = require('readable-stream') + , util = require('util') + , fs = require('fs') + , crypto = require('crypto') + , path = require('path') + , os = require('os') + , StringDecoder = require('string_decoder').StringDecoder + , StreamCounter = require('stream-counter') + +var START = 0 + , START_BOUNDARY = 1 + , HEADER_FIELD_START = 2 + , HEADER_FIELD = 3 + , HEADER_VALUE_START = 4 + , HEADER_VALUE = 5 + , HEADER_VALUE_ALMOST_DONE = 6 + , HEADERS_ALMOST_DONE = 7 + , PART_DATA_START = 8 + , PART_DATA = 9 + , PART_END = 10 + , END = 11 + + , LF = 10 + , CR = 13 + , SPACE = 32 + , HYPHEN = 45 + , COLON = 58 + , A = 97 + , Z = 122 + +var CONTENT_TYPE_RE = /^multipart\/(form-data|related);\s*boundary=(?:"([^"]+)"|([^;]+))$/i; +var FILE_EXT_RE = /(\.[_\-a-zA-Z0-9]{0,16}).*/; +var LAST_BOUNDARY_SUFFIX_LEN = 4; // --\r\n + +util.inherits(Form, stream.Writable); +function Form(options) { + var self = this; + stream.Writable.call(self); + + options = options || {}; + + self.error = null; + self.finished = false; + + self.autoFields = !!options.autoFields; + self.autoFiles = !!options.autoFields; + + self.maxFields = options.maxFields || 1000; + self.maxFieldsSize = options.maxFieldsSize || 2 * 1024 * 1024; + self.uploadDir = options.uploadDir || os.tmpDir(); + self.encoding = options.encoding || 'utf8'; + self.hash = options.hash || false; + + self.bytesReceived = 0; + self.bytesExpected = null; + + self.openedFiles = []; + self.totalFieldSize = 0; + self.totalFieldCount = 0; + self.flushing = 0; + + self.backpressure = false; + self.writeCbs = []; + + if (options.boundary) setUpParser(self, options.boundary); + + self.on('newListener', function(eventName) { + if (eventName === 'file') { + self.autoFiles = true; + } else if (eventName === 'field') { + self.autoFields = true; + } + }); +} + +Form.prototype.parse = function(req, cb) { + var self = this; + + // if the user supplies a callback, this implies autoFields and autoFiles + if (cb) { + self.autoFields = true; + self.autoFiles = true; + } + + self.handleError = handleError; + self.bytesExpected = getBytesExpected(req.headers); + + req.on('error', handleError); + req.on('aborted', onReqAborted); + + var contentType = req.headers['content-type']; + if (!contentType) { + handleError(new Error('missing content-type header')); + return; + } + + var m = contentType.match(CONTENT_TYPE_RE); + if (!m) { + handleError(new Error('unrecognized content-type: ' + contentType)); + return; + } + var boundary = m[2] || m[3]; + setUpParser(self, boundary); + req.pipe(self); + + if (cb) { + var fieldsTable = {}; + var filesTable = {}; + var fieldsList = []; + var filesList = []; + self.on('error', function(err) { + cb(err); + }); + self.on('field', function(name, value) { + fieldsTable[name] = value; + fieldsList.push({name: name, value: value}); + }); + self.on('file', function(name, file) { + filesTable[name] = file; + filesList.push(file); + }); + self.on('close', function() { + cb(null, fieldsTable, filesTable, fieldsList, filesList); + }); + } + + function onReqAborted() { + self.emit('aborted'); + handleError(new Error("Request aborted")); + } + + function handleError(err) { + var first = !self.error; + if (first) { + self.error = err; + req.removeListener('aborted', onReqAborted); + + // welp. 0.8 doesn't support unpipe, too bad so sad. + // let's drop support for 0.8 soon. + if (req.unpipe) { + req.unpipe(self); + } + } + + self.openedFiles.forEach(function(file) { + file.ws.destroy(); + fs.unlink(file.path, function(err) { + // this is already an error condition, ignore 2nd error + }); + }); + self.openedFiles = []; + + if (first) { + self.emit('error', err); + } + } + +}; + +Form.prototype._write = function(buffer, encoding, cb) { + var self = this + , i = 0 + , len = buffer.length + , prevIndex = self.index + , index = self.index + , state = self.state + , lookbehind = self.lookbehind + , boundary = self.boundary + , boundaryChars = self.boundaryChars + , boundaryLength = self.boundary.length + , boundaryEnd = boundaryLength - 1 + , bufferLength = buffer.length + , c + , cl + + for (i = 0; i < len; i++) { + c = buffer[i]; + switch (state) { + case START: + index = 0; + state = START_BOUNDARY; + /* falls through */ + case START_BOUNDARY: + if (index === boundaryLength - 2) { + if (c !== CR) return self.handleError(new Error("Expected CR Received " + c)); + index++; + break; + } else if (index === boundaryLength - 1) { + if (c !== LF) return self.handleError(new Error("Expected LF Received " + c)); + index = 0; + self.onParsePartBegin(); + state = HEADER_FIELD_START; + break; + } + + if (c !== boundary[index+2]) index = -2; + if (c === boundary[index+2]) index++; + break; + case HEADER_FIELD_START: + state = HEADER_FIELD; + self.headerFieldMark = i; + index = 0; + /* falls through */ + case HEADER_FIELD: + if (c === CR) { + self.headerFieldMark = null; + state = HEADERS_ALMOST_DONE; + break; + } + + index++; + if (c === HYPHEN) break; + + if (c === COLON) { + if (index === 1) { + // empty header field + self.handleError(new Error("Empty header field")); + return; + } + self.onParseHeaderField(buffer.slice(self.headerFieldMark, i)); + self.headerFieldMark = null; + state = HEADER_VALUE_START; + break; + } + + cl = lower(c); + if (cl < A || cl > Z) { + self.handleError(new Error("Expected alphabetic character, received " + c)); + return; + } + break; + case HEADER_VALUE_START: + if (c === SPACE) break; + + self.headerValueMark = i; + state = HEADER_VALUE; + /* falls through */ + case HEADER_VALUE: + if (c === CR) { + self.onParseHeaderValue(buffer.slice(self.headerValueMark, i)); + self.headerValueMark = null; + self.onParseHeaderEnd(); + state = HEADER_VALUE_ALMOST_DONE; + } + break; + case HEADER_VALUE_ALMOST_DONE: + if (c !== LF) return self.handleError(new Error("Expected LF Received " + c)); + state = HEADER_FIELD_START; + break; + case HEADERS_ALMOST_DONE: + if (c !== LF) return self.handleError(new Error("Expected LF Received " + c)); + var err = self.onParseHeadersEnd(i + 1); + if (err) return self.handleError(err); + state = PART_DATA_START; + break; + case PART_DATA_START: + state = PART_DATA; + self.partDataMark = i; + /* falls through */ + case PART_DATA: + prevIndex = index; + + if (index === 0) { + // boyer-moore derrived algorithm to safely skip non-boundary data + i += boundaryEnd; + while (i < bufferLength && !(buffer[i] in boundaryChars)) { + i += boundaryLength; + } + i -= boundaryEnd; + c = buffer[i]; + } + + if (index < boundaryLength) { + if (boundary[index] === c) { + if (index === 0) { + self.onParsePartData(buffer.slice(self.partDataMark, i)); + self.partDataMark = null; + } + index++; + } else { + index = 0; + } + } else if (index === boundaryLength) { + index++; + if (c === CR) { + // CR = part boundary + self.partBoundaryFlag = true; + } else if (c === HYPHEN) { + // HYPHEN = end boundary + self.lastBoundaryFlag = true; + } else { + index = 0; + } + } else if (index - 1 === boundaryLength) { + if (self.partBoundaryFlag) { + index = 0; + if (c === LF) { + self.partBoundaryFlag = false; + self.onParsePartEnd(); + self.onParsePartBegin(); + state = HEADER_FIELD_START; + break; + } + } else if (self.lastBoundaryFlag) { + if (c === HYPHEN) { + self.onParsePartEnd(); + self.end(); + state = END; + } else { + index = 0; + } + } else { + index = 0; + } + } + + if (index > 0) { + // when matching a possible boundary, keep a lookbehind reference + // in case it turns out to be a false lead + lookbehind[index-1] = c; + } else if (prevIndex > 0) { + // if our boundary turned out to be rubbish, the captured lookbehind + // belongs to partData + self.onParsePartData(lookbehind.slice(0, prevIndex)); + prevIndex = 0; + self.partDataMark = i; + + // reconsider the current character even so it interrupted the sequence + // it could be the beginning of a new sequence + i--; + } + + break; + case END: + break; + default: + self.handleError(new Error("Parser has invalid state.")); + return; + } + } + + if (self.headerFieldMark != null) { + self.onParseHeaderField(buffer.slice(self.headerFieldMark)); + self.headerFieldMark = 0; + } + if (self.headerValueMark != null) { + self.onParseHeaderValue(buffer.slice(self.headerValueMark)); + self.headerValueMark = 0; + } + if (self.partDataMark != null) { + self.onParsePartData(buffer.slice(self.partDataMark)); + self.partDataMark = 0; + } + + self.index = index; + self.state = state; + + self.bytesReceived += buffer.length; + self.emit('progress', self.bytesReceived, self.bytesExpected); + + if (self.backpressure) { + self.writeCbs.push(cb); + } else { + cb(); + } +}; + +Form.prototype.onParsePartBegin = function() { + clearPartVars(this); +} + +Form.prototype.onParseHeaderField = function(b) { + this.headerField += this.headerFieldDecoder.write(b); +} + +Form.prototype.onParseHeaderValue = function(b) { + this.headerValue += this.headerValueDecoder.write(b); +} + +Form.prototype.onParseHeaderEnd = function() { + this.headerField = this.headerField.toLowerCase(); + this.partHeaders[this.headerField] = this.headerValue; + + var m; + if (this.headerField === 'content-disposition') { + if (m = this.headerValue.match(/\bname="([^"]+)"/i)) { + this.partName = m[1]; + } + this.partFilename = parseFilename(this.headerValue); + } else if (this.headerField === 'content-transfer-encoding') { + this.partTransferEncoding = this.headerValue.toLowerCase(); + } + + this.headerFieldDecoder = new StringDecoder(this.encoding); + this.headerField = ''; + this.headerValueDecoder = new StringDecoder(this.encoding); + this.headerValue = ''; +} + +Form.prototype.onParsePartData = function(b) { + if (this.partTransferEncoding === 'base64') { + this.backpressure = ! this.destStream.write(b.toString('ascii'), 'base64'); + } else { + this.backpressure = ! this.destStream.write(b); + } +} + +Form.prototype.onParsePartEnd = function() { + if (this.destStream) { + flushWriteCbs(this); + var s = this.destStream; + process.nextTick(function() { + s.end(); + }); + } + clearPartVars(this); +} + +Form.prototype.onParseHeadersEnd = function(offset) { + var self = this; + switch(self.partTransferEncoding){ + case 'binary': + case '7bit': + case '8bit': + self.partTransferEncoding = 'binary'; + break; + + case 'base64': break; + default: + return new Error("unknown transfer-encoding: " + self.partTransferEncoding); + } + + self.totalFieldCount += 1; + if (self.totalFieldCount >= self.maxFields) { + return new Error("maxFields " + self.maxFields + " exceeded."); + } + + self.destStream = new stream.PassThrough(); + self.destStream.on('drain', function() { + flushWriteCbs(self); + }); + self.destStream.headers = self.partHeaders; + self.destStream.name = self.partName; + self.destStream.filename = self.partFilename; + self.destStream.byteOffset = self.bytesReceived + offset; + var partContentLength = self.destStream.headers['content-length']; + self.destStream.byteCount = partContentLength ? + parseInt(partContentLength, 10) : + (self.bytesExpected - self.destStream.byteOffset - + self.boundary.length - LAST_BOUNDARY_SUFFIX_LEN); + + self.emit('part', self.destStream); + if (self.destStream.filename == null && self.autoFields) { + handleField(self, self.destStream); + } else if (self.destStream.filename != null && self.autoFiles) { + handleFile(self, self.destStream); + } +} + +function flushWriteCbs(self) { + self.writeCbs.forEach(function(cb) { + process.nextTick(cb); + }); + self.writeCbs = []; + self.backpressure = false; +} + +function getBytesExpected(headers) { + var contentLength = headers['content-length']; + if (contentLength) { + return parseInt(contentLength, 10); + } else if (headers['transfer-encoding'] == null) { + return 0; + } else { + return null; + } +} + +function beginFlush(self) { + self.flushing += 1; +} + +function endFlush(self) { + self.flushing -= 1; + maybeClose(self); +} + +function maybeClose(self) { + if (!self.flushing && self.finished && !self.error) { + self.emit('close'); + } +} + +function handleFile(self, fileStream) { + beginFlush(self); + var file = { + fieldName: fileStream.name, + originalFilename: fileStream.filename, + path: uploadPath(self.uploadDir, fileStream.filename), + headers: fileStream.headers, + }; + file.ws = fs.createWriteStream(file.path); + self.openedFiles.push(file); + fileStream.pipe(file.ws); + var counter = new StreamCounter(); + fileStream.pipe(counter); + var hashWorkaroundStream + , hash = null; + if (self.hash) { + // workaround stream because https://github.com/joyent/node/issues/5216 + hashWorkaroundStream = stream.Writable(); + hash = crypto.createHash(self.hash); + hashWorkaroundStream._write = function(buffer, encoding, callback) { + hash.update(buffer); + callback(); + }; + fileStream.pipe(hashWorkaroundStream); + } + file.ws.on('error', function(err) { + if (!self.error) self.handleError(err); + }); + file.ws.on('close', function() { + if (hash) file.hash = hash.digest('hex'); + file.size = counter.bytes; + self.emit('file', fileStream.name, file); + endFlush(self); + }); +} + +function handleField(self, fieldStream) { + var value = ''; + var decoder = new StringDecoder(self.encoding); + + beginFlush(self); + fieldStream.on('readable', function() { + var buffer = fieldStream.read(); + if (!buffer) return; + + self.totalFieldSize += buffer.length; + if (self.totalFieldSize > self.maxFieldsSize) { + self.handleError(new Error("maxFieldsSize " + self.maxFieldsSize + " exceeded")); + return; + } + value += decoder.write(buffer); + }); + + fieldStream.on('end', function() { + self.emit('field', fieldStream.name, value); + endFlush(self); + }); +} + +function clearPartVars(self) { + self.partHeaders = {}; + self.partName = null; + self.partFilename = null; + self.partTransferEncoding = 'binary'; + self.destStream = null; + + self.headerFieldDecoder = new StringDecoder(self.encoding); + self.headerField = ""; + self.headerValueDecoder = new StringDecoder(self.encoding); + self.headerValue = ""; +} + +function setUpParser(self, boundary) { + self.boundary = new Buffer(boundary.length + 4); + self.boundary.write('\r\n--', 0, boundary.length + 4, 'ascii'); + self.boundary.write(boundary, 4, boundary.length, 'ascii'); + self.lookbehind = new Buffer(self.boundary.length + 8); + self.state = START; + self.boundaryChars = {}; + for (var i = 0; i < self.boundary.length; i++) { + self.boundaryChars[self.boundary[i]] = true; + } + + self.index = null; + self.partBoundaryFlag = false; + self.lastBoundaryFlag = false; + + self.on('finish', function() { + if ((self.state === HEADER_FIELD_START && self.index === 0) || + (self.state === PART_DATA && self.index === self.boundary.length)) + { + self.onParsePartEnd(); + } else if (self.state !== END) { + self.handleError(new Error('stream ended unexpectedly')); + } + self.finished = true; + maybeClose(self); + }); +} + +function uploadPath(baseDir, filename) { + var ext = path.extname(filename).replace(FILE_EXT_RE, '$1'); + var name = process.pid + '-' + + (Math.random() * 0x100000000 + 1).toString(36) + ext; + return path.join(baseDir, name); +} + +function parseFilename(headerValue) { + var m = headerValue.match(/\bfilename="(.*?)"($|; )/i); + if (!m) return; + + var filename = m[1].substr(m[1].lastIndexOf('\\') + 1); + filename = filename.replace(/%22/g, '"'); + filename = filename.replace(/&#([\d]{4});/g, function(m, code) { + return String.fromCharCode(code); + }); + return filename; +} + +function lower(c) { + return c | 0x20; +} + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/.npmignore new file mode 100644 index 00000000..38344f87 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/.npmignore @@ -0,0 +1,5 @@ +build/ +test/ +examples/ +fs.js +zlib.js \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/LICENSE new file mode 100644 index 00000000..e3d4e695 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. and other Node contributors. All rights reserved. +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/README.md new file mode 100644 index 00000000..be976683 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/README.md @@ -0,0 +1,768 @@ +# readable-stream + +A new class of streams for Node.js + +This module provides the new Stream base classes introduced in Node +v0.10, for use in Node v0.8. You can use it to have programs that +have to work with node v0.8, while being forward-compatible for v0.10 +and beyond. When you drop support for v0.8, you can remove this +module, and only use the native streams. + +This is almost exactly the same codebase as appears in Node v0.10. +However: + +1. The exported object is actually the Readable class. Decorating the + native `stream` module would be global pollution. +2. In v0.10, you can safely use `base64` as an argument to + `setEncoding` in Readable streams. However, in v0.8, the + StringDecoder class has no `end()` method, which is problematic for + Base64. So, don't use that, because it'll break and be weird. + +Other than that, the API is the same as `require('stream')` in v0.10, +so the API docs are reproduced below. + +---------- + + Stability: 2 - Unstable + +A stream is an abstract interface implemented by various objects in +Node. For example a request to an HTTP server is a stream, as is +stdout. Streams are readable, writable, or both. All streams are +instances of [EventEmitter][] + +You can load the Stream base classes by doing `require('stream')`. +There are base classes provided for Readable streams, Writable +streams, Duplex streams, and Transform streams. + +## Compatibility + +In earlier versions of Node, the Readable stream interface was +simpler, but also less powerful and less useful. + +* Rather than waiting for you to call the `read()` method, `'data'` + events would start emitting immediately. If you needed to do some + I/O to decide how to handle data, then you had to store the chunks + in some kind of buffer so that they would not be lost. +* The `pause()` method was advisory, rather than guaranteed. This + meant that you still had to be prepared to receive `'data'` events + even when the stream was in a paused state. + +In Node v0.10, the Readable class described below was added. For +backwards compatibility with older Node programs, Readable streams +switch into "old mode" when a `'data'` event handler is added, or when +the `pause()` or `resume()` methods are called. The effect is that, +even if you are not using the new `read()` method and `'readable'` +event, you no longer have to worry about losing `'data'` chunks. + +Most programs will continue to function normally. However, this +introduces an edge case in the following conditions: + +* No `'data'` event handler is added. +* The `pause()` and `resume()` methods are never called. + +For example, consider the following code: + +```javascript +// WARNING! BROKEN! +net.createServer(function(socket) { + + // we add an 'end' method, but never consume the data + socket.on('end', function() { + // It will never get here. + socket.end('I got your message (but didnt read it)\n'); + }); + +}).listen(1337); +``` + +In versions of node prior to v0.10, the incoming message data would be +simply discarded. However, in Node v0.10 and beyond, the socket will +remain paused forever. + +The workaround in this situation is to call the `resume()` method to +trigger "old mode" behavior: + +```javascript +// Workaround +net.createServer(function(socket) { + + socket.on('end', function() { + socket.end('I got your message (but didnt read it)\n'); + }); + + // start the flow of data, discarding it. + socket.resume(); + +}).listen(1337); +``` + +In addition to new Readable streams switching into old-mode, pre-v0.10 +style streams can be wrapped in a Readable class using the `wrap()` +method. + +## Class: stream.Readable + + + +A `Readable Stream` has the following methods, members, and events. + +Note that `stream.Readable` is an abstract class designed to be +extended with an underlying implementation of the `_read(size)` +method. (See below.) + +### new stream.Readable([options]) + +* `options` {Object} + * `highWaterMark` {Number} The maximum number of bytes to store in + the internal buffer before ceasing to read from the underlying + resource. Default=16kb + * `encoding` {String} If specified, then buffers will be decoded to + strings using the specified encoding. Default=null + * `objectMode` {Boolean} Whether this stream should behave + as a stream of objects. Meaning that stream.read(n) returns + a single value instead of a Buffer of size n + +In classes that extend the Readable class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### readable.\_read(size) + +* `size` {Number} Number of bytes to read asynchronously + +Note: **This function should NOT be called directly.** It should be +implemented by child classes, and called by the internal Readable +class methods only. + +All Readable stream implementations must provide a `_read` method +to fetch data from the underlying resource. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +When data is available, put it into the read queue by calling +`readable.push(chunk)`. If `push` returns false, then you should stop +reading. When `_read` is called again, you should start pushing more +data. + +The `size` argument is advisory. Implementations where a "read" is a +single call that returns data can use this to know how much data to +fetch. Implementations where that is not relevant, such as TCP or +TLS, may ignore this argument, and simply provide data whenever it +becomes available. There is no need, for example to "wait" until +`size` bytes are available before calling `stream.push(chunk)`. + +### readable.push(chunk) + +* `chunk` {Buffer | null | String} Chunk of data to push into the read queue +* return {Boolean} Whether or not more pushes should be performed + +Note: **This function should be called by Readable implementors, NOT +by consumers of Readable subclasses.** The `_read()` function will not +be called again until at least one `push(chunk)` call is made. If no +data is available, then you MAY call `push('')` (an empty string) to +allow a future `_read` call, without adding any data to the queue. + +The `Readable` class works by putting data into a read queue to be +pulled out later by calling the `read()` method when the `'readable'` +event fires. + +The `push()` method will explicitly insert some data into the read +queue. If it is called with `null` then it will signal the end of the +data. + +In some cases, you may be wrapping a lower-level source which has some +sort of pause/resume mechanism, and a data callback. In those cases, +you could wrap the low-level source object by doing something like +this: + +```javascript +// source is an object with readStop() and readStart() methods, +// and an `ondata` member that gets called when it has data, and +// an `onend` member that gets called when the data is over. + +var stream = new Readable(); + +source.ondata = function(chunk) { + // if push() returns false, then we need to stop reading from source + if (!stream.push(chunk)) + source.readStop(); +}; + +source.onend = function() { + stream.push(null); +}; + +// _read will be called when the stream wants to pull more data in +// the advisory size argument is ignored in this case. +stream._read = function(n) { + source.readStart(); +}; +``` + +### readable.unshift(chunk) + +* `chunk` {Buffer | null | String} Chunk of data to unshift onto the read queue +* return {Boolean} Whether or not more pushes should be performed + +This is the corollary of `readable.push(chunk)`. Rather than putting +the data at the *end* of the read queue, it puts it at the *front* of +the read queue. + +This is useful in certain use-cases where a stream is being consumed +by a parser, which needs to "un-consume" some data that it has +optimistically pulled out of the source. + +```javascript +// A parser for a simple data protocol. +// The "header" is a JSON object, followed by 2 \n characters, and +// then a message body. +// +// Note: This can be done more simply as a Transform stream. See below. + +function SimpleProtocol(source, options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(options); + + Readable.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + + // source is a readable stream, such as a socket or file + this._source = source; + + var self = this; + source.on('end', function() { + self.push(null); + }); + + // give it a kick whenever the source is readable + // read(0) will not consume any bytes + source.on('readable', function() { + self.read(0); + }); + + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype = Object.create( + Readable.prototype, { constructor: { value: SimpleProtocol }}); + +SimpleProtocol.prototype._read = function(n) { + if (!this._inBody) { + var chunk = this._source.read(); + + // if the source doesn't have data, we don't have data yet. + if (chunk === null) + return this.push(''); + + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + this.push(''); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // now, because we got some extra data, unshift the rest + // back into the read queue so that our consumer will see it. + var b = chunk.slice(split); + this.unshift(b); + + // and let them know that we are done parsing the header. + this.emit('header', this.header); + } + } else { + // from there on, just provide the data to our consumer. + // careful not to push(null), since that would indicate EOF. + var chunk = this._source.read(); + if (chunk) this.push(chunk); + } +}; + +// Usage: +var parser = new SimpleProtocol(source); +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + +### readable.wrap(stream) + +* `stream` {Stream} An "old style" readable stream + +If you are using an older Node library that emits `'data'` events and +has a `pause()` method that is advisory only, then you can use the +`wrap()` method to create a Readable stream that uses the old stream +as its data source. + +For example: + +```javascript +var OldReader = require('./old-api-module.js').OldReader; +var oreader = new OldReader; +var Readable = require('stream').Readable; +var myReader = new Readable().wrap(oreader); + +myReader.on('readable', function() { + myReader.read(); // etc. +}); +``` + +### Event: 'readable' + +When there is data ready to be consumed, this event will fire. + +When this event emits, call the `read()` method to consume the data. + +### Event: 'end' + +Emitted when the stream has received an EOF (FIN in TCP terminology). +Indicates that no more `'data'` events will happen. If the stream is +also writable, it may be possible to continue writing. + +### Event: 'data' + +The `'data'` event emits either a `Buffer` (by default) or a string if +`setEncoding()` was used. + +Note that adding a `'data'` event listener will switch the Readable +stream into "old mode", where data is emitted as soon as it is +available, rather than waiting for you to call `read()` to consume it. + +### Event: 'error' + +Emitted if there was an error receiving data. + +### Event: 'close' + +Emitted when the underlying resource (for example, the backing file +descriptor) has been closed. Not all streams will emit this. + +### readable.setEncoding(encoding) + +Makes the `'data'` event emit a string instead of a `Buffer`. `encoding` +can be `'utf8'`, `'utf16le'` (`'ucs2'`), `'ascii'`, or `'hex'`. + +The encoding can also be set by specifying an `encoding` field to the +constructor. + +### readable.read([size]) + +* `size` {Number | null} Optional number of bytes to read. +* Return: {Buffer | String | null} + +Note: **This function SHOULD be called by Readable stream users.** + +Call this method to consume data once the `'readable'` event is +emitted. + +The `size` argument will set a minimum number of bytes that you are +interested in. If not set, then the entire content of the internal +buffer is returned. + +If there is no data to consume, or if there are fewer bytes in the +internal buffer than the `size` argument, then `null` is returned, and +a future `'readable'` event will be emitted when more is available. + +Calling `stream.read(0)` will always return `null`, and will trigger a +refresh of the internal buffer, but otherwise be a no-op. + +### readable.pipe(destination, [options]) + +* `destination` {Writable Stream} +* `options` {Object} Optional + * `end` {Boolean} Default=true + +Connects this readable stream to `destination` WriteStream. Incoming +data on this stream gets written to `destination`. Properly manages +back-pressure so that a slow destination will not be overwhelmed by a +fast readable stream. + +This function returns the `destination` stream. + +For example, emulating the Unix `cat` command: + + process.stdin.pipe(process.stdout); + +By default `end()` is called on the destination when the source stream +emits `end`, so that `destination` is no longer writable. Pass `{ end: +false }` as `options` to keep the destination stream open. + +This keeps `writer` open so that "Goodbye" can be written at the +end. + + reader.pipe(writer, { end: false }); + reader.on("end", function() { + writer.end("Goodbye\n"); + }); + +Note that `process.stderr` and `process.stdout` are never closed until +the process exits, regardless of the specified options. + +### readable.unpipe([destination]) + +* `destination` {Writable Stream} Optional + +Undo a previously established `pipe()`. If no destination is +provided, then all previously established pipes are removed. + +### readable.pause() + +Switches the readable stream into "old mode", where data is emitted +using a `'data'` event rather than being buffered for consumption via +the `read()` method. + +Ceases the flow of data. No `'data'` events are emitted while the +stream is in a paused state. + +### readable.resume() + +Switches the readable stream into "old mode", where data is emitted +using a `'data'` event rather than being buffered for consumption via +the `read()` method. + +Resumes the incoming `'data'` events after a `pause()`. + + +## Class: stream.Writable + + + +A `Writable` Stream has the following methods, members, and events. + +Note that `stream.Writable` is an abstract class designed to be +extended with an underlying implementation of the +`_write(chunk, encoding, cb)` method. (See below.) + +### new stream.Writable([options]) + +* `options` {Object} + * `highWaterMark` {Number} Buffer level when `write()` starts + returning false. Default=16kb + * `decodeStrings` {Boolean} Whether or not to decode strings into + Buffers before passing them to `_write()`. Default=true + +In classes that extend the Writable class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### writable.\_write(chunk, encoding, callback) + +* `chunk` {Buffer | String} The chunk to be written. Will always + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. Ignore chunk is a buffer. Note that chunk will + **always** be a buffer unless the `decodeStrings` option is + explicitly set to `false`. +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunk. + +All Writable stream implementations must provide a `_write` method to +send data to the underlying resource. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Writable +class methods only. + +Call the callback using the standard `callback(error)` pattern to +signal that the write completed successfully or with an error. + +If the `decodeStrings` flag is set in the constructor options, then +`chunk` may be a string rather than a Buffer, and `encoding` will +indicate the sort of string that it is. This is to support +implementations that have an optimized handling for certain string +data encodings. If you do not explicitly set the `decodeStrings` +option to `false`, then you can safely ignore the `encoding` argument, +and assume that `chunk` will always be a Buffer. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + + +### writable.write(chunk, [encoding], [callback]) + +* `chunk` {Buffer | String} Data to be written +* `encoding` {String} Optional. If `chunk` is a string, then encoding + defaults to `'utf8'` +* `callback` {Function} Optional. Called when this chunk is + successfully written. +* Returns {Boolean} + +Writes `chunk` to the stream. Returns `true` if the data has been +flushed to the underlying resource. Returns `false` to indicate that +the buffer is full, and the data will be sent out in the future. The +`'drain'` event will indicate when the buffer is empty again. + +The specifics of when `write()` will return false, is determined by +the `highWaterMark` option provided to the constructor. + +### writable.end([chunk], [encoding], [callback]) + +* `chunk` {Buffer | String} Optional final data to be written +* `encoding` {String} Optional. If `chunk` is a string, then encoding + defaults to `'utf8'` +* `callback` {Function} Optional. Called when the final chunk is + successfully written. + +Call this method to signal the end of the data being written to the +stream. + +### Event: 'drain' + +Emitted when the stream's write queue empties and it's safe to write +without buffering again. Listen for it when `stream.write()` returns +`false`. + +### Event: 'close' + +Emitted when the underlying resource (for example, the backing file +descriptor) has been closed. Not all streams will emit this. + +### Event: 'finish' + +When `end()` is called and there are no more chunks to write, this +event is emitted. + +### Event: 'pipe' + +* `source` {Readable Stream} + +Emitted when the stream is passed to a readable stream's pipe method. + +### Event 'unpipe' + +* `source` {Readable Stream} + +Emitted when a previously established `pipe()` is removed using the +source Readable stream's `unpipe()` method. + +## Class: stream.Duplex + + + +A "duplex" stream is one that is both Readable and Writable, such as a +TCP socket connection. + +Note that `stream.Duplex` is an abstract class designed to be +extended with an underlying implementation of the `_read(size)` +and `_write(chunk, encoding, callback)` methods as you would with a Readable or +Writable stream class. + +Since JavaScript doesn't have multiple prototypal inheritance, this +class prototypally inherits from Readable, and then parasitically from +Writable. It is thus up to the user to implement both the lowlevel +`_read(n)` method as well as the lowlevel `_write(chunk, encoding, cb)` method +on extension duplex classes. + +### new stream.Duplex(options) + +* `options` {Object} Passed to both Writable and Readable + constructors. Also has the following fields: + * `allowHalfOpen` {Boolean} Default=true. If set to `false`, then + the stream will automatically end the readable side when the + writable side ends and vice versa. + +In classes that extend the Duplex class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +## Class: stream.Transform + +A "transform" stream is a duplex stream where the output is causally +connected in some way to the input, such as a zlib stream or a crypto +stream. + +There is no requirement that the output be the same size as the input, +the same number of chunks, or arrive at the same time. For example, a +Hash stream will only ever have a single chunk of output which is +provided when the input is ended. A zlib stream will either produce +much smaller or much larger than its input. + +Rather than implement the `_read()` and `_write()` methods, Transform +classes must implement the `_transform()` method, and may optionally +also implement the `_flush()` method. (See below.) + +### new stream.Transform([options]) + +* `options` {Object} Passed to both Writable and Readable + constructors. + +In classes that extend the Transform class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### transform.\_transform(chunk, encoding, callback) + +* `chunk` {Buffer | String} The chunk to be transformed. Will always + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. (Ignore if `decodeStrings` chunk is a buffer.) +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunk. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Transform +class methods only. + +All Transform stream implementations must provide a `_transform` +method to accept input and produce output. + +`_transform` should do whatever has to be done in this specific +Transform class, to handle the bytes being written, and pass them off +to the readable portion of the interface. Do asynchronous I/O, +process things, and so on. + +Call `transform.push(outputChunk)` 0 or more times to generate output +from this input chunk, depending on how much data you want to output +as a result of this chunk. + +Call the callback function only when the current chunk is completely +consumed. Note that there may or may not be output as a result of any +particular input chunk. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +### transform.\_flush(callback) + +* `callback` {Function} Call this function (optionally with an error + argument) when you are done flushing any remaining data. + +Note: **This function MUST NOT be called directly.** It MAY be implemented +by child classes, and if so, will be called by the internal Transform +class methods only. + +In some cases, your transform operation may need to emit a bit more +data at the end of the stream. For example, a `Zlib` compression +stream will store up some internal state so that it can optimally +compress the output. At the end, however, it needs to do the best it +can with what is left, so that the data will be complete. + +In those cases, you can implement a `_flush` method, which will be +called at the very end, after all the written data is consumed, but +before emitting `end` to signal the end of the readable side. Just +like with `_transform`, call `transform.push(chunk)` zero or more +times, as appropriate, and call `callback` when the flush operation is +complete. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +### Example: `SimpleProtocol` parser + +The example above of a simple protocol parser can be implemented much +more simply by using the higher level `Transform` stream class. + +In this example, rather than providing the input as an argument, it +would be piped into the parser, which is a more idiomatic Node stream +approach. + +```javascript +function SimpleProtocol(options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(options); + + Transform.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype = Object.create( + Transform.prototype, { constructor: { value: SimpleProtocol }}); + +SimpleProtocol.prototype._transform = function(chunk, encoding, done) { + if (!this._inBody) { + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // and let them know that we are done parsing the header. + this.emit('header', this.header); + + // now, because we got some extra data, emit this first. + this.push(b); + } + } else { + // from there on, just provide the data to our consumer as-is. + this.push(b); + } + done(); +}; + +var parser = new SimpleProtocol(); +source.pipe(parser) + +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + + +## Class: stream.PassThrough + +This is a trivial implementation of a `Transform` stream that simply +passes the input bytes across to the output. Its purpose is mainly +for examples and testing, but there are occasionally use cases where +it can come in handy. + + +[EventEmitter]: events.html#events_class_events_eventemitter diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/duplex.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/duplex.js new file mode 100644 index 00000000..ca807af8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/duplex.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_duplex.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/float.patch b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/float.patch new file mode 100644 index 00000000..b984607a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/float.patch @@ -0,0 +1,923 @@ +diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js +index c5a741c..a2e0d8e 100644 +--- a/lib/_stream_duplex.js ++++ b/lib/_stream_duplex.js +@@ -26,8 +26,8 @@ + + module.exports = Duplex; + var util = require('util'); +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('./_stream_readable'); ++var Writable = require('./_stream_writable'); + + util.inherits(Duplex, Readable); + +diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js +index a5e9864..330c247 100644 +--- a/lib/_stream_passthrough.js ++++ b/lib/_stream_passthrough.js +@@ -25,7 +25,7 @@ + + module.exports = PassThrough; + +-var Transform = require('_stream_transform'); ++var Transform = require('./_stream_transform'); + var util = require('util'); + util.inherits(PassThrough, Transform); + +diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js +index 0c3fe3e..90a8298 100644 +--- a/lib/_stream_readable.js ++++ b/lib/_stream_readable.js +@@ -23,10 +23,34 @@ module.exports = Readable; + Readable.ReadableState = ReadableState; + + var EE = require('events').EventEmitter; ++if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { ++ return emitter.listeners(type).length; ++}; ++ ++if (!global.setImmediate) global.setImmediate = function setImmediate(fn) { ++ return setTimeout(fn, 0); ++}; ++if (!global.clearImmediate) global.clearImmediate = function clearImmediate(i) { ++ return clearTimeout(i); ++}; ++ + var Stream = require('stream'); + var util = require('util'); ++if (!util.isUndefined) { ++ var utilIs = require('core-util-is'); ++ for (var f in utilIs) { ++ util[f] = utilIs[f]; ++ } ++} + var StringDecoder; +-var debug = util.debuglog('stream'); ++var debug; ++if (util.debuglog) ++ debug = util.debuglog('stream'); ++else try { ++ debug = require('debuglog')('stream'); ++} catch (er) { ++ debug = function() {}; ++} + + util.inherits(Readable, Stream); + +@@ -380,7 +404,7 @@ function chunkInvalid(state, chunk) { + + + function onEofChunk(stream, state) { +- if (state.decoder && !state.ended) { ++ if (state.decoder && !state.ended && state.decoder.end) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); +diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js +index b1f9fcc..b0caf57 100644 +--- a/lib/_stream_transform.js ++++ b/lib/_stream_transform.js +@@ -64,8 +64,14 @@ + + module.exports = Transform; + +-var Duplex = require('_stream_duplex'); ++var Duplex = require('./_stream_duplex'); + var util = require('util'); ++if (!util.isUndefined) { ++ var utilIs = require('core-util-is'); ++ for (var f in utilIs) { ++ util[f] = utilIs[f]; ++ } ++} + util.inherits(Transform, Duplex); + + +diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js +index ba2e920..f49288b 100644 +--- a/lib/_stream_writable.js ++++ b/lib/_stream_writable.js +@@ -27,6 +27,12 @@ module.exports = Writable; + Writable.WritableState = WritableState; + + var util = require('util'); ++if (!util.isUndefined) { ++ var utilIs = require('core-util-is'); ++ for (var f in utilIs) { ++ util[f] = utilIs[f]; ++ } ++} + var Stream = require('stream'); + + util.inherits(Writable, Stream); +@@ -119,7 +125,7 @@ function WritableState(options, stream) { + function Writable(options) { + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. +- if (!(this instanceof Writable) && !(this instanceof Stream.Duplex)) ++ if (!(this instanceof Writable) && !(this instanceof require('./_stream_duplex'))) + return new Writable(options); + + this._writableState = new WritableState(options, this); +diff --git a/test/simple/test-stream-big-push.js b/test/simple/test-stream-big-push.js +index e3787e4..8cd2127 100644 +--- a/test/simple/test-stream-big-push.js ++++ b/test/simple/test-stream-big-push.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + var str = 'asdfasdfasdfasdfasdf'; + + var r = new stream.Readable({ +diff --git a/test/simple/test-stream-end-paused.js b/test/simple/test-stream-end-paused.js +index bb73777..d40efc7 100644 +--- a/test/simple/test-stream-end-paused.js ++++ b/test/simple/test-stream-end-paused.js +@@ -25,7 +25,7 @@ var gotEnd = false; + + // Make sure we don't miss the end event for paused 0-length streams + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var stream = new Readable(); + var calledRead = false; + stream._read = function() { +diff --git a/test/simple/test-stream-pipe-after-end.js b/test/simple/test-stream-pipe-after-end.js +index b46ee90..0be8366 100644 +--- a/test/simple/test-stream-pipe-after-end.js ++++ b/test/simple/test-stream-pipe-after-end.js +@@ -22,8 +22,8 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('../../lib/_stream_readable'); ++var Writable = require('../../lib/_stream_writable'); + var util = require('util'); + + util.inherits(TestReadable, Readable); +diff --git a/test/simple/test-stream-pipe-cleanup.js b/test/simple/test-stream-pipe-cleanup.js +deleted file mode 100644 +index f689358..0000000 +--- a/test/simple/test-stream-pipe-cleanup.js ++++ /dev/null +@@ -1,122 +0,0 @@ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// 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. +- +-// This test asserts that Stream.prototype.pipe does not leave listeners +-// hanging on the source or dest. +- +-var common = require('../common'); +-var stream = require('stream'); +-var assert = require('assert'); +-var util = require('util'); +- +-function Writable() { +- this.writable = true; +- this.endCalls = 0; +- stream.Stream.call(this); +-} +-util.inherits(Writable, stream.Stream); +-Writable.prototype.end = function() { +- this.endCalls++; +-}; +- +-Writable.prototype.destroy = function() { +- this.endCalls++; +-}; +- +-function Readable() { +- this.readable = true; +- stream.Stream.call(this); +-} +-util.inherits(Readable, stream.Stream); +- +-function Duplex() { +- this.readable = true; +- Writable.call(this); +-} +-util.inherits(Duplex, Writable); +- +-var i = 0; +-var limit = 100; +- +-var w = new Writable(); +- +-var r; +- +-for (i = 0; i < limit; i++) { +- r = new Readable(); +- r.pipe(w); +- r.emit('end'); +-} +-assert.equal(0, r.listeners('end').length); +-assert.equal(limit, w.endCalls); +- +-w.endCalls = 0; +- +-for (i = 0; i < limit; i++) { +- r = new Readable(); +- r.pipe(w); +- r.emit('close'); +-} +-assert.equal(0, r.listeners('close').length); +-assert.equal(limit, w.endCalls); +- +-w.endCalls = 0; +- +-r = new Readable(); +- +-for (i = 0; i < limit; i++) { +- w = new Writable(); +- r.pipe(w); +- w.emit('close'); +-} +-assert.equal(0, w.listeners('close').length); +- +-r = new Readable(); +-w = new Writable(); +-var d = new Duplex(); +-r.pipe(d); // pipeline A +-d.pipe(w); // pipeline B +-assert.equal(r.listeners('end').length, 2); // A.onend, A.cleanup +-assert.equal(r.listeners('close').length, 2); // A.onclose, A.cleanup +-assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup +-assert.equal(d.listeners('close').length, 3); // A.cleanup, B.onclose, B.cleanup +-assert.equal(w.listeners('end').length, 0); +-assert.equal(w.listeners('close').length, 1); // B.cleanup +- +-r.emit('end'); +-assert.equal(d.endCalls, 1); +-assert.equal(w.endCalls, 0); +-assert.equal(r.listeners('end').length, 0); +-assert.equal(r.listeners('close').length, 0); +-assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup +-assert.equal(d.listeners('close').length, 2); // B.onclose, B.cleanup +-assert.equal(w.listeners('end').length, 0); +-assert.equal(w.listeners('close').length, 1); // B.cleanup +- +-d.emit('end'); +-assert.equal(d.endCalls, 1); +-assert.equal(w.endCalls, 1); +-assert.equal(r.listeners('end').length, 0); +-assert.equal(r.listeners('close').length, 0); +-assert.equal(d.listeners('end').length, 0); +-assert.equal(d.listeners('close').length, 0); +-assert.equal(w.listeners('end').length, 0); +-assert.equal(w.listeners('close').length, 0); +diff --git a/test/simple/test-stream-pipe-error-handling.js b/test/simple/test-stream-pipe-error-handling.js +index c5d724b..c7d6b7d 100644 +--- a/test/simple/test-stream-pipe-error-handling.js ++++ b/test/simple/test-stream-pipe-error-handling.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var Stream = require('stream').Stream; ++var Stream = require('../../').Stream; + + (function testErrorListenerCatches() { + var source = new Stream(); +diff --git a/test/simple/test-stream-pipe-event.js b/test/simple/test-stream-pipe-event.js +index cb9d5fe..56f8d61 100644 +--- a/test/simple/test-stream-pipe-event.js ++++ b/test/simple/test-stream-pipe-event.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common'); +-var stream = require('stream'); ++var stream = require('../../'); + var assert = require('assert'); + var util = require('util'); + +diff --git a/test/simple/test-stream-push-order.js b/test/simple/test-stream-push-order.js +index f2e6ec2..a5c9bf9 100644 +--- a/test/simple/test-stream-push-order.js ++++ b/test/simple/test-stream-push-order.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var assert = require('assert'); + + var s = new Readable({ +diff --git a/test/simple/test-stream-push-strings.js b/test/simple/test-stream-push-strings.js +index 06f43dc..1701a9a 100644 +--- a/test/simple/test-stream-push-strings.js ++++ b/test/simple/test-stream-push-strings.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var util = require('util'); + + util.inherits(MyStream, Readable); +diff --git a/test/simple/test-stream-readable-event.js b/test/simple/test-stream-readable-event.js +index ba6a577..a8e6f7b 100644 +--- a/test/simple/test-stream-readable-event.js ++++ b/test/simple/test-stream-readable-event.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + (function first() { + // First test, not reading when the readable is added. +diff --git a/test/simple/test-stream-readable-flow-recursion.js b/test/simple/test-stream-readable-flow-recursion.js +index 2891ad6..11689ba 100644 +--- a/test/simple/test-stream-readable-flow-recursion.js ++++ b/test/simple/test-stream-readable-flow-recursion.js +@@ -27,7 +27,7 @@ var assert = require('assert'); + // more data continuously, but without triggering a nextTick + // warning or RangeError. + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + // throw an error if we trigger a nextTick warning. + process.throwDeprecation = true; +diff --git a/test/simple/test-stream-unshift-empty-chunk.js b/test/simple/test-stream-unshift-empty-chunk.js +index 0c96476..7827538 100644 +--- a/test/simple/test-stream-unshift-empty-chunk.js ++++ b/test/simple/test-stream-unshift-empty-chunk.js +@@ -24,7 +24,7 @@ var assert = require('assert'); + + // This test verifies that stream.unshift(Buffer(0)) or + // stream.unshift('') does not set state.reading=false. +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + var r = new Readable(); + var nChunks = 10; +diff --git a/test/simple/test-stream-unshift-read-race.js b/test/simple/test-stream-unshift-read-race.js +index 83fd9fa..17c18aa 100644 +--- a/test/simple/test-stream-unshift-read-race.js ++++ b/test/simple/test-stream-unshift-read-race.js +@@ -29,7 +29,7 @@ var assert = require('assert'); + // 3. push() after the EOF signaling null is an error. + // 4. _read() is not called after pushing the EOF null chunk. + +-var stream = require('stream'); ++var stream = require('../../'); + var hwm = 10; + var r = stream.Readable({ highWaterMark: hwm }); + var chunks = 10; +@@ -51,7 +51,14 @@ r._read = function(n) { + + function push(fast) { + assert(!pushedNull, 'push() after null push'); +- var c = pos >= data.length ? null : data.slice(pos, pos + n); ++ var c; ++ if (pos >= data.length) ++ c = null; ++ else { ++ if (n + pos > data.length) ++ n = data.length - pos; ++ c = data.slice(pos, pos + n); ++ } + pushedNull = c === null; + if (fast) { + pos += n; +diff --git a/test/simple/test-stream-writev.js b/test/simple/test-stream-writev.js +index 5b49e6e..b5321f3 100644 +--- a/test/simple/test-stream-writev.js ++++ b/test/simple/test-stream-writev.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var stream = require('stream'); ++var stream = require('../../'); + + var queue = []; + for (var decode = 0; decode < 2; decode++) { +diff --git a/test/simple/test-stream2-basic.js b/test/simple/test-stream2-basic.js +index 3814bf0..248c1be 100644 +--- a/test/simple/test-stream2-basic.js ++++ b/test/simple/test-stream2-basic.js +@@ -21,7 +21,7 @@ + + + var common = require('../common.js'); +-var R = require('_stream_readable'); ++var R = require('../../lib/_stream_readable'); + var assert = require('assert'); + + var util = require('util'); +diff --git a/test/simple/test-stream2-compatibility.js b/test/simple/test-stream2-compatibility.js +index 6cdd4e9..f0fa84b 100644 +--- a/test/simple/test-stream2-compatibility.js ++++ b/test/simple/test-stream2-compatibility.js +@@ -21,7 +21,7 @@ + + + var common = require('../common.js'); +-var R = require('_stream_readable'); ++var R = require('../../lib/_stream_readable'); + var assert = require('assert'); + + var util = require('util'); +diff --git a/test/simple/test-stream2-finish-pipe.js b/test/simple/test-stream2-finish-pipe.js +index 39b274f..006a19b 100644 +--- a/test/simple/test-stream2-finish-pipe.js ++++ b/test/simple/test-stream2-finish-pipe.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var stream = require('stream'); ++var stream = require('../../'); + var Buffer = require('buffer').Buffer; + + var r = new stream.Readable(); +diff --git a/test/simple/test-stream2-fs.js b/test/simple/test-stream2-fs.js +deleted file mode 100644 +index e162406..0000000 +--- a/test/simple/test-stream2-fs.js ++++ /dev/null +@@ -1,72 +0,0 @@ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// 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. +- +- +-var common = require('../common.js'); +-var R = require('_stream_readable'); +-var assert = require('assert'); +- +-var fs = require('fs'); +-var FSReadable = fs.ReadStream; +- +-var path = require('path'); +-var file = path.resolve(common.fixturesDir, 'x1024.txt'); +- +-var size = fs.statSync(file).size; +- +-var expectLengths = [1024]; +- +-var util = require('util'); +-var Stream = require('stream'); +- +-util.inherits(TestWriter, Stream); +- +-function TestWriter() { +- Stream.apply(this); +- this.buffer = []; +- this.length = 0; +-} +- +-TestWriter.prototype.write = function(c) { +- this.buffer.push(c.toString()); +- this.length += c.length; +- return true; +-}; +- +-TestWriter.prototype.end = function(c) { +- if (c) this.buffer.push(c.toString()); +- this.emit('results', this.buffer); +-} +- +-var r = new FSReadable(file); +-var w = new TestWriter(); +- +-w.on('results', function(res) { +- console.error(res, w.length); +- assert.equal(w.length, size); +- var l = 0; +- assert.deepEqual(res.map(function (c) { +- return c.length; +- }), expectLengths); +- console.log('ok'); +-}); +- +-r.pipe(w); +diff --git a/test/simple/test-stream2-httpclient-response-end.js b/test/simple/test-stream2-httpclient-response-end.js +deleted file mode 100644 +index 15cffc2..0000000 +--- a/test/simple/test-stream2-httpclient-response-end.js ++++ /dev/null +@@ -1,52 +0,0 @@ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// 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. +- +-var common = require('../common.js'); +-var assert = require('assert'); +-var http = require('http'); +-var msg = 'Hello'; +-var readable_event = false; +-var end_event = false; +-var server = http.createServer(function(req, res) { +- res.writeHead(200, {'Content-Type': 'text/plain'}); +- res.end(msg); +-}).listen(common.PORT, function() { +- http.get({port: common.PORT}, function(res) { +- var data = ''; +- res.on('readable', function() { +- console.log('readable event'); +- readable_event = true; +- data += res.read(); +- }); +- res.on('end', function() { +- console.log('end event'); +- end_event = true; +- assert.strictEqual(msg, data); +- server.close(); +- }); +- }); +-}); +- +-process.on('exit', function() { +- assert(readable_event); +- assert(end_event); +-}); +- +diff --git a/test/simple/test-stream2-large-read-stall.js b/test/simple/test-stream2-large-read-stall.js +index 2fbfbca..667985b 100644 +--- a/test/simple/test-stream2-large-read-stall.js ++++ b/test/simple/test-stream2-large-read-stall.js +@@ -30,7 +30,7 @@ var PUSHSIZE = 20; + var PUSHCOUNT = 1000; + var HWM = 50; + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var r = new Readable({ + highWaterMark: HWM + }); +@@ -39,23 +39,23 @@ var rs = r._readableState; + r._read = push; + + r.on('readable', function() { +- console.error('>> readable'); ++ //console.error('>> readable'); + do { +- console.error(' > read(%d)', READSIZE); ++ //console.error(' > read(%d)', READSIZE); + var ret = r.read(READSIZE); +- console.error(' < %j (%d remain)', ret && ret.length, rs.length); ++ //console.error(' < %j (%d remain)', ret && ret.length, rs.length); + } while (ret && ret.length === READSIZE); + +- console.error('<< after read()', +- ret && ret.length, +- rs.needReadable, +- rs.length); ++ //console.error('<< after read()', ++ // ret && ret.length, ++ // rs.needReadable, ++ // rs.length); + }); + + var endEmitted = false; + r.on('end', function() { + endEmitted = true; +- console.error('end'); ++ //console.error('end'); + }); + + var pushes = 0; +@@ -64,11 +64,11 @@ function push() { + return; + + if (pushes++ === PUSHCOUNT) { +- console.error(' push(EOF)'); ++ //console.error(' push(EOF)'); + return r.push(null); + } + +- console.error(' push #%d', pushes); ++ //console.error(' push #%d', pushes); + if (r.push(new Buffer(PUSHSIZE))) + setTimeout(push); + } +diff --git a/test/simple/test-stream2-objects.js b/test/simple/test-stream2-objects.js +index 3e6931d..ff47d89 100644 +--- a/test/simple/test-stream2-objects.js ++++ b/test/simple/test-stream2-objects.js +@@ -21,8 +21,8 @@ + + + var common = require('../common.js'); +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('../../lib/_stream_readable'); ++var Writable = require('../../lib/_stream_writable'); + var assert = require('assert'); + + // tiny node-tap lookalike. +diff --git a/test/simple/test-stream2-pipe-error-handling.js b/test/simple/test-stream2-pipe-error-handling.js +index cf7531c..e3f3e4e 100644 +--- a/test/simple/test-stream2-pipe-error-handling.js ++++ b/test/simple/test-stream2-pipe-error-handling.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + + (function testErrorListenerCatches() { + var count = 1000; +diff --git a/test/simple/test-stream2-pipe-error-once-listener.js b/test/simple/test-stream2-pipe-error-once-listener.js +index 5e8e3cb..53b2616 100755 +--- a/test/simple/test-stream2-pipe-error-once-listener.js ++++ b/test/simple/test-stream2-pipe-error-once-listener.js +@@ -24,7 +24,7 @@ var common = require('../common.js'); + var assert = require('assert'); + + var util = require('util'); +-var stream = require('stream'); ++var stream = require('../../'); + + + var Read = function() { +diff --git a/test/simple/test-stream2-push.js b/test/simple/test-stream2-push.js +index b63edc3..eb2b0e9 100644 +--- a/test/simple/test-stream2-push.js ++++ b/test/simple/test-stream2-push.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var stream = require('stream'); ++var stream = require('../../'); + var Readable = stream.Readable; + var Writable = stream.Writable; + var assert = require('assert'); +diff --git a/test/simple/test-stream2-read-sync-stack.js b/test/simple/test-stream2-read-sync-stack.js +index e8a7305..9740a47 100644 +--- a/test/simple/test-stream2-read-sync-stack.js ++++ b/test/simple/test-stream2-read-sync-stack.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var r = new Readable(); + var N = 256 * 1024; + +diff --git a/test/simple/test-stream2-readable-empty-buffer-no-eof.js b/test/simple/test-stream2-readable-empty-buffer-no-eof.js +index cd30178..4b1659d 100644 +--- a/test/simple/test-stream2-readable-empty-buffer-no-eof.js ++++ b/test/simple/test-stream2-readable-empty-buffer-no-eof.js +@@ -22,10 +22,9 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + test1(); +-test2(); + + function test1() { + var r = new Readable(); +@@ -88,31 +87,3 @@ function test1() { + console.log('ok'); + }); + } +- +-function test2() { +- var r = new Readable({ encoding: 'base64' }); +- var reads = 5; +- r._read = function(n) { +- if (!reads--) +- return r.push(null); // EOF +- else +- return r.push(new Buffer('x')); +- }; +- +- var results = []; +- function flow() { +- var chunk; +- while (null !== (chunk = r.read())) +- results.push(chunk + ''); +- } +- r.on('readable', flow); +- r.on('end', function() { +- results.push('EOF'); +- }); +- flow(); +- +- process.on('exit', function() { +- assert.deepEqual(results, [ 'eHh4', 'eHg=', 'EOF' ]); +- console.log('ok'); +- }); +-} +diff --git a/test/simple/test-stream2-readable-from-list.js b/test/simple/test-stream2-readable-from-list.js +index 7c96ffe..04a96f5 100644 +--- a/test/simple/test-stream2-readable-from-list.js ++++ b/test/simple/test-stream2-readable-from-list.js +@@ -21,7 +21,7 @@ + + var assert = require('assert'); + var common = require('../common.js'); +-var fromList = require('_stream_readable')._fromList; ++var fromList = require('../../lib/_stream_readable')._fromList; + + // tiny node-tap lookalike. + var tests = []; +diff --git a/test/simple/test-stream2-readable-legacy-drain.js b/test/simple/test-stream2-readable-legacy-drain.js +index 675da8e..51fd3d5 100644 +--- a/test/simple/test-stream2-readable-legacy-drain.js ++++ b/test/simple/test-stream2-readable-legacy-drain.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Stream = require('stream'); ++var Stream = require('../../'); + var Readable = Stream.Readable; + + var r = new Readable(); +diff --git a/test/simple/test-stream2-readable-non-empty-end.js b/test/simple/test-stream2-readable-non-empty-end.js +index 7314ae7..c971898 100644 +--- a/test/simple/test-stream2-readable-non-empty-end.js ++++ b/test/simple/test-stream2-readable-non-empty-end.js +@@ -21,7 +21,7 @@ + + var assert = require('assert'); + var common = require('../common.js'); +-var Readable = require('_stream_readable'); ++var Readable = require('../../lib/_stream_readable'); + + var len = 0; + var chunks = new Array(10); +diff --git a/test/simple/test-stream2-readable-wrap-empty.js b/test/simple/test-stream2-readable-wrap-empty.js +index 2e5cf25..fd8a3dc 100644 +--- a/test/simple/test-stream2-readable-wrap-empty.js ++++ b/test/simple/test-stream2-readable-wrap-empty.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('_stream_readable'); ++var Readable = require('../../lib/_stream_readable'); + var EE = require('events').EventEmitter; + + var oldStream = new EE(); +diff --git a/test/simple/test-stream2-readable-wrap.js b/test/simple/test-stream2-readable-wrap.js +index 90eea01..6b177f7 100644 +--- a/test/simple/test-stream2-readable-wrap.js ++++ b/test/simple/test-stream2-readable-wrap.js +@@ -22,8 +22,8 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('../../lib/_stream_readable'); ++var Writable = require('../../lib/_stream_writable'); + var EE = require('events').EventEmitter; + + var testRuns = 0, completedRuns = 0; +diff --git a/test/simple/test-stream2-set-encoding.js b/test/simple/test-stream2-set-encoding.js +index 5d2c32a..685531b 100644 +--- a/test/simple/test-stream2-set-encoding.js ++++ b/test/simple/test-stream2-set-encoding.js +@@ -22,7 +22,7 @@ + + var common = require('../common.js'); + var assert = require('assert'); +-var R = require('_stream_readable'); ++var R = require('../../lib/_stream_readable'); + var util = require('util'); + + // tiny node-tap lookalike. +diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js +index 9c9ddd8..a0cacc6 100644 +--- a/test/simple/test-stream2-transform.js ++++ b/test/simple/test-stream2-transform.js +@@ -21,8 +21,8 @@ + + var assert = require('assert'); + var common = require('../common.js'); +-var PassThrough = require('_stream_passthrough'); +-var Transform = require('_stream_transform'); ++var PassThrough = require('../../').PassThrough; ++var Transform = require('../../').Transform; + + // tiny node-tap lookalike. + var tests = []; +diff --git a/test/simple/test-stream2-unpipe-drain.js b/test/simple/test-stream2-unpipe-drain.js +index d66dc3c..365b327 100644 +--- a/test/simple/test-stream2-unpipe-drain.js ++++ b/test/simple/test-stream2-unpipe-drain.js +@@ -22,7 +22,7 @@ + + var common = require('../common.js'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + var crypto = require('crypto'); + + var util = require('util'); +diff --git a/test/simple/test-stream2-unpipe-leak.js b/test/simple/test-stream2-unpipe-leak.js +index 99f8746..17c92ae 100644 +--- a/test/simple/test-stream2-unpipe-leak.js ++++ b/test/simple/test-stream2-unpipe-leak.js +@@ -22,7 +22,7 @@ + + var common = require('../common.js'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + + var chunk = new Buffer('hallo'); + +diff --git a/test/simple/test-stream2-writable.js b/test/simple/test-stream2-writable.js +index 704100c..209c3a6 100644 +--- a/test/simple/test-stream2-writable.js ++++ b/test/simple/test-stream2-writable.js +@@ -20,8 +20,8 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var W = require('_stream_writable'); +-var D = require('_stream_duplex'); ++var W = require('../../').Writable; ++var D = require('../../').Duplex; + var assert = require('assert'); + + var util = require('util'); +diff --git a/test/simple/test-stream3-pause-then-read.js b/test/simple/test-stream3-pause-then-read.js +index b91bde3..2f72c15 100644 +--- a/test/simple/test-stream3-pause-then-read.js ++++ b/test/simple/test-stream3-pause-then-read.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var stream = require('stream'); ++var stream = require('../../'); + var Readable = stream.Readable; + var Writable = stream.Writable; + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_duplex.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_duplex.js new file mode 100644 index 00000000..a2e0d8e0 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_duplex.js @@ -0,0 +1,69 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +module.exports = Duplex; +var util = require('util'); +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +Object.keys(Writable.prototype).forEach(function(method) { + if (!Duplex.prototype[method]) + Duplex.prototype[method] = Writable.prototype[method]; +}); + +function Duplex(options) { + if (!(this instanceof Duplex)) + return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) + this.readable = false; + + if (options && options.writable === false) + this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) + this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) + return; + + // no more data can be written. + // But allow more writes to happen in this tick. + process.nextTick(this.end.bind(this)); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_passthrough.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_passthrough.js new file mode 100644 index 00000000..330c247d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_passthrough.js @@ -0,0 +1,41 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); +var util = require('util'); +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) + return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function(chunk, encoding, cb) { + cb(null, chunk); +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_readable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_readable.js new file mode 100644 index 00000000..f50ea0f2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_readable.js @@ -0,0 +1,924 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +module.exports = Readable; +Readable.ReadableState = ReadableState; + +var EE = require('events').EventEmitter; +if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { + return emitter.listeners(type).length; +}; + +if (!global.setImmediate) global.setImmediate = function setImmediate(fn) { + return setTimeout(fn, 0); +}; +if (!global.clearImmediate) global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); +}; + +var Stream = require('stream'); +var util = require('util'); +if (!util.isUndefined) { + var utilIs = require('core-util-is'); + for (var f in utilIs) { + util[f] = utilIs[f]; + } +} +var StringDecoder; +var debug; +if (util.debuglog) + debug = util.debuglog('stream'); +else try { + debug = require('debuglog')('stream'); +} catch (er) { + debug = function() {}; +} + +util.inherits(Readable, Stream); + +function ReadableState(options, stream) { + options = options || {}; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = options.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + if (!(this instanceof Readable)) + return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function(chunk, encoding) { + var state = this._readableState; + + if (util.isString(chunk) && !state.objectMode) { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function(chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (util.isNullOrUndefined(chunk)) { + state.reading = false; + if (!state.ended) + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + if (state.decoder && !addToFront && !encoding) + chunk = state.decoder.write(chunk); + + if (!addToFront) + state.reading = false; + + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) + state.buffer.unshift(chunk); + else + state.buffer.push(chunk); + + if (state.needReadable) + emitReadable(stream); + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + + + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && + (state.needReadable || + state.length < state.highWaterMark || + state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function(enc) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 128MB +var MAX_HWM = 0x800000; +function roundUpToNextPowerOf2(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + for (var p = 1; p < 32; p <<= 1) n |= n >> p; + n++; + } + return n; +} + +function howMuchToRead(n, state) { + if (state.length === 0 && state.ended) + return 0; + + if (state.objectMode) + return n === 0 ? 0 : 1; + + if (isNaN(n) || util.isNull(n)) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) + return state.buffer[0].length; + else + return state.length; + } + + if (n <= 0) + return 0; + + // If we're asking for more than the target buffer level, + // then raise the water mark. Bump up to the next highest + // power of 2, to prevent increasing it excessively in tiny + // amounts. + if (n > state.highWaterMark) + state.highWaterMark = roundUpToNextPowerOf2(n); + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else + return state.length; + } + + return n; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function(n) { + debug('read', n); + var state = this._readableState; + var nOrig = n; + + if (!util.isNumber(n) || n > 0) + state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && + state.needReadable && + (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) + endReadable(this); + else + emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) + endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } + + if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) + state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + } + + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (doRead && !state.reading) + n = howMuchToRead(nOrig, state); + + var ret; + if (n > 0) + ret = fromList(n, state); + else + ret = null; + + if (util.isNull(ret)) { + state.needReadable = true; + n = 0; + } + + state.length -= n; + + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (state.length === 0 && !state.ended) + state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended && state.length === 0) + endReadable(this); + + if (!util.isNull(ret)) + this.emit('data', ret); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!util.isBuffer(chunk) && + !util.isString(chunk) && + !util.isNullOrUndefined(chunk) && + !state.objectMode && + !er) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + + +function onEofChunk(stream, state) { + if (state.decoder && !state.ended && state.decoder.end) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) + process.nextTick(function() { + emitReadable_(stream); + }); + else + emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(function() { + maybeReadMore_(stream, state); + }); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && + state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break; + else + len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function(n) { + this.emit('error', new Error('not implemented')); +}; + +Readable.prototype.pipe = function(dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && + dest !== process.stdout && + dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) + process.nextTick(endFn); + else + src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + debug('onunpipe'); + if (readable === src) { + cleanup(); + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + src.removeListener('data', ondata); + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && + (!dest._writableState || dest._writableState.needDrain)) + ondrain(); + } + + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + if (false === ret) { + debug('false write response, pause', + src._readableState.awaitDrain); + src._readableState.awaitDrain++; + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EE.listenerCount(dest, 'error') === 0) + dest.emit('error', er); + } + // This is a brutally ugly hack to make sure that our error handler + // is attached before any userland ones. NEVER DO THIS. + if (!dest._events || !dest._events.error) + dest.on('error', onerror); + else if (Array.isArray(dest._events.error)) + dest._events.error.unshift(onerror); + else + dest._events.error = [onerror, dest._events.error]; + + + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) + state.awaitDrain--; + if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + + +Readable.prototype.unpipe = function(dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) + return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) + return this; + + if (!dest) + dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) + dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) + dests[i].emit('unpipe', this); + return this; + } + + // try to find the right one. + var i = state.pipes.indexOf(dest); + if (i === -1) + return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) + state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function(ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + // If listening to data, and it has not explicitly been paused, + // then call resume to start the flow of data on the next tick. + if (ev === 'data' && false !== this._readableState.flowing) { + this.resume(); + } + + if (ev === 'readable' && this.readable) { + var state = this._readableState; + if (!state.readableListening) { + state.readableListening = true; + state.emittedReadable = false; + state.needReadable = true; + if (!state.reading) { + var self = this; + process.nextTick(function() { + debug('readable nexttick read 0'); + self.read(0); + }); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function() { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + if (!state.reading) { + debug('resume read 0'); + this.read(0); + } + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process.nextTick(function() { + resume_(stream, state); + }); + } +} + +function resume_(stream, state) { + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) + stream.read(0); +} + +Readable.prototype.pause = function() { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + if (state.flowing) { + do { + var chunk = stream.read(); + } while (null !== chunk && state.flowing); + } +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function(stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function() { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) + self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function(chunk) { + debug('wrapped data'); + if (state.decoder) + chunk = state.decoder.write(chunk); + if (!chunk || !state.objectMode && !chunk.length) + return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (util.isFunction(stream[i]) && util.isUndefined(this[i])) { + this[i] = function(method) { return function() { + return stream[method].apply(stream, arguments); + }}(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + events.forEach(function(ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function(n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + + + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +function fromList(n, state) { + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; + var ret; + + // nothing in the list, definitely empty. + if (list.length === 0) + return null; + + if (length === 0) + ret = null; + else if (objectMode) + ret = list.shift(); + else if (!n || n >= length) { + // read it all, truncate the array. + if (stringMode) + ret = list.join(''); + else + ret = Buffer.concat(list, length); + list.length = 0; + } else { + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) + ret = ''; + else + ret = new Buffer(n); + + var c = 0; + for (var i = 0, l = list.length; i < l && c < n; i++) { + var buf = list[0]; + var cpy = Math.min(n - c, buf.length); + + if (stringMode) + ret += buf.slice(0, cpy); + else + buf.copy(ret, c, 0, cpy); + + if (cpy < buf.length) + list[0] = buf.slice(cpy); + else + list.shift(); + + c += cpy; + } + } + } + + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) + throw new Error('endReadable called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + process.nextTick(function() { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } + }); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_transform.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_transform.js new file mode 100644 index 00000000..b0caf57d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_transform.js @@ -0,0 +1,210 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); +var util = require('util'); +if (!util.isUndefined) { + var utilIs = require('core-util-is'); + for (var f in utilIs) { + util[f] = utilIs[f]; + } +} +util.inherits(Transform, Duplex); + + +function TransformState(options, stream) { + this.afterTransform = function(er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) + return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (!util.isNullOrUndefined(data)) + stream.push(data); + + if (cb) + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + + +function Transform(options) { + if (!(this instanceof Transform)) + return new Transform(options); + + Duplex.call(this, options); + + this._transformState = new TransformState(options, this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + this.once('prefinish', function() { + if (util.isFunction(this._flush)) + this._flush(function(er) { + done(stream, er); + }); + else + done(stream); + }); +} + +Transform.prototype.push = function(chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function(chunk, encoding, cb) { + throw new Error('not implemented'); +}; + +Transform.prototype._write = function(chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || + rs.needReadable || + rs.length < rs.highWaterMark) + this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function(n) { + var ts = this._transformState; + + if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + + +function done(stream, er) { + if (er) + return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var ts = stream._transformState; + + if (ws.length) + throw new Error('calling transform done when ws.length != 0'); + + if (ts.transforming) + throw new Error('calling transform done when still transforming'); + + return stream.push(null); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_writable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_writable.js new file mode 100644 index 00000000..1dfca70d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/lib/_stream_writable.js @@ -0,0 +1,460 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, cb), and it'll handle all +// the drain event emission and buffering. + +module.exports = Writable; +Writable.WritableState = WritableState; + +var util = require('util'); +if (!util.isUndefined) { + var utilIs = require('core-util-is'); + for (var f in utilIs) { + util[f] = utilIs[f]; + } +} +var Stream = require('stream'); + +util.inherits(Writable, Stream); + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; +} + +function WritableState(options, stream) { + options = options || {}; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = options.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function(er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.buffer = []; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; +} + +function Writable(options) { + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof require('./_stream_duplex'))) + return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function() { + this.emit('error', new Error('Cannot pipe. Not readable.')); +}; + + +function writeAfterEnd(stream, state, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); +} + +// If we get something that is not a buffer, string, null, or undefined, +// and we're not in objectMode, then that's an error. +// Otherwise stream chunks are all considered to be of length=1, and the +// watermarks determine how many objects to keep in the buffer, rather than +// how many bytes or characters. +function validChunk(stream, state, chunk, cb) { + var valid = true; + if (!util.isBuffer(chunk) && + !util.isString(chunk) && + !util.isNullOrUndefined(chunk) && + !state.objectMode) { + var er = new TypeError('Invalid non-string/buffer chunk'); + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); + valid = false; + } + return valid; +} + +Writable.prototype.write = function(chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (util.isFunction(encoding)) { + cb = encoding; + encoding = null; + } + + if (util.isBuffer(chunk)) + encoding = 'buffer'; + else if (!encoding) + encoding = state.defaultEncoding; + + if (!util.isFunction(cb)) + cb = function() {}; + + if (state.ended) + writeAfterEnd(this, state, cb); + else if (validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function() { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function() { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && + !state.corked && + !state.finished && + !state.bufferProcessing && + state.buffer.length) + clearBuffer(this, state); + } +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && + state.decodeStrings !== false && + util.isString(chunk)) { + chunk = new Buffer(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + if (util.isBuffer(chunk)) + encoding = 'buffer'; + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + state.needDrain = !ret; + + if (state.writing || state.corked) + state.buffer.push(new WriteReq(chunk, encoding, cb)); + else + doWrite(stream, state, false, len, chunk, encoding, cb); + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) + stream._writev(chunk, state.onwrite); + else + stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + if (sync) + process.nextTick(function() { + state.pendingcb--; + cb(er); + }); + else { + state.pendingcb--; + cb(er); + } + + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) + onwriteError(stream, state, sync, er, cb); + else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(stream, state); + + if (!finished && + !state.corked && + !state.bufferProcessing && + state.buffer.length) { + clearBuffer(stream, state); + } + + if (sync) { + process.nextTick(function() { + afterWrite(stream, state, finished, cb); + }); + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) + onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + + if (stream._writev && state.buffer.length > 1) { + // Fast case, write everything using _writev() + var cbs = []; + for (var c = 0; c < state.buffer.length; c++) + cbs.push(state.buffer[c].callback); + + // count the one we are adding, as well. + // TODO(isaacs) clean this up + state.pendingcb++; + doWrite(stream, state, true, state.length, state.buffer, '', function(err) { + for (var i = 0; i < cbs.length; i++) { + state.pendingcb--; + cbs[i](err); + } + }); + + // Clear buffer + state.buffer = []; + } else { + // Slow case, write chunks one-by-one + for (var c = 0; c < state.buffer.length; c++) { + var entry = state.buffer[c]; + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + c++; + break; + } + } + + if (c < state.buffer.length) + state.buffer = state.buffer.slice(c); + else + state.buffer.length = 0; + } + + state.bufferProcessing = false; +} + +Writable.prototype._write = function(chunk, encoding, cb) { + cb(new Error('not implemented')); + +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function(chunk, encoding, cb) { + var state = this._writableState; + + if (util.isFunction(chunk)) { + cb = chunk; + chunk = null; + encoding = null; + } else if (util.isFunction(encoding)) { + cb = encoding; + encoding = null; + } + + if (!util.isNullOrUndefined(chunk)) + this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) + endWritable(this, state, cb); +}; + + +function needFinish(stream, state) { + return (state.ending && + state.length === 0 && + !state.finished && + !state.writing); +} + +function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } +} + +function finishMaybe(stream, state) { + var need = needFinish(stream, state); + if (need) { + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else + prefinish(stream, state); + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) + process.nextTick(cb); + else + stream.once('finish', cb); + } + state.ended = true; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/README.md new file mode 100644 index 00000000..5a76b414 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/README.md @@ -0,0 +1,3 @@ +# core-util-is + +The `util.is*` functions introduced in Node v0.12. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/float.patch b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/float.patch new file mode 100644 index 00000000..a06d5c05 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/float.patch @@ -0,0 +1,604 @@ +diff --git a/lib/util.js b/lib/util.js +index a03e874..9074e8e 100644 +--- a/lib/util.js ++++ b/lib/util.js +@@ -19,430 +19,6 @@ + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + +-var formatRegExp = /%[sdj%]/g; +-exports.format = function(f) { +- if (!isString(f)) { +- var objects = []; +- for (var i = 0; i < arguments.length; i++) { +- objects.push(inspect(arguments[i])); +- } +- return objects.join(' '); +- } +- +- var i = 1; +- var args = arguments; +- var len = args.length; +- var str = String(f).replace(formatRegExp, function(x) { +- if (x === '%%') return '%'; +- if (i >= len) return x; +- switch (x) { +- case '%s': return String(args[i++]); +- case '%d': return Number(args[i++]); +- case '%j': +- try { +- return JSON.stringify(args[i++]); +- } catch (_) { +- return '[Circular]'; +- } +- default: +- return x; +- } +- }); +- for (var x = args[i]; i < len; x = args[++i]) { +- if (isNull(x) || !isObject(x)) { +- str += ' ' + x; +- } else { +- str += ' ' + inspect(x); +- } +- } +- return str; +-}; +- +- +-// Mark that a method should not be used. +-// Returns a modified function which warns once by default. +-// If --no-deprecation is set, then it is a no-op. +-exports.deprecate = function(fn, msg) { +- // Allow for deprecating things in the process of starting up. +- if (isUndefined(global.process)) { +- return function() { +- return exports.deprecate(fn, msg).apply(this, arguments); +- }; +- } +- +- if (process.noDeprecation === true) { +- return fn; +- } +- +- var warned = false; +- function deprecated() { +- if (!warned) { +- if (process.throwDeprecation) { +- throw new Error(msg); +- } else if (process.traceDeprecation) { +- console.trace(msg); +- } else { +- console.error(msg); +- } +- warned = true; +- } +- return fn.apply(this, arguments); +- } +- +- return deprecated; +-}; +- +- +-var debugs = {}; +-var debugEnviron; +-exports.debuglog = function(set) { +- if (isUndefined(debugEnviron)) +- debugEnviron = process.env.NODE_DEBUG || ''; +- set = set.toUpperCase(); +- if (!debugs[set]) { +- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { +- var pid = process.pid; +- debugs[set] = function() { +- var msg = exports.format.apply(exports, arguments); +- console.error('%s %d: %s', set, pid, msg); +- }; +- } else { +- debugs[set] = function() {}; +- } +- } +- return debugs[set]; +-}; +- +- +-/** +- * Echos the value of a value. Trys to print the value out +- * in the best way possible given the different types. +- * +- * @param {Object} obj The object to print out. +- * @param {Object} opts Optional options object that alters the output. +- */ +-/* legacy: obj, showHidden, depth, colors*/ +-function inspect(obj, opts) { +- // default options +- var ctx = { +- seen: [], +- stylize: stylizeNoColor +- }; +- // legacy... +- if (arguments.length >= 3) ctx.depth = arguments[2]; +- if (arguments.length >= 4) ctx.colors = arguments[3]; +- if (isBoolean(opts)) { +- // legacy... +- ctx.showHidden = opts; +- } else if (opts) { +- // got an "options" object +- exports._extend(ctx, opts); +- } +- // set default options +- if (isUndefined(ctx.showHidden)) ctx.showHidden = false; +- if (isUndefined(ctx.depth)) ctx.depth = 2; +- if (isUndefined(ctx.colors)) ctx.colors = false; +- if (isUndefined(ctx.customInspect)) ctx.customInspect = true; +- if (ctx.colors) ctx.stylize = stylizeWithColor; +- return formatValue(ctx, obj, ctx.depth); +-} +-exports.inspect = inspect; +- +- +-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +-inspect.colors = { +- 'bold' : [1, 22], +- 'italic' : [3, 23], +- 'underline' : [4, 24], +- 'inverse' : [7, 27], +- 'white' : [37, 39], +- 'grey' : [90, 39], +- 'black' : [30, 39], +- 'blue' : [34, 39], +- 'cyan' : [36, 39], +- 'green' : [32, 39], +- 'magenta' : [35, 39], +- 'red' : [31, 39], +- 'yellow' : [33, 39] +-}; +- +-// Don't use 'blue' not visible on cmd.exe +-inspect.styles = { +- 'special': 'cyan', +- 'number': 'yellow', +- 'boolean': 'yellow', +- 'undefined': 'grey', +- 'null': 'bold', +- 'string': 'green', +- 'date': 'magenta', +- // "name": intentionally not styling +- 'regexp': 'red' +-}; +- +- +-function stylizeWithColor(str, styleType) { +- var style = inspect.styles[styleType]; +- +- if (style) { +- return '\u001b[' + inspect.colors[style][0] + 'm' + str + +- '\u001b[' + inspect.colors[style][1] + 'm'; +- } else { +- return str; +- } +-} +- +- +-function stylizeNoColor(str, styleType) { +- return str; +-} +- +- +-function arrayToHash(array) { +- var hash = {}; +- +- array.forEach(function(val, idx) { +- hash[val] = true; +- }); +- +- return hash; +-} +- +- +-function formatValue(ctx, value, recurseTimes) { +- // Provide a hook for user-specified inspect functions. +- // Check that value is an object with an inspect function on it +- if (ctx.customInspect && +- value && +- isFunction(value.inspect) && +- // Filter out the util module, it's inspect function is special +- value.inspect !== exports.inspect && +- // Also filter out any prototype objects using the circular check. +- !(value.constructor && value.constructor.prototype === value)) { +- var ret = value.inspect(recurseTimes, ctx); +- if (!isString(ret)) { +- ret = formatValue(ctx, ret, recurseTimes); +- } +- return ret; +- } +- +- // Primitive types cannot have properties +- var primitive = formatPrimitive(ctx, value); +- if (primitive) { +- return primitive; +- } +- +- // Look up the keys of the object. +- var keys = Object.keys(value); +- var visibleKeys = arrayToHash(keys); +- +- if (ctx.showHidden) { +- keys = Object.getOwnPropertyNames(value); +- } +- +- // Some type of object without properties can be shortcutted. +- if (keys.length === 0) { +- if (isFunction(value)) { +- var name = value.name ? ': ' + value.name : ''; +- return ctx.stylize('[Function' + name + ']', 'special'); +- } +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } +- if (isDate(value)) { +- return ctx.stylize(Date.prototype.toString.call(value), 'date'); +- } +- if (isError(value)) { +- return formatError(value); +- } +- } +- +- var base = '', array = false, braces = ['{', '}']; +- +- // Make Array say that they are Array +- if (isArray(value)) { +- array = true; +- braces = ['[', ']']; +- } +- +- // Make functions say that they are functions +- if (isFunction(value)) { +- var n = value.name ? ': ' + value.name : ''; +- base = ' [Function' + n + ']'; +- } +- +- // Make RegExps say that they are RegExps +- if (isRegExp(value)) { +- base = ' ' + RegExp.prototype.toString.call(value); +- } +- +- // Make dates with properties first say the date +- if (isDate(value)) { +- base = ' ' + Date.prototype.toUTCString.call(value); +- } +- +- // Make error with message first say the error +- if (isError(value)) { +- base = ' ' + formatError(value); +- } +- +- if (keys.length === 0 && (!array || value.length == 0)) { +- return braces[0] + base + braces[1]; +- } +- +- if (recurseTimes < 0) { +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } else { +- return ctx.stylize('[Object]', 'special'); +- } +- } +- +- ctx.seen.push(value); +- +- var output; +- if (array) { +- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); +- } else { +- output = keys.map(function(key) { +- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); +- }); +- } +- +- ctx.seen.pop(); +- +- return reduceToSingleString(output, base, braces); +-} +- +- +-function formatPrimitive(ctx, value) { +- if (isUndefined(value)) +- return ctx.stylize('undefined', 'undefined'); +- if (isString(value)) { +- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') +- .replace(/'/g, "\\'") +- .replace(/\\"/g, '"') + '\''; +- return ctx.stylize(simple, 'string'); +- } +- if (isNumber(value)) { +- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0, +- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 . +- if (value === 0 && 1 / value < 0) +- return ctx.stylize('-0', 'number'); +- return ctx.stylize('' + value, 'number'); +- } +- if (isBoolean(value)) +- return ctx.stylize('' + value, 'boolean'); +- // For some reason typeof null is "object", so special case here. +- if (isNull(value)) +- return ctx.stylize('null', 'null'); +-} +- +- +-function formatError(value) { +- return '[' + Error.prototype.toString.call(value) + ']'; +-} +- +- +-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { +- var output = []; +- for (var i = 0, l = value.length; i < l; ++i) { +- if (hasOwnProperty(value, String(i))) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- String(i), true)); +- } else { +- output.push(''); +- } +- } +- keys.forEach(function(key) { +- if (!key.match(/^\d+$/)) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- key, true)); +- } +- }); +- return output; +-} +- +- +-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { +- var name, str, desc; +- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; +- if (desc.get) { +- if (desc.set) { +- str = ctx.stylize('[Getter/Setter]', 'special'); +- } else { +- str = ctx.stylize('[Getter]', 'special'); +- } +- } else { +- if (desc.set) { +- str = ctx.stylize('[Setter]', 'special'); +- } +- } +- if (!hasOwnProperty(visibleKeys, key)) { +- name = '[' + key + ']'; +- } +- if (!str) { +- if (ctx.seen.indexOf(desc.value) < 0) { +- if (isNull(recurseTimes)) { +- str = formatValue(ctx, desc.value, null); +- } else { +- str = formatValue(ctx, desc.value, recurseTimes - 1); +- } +- if (str.indexOf('\n') > -1) { +- if (array) { +- str = str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n').substr(2); +- } else { +- str = '\n' + str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n'); +- } +- } +- } else { +- str = ctx.stylize('[Circular]', 'special'); +- } +- } +- if (isUndefined(name)) { +- if (array && key.match(/^\d+$/)) { +- return str; +- } +- name = JSON.stringify('' + key); +- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { +- name = name.substr(1, name.length - 2); +- name = ctx.stylize(name, 'name'); +- } else { +- name = name.replace(/'/g, "\\'") +- .replace(/\\"/g, '"') +- .replace(/(^"|"$)/g, "'"); +- name = ctx.stylize(name, 'string'); +- } +- } +- +- return name + ': ' + str; +-} +- +- +-function reduceToSingleString(output, base, braces) { +- var numLinesEst = 0; +- var length = output.reduce(function(prev, cur) { +- numLinesEst++; +- if (cur.indexOf('\n') >= 0) numLinesEst++; +- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; +- }, 0); +- +- if (length > 60) { +- return braces[0] + +- (base === '' ? '' : base + '\n ') + +- ' ' + +- output.join(',\n ') + +- ' ' + +- braces[1]; +- } +- +- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +-} +- +- + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray(ar) { +@@ -522,166 +98,10 @@ function isPrimitive(arg) { + exports.isPrimitive = isPrimitive; + + function isBuffer(arg) { +- return arg instanceof Buffer; ++ return Buffer.isBuffer(arg); + } + exports.isBuffer = isBuffer; + + function objectToString(o) { + return Object.prototype.toString.call(o); +-} +- +- +-function pad(n) { +- return n < 10 ? '0' + n.toString(10) : n.toString(10); +-} +- +- +-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', +- 'Oct', 'Nov', 'Dec']; +- +-// 26 Feb 16:19:34 +-function timestamp() { +- var d = new Date(); +- var time = [pad(d.getHours()), +- pad(d.getMinutes()), +- pad(d.getSeconds())].join(':'); +- return [d.getDate(), months[d.getMonth()], time].join(' '); +-} +- +- +-// log is just a thin wrapper to console.log that prepends a timestamp +-exports.log = function() { +- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +-}; +- +- +-/** +- * Inherit the prototype methods from one constructor into another. +- * +- * The Function.prototype.inherits from lang.js rewritten as a standalone +- * function (not on Function.prototype). NOTE: If this file is to be loaded +- * during bootstrapping this function needs to be rewritten using some native +- * functions as prototype setup using normal JavaScript does not work as +- * expected during bootstrapping (see mirror.js in r114903). +- * +- * @param {function} ctor Constructor function which needs to inherit the +- * prototype. +- * @param {function} superCtor Constructor function to inherit prototype from. +- */ +-exports.inherits = function(ctor, superCtor) { +- ctor.super_ = superCtor; +- ctor.prototype = Object.create(superCtor.prototype, { +- constructor: { +- value: ctor, +- enumerable: false, +- writable: true, +- configurable: true +- } +- }); +-}; +- +-exports._extend = function(origin, add) { +- // Don't do anything if add isn't an object +- if (!add || !isObject(add)) return origin; +- +- var keys = Object.keys(add); +- var i = keys.length; +- while (i--) { +- origin[keys[i]] = add[keys[i]]; +- } +- return origin; +-}; +- +-function hasOwnProperty(obj, prop) { +- return Object.prototype.hasOwnProperty.call(obj, prop); +-} +- +- +-// Deprecated old stuff. +- +-exports.p = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- console.error(exports.inspect(arguments[i])); +- } +-}, 'util.p: Use console.error() instead'); +- +- +-exports.exec = exports.deprecate(function() { +- return require('child_process').exec.apply(this, arguments); +-}, 'util.exec is now called `child_process.exec`.'); +- +- +-exports.print = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(String(arguments[i])); +- } +-}, 'util.print: Use console.log instead'); +- +- +-exports.puts = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(arguments[i] + '\n'); +- } +-}, 'util.puts: Use console.log instead'); +- +- +-exports.debug = exports.deprecate(function(x) { +- process.stderr.write('DEBUG: ' + x + '\n'); +-}, 'util.debug: Use console.error instead'); +- +- +-exports.error = exports.deprecate(function(x) { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stderr.write(arguments[i] + '\n'); +- } +-}, 'util.error: Use console.error instead'); +- +- +-exports.pump = exports.deprecate(function(readStream, writeStream, callback) { +- var callbackCalled = false; +- +- function call(a, b, c) { +- if (callback && !callbackCalled) { +- callback(a, b, c); +- callbackCalled = true; +- } +- } +- +- readStream.addListener('data', function(chunk) { +- if (writeStream.write(chunk) === false) readStream.pause(); +- }); +- +- writeStream.addListener('drain', function() { +- readStream.resume(); +- }); +- +- readStream.addListener('end', function() { +- writeStream.end(); +- }); +- +- readStream.addListener('close', function() { +- call(); +- }); +- +- readStream.addListener('error', function(err) { +- writeStream.end(); +- call(err); +- }); +- +- writeStream.addListener('error', function(err) { +- readStream.destroy(); +- call(err); +- }); +-}, 'util.pump(): Use readableStream.pipe() instead'); +- +- +-var uv; +-exports._errnoException = function(err, syscall) { +- if (isUndefined(uv)) uv = process.binding('uv'); +- var errname = uv.errname(err); +- var e = new Error(syscall + ' ' + errname); +- e.code = errname; +- e.errno = errname; +- e.syscall = syscall; +- return e; +-}; ++} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/lib/util.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/lib/util.js new file mode 100644 index 00000000..9074e8eb --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/lib/util.js @@ -0,0 +1,107 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return Buffer.isBuffer(arg); +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/package.json new file mode 100644 index 00000000..4114d29c --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/package.json @@ -0,0 +1,38 @@ +{ + "name": "core-util-is", + "version": "1.0.1", + "description": "The `util.is*` functions introduced in Node v0.12.", + "main": "lib/util.js", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/core-util-is" + }, + "keywords": [ + "util", + "isBuffer", + "isArray", + "isNumber", + "isString", + "isRegExp", + "isThis", + "isThat", + "polyfill" + ], + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/isaacs/core-util-is/issues" + }, + "readme": "# core-util-is\n\nThe `util.is*` functions introduced in Node v0.12.\n", + "readmeFilename": "README.md", + "_id": "core-util-is@1.0.1", + "dist": { + "shasum": "bd815063f8aadddea630e8412d0708c753aabd57" + }, + "_from": "core-util-is@~1.0.0", + "_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/util.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/util.js new file mode 100644 index 00000000..007fa105 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/core-util-is/util.js @@ -0,0 +1,106 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && objectToString(e) === '[object Error]'; +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return arg instanceof Buffer; +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/LICENSE new file mode 100644 index 00000000..a3187cc1 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/LICENSE @@ -0,0 +1,19 @@ +Copyright Joyent, Inc. and other Node contributors. All rights reserved. + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/README.md new file mode 100644 index 00000000..dc6fccec --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/README.md @@ -0,0 +1,40 @@ +# debuglog - backport of util.debuglog() from node v0.11 + +To facilitate using the `util.debuglog()` function that will be available when +node v0.12 is released now, this is a copy extracted from the source. + +## require('debuglog') + +Return `util.debuglog`, if it exists, otherwise it will return an internal copy +of the implementation from node v0.11. + +## debuglog(section) + +* `section` {String} The section of the program to be debugged +* Returns: {Function} The logging function + +This is used to create a function which conditionally writes to stderr +based on the existence of a `NODE_DEBUG` environment variable. If the +`section` name appears in that environment variable, then the returned +function will be similar to `console.error()`. If not, then the +returned function is a no-op. + +For example: + +```javascript +var debuglog = util.debuglog('foo'); + +var bar = 123; +debuglog('hello from foo [%d]', bar); +``` + +If this program is run with `NODE_DEBUG=foo` in the environment, then +it will output something like: + + FOO 3245: hello from foo [123] + +where `3245` is the process id. If it is not run with that +environment variable set, then it will not print anything. + +You may separate multiple `NODE_DEBUG` environment variables with a +comma. For example, `NODE_DEBUG=fs,net,tls`. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/debuglog.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/debuglog.js new file mode 100644 index 00000000..da465c29 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/debuglog.js @@ -0,0 +1,22 @@ +var util = require('util'); + +module.exports = util.debuglog || debuglog; + +var debugs = {}; +var debugEnviron = process.env.NODE_DEBUG || ''; + +function debuglog(set) { + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = util.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/package.json new file mode 100644 index 00000000..7582bdfd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/debuglog/package.json @@ -0,0 +1,26 @@ +{ + "name": "debuglog", + "version": "0.0.2", + "description": "backport of util.debuglog from node v0.11", + "license": "MIT", + "main": "debuglog.js", + "repository": { + "type": "git", + "url": "https://github.com/sam-github/node-debuglog.git" + }, + "author": { + "name": "Sam Roberts", + "email": "sam@strongloop.com" + }, + "engines": { + "node": "*" + }, + "readme": "# debuglog - backport of util.debuglog() from node v0.11\n\nTo facilitate using the `util.debuglog()` function that will be available when\nnode v0.12 is released now, this is a copy extracted from the source.\n\n## require('debuglog')\n\nReturn `util.debuglog`, if it exists, otherwise it will return an internal copy\nof the implementation from node v0.11.\n\n## debuglog(section)\n\n* `section` {String} The section of the program to be debugged\n* Returns: {Function} The logging function\n\nThis is used to create a function which conditionally writes to stderr\nbased on the existence of a `NODE_DEBUG` environment variable. If the\n`section` name appears in that environment variable, then the returned\nfunction will be similar to `console.error()`. If not, then the\nreturned function is a no-op.\n\nFor example:\n\n```javascript\nvar debuglog = util.debuglog('foo');\n\nvar bar = 123;\ndebuglog('hello from foo [%d]', bar);\n```\n\nIf this program is run with `NODE_DEBUG=foo` in the environment, then\nit will output something like:\n\n FOO 3245: hello from foo [123]\n\nwhere `3245` is the process id. If it is not run with that\nenvironment variable set, then it will not print anything.\n\nYou may separate multiple `NODE_DEBUG` environment variables with a\ncomma. For example, `NODE_DEBUG=fs,net,tls`.\n", + "readmeFilename": "README.md", + "_id": "debuglog@0.0.2", + "dist": { + "shasum": "50e76262c774c0480f9537a6f7b7991d54c9135e" + }, + "_from": "debuglog@0.0.2", + "_resolved": "https://registry.npmjs.org/debuglog/-/debuglog-0.0.2.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/.npmignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/.npmignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/LICENSE new file mode 100644 index 00000000..6de584a4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/LICENSE @@ -0,0 +1,20 @@ +Copyright Joyent, Inc. and other Node contributors. + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/README.md new file mode 100644 index 00000000..4d2aa001 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/README.md @@ -0,0 +1,7 @@ +**string_decoder.js** (`require('string_decoder')`) from Node.js core + +Copyright Joyent, Inc. and other Node contributors. See LICENCE file for details. + +Version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10. **Prefer the stable version over the unstable.** + +The *build/* directory contains a build script that will scrape the source from the [joyent/node](https://github.com/joyent/node) repo given a specific Node version. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/.npmignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/build.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/build.js new file mode 100644 index 00000000..46470cfd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/build.js @@ -0,0 +1,94 @@ +#!/usr/bin/env node + +const hyperquest = require('hyperzip')(require('hyperdirect')) + , bl = require('bl') + , fs = require('fs') + , path = require('path') + , cheerio = require('cheerio') + + , files = require('./files') + , testReplace = require('./test-replacements') + + , srcurlpfx = 'https://raw.github.com/joyent/node/v' + process.argv[2] + '-release/' + , libsrcurl = srcurlpfx + 'lib/' + , testsrcurl = srcurlpfx + 'test/simple/' + , testlisturl = 'https://github.com/joyent/node/tree/v' + process.argv[2] + '-release/test/simple' + , libourroot = path.join(__dirname, '../') + , testourroot = path.join(__dirname, '../test/simple/') + + +function processFile (url, out, replacements) { + hyperquest(url).pipe(bl(function (err, data) { + if (err) + throw err + + data = data.toString() + replacements.forEach(function (replacement) { + data = data.replace.apply(data, replacement) + }) + + fs.writeFile(out, data, 'utf8', function (err) { + if (err) + throw err + + console.log('Wrote', out) + }) + })) +} + +function processLibFile (file) { + var replacements = files[file] + , url = libsrcurl + file + , out = path.join(libourroot, replacements.out || file) + + processFile(url, out, replacements) +} + + +function processTestFile (file) { + var replacements = testReplace.all + , url = testsrcurl + file + , out = path.join(testourroot, file) + + if (testReplace[file]) + replacements = replacements.concat(testReplace[file]) + + processFile(url, out, replacements) +} + + +if (!/0\.1\d\.\d+/.test(process.argv[2])) { + console.log('Usage: build.js ') + return process.exit(-1) +} + + +//-------------------------------------------------------------------- +// Grab & process files in ../lib/ + +Object.keys(files).forEach(processLibFile) + +//-------------------------------------------------------------------- +// Discover, grab and process all test-string-decoder* files on joyent/node + +hyperquest(testlisturl).pipe(bl(function (err, data) { + if (err) + throw err + + var $ = cheerio.load(data.toString()) + + $('table.files .js-directory-link').each(function () { + var file = $(this).text() + if (/^test-string-decoder/.test(file) || file == 'common.js') + processTestFile(file) + }) +})) + +//-------------------------------------------------------------------- +// Grab the joyent/node test/common.js + +processFile( + testsrcurl + '../common.js' + , path.join(testourroot, '../common.js') + , testReplace['common.js'] +) \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/files.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/files.js new file mode 100644 index 00000000..7396a4f4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/files.js @@ -0,0 +1,36 @@ +/* This file lists the files to be fetched from the node repo + * in the /lib/ directory which will be placed in the ../lib/ + * directory after having each of the "replacements" in the + * array for that file applied to it. The replacements are + * simply the arguments to String#replace, so they can be + * strings, regexes, functions. + */ + +module.exports['string_decoder.js'] = [ + + // pull in Bufer as a require + // add Buffer.isEncoding where missing + [ + /^(\/\/ USE OR OTHER DEALINGS IN THE SOFTWARE\.)/m + , '$1\n\nvar Buffer = require(\'buffer\').Buffer;' + + '\n' + + '\nvar isBufferEncoding = Buffer.isEncoding' + + '\n || function(encoding) {' + + '\n switch (encoding && encoding.toLowerCase()) {' + + '\n case \'hex\': case \'utf8\': case \'utf-8\': case \'ascii\': case \'binary\': case \'base64\': case \'ucs2\': case \'ucs-2\': case \'utf16le\': case \'utf-16le\': case \'raw\': return true;' + + '\n default: return false;' + + '\n }' + + '\n }' + + '\n' + + ] + + // use custom Buffer.isEncoding reference + , [ + /Buffer\.isEncoding\(/g + , 'isBufferEncoding\(' + ] + +] + +module.exports['string_decoder.js'].out = 'index.js' \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.jshintrc b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.jshintrc new file mode 100644 index 00000000..c8ef3ca4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.jshintrc @@ -0,0 +1,59 @@ +{ + "predef": [ ] + , "bitwise": false + , "camelcase": false + , "curly": false + , "eqeqeq": false + , "forin": false + , "immed": false + , "latedef": false + , "noarg": true + , "noempty": true + , "nonew": true + , "plusplus": false + , "quotmark": true + , "regexp": false + , "undef": true + , "unused": true + , "strict": false + , "trailing": true + , "maxlen": 120 + , "asi": true + , "boss": true + , "debug": true + , "eqnull": true + , "esnext": true + , "evil": true + , "expr": true + , "funcscope": false + , "globalstrict": false + , "iterator": false + , "lastsemic": true + , "laxbreak": true + , "laxcomma": true + , "loopfunc": true + , "multistr": false + , "onecase": false + , "proto": false + , "regexdash": false + , "scripturl": true + , "smarttabs": false + , "shadow": false + , "sub": true + , "supernew": false + , "validthis": true + , "browser": true + , "couch": false + , "devel": false + , "dojo": false + , "mootools": false + , "node": true + , "nonstandard": true + , "prototypejs": false + , "rhino": false + , "worker": true + , "wsh": false + , "nomen": false + , "onevar": false + , "passfail": false +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.npmignore new file mode 100644 index 00000000..40b878db --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.npmignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.travis.yml new file mode 100644 index 00000000..7ddb9c97 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +node_js: + - 0.8 + - "0.10" +branches: + only: + - master +notifications: + email: + - rod@vagg.org +script: npm test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/LICENSE new file mode 100644 index 00000000..f6a0029d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/LICENSE @@ -0,0 +1,39 @@ +Copyright 2013, Rod Vagg (the "Original Author") +All rights reserved. + +MIT +no-false-attribs License + +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. + +Distributions of all or part of the Software intended to be used +by the recipients as they would use the unmodified Software, +containing modifications that substantially alter, remove, or +disable functionality of the Software, outside of the documented +configuration mechanisms provided by the Software, shall be +modified such that the Original Author's bug reporting email +addresses and urls are either replaced with the contact information +of the parties responsible for the changes, or removed entirely. + +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. + + +Except where noted, this license applies to any and all software +programs and associated documentation files created by the +Original Author, when distributed with the Software. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/README.md new file mode 100644 index 00000000..264c46e4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/README.md @@ -0,0 +1,193 @@ +# bl *(BufferList)* + +[![Build Status](https://secure.travis-ci.org/rvagg/bl.png)](http://travis-ci.org/rvagg/bl) + +**A Node.js Buffer list collector, reader and streamer thingy.** + +**bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them! + +The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently. + +```js +const BufferList = require('bl') + +var bl = new BufferList() +bl.append(new Buffer('abcd')) +bl.append(new Buffer('efg')) +bl.append('hi') // bl will also accept & convert Strings +bl.append(new Buffer('j')) +bl.append(new Buffer([ 0x3, 0x4 ])) + +console.log(bl.length) // 12 + +console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij' +console.log(bl.slice(3, 10).toString('ascii')) // 'defghij' +console.log(bl.slice(3, 6).toString('ascii')) // 'def' +console.log(bl.slice(3, 8).toString('ascii')) // 'defgh' +console.log(bl.slice(5, 10).toString('ascii')) // 'fghij' + +// or just use toString! +console.log(bl.toString()) // 'abcdefghij\u0003\u0004' +console.log(bl.toString('ascii', 3, 8)) // 'defgh' +console.log(bl.toString('ascii', 5, 10)) // 'fghij' + +// other standard Buffer readables +console.log(bl.readUInt16BE(10)) // 0x0304 +console.log(bl.readUInt16LE(10)) // 0x0403 +``` + +Give it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**: + +```js +const bl = require('bl') + , fs = require('fs') + +fs.createReadStream('README.md') + .pipe(bl(function (err, data) { // note 'new' isn't strictly required + // `data` is a complete Buffer object containing the full data + console.log(data.toString()) + }) +``` + +Note that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream. + +Or to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!): +```js +const hyperquest = require('hyperquest') + , bl = require('bl') + , url = 'https://raw.github.com/rvagg/bl/master/README.md' + +hyperquest(url).pipe(bl(function (err, data) { + console.log(data.toString()) +})) +``` + +Or, use it as a readable stream to recompose a list of Buffers to an output source: + +```js +const BufferList = require('bl') + , fs = require('fs') + +var bl = new BufferList() +bl.append(new Buffer('abcd')) +bl.append(new Buffer('efg')) +bl.append(new Buffer('hi')) +bl.append(new Buffer('j')) + +bl.pipe(fs.createWriteStream('gibberish.txt')) +``` + +## API + + * new BufferList([ callback ]) + * bl.length + * bl.append(buffer) + * bl.get(index) + * bl.slice([ start[, end ] ]) + * bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ]) + * bl.duplicate() + * bl.consume(bytes) + * bl.toString([encoding, [ start, [ end ]]]) + * bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8() + * Streams + +-------------------------------------------------------- + +### new BufferList([ callback | buffer | buffer array ]) +The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream. + +Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object. + +`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with: + +```js +var bl = require('bl') +var myinstance = bl() + +// equivilant to: + +var BufferList = require('bl') +var myinstance = new BufferList() +``` + +-------------------------------------------------------- + +### bl.length +Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list. + +-------------------------------------------------------- + +### bl.append(buffer) +`append(buffer)` adds an additional buffer to the internal list. + +-------------------------------------------------------- + +### bl.get(index) +`get()` will return the byte at the specified index. + +-------------------------------------------------------- + +### bl.slice([ start, [ end ] ]) +`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively. + +If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer. + +-------------------------------------------------------- + +### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ]) +`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively. + +-------------------------------------------------------- + +### bl.duplicate() +`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example: + +```js +var bl = new BufferList() + +bl.append('hello') +bl.append(' world') +bl.append('\n') + +bl.duplicate().pipe(process.stdout, { end: false }) + +console.log(bl.toString()) +``` + +-------------------------------------------------------- + +### bl.consume(bytes) +`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers—initial offsets will be calculated accordingly in order to give you a consistent view of the data. + +-------------------------------------------------------- + +### bl.toString([encoding, [ start, [ end ]]]) +`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information. + +-------------------------------------------------------- + +### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8() + +All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently. + +See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work. + +-------------------------------------------------------- + +### Streams +**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance. + +-------------------------------------------------------- + +## Contributors + +**bl** is brought to you by the following hackers: + + * [Rod Vagg](https://github.com/rvagg) + * [Matteo Collina](https://github.com/mcollina) + +======= + +## License + +**bl** is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/bl.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/bl.js new file mode 100644 index 00000000..192e16b9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/bl.js @@ -0,0 +1,205 @@ +const DuplexStream = require('stream').DuplexStream || require('readable-stream/duplex') + , util = require('util') + +function BufferList (callback) { + if (!(this instanceof BufferList)) + return new BufferList(callback) + + this._bufs = [] + this.length = 0 + + if (typeof callback == 'function') { + this._callback = callback + + var piper = function (err) { + if (this._callback) { + this._callback(err) + this._callback = null + } + }.bind(this) + + this.on('pipe', function (src) { + src.on('error', piper) + }) + this.on('unpipe', function (src) { + src.removeListener('error', piper) + }) + } + else if (Buffer.isBuffer(callback)) + this.append(callback) + else if (Array.isArray(callback)) { + callback.forEach(function (b) { + Buffer.isBuffer(b) && this.append(b) + }.bind(this)) + } + + DuplexStream.call(this) +} + +util.inherits(BufferList, DuplexStream) + +BufferList.prototype._offset = function (offset) { + var tot = 0, i = 0, _t + for (; i < this._bufs.length; i++) { + _t = tot + this._bufs[i].length + if (offset < _t) + return [ i, offset - tot ] + tot = _t + } +} + +BufferList.prototype.append = function (buf) { + this._bufs.push(Buffer.isBuffer(buf) ? buf : new Buffer(buf)) + this.length += buf.length + return this +} + +BufferList.prototype._write = function (buf, encoding, callback) { + this.append(buf) + if (callback) + callback() +} + +BufferList.prototype._read = function (size) { + if (!this.length) + return this.push(null) + size = Math.min(size, this.length) + this.push(this.slice(0, size)) + this.consume(size) +} + +BufferList.prototype.end = function (chunk) { + DuplexStream.prototype.end.call(this, chunk) + + if (this._callback) { + this._callback(null, this.slice()) + this._callback = null + } +} + +BufferList.prototype.get = function (index) { + return this.slice(index, index + 1)[0] +} + +BufferList.prototype.slice = function (start, end) { + return this.copy(null, 0, start, end) +} + +BufferList.prototype.copy = function (dst, dstStart, srcStart, srcEnd) { + if (typeof srcStart != 'number' || srcStart < 0) + srcStart = 0 + if (typeof srcEnd != 'number' || srcEnd > this.length) + srcEnd = this.length + if (srcStart >= this.length) + return dst || new Buffer(0) + if (srcEnd <= 0) + return dst || new Buffer(0) + + var copy = !!dst + , off = this._offset(srcStart) + , len = srcEnd - srcStart + , bytes = len + , bufoff = (copy && dstStart) || 0 + , start = off[1] + , l + , i + + // copy/slice everything + if (srcStart === 0 && srcEnd == this.length) { + if (!copy) // slice, just return a full concat + return Buffer.concat(this._bufs) + + // copy, need to copy individual buffers + for (i = 0; i < this._bufs.length; i++) { + this._bufs[i].copy(dst, bufoff) + bufoff += this._bufs[i].length + } + + return dst + } + + // easy, cheap case where it's a subset of one of the buffers + if (bytes <= this._bufs[off[0]].length - start) { + return copy + ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes) + : this._bufs[off[0]].slice(start, start + bytes) + } + + if (!copy) // a slice, we need something to copy in to + dst = new Buffer(len) + + for (i = off[0]; i < this._bufs.length; i++) { + l = this._bufs[i].length - start + + if (bytes > l) { + this._bufs[i].copy(dst, bufoff, start) + } else { + this._bufs[i].copy(dst, bufoff, start, start + bytes) + break + } + + bufoff += l + bytes -= l + + if (start) + start = 0 + } + + return dst +} + +BufferList.prototype.toString = function (encoding, start, end) { + return this.slice(start, end).toString(encoding) +} + +BufferList.prototype.consume = function (bytes) { + while (this._bufs.length) { + if (bytes > this._bufs[0].length) { + bytes -= this._bufs[0].length + this.length -= this._bufs[0].length + this._bufs.shift() + } else { + this._bufs[0] = this._bufs[0].slice(bytes) + this.length -= bytes + break + } + } + return this +} + +BufferList.prototype.duplicate = function () { + var i = 0 + , copy = new BufferList() + + for (; i < this._bufs.length; i++) + copy.append(this._bufs[i]) + + return copy +} + +;(function () { + var methods = { + 'readDoubleBE' : 8 + , 'readDoubleLE' : 8 + , 'readFloatBE' : 4 + , 'readFloatLE' : 4 + , 'readInt32BE' : 4 + , 'readInt32LE' : 4 + , 'readUInt32BE' : 4 + , 'readUInt32LE' : 4 + , 'readInt16BE' : 2 + , 'readInt16LE' : 2 + , 'readUInt16BE' : 2 + , 'readUInt16LE' : 2 + , 'readInt8' : 1 + , 'readUInt8' : 1 + } + + Object.keys(methods).forEach(function (m) { + BufferList.prototype[m] = function (offset) { + return this.slice(offset, offset + methods[m])[m](0) + } + }) +}()) + +module.exports = BufferList diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/LICENSE new file mode 100644 index 00000000..0c44ae71 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Isaac Z. Schlueter ("Author") +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/README.md new file mode 100644 index 00000000..be976683 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/README.md @@ -0,0 +1,768 @@ +# readable-stream + +A new class of streams for Node.js + +This module provides the new Stream base classes introduced in Node +v0.10, for use in Node v0.8. You can use it to have programs that +have to work with node v0.8, while being forward-compatible for v0.10 +and beyond. When you drop support for v0.8, you can remove this +module, and only use the native streams. + +This is almost exactly the same codebase as appears in Node v0.10. +However: + +1. The exported object is actually the Readable class. Decorating the + native `stream` module would be global pollution. +2. In v0.10, you can safely use `base64` as an argument to + `setEncoding` in Readable streams. However, in v0.8, the + StringDecoder class has no `end()` method, which is problematic for + Base64. So, don't use that, because it'll break and be weird. + +Other than that, the API is the same as `require('stream')` in v0.10, +so the API docs are reproduced below. + +---------- + + Stability: 2 - Unstable + +A stream is an abstract interface implemented by various objects in +Node. For example a request to an HTTP server is a stream, as is +stdout. Streams are readable, writable, or both. All streams are +instances of [EventEmitter][] + +You can load the Stream base classes by doing `require('stream')`. +There are base classes provided for Readable streams, Writable +streams, Duplex streams, and Transform streams. + +## Compatibility + +In earlier versions of Node, the Readable stream interface was +simpler, but also less powerful and less useful. + +* Rather than waiting for you to call the `read()` method, `'data'` + events would start emitting immediately. If you needed to do some + I/O to decide how to handle data, then you had to store the chunks + in some kind of buffer so that they would not be lost. +* The `pause()` method was advisory, rather than guaranteed. This + meant that you still had to be prepared to receive `'data'` events + even when the stream was in a paused state. + +In Node v0.10, the Readable class described below was added. For +backwards compatibility with older Node programs, Readable streams +switch into "old mode" when a `'data'` event handler is added, or when +the `pause()` or `resume()` methods are called. The effect is that, +even if you are not using the new `read()` method and `'readable'` +event, you no longer have to worry about losing `'data'` chunks. + +Most programs will continue to function normally. However, this +introduces an edge case in the following conditions: + +* No `'data'` event handler is added. +* The `pause()` and `resume()` methods are never called. + +For example, consider the following code: + +```javascript +// WARNING! BROKEN! +net.createServer(function(socket) { + + // we add an 'end' method, but never consume the data + socket.on('end', function() { + // It will never get here. + socket.end('I got your message (but didnt read it)\n'); + }); + +}).listen(1337); +``` + +In versions of node prior to v0.10, the incoming message data would be +simply discarded. However, in Node v0.10 and beyond, the socket will +remain paused forever. + +The workaround in this situation is to call the `resume()` method to +trigger "old mode" behavior: + +```javascript +// Workaround +net.createServer(function(socket) { + + socket.on('end', function() { + socket.end('I got your message (but didnt read it)\n'); + }); + + // start the flow of data, discarding it. + socket.resume(); + +}).listen(1337); +``` + +In addition to new Readable streams switching into old-mode, pre-v0.10 +style streams can be wrapped in a Readable class using the `wrap()` +method. + +## Class: stream.Readable + + + +A `Readable Stream` has the following methods, members, and events. + +Note that `stream.Readable` is an abstract class designed to be +extended with an underlying implementation of the `_read(size)` +method. (See below.) + +### new stream.Readable([options]) + +* `options` {Object} + * `highWaterMark` {Number} The maximum number of bytes to store in + the internal buffer before ceasing to read from the underlying + resource. Default=16kb + * `encoding` {String} If specified, then buffers will be decoded to + strings using the specified encoding. Default=null + * `objectMode` {Boolean} Whether this stream should behave + as a stream of objects. Meaning that stream.read(n) returns + a single value instead of a Buffer of size n + +In classes that extend the Readable class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### readable.\_read(size) + +* `size` {Number} Number of bytes to read asynchronously + +Note: **This function should NOT be called directly.** It should be +implemented by child classes, and called by the internal Readable +class methods only. + +All Readable stream implementations must provide a `_read` method +to fetch data from the underlying resource. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +When data is available, put it into the read queue by calling +`readable.push(chunk)`. If `push` returns false, then you should stop +reading. When `_read` is called again, you should start pushing more +data. + +The `size` argument is advisory. Implementations where a "read" is a +single call that returns data can use this to know how much data to +fetch. Implementations where that is not relevant, such as TCP or +TLS, may ignore this argument, and simply provide data whenever it +becomes available. There is no need, for example to "wait" until +`size` bytes are available before calling `stream.push(chunk)`. + +### readable.push(chunk) + +* `chunk` {Buffer | null | String} Chunk of data to push into the read queue +* return {Boolean} Whether or not more pushes should be performed + +Note: **This function should be called by Readable implementors, NOT +by consumers of Readable subclasses.** The `_read()` function will not +be called again until at least one `push(chunk)` call is made. If no +data is available, then you MAY call `push('')` (an empty string) to +allow a future `_read` call, without adding any data to the queue. + +The `Readable` class works by putting data into a read queue to be +pulled out later by calling the `read()` method when the `'readable'` +event fires. + +The `push()` method will explicitly insert some data into the read +queue. If it is called with `null` then it will signal the end of the +data. + +In some cases, you may be wrapping a lower-level source which has some +sort of pause/resume mechanism, and a data callback. In those cases, +you could wrap the low-level source object by doing something like +this: + +```javascript +// source is an object with readStop() and readStart() methods, +// and an `ondata` member that gets called when it has data, and +// an `onend` member that gets called when the data is over. + +var stream = new Readable(); + +source.ondata = function(chunk) { + // if push() returns false, then we need to stop reading from source + if (!stream.push(chunk)) + source.readStop(); +}; + +source.onend = function() { + stream.push(null); +}; + +// _read will be called when the stream wants to pull more data in +// the advisory size argument is ignored in this case. +stream._read = function(n) { + source.readStart(); +}; +``` + +### readable.unshift(chunk) + +* `chunk` {Buffer | null | String} Chunk of data to unshift onto the read queue +* return {Boolean} Whether or not more pushes should be performed + +This is the corollary of `readable.push(chunk)`. Rather than putting +the data at the *end* of the read queue, it puts it at the *front* of +the read queue. + +This is useful in certain use-cases where a stream is being consumed +by a parser, which needs to "un-consume" some data that it has +optimistically pulled out of the source. + +```javascript +// A parser for a simple data protocol. +// The "header" is a JSON object, followed by 2 \n characters, and +// then a message body. +// +// Note: This can be done more simply as a Transform stream. See below. + +function SimpleProtocol(source, options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(options); + + Readable.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + + // source is a readable stream, such as a socket or file + this._source = source; + + var self = this; + source.on('end', function() { + self.push(null); + }); + + // give it a kick whenever the source is readable + // read(0) will not consume any bytes + source.on('readable', function() { + self.read(0); + }); + + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype = Object.create( + Readable.prototype, { constructor: { value: SimpleProtocol }}); + +SimpleProtocol.prototype._read = function(n) { + if (!this._inBody) { + var chunk = this._source.read(); + + // if the source doesn't have data, we don't have data yet. + if (chunk === null) + return this.push(''); + + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + this.push(''); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // now, because we got some extra data, unshift the rest + // back into the read queue so that our consumer will see it. + var b = chunk.slice(split); + this.unshift(b); + + // and let them know that we are done parsing the header. + this.emit('header', this.header); + } + } else { + // from there on, just provide the data to our consumer. + // careful not to push(null), since that would indicate EOF. + var chunk = this._source.read(); + if (chunk) this.push(chunk); + } +}; + +// Usage: +var parser = new SimpleProtocol(source); +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + +### readable.wrap(stream) + +* `stream` {Stream} An "old style" readable stream + +If you are using an older Node library that emits `'data'` events and +has a `pause()` method that is advisory only, then you can use the +`wrap()` method to create a Readable stream that uses the old stream +as its data source. + +For example: + +```javascript +var OldReader = require('./old-api-module.js').OldReader; +var oreader = new OldReader; +var Readable = require('stream').Readable; +var myReader = new Readable().wrap(oreader); + +myReader.on('readable', function() { + myReader.read(); // etc. +}); +``` + +### Event: 'readable' + +When there is data ready to be consumed, this event will fire. + +When this event emits, call the `read()` method to consume the data. + +### Event: 'end' + +Emitted when the stream has received an EOF (FIN in TCP terminology). +Indicates that no more `'data'` events will happen. If the stream is +also writable, it may be possible to continue writing. + +### Event: 'data' + +The `'data'` event emits either a `Buffer` (by default) or a string if +`setEncoding()` was used. + +Note that adding a `'data'` event listener will switch the Readable +stream into "old mode", where data is emitted as soon as it is +available, rather than waiting for you to call `read()` to consume it. + +### Event: 'error' + +Emitted if there was an error receiving data. + +### Event: 'close' + +Emitted when the underlying resource (for example, the backing file +descriptor) has been closed. Not all streams will emit this. + +### readable.setEncoding(encoding) + +Makes the `'data'` event emit a string instead of a `Buffer`. `encoding` +can be `'utf8'`, `'utf16le'` (`'ucs2'`), `'ascii'`, or `'hex'`. + +The encoding can also be set by specifying an `encoding` field to the +constructor. + +### readable.read([size]) + +* `size` {Number | null} Optional number of bytes to read. +* Return: {Buffer | String | null} + +Note: **This function SHOULD be called by Readable stream users.** + +Call this method to consume data once the `'readable'` event is +emitted. + +The `size` argument will set a minimum number of bytes that you are +interested in. If not set, then the entire content of the internal +buffer is returned. + +If there is no data to consume, or if there are fewer bytes in the +internal buffer than the `size` argument, then `null` is returned, and +a future `'readable'` event will be emitted when more is available. + +Calling `stream.read(0)` will always return `null`, and will trigger a +refresh of the internal buffer, but otherwise be a no-op. + +### readable.pipe(destination, [options]) + +* `destination` {Writable Stream} +* `options` {Object} Optional + * `end` {Boolean} Default=true + +Connects this readable stream to `destination` WriteStream. Incoming +data on this stream gets written to `destination`. Properly manages +back-pressure so that a slow destination will not be overwhelmed by a +fast readable stream. + +This function returns the `destination` stream. + +For example, emulating the Unix `cat` command: + + process.stdin.pipe(process.stdout); + +By default `end()` is called on the destination when the source stream +emits `end`, so that `destination` is no longer writable. Pass `{ end: +false }` as `options` to keep the destination stream open. + +This keeps `writer` open so that "Goodbye" can be written at the +end. + + reader.pipe(writer, { end: false }); + reader.on("end", function() { + writer.end("Goodbye\n"); + }); + +Note that `process.stderr` and `process.stdout` are never closed until +the process exits, regardless of the specified options. + +### readable.unpipe([destination]) + +* `destination` {Writable Stream} Optional + +Undo a previously established `pipe()`. If no destination is +provided, then all previously established pipes are removed. + +### readable.pause() + +Switches the readable stream into "old mode", where data is emitted +using a `'data'` event rather than being buffered for consumption via +the `read()` method. + +Ceases the flow of data. No `'data'` events are emitted while the +stream is in a paused state. + +### readable.resume() + +Switches the readable stream into "old mode", where data is emitted +using a `'data'` event rather than being buffered for consumption via +the `read()` method. + +Resumes the incoming `'data'` events after a `pause()`. + + +## Class: stream.Writable + + + +A `Writable` Stream has the following methods, members, and events. + +Note that `stream.Writable` is an abstract class designed to be +extended with an underlying implementation of the +`_write(chunk, encoding, cb)` method. (See below.) + +### new stream.Writable([options]) + +* `options` {Object} + * `highWaterMark` {Number} Buffer level when `write()` starts + returning false. Default=16kb + * `decodeStrings` {Boolean} Whether or not to decode strings into + Buffers before passing them to `_write()`. Default=true + +In classes that extend the Writable class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### writable.\_write(chunk, encoding, callback) + +* `chunk` {Buffer | String} The chunk to be written. Will always + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. Ignore chunk is a buffer. Note that chunk will + **always** be a buffer unless the `decodeStrings` option is + explicitly set to `false`. +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunk. + +All Writable stream implementations must provide a `_write` method to +send data to the underlying resource. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Writable +class methods only. + +Call the callback using the standard `callback(error)` pattern to +signal that the write completed successfully or with an error. + +If the `decodeStrings` flag is set in the constructor options, then +`chunk` may be a string rather than a Buffer, and `encoding` will +indicate the sort of string that it is. This is to support +implementations that have an optimized handling for certain string +data encodings. If you do not explicitly set the `decodeStrings` +option to `false`, then you can safely ignore the `encoding` argument, +and assume that `chunk` will always be a Buffer. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + + +### writable.write(chunk, [encoding], [callback]) + +* `chunk` {Buffer | String} Data to be written +* `encoding` {String} Optional. If `chunk` is a string, then encoding + defaults to `'utf8'` +* `callback` {Function} Optional. Called when this chunk is + successfully written. +* Returns {Boolean} + +Writes `chunk` to the stream. Returns `true` if the data has been +flushed to the underlying resource. Returns `false` to indicate that +the buffer is full, and the data will be sent out in the future. The +`'drain'` event will indicate when the buffer is empty again. + +The specifics of when `write()` will return false, is determined by +the `highWaterMark` option provided to the constructor. + +### writable.end([chunk], [encoding], [callback]) + +* `chunk` {Buffer | String} Optional final data to be written +* `encoding` {String} Optional. If `chunk` is a string, then encoding + defaults to `'utf8'` +* `callback` {Function} Optional. Called when the final chunk is + successfully written. + +Call this method to signal the end of the data being written to the +stream. + +### Event: 'drain' + +Emitted when the stream's write queue empties and it's safe to write +without buffering again. Listen for it when `stream.write()` returns +`false`. + +### Event: 'close' + +Emitted when the underlying resource (for example, the backing file +descriptor) has been closed. Not all streams will emit this. + +### Event: 'finish' + +When `end()` is called and there are no more chunks to write, this +event is emitted. + +### Event: 'pipe' + +* `source` {Readable Stream} + +Emitted when the stream is passed to a readable stream's pipe method. + +### Event 'unpipe' + +* `source` {Readable Stream} + +Emitted when a previously established `pipe()` is removed using the +source Readable stream's `unpipe()` method. + +## Class: stream.Duplex + + + +A "duplex" stream is one that is both Readable and Writable, such as a +TCP socket connection. + +Note that `stream.Duplex` is an abstract class designed to be +extended with an underlying implementation of the `_read(size)` +and `_write(chunk, encoding, callback)` methods as you would with a Readable or +Writable stream class. + +Since JavaScript doesn't have multiple prototypal inheritance, this +class prototypally inherits from Readable, and then parasitically from +Writable. It is thus up to the user to implement both the lowlevel +`_read(n)` method as well as the lowlevel `_write(chunk, encoding, cb)` method +on extension duplex classes. + +### new stream.Duplex(options) + +* `options` {Object} Passed to both Writable and Readable + constructors. Also has the following fields: + * `allowHalfOpen` {Boolean} Default=true. If set to `false`, then + the stream will automatically end the readable side when the + writable side ends and vice versa. + +In classes that extend the Duplex class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +## Class: stream.Transform + +A "transform" stream is a duplex stream where the output is causally +connected in some way to the input, such as a zlib stream or a crypto +stream. + +There is no requirement that the output be the same size as the input, +the same number of chunks, or arrive at the same time. For example, a +Hash stream will only ever have a single chunk of output which is +provided when the input is ended. A zlib stream will either produce +much smaller or much larger than its input. + +Rather than implement the `_read()` and `_write()` methods, Transform +classes must implement the `_transform()` method, and may optionally +also implement the `_flush()` method. (See below.) + +### new stream.Transform([options]) + +* `options` {Object} Passed to both Writable and Readable + constructors. + +In classes that extend the Transform class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### transform.\_transform(chunk, encoding, callback) + +* `chunk` {Buffer | String} The chunk to be transformed. Will always + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. (Ignore if `decodeStrings` chunk is a buffer.) +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunk. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Transform +class methods only. + +All Transform stream implementations must provide a `_transform` +method to accept input and produce output. + +`_transform` should do whatever has to be done in this specific +Transform class, to handle the bytes being written, and pass them off +to the readable portion of the interface. Do asynchronous I/O, +process things, and so on. + +Call `transform.push(outputChunk)` 0 or more times to generate output +from this input chunk, depending on how much data you want to output +as a result of this chunk. + +Call the callback function only when the current chunk is completely +consumed. Note that there may or may not be output as a result of any +particular input chunk. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +### transform.\_flush(callback) + +* `callback` {Function} Call this function (optionally with an error + argument) when you are done flushing any remaining data. + +Note: **This function MUST NOT be called directly.** It MAY be implemented +by child classes, and if so, will be called by the internal Transform +class methods only. + +In some cases, your transform operation may need to emit a bit more +data at the end of the stream. For example, a `Zlib` compression +stream will store up some internal state so that it can optimally +compress the output. At the end, however, it needs to do the best it +can with what is left, so that the data will be complete. + +In those cases, you can implement a `_flush` method, which will be +called at the very end, after all the written data is consumed, but +before emitting `end` to signal the end of the readable side. Just +like with `_transform`, call `transform.push(chunk)` zero or more +times, as appropriate, and call `callback` when the flush operation is +complete. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +### Example: `SimpleProtocol` parser + +The example above of a simple protocol parser can be implemented much +more simply by using the higher level `Transform` stream class. + +In this example, rather than providing the input as an argument, it +would be piped into the parser, which is a more idiomatic Node stream +approach. + +```javascript +function SimpleProtocol(options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(options); + + Transform.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype = Object.create( + Transform.prototype, { constructor: { value: SimpleProtocol }}); + +SimpleProtocol.prototype._transform = function(chunk, encoding, done) { + if (!this._inBody) { + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // and let them know that we are done parsing the header. + this.emit('header', this.header); + + // now, because we got some extra data, emit this first. + this.push(b); + } + } else { + // from there on, just provide the data to our consumer as-is. + this.push(b); + } + done(); +}; + +var parser = new SimpleProtocol(); +source.pipe(parser) + +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + + +## Class: stream.PassThrough + +This is a trivial implementation of a `Transform` stream that simply +passes the input bytes across to the output. Its purpose is mainly +for examples and testing, but there are occasionally use cases where +it can come in handy. + + +[EventEmitter]: events.html#events_class_events_eventemitter diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/duplex.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/duplex.js new file mode 100644 index 00000000..ca807af8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/duplex.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_duplex.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/CAPSLOCKTYPER.JS b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/CAPSLOCKTYPER.JS new file mode 100644 index 00000000..205a4256 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/CAPSLOCKTYPER.JS @@ -0,0 +1,32 @@ +var Transform = require('../transform'); +var inherits = require('util').inherits; + +// subclass +function MyStream () { + Transform.call(this, { + lowWaterMark: 0, + encoding: 'utf8' + }); +} +inherits(MyStream, Transform); + +MyStream.prototype._transform = function (chunk, outputFn, callback) { + outputFn(new Buffer(String(chunk).toUpperCase())); + callback(); +}; + +// use it! +var s = new MyStream(); +process.stdin.resume(); +process.stdin.pipe(s).pipe(process.stdout); +if (process.stdin.setRawMode) + process.stdin.setRawMode(true); +process.stdin.on('data', function (c) { + c = c.toString(); + if (c === '\u0003' || c === '\u0004') { + process.stdin.pause(); + s.end(); + } + if (c === '\r') + process.stdout.write('\n'); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/typer-fsr.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/typer-fsr.js new file mode 100644 index 00000000..7e715844 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/typer-fsr.js @@ -0,0 +1,15 @@ +var fs = require('fs'); +var FSReadable = require('../fs.js'); +var rst = new FSReadable(__filename); + +rst.on('end', function() { + process.stdin.pause(); +}); + +process.stdin.setRawMode(true); +process.stdin.on('data', function() { + var c = rst.read(3); + if (!c) return; + process.stdout.write(c); +}); +process.stdin.resume(); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/typer.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/typer.js new file mode 100644 index 00000000..c16eb6fb --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/examples/typer.js @@ -0,0 +1,17 @@ +var fs = require('fs'); +var fst = fs.createReadStream(__filename); +var Readable = require('../readable.js'); +var rst = new Readable(); +rst.wrap(fst); + +rst.on('end', function() { + process.stdin.pause(); +}); + +process.stdin.setRawMode(true); +process.stdin.on('data', function() { + var c = rst.read(3); + if (!c) return setTimeout(process.exit, 500) + process.stdout.write(c); +}); +process.stdin.resume(); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/float.patch b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/float.patch new file mode 100644 index 00000000..0ad71a1f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/float.patch @@ -0,0 +1,68 @@ +diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js +index c5a741c..a2e0d8e 100644 +--- a/lib/_stream_duplex.js ++++ b/lib/_stream_duplex.js +@@ -26,8 +26,8 @@ + + module.exports = Duplex; + var util = require('util'); +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('./_stream_readable'); ++var Writable = require('./_stream_writable'); + + util.inherits(Duplex, Readable); + +diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js +index a5e9864..330c247 100644 +--- a/lib/_stream_passthrough.js ++++ b/lib/_stream_passthrough.js +@@ -25,7 +25,7 @@ + + module.exports = PassThrough; + +-var Transform = require('_stream_transform'); ++var Transform = require('./_stream_transform'); + var util = require('util'); + util.inherits(PassThrough, Transform); + +diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js +index 2259d2e..e6681ee 100644 +--- a/lib/_stream_readable.js ++++ b/lib/_stream_readable.js +@@ -23,6 +23,9 @@ module.exports = Readable; + Readable.ReadableState = ReadableState; + + var EE = require('events').EventEmitter; ++if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { ++ return emitter.listeners(type).length; ++}; + var Stream = require('stream'); + var util = require('util'); + var StringDecoder; +diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js +index e925b4b..f08b05e 100644 +--- a/lib/_stream_transform.js ++++ b/lib/_stream_transform.js +@@ -64,7 +64,7 @@ + + module.exports = Transform; + +-var Duplex = require('_stream_duplex'); ++var Duplex = require('./_stream_duplex'); + var util = require('util'); + util.inherits(Transform, Duplex); + +diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js +index a26f711..56ca47d 100644 +--- a/lib/_stream_writable.js ++++ b/lib/_stream_writable.js +@@ -109,7 +109,7 @@ function WritableState(options, stream) { + function Writable(options) { + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. +- if (!(this instanceof Writable) && !(this instanceof Stream.Duplex)) ++ if (!(this instanceof Writable) && !(this instanceof require('./_stream_duplex'))) + return new Writable(options); + + this._writableState = new WritableState(options, this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/fs.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/fs.js new file mode 100644 index 00000000..a663af86 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/fs.js @@ -0,0 +1,1705 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// Maintainers, keep in mind that octal literals are not allowed +// in strict mode. Use the decimal value and add a comment with +// the octal value. Example: +// +// var mode = 438; /* mode=0666 */ + +var util = require('util'); +var pathModule = require('path'); + +var binding = process.binding('fs'); +var constants = process.binding('constants'); +var fs = exports; +var Stream = require('stream').Stream; +var EventEmitter = require('events').EventEmitter; + +var Readable = require('./lib/_stream_readable.js'); +var Writable = require('./lib/_stream_writable.js'); + +var kMinPoolSpace = 128; +var kPoolSize = 40 * 1024; + +var O_APPEND = constants.O_APPEND || 0; +var O_CREAT = constants.O_CREAT || 0; +var O_DIRECTORY = constants.O_DIRECTORY || 0; +var O_EXCL = constants.O_EXCL || 0; +var O_NOCTTY = constants.O_NOCTTY || 0; +var O_NOFOLLOW = constants.O_NOFOLLOW || 0; +var O_RDONLY = constants.O_RDONLY || 0; +var O_RDWR = constants.O_RDWR || 0; +var O_SYMLINK = constants.O_SYMLINK || 0; +var O_SYNC = constants.O_SYNC || 0; +var O_TRUNC = constants.O_TRUNC || 0; +var O_WRONLY = constants.O_WRONLY || 0; + +var isWindows = process.platform === 'win32'; + +var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); + +function rethrow() { + // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and + // is fairly slow to generate. + if (DEBUG) { + var backtrace = new Error; + return function(err) { + if (err) { + backtrace.message = err.message; + err = backtrace; + throw err; + } + }; + } + + return function(err) { + if (err) { + throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs + } + }; +} + +function maybeCallback(cb) { + return typeof cb === 'function' ? cb : rethrow(); +} + +// Ensure that callbacks run in the global context. Only use this function +// for callbacks that are passed to the binding layer, callbacks that are +// invoked from JS already run in the proper scope. +function makeCallback(cb) { + if (typeof cb !== 'function') { + return rethrow(); + } + + return function() { + return cb.apply(null, arguments); + }; +} + +function assertEncoding(encoding) { + if (encoding && !Buffer.isEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +function nullCheck(path, callback) { + if (('' + path).indexOf('\u0000') !== -1) { + var er = new Error('Path must be a string without null bytes.'); + if (!callback) + throw er; + process.nextTick(function() { + callback(er); + }); + return false; + } + return true; +} + +fs.Stats = binding.Stats; + +fs.Stats.prototype._checkModeProperty = function(property) { + return ((this.mode & constants.S_IFMT) === property); +}; + +fs.Stats.prototype.isDirectory = function() { + return this._checkModeProperty(constants.S_IFDIR); +}; + +fs.Stats.prototype.isFile = function() { + return this._checkModeProperty(constants.S_IFREG); +}; + +fs.Stats.prototype.isBlockDevice = function() { + return this._checkModeProperty(constants.S_IFBLK); +}; + +fs.Stats.prototype.isCharacterDevice = function() { + return this._checkModeProperty(constants.S_IFCHR); +}; + +fs.Stats.prototype.isSymbolicLink = function() { + return this._checkModeProperty(constants.S_IFLNK); +}; + +fs.Stats.prototype.isFIFO = function() { + return this._checkModeProperty(constants.S_IFIFO); +}; + +fs.Stats.prototype.isSocket = function() { + return this._checkModeProperty(constants.S_IFSOCK); +}; + +fs.exists = function(path, callback) { + if (!nullCheck(path, cb)) return; + binding.stat(pathModule._makeLong(path), cb); + function cb(err, stats) { + if (callback) callback(err ? false : true); + } +}; + +fs.existsSync = function(path) { + try { + nullCheck(path); + binding.stat(pathModule._makeLong(path)); + return true; + } catch (e) { + return false; + } +}; + +fs.readFile = function(path, encoding_) { + var encoding = typeof(encoding_) === 'string' ? encoding_ : null; + var callback = maybeCallback(arguments[arguments.length - 1]); + + assertEncoding(encoding); + + // first, stat the file, so we know the size. + var size; + var buffer; // single buffer with file data + var buffers; // list for when size is unknown + var pos = 0; + var fd; + + fs.open(path, constants.O_RDONLY, 438 /*=0666*/, function(er, fd_) { + if (er) return callback(er); + fd = fd_; + + fs.fstat(fd, function(er, st) { + if (er) return callback(er); + size = st.size; + if (size === 0) { + // the kernel lies about many files. + // Go ahead and try to read some bytes. + buffers = []; + return read(); + } + + buffer = new Buffer(size); + read(); + }); + }); + + function read() { + if (size === 0) { + buffer = new Buffer(8192); + fs.read(fd, buffer, 0, 8192, -1, afterRead); + } else { + fs.read(fd, buffer, pos, size - pos, -1, afterRead); + } + } + + function afterRead(er, bytesRead) { + if (er) { + return fs.close(fd, function(er2) { + return callback(er); + }); + } + + if (bytesRead === 0) { + return close(); + } + + pos += bytesRead; + if (size !== 0) { + if (pos === size) close(); + else read(); + } else { + // unknown size, just read until we don't get bytes. + buffers.push(buffer.slice(0, bytesRead)); + read(); + } + } + + function close() { + fs.close(fd, function(er) { + if (size === 0) { + // collected the data into the buffers list. + buffer = Buffer.concat(buffers, pos); + } else if (pos < size) { + buffer = buffer.slice(0, pos); + } + + if (encoding) buffer = buffer.toString(encoding); + return callback(er, buffer); + }); + } +}; + +fs.readFileSync = function(path, encoding) { + assertEncoding(encoding); + + var fd = fs.openSync(path, constants.O_RDONLY, 438 /*=0666*/); + + var size; + var threw = true; + try { + size = fs.fstatSync(fd).size; + threw = false; + } finally { + if (threw) fs.closeSync(fd); + } + + var pos = 0; + var buffer; // single buffer with file data + var buffers; // list for when size is unknown + + if (size === 0) { + buffers = []; + } else { + buffer = new Buffer(size); + } + + var done = false; + while (!done) { + var threw = true; + try { + if (size !== 0) { + var bytesRead = fs.readSync(fd, buffer, pos, size - pos); + } else { + // the kernel lies about many files. + // Go ahead and try to read some bytes. + buffer = new Buffer(8192); + var bytesRead = fs.readSync(fd, buffer, 0, 8192); + if (bytesRead) { + buffers.push(buffer.slice(0, bytesRead)); + } + } + threw = false; + } finally { + if (threw) fs.closeSync(fd); + } + + pos += bytesRead; + done = (bytesRead === 0) || (size !== 0 && pos >= size); + } + + fs.closeSync(fd); + + if (size === 0) { + // data was collected into the buffers list. + buffer = Buffer.concat(buffers, pos); + } else if (pos < size) { + buffer = buffer.slice(0, pos); + } + + if (encoding) buffer = buffer.toString(encoding); + return buffer; +}; + + +// Used by binding.open and friends +function stringToFlags(flag) { + // Only mess with strings + if (typeof flag !== 'string') { + return flag; + } + + // O_EXCL is mandated by POSIX, Windows supports it too. + // Let's add a check anyway, just in case. + if (!O_EXCL && ~flag.indexOf('x')) { + throw errnoException('ENOSYS', 'fs.open(O_EXCL)'); + } + + switch (flag) { + case 'r' : return O_RDONLY; + case 'rs' : return O_RDONLY | O_SYNC; + case 'r+' : return O_RDWR; + case 'rs+' : return O_RDWR | O_SYNC; + + case 'w' : return O_TRUNC | O_CREAT | O_WRONLY; + case 'wx' : // fall through + case 'xw' : return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL; + + case 'w+' : return O_TRUNC | O_CREAT | O_RDWR; + case 'wx+': // fall through + case 'xw+': return O_TRUNC | O_CREAT | O_RDWR | O_EXCL; + + case 'a' : return O_APPEND | O_CREAT | O_WRONLY; + case 'ax' : // fall through + case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL; + + case 'a+' : return O_APPEND | O_CREAT | O_RDWR; + case 'ax+': // fall through + case 'xa+': return O_APPEND | O_CREAT | O_RDWR | O_EXCL; + } + + throw new Error('Unknown file open flag: ' + flag); +} + +// exported but hidden, only used by test/simple/test-fs-open-flags.js +Object.defineProperty(exports, '_stringToFlags', { + enumerable: false, + value: stringToFlags +}); + + +// Yes, the follow could be easily DRYed up but I provide the explicit +// list to make the arguments clear. + +fs.close = function(fd, callback) { + binding.close(fd, makeCallback(callback)); +}; + +fs.closeSync = function(fd) { + return binding.close(fd); +}; + +function modeNum(m, def) { + switch (typeof m) { + case 'number': return m; + case 'string': return parseInt(m, 8); + default: + if (def) { + return modeNum(def); + } else { + return undefined; + } + } +} + +fs.open = function(path, flags, mode, callback) { + callback = makeCallback(arguments[arguments.length - 1]); + mode = modeNum(mode, 438 /*=0666*/); + + if (!nullCheck(path, callback)) return; + binding.open(pathModule._makeLong(path), + stringToFlags(flags), + mode, + callback); +}; + +fs.openSync = function(path, flags, mode) { + mode = modeNum(mode, 438 /*=0666*/); + nullCheck(path); + return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); +}; + +fs.read = function(fd, buffer, offset, length, position, callback) { + if (!Buffer.isBuffer(buffer)) { + // legacy string interface (fd, length, position, encoding, callback) + var cb = arguments[4], + encoding = arguments[3]; + + assertEncoding(encoding); + + position = arguments[2]; + length = arguments[1]; + buffer = new Buffer(length); + offset = 0; + + callback = function(err, bytesRead) { + if (!cb) return; + + var str = (bytesRead > 0) ? buffer.toString(encoding, 0, bytesRead) : ''; + + (cb)(err, str, bytesRead); + }; + } + + function wrapper(err, bytesRead) { + // Retain a reference to buffer so that it can't be GC'ed too soon. + callback && callback(err, bytesRead || 0, buffer); + } + + binding.read(fd, buffer, offset, length, position, wrapper); +}; + +fs.readSync = function(fd, buffer, offset, length, position) { + var legacy = false; + if (!Buffer.isBuffer(buffer)) { + // legacy string interface (fd, length, position, encoding, callback) + legacy = true; + var encoding = arguments[3]; + + assertEncoding(encoding); + + position = arguments[2]; + length = arguments[1]; + buffer = new Buffer(length); + + offset = 0; + } + + var r = binding.read(fd, buffer, offset, length, position); + if (!legacy) { + return r; + } + + var str = (r > 0) ? buffer.toString(encoding, 0, r) : ''; + return [str, r]; +}; + +fs.write = function(fd, buffer, offset, length, position, callback) { + if (!Buffer.isBuffer(buffer)) { + // legacy string interface (fd, data, position, encoding, callback) + callback = arguments[4]; + position = arguments[2]; + assertEncoding(arguments[3]); + + buffer = new Buffer('' + arguments[1], arguments[3]); + offset = 0; + length = buffer.length; + } + + if (!length) { + if (typeof callback == 'function') { + process.nextTick(function() { + callback(undefined, 0); + }); + } + return; + } + + callback = maybeCallback(callback); + + function wrapper(err, written) { + // Retain a reference to buffer so that it can't be GC'ed too soon. + callback(err, written || 0, buffer); + } + + binding.write(fd, buffer, offset, length, position, wrapper); +}; + +fs.writeSync = function(fd, buffer, offset, length, position) { + if (!Buffer.isBuffer(buffer)) { + // legacy string interface (fd, data, position, encoding) + position = arguments[2]; + assertEncoding(arguments[3]); + + buffer = new Buffer('' + arguments[1], arguments[3]); + offset = 0; + length = buffer.length; + } + if (!length) return 0; + + return binding.write(fd, buffer, offset, length, position); +}; + +fs.rename = function(oldPath, newPath, callback) { + callback = makeCallback(callback); + if (!nullCheck(oldPath, callback)) return; + if (!nullCheck(newPath, callback)) return; + binding.rename(pathModule._makeLong(oldPath), + pathModule._makeLong(newPath), + callback); +}; + +fs.renameSync = function(oldPath, newPath) { + nullCheck(oldPath); + nullCheck(newPath); + return binding.rename(pathModule._makeLong(oldPath), + pathModule._makeLong(newPath)); +}; + +fs.truncate = function(path, len, callback) { + if (typeof path === 'number') { + // legacy + return fs.ftruncate(path, len, callback); + } + if (typeof len === 'function') { + callback = len; + len = 0; + } else if (typeof len === 'undefined') { + len = 0; + } + callback = maybeCallback(callback); + fs.open(path, 'w', function(er, fd) { + if (er) return callback(er); + binding.ftruncate(fd, len, function(er) { + fs.close(fd, function(er2) { + callback(er || er2); + }); + }); + }); +}; + +fs.truncateSync = function(path, len) { + if (typeof path === 'number') { + // legacy + return fs.ftruncateSync(path, len); + } + if (typeof len === 'undefined') { + len = 0; + } + // allow error to be thrown, but still close fd. + var fd = fs.openSync(path, 'w'); + try { + var ret = fs.ftruncateSync(fd, len); + } finally { + fs.closeSync(fd); + } + return ret; +}; + +fs.ftruncate = function(fd, len, callback) { + if (typeof len === 'function') { + callback = len; + len = 0; + } else if (typeof len === 'undefined') { + len = 0; + } + binding.ftruncate(fd, len, makeCallback(callback)); +}; + +fs.ftruncateSync = function(fd, len) { + if (typeof len === 'undefined') { + len = 0; + } + return binding.ftruncate(fd, len); +}; + +fs.rmdir = function(path, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.rmdir(pathModule._makeLong(path), callback); +}; + +fs.rmdirSync = function(path) { + nullCheck(path); + return binding.rmdir(pathModule._makeLong(path)); +}; + +fs.fdatasync = function(fd, callback) { + binding.fdatasync(fd, makeCallback(callback)); +}; + +fs.fdatasyncSync = function(fd) { + return binding.fdatasync(fd); +}; + +fs.fsync = function(fd, callback) { + binding.fsync(fd, makeCallback(callback)); +}; + +fs.fsyncSync = function(fd) { + return binding.fsync(fd); +}; + +fs.mkdir = function(path, mode, callback) { + if (typeof mode === 'function') callback = mode; + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.mkdir(pathModule._makeLong(path), + modeNum(mode, 511 /*=0777*/), + callback); +}; + +fs.mkdirSync = function(path, mode) { + nullCheck(path); + return binding.mkdir(pathModule._makeLong(path), + modeNum(mode, 511 /*=0777*/)); +}; + +fs.sendfile = function(outFd, inFd, inOffset, length, callback) { + binding.sendfile(outFd, inFd, inOffset, length, makeCallback(callback)); +}; + +fs.sendfileSync = function(outFd, inFd, inOffset, length) { + return binding.sendfile(outFd, inFd, inOffset, length); +}; + +fs.readdir = function(path, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.readdir(pathModule._makeLong(path), callback); +}; + +fs.readdirSync = function(path) { + nullCheck(path); + return binding.readdir(pathModule._makeLong(path)); +}; + +fs.fstat = function(fd, callback) { + binding.fstat(fd, makeCallback(callback)); +}; + +fs.lstat = function(path, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.lstat(pathModule._makeLong(path), callback); +}; + +fs.stat = function(path, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.stat(pathModule._makeLong(path), callback); +}; + +fs.fstatSync = function(fd) { + return binding.fstat(fd); +}; + +fs.lstatSync = function(path) { + nullCheck(path); + return binding.lstat(pathModule._makeLong(path)); +}; + +fs.statSync = function(path) { + nullCheck(path); + return binding.stat(pathModule._makeLong(path)); +}; + +fs.readlink = function(path, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.readlink(pathModule._makeLong(path), callback); +}; + +fs.readlinkSync = function(path) { + nullCheck(path); + return binding.readlink(pathModule._makeLong(path)); +}; + +function preprocessSymlinkDestination(path, type) { + if (!isWindows) { + // No preprocessing is needed on Unix. + return path; + } else if (type === 'junction') { + // Junctions paths need to be absolute and \\?\-prefixed. + return pathModule._makeLong(path); + } else { + // Windows symlinks don't tolerate forward slashes. + return ('' + path).replace(/\//g, '\\'); + } +} + +fs.symlink = function(destination, path, type_, callback) { + var type = (typeof type_ === 'string' ? type_ : null); + var callback = makeCallback(arguments[arguments.length - 1]); + + if (!nullCheck(destination, callback)) return; + if (!nullCheck(path, callback)) return; + + binding.symlink(preprocessSymlinkDestination(destination, type), + pathModule._makeLong(path), + type, + callback); +}; + +fs.symlinkSync = function(destination, path, type) { + type = (typeof type === 'string' ? type : null); + + nullCheck(destination); + nullCheck(path); + + return binding.symlink(preprocessSymlinkDestination(destination, type), + pathModule._makeLong(path), + type); +}; + +fs.link = function(srcpath, dstpath, callback) { + callback = makeCallback(callback); + if (!nullCheck(srcpath, callback)) return; + if (!nullCheck(dstpath, callback)) return; + + binding.link(pathModule._makeLong(srcpath), + pathModule._makeLong(dstpath), + callback); +}; + +fs.linkSync = function(srcpath, dstpath) { + nullCheck(srcpath); + nullCheck(dstpath); + return binding.link(pathModule._makeLong(srcpath), + pathModule._makeLong(dstpath)); +}; + +fs.unlink = function(path, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.unlink(pathModule._makeLong(path), callback); +}; + +fs.unlinkSync = function(path) { + nullCheck(path); + return binding.unlink(pathModule._makeLong(path)); +}; + +fs.fchmod = function(fd, mode, callback) { + binding.fchmod(fd, modeNum(mode), makeCallback(callback)); +}; + +fs.fchmodSync = function(fd, mode) { + return binding.fchmod(fd, modeNum(mode)); +}; + +if (constants.hasOwnProperty('O_SYMLINK')) { + fs.lchmod = function(path, mode, callback) { + callback = maybeCallback(callback); + fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function(err, fd) { + if (err) { + callback(err); + return; + } + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. + fs.fchmod(fd, mode, function(err) { + fs.close(fd, function(err2) { + callback(err || err2); + }); + }); + }); + }; + + fs.lchmodSync = function(path, mode) { + var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK); + + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. + var err, err2; + try { + var ret = fs.fchmodSync(fd, mode); + } catch (er) { + err = er; + } + try { + fs.closeSync(fd); + } catch (er) { + err2 = er; + } + if (err || err2) throw (err || err2); + return ret; + }; +} + + +fs.chmod = function(path, mode, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.chmod(pathModule._makeLong(path), + modeNum(mode), + callback); +}; + +fs.chmodSync = function(path, mode) { + nullCheck(path); + return binding.chmod(pathModule._makeLong(path), modeNum(mode)); +}; + +if (constants.hasOwnProperty('O_SYMLINK')) { + fs.lchown = function(path, uid, gid, callback) { + callback = maybeCallback(callback); + fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function(err, fd) { + if (err) { + callback(err); + return; + } + fs.fchown(fd, uid, gid, callback); + }); + }; + + fs.lchownSync = function(path, uid, gid) { + var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK); + return fs.fchownSync(fd, uid, gid); + }; +} + +fs.fchown = function(fd, uid, gid, callback) { + binding.fchown(fd, uid, gid, makeCallback(callback)); +}; + +fs.fchownSync = function(fd, uid, gid) { + return binding.fchown(fd, uid, gid); +}; + +fs.chown = function(path, uid, gid, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.chown(pathModule._makeLong(path), uid, gid, callback); +}; + +fs.chownSync = function(path, uid, gid) { + nullCheck(path); + return binding.chown(pathModule._makeLong(path), uid, gid); +}; + +// converts Date or number to a fractional UNIX timestamp +function toUnixTimestamp(time) { + if (typeof time == 'number') { + return time; + } + if (time instanceof Date) { + // convert to 123.456 UNIX timestamp + return time.getTime() / 1000; + } + throw new Error('Cannot parse time: ' + time); +} + +// exported for unit tests, not for public consumption +fs._toUnixTimestamp = toUnixTimestamp; + +fs.utimes = function(path, atime, mtime, callback) { + callback = makeCallback(callback); + if (!nullCheck(path, callback)) return; + binding.utimes(pathModule._makeLong(path), + toUnixTimestamp(atime), + toUnixTimestamp(mtime), + callback); +}; + +fs.utimesSync = function(path, atime, mtime) { + nullCheck(path); + atime = toUnixTimestamp(atime); + mtime = toUnixTimestamp(mtime); + binding.utimes(pathModule._makeLong(path), atime, mtime); +}; + +fs.futimes = function(fd, atime, mtime, callback) { + atime = toUnixTimestamp(atime); + mtime = toUnixTimestamp(mtime); + binding.futimes(fd, atime, mtime, makeCallback(callback)); +}; + +fs.futimesSync = function(fd, atime, mtime) { + atime = toUnixTimestamp(atime); + mtime = toUnixTimestamp(mtime); + binding.futimes(fd, atime, mtime); +}; + +function writeAll(fd, buffer, offset, length, position, callback) { + callback = maybeCallback(arguments[arguments.length - 1]); + + // write(fd, buffer, offset, length, position, callback) + fs.write(fd, buffer, offset, length, position, function(writeErr, written) { + if (writeErr) { + fs.close(fd, function() { + if (callback) callback(writeErr); + }); + } else { + if (written === length) { + fs.close(fd, callback); + } else { + offset += written; + length -= written; + position += written; + writeAll(fd, buffer, offset, length, position, callback); + } + } + }); +} + +fs.writeFile = function(path, data, encoding_, callback) { + var encoding = (typeof(encoding_) == 'string' ? encoding_ : 'utf8'); + assertEncoding(encoding); + + callback = maybeCallback(arguments[arguments.length - 1]); + fs.open(path, 'w', 438 /*=0666*/, function(openErr, fd) { + if (openErr) { + if (callback) callback(openErr); + } else { + var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data, + encoding); + writeAll(fd, buffer, 0, buffer.length, 0, callback); + } + }); +}; + +fs.writeFileSync = function(path, data, encoding) { + assertEncoding(encoding); + + var fd = fs.openSync(path, 'w'); + if (!Buffer.isBuffer(data)) { + data = new Buffer('' + data, encoding || 'utf8'); + } + var written = 0; + var length = data.length; + try { + while (written < length) { + written += fs.writeSync(fd, data, written, length - written, written); + } + } finally { + fs.closeSync(fd); + } +}; + +fs.appendFile = function(path, data, encoding_, callback) { + var encoding = (typeof(encoding_) == 'string' ? encoding_ : 'utf8'); + assertEncoding(encoding); + + callback = maybeCallback(arguments[arguments.length - 1]); + + fs.open(path, 'a', 438 /*=0666*/, function(err, fd) { + if (err) return callback(err); + var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data, encoding); + writeAll(fd, buffer, 0, buffer.length, null, callback); + }); +}; + +fs.appendFileSync = function(path, data, encoding) { + assertEncoding(encoding); + + var fd = fs.openSync(path, 'a'); + if (!Buffer.isBuffer(data)) { + data = new Buffer('' + data, encoding || 'utf8'); + } + var written = 0; + var position = null; + var length = data.length; + + try { + while (written < length) { + written += fs.writeSync(fd, data, written, length - written, position); + position += written; // XXX not safe with multiple concurrent writers? + } + } finally { + fs.closeSync(fd); + } +}; + +function errnoException(errorno, syscall) { + // TODO make this more compatible with ErrnoException from src/node.cc + // Once all of Node is using this function the ErrnoException from + // src/node.cc should be removed. + var e = new Error(syscall + ' ' + errorno); + e.errno = e.code = errorno; + e.syscall = syscall; + return e; +} + + +function FSWatcher() { + EventEmitter.call(this); + + var self = this; + var FSEvent = process.binding('fs_event_wrap').FSEvent; + this._handle = new FSEvent(); + this._handle.owner = this; + + this._handle.onchange = function(status, event, filename) { + if (status) { + self._handle.close(); + self.emit('error', errnoException(errno, 'watch')); + } else { + self.emit('change', event, filename); + } + }; +} +util.inherits(FSWatcher, EventEmitter); + +FSWatcher.prototype.start = function(filename, persistent) { + nullCheck(filename); + var r = this._handle.start(pathModule._makeLong(filename), persistent); + + if (r) { + this._handle.close(); + throw errnoException(errno, 'watch'); + } +}; + +FSWatcher.prototype.close = function() { + this._handle.close(); +}; + +fs.watch = function(filename) { + nullCheck(filename); + var watcher; + var options; + var listener; + + if ('object' == typeof arguments[1]) { + options = arguments[1]; + listener = arguments[2]; + } else { + options = {}; + listener = arguments[1]; + } + + if (options.persistent === undefined) options.persistent = true; + + watcher = new FSWatcher(); + watcher.start(filename, options.persistent); + + if (listener) { + watcher.addListener('change', listener); + } + + return watcher; +}; + + +// Stat Change Watchers + +function StatWatcher() { + EventEmitter.call(this); + + var self = this; + this._handle = new binding.StatWatcher(); + + // uv_fs_poll is a little more powerful than ev_stat but we curb it for + // the sake of backwards compatibility + var oldStatus = -1; + + this._handle.onchange = function(current, previous, newStatus) { + if (oldStatus === -1 && + newStatus === -1 && + current.nlink === previous.nlink) return; + + oldStatus = newStatus; + self.emit('change', current, previous); + }; + + this._handle.onstop = function() { + self.emit('stop'); + }; +} +util.inherits(StatWatcher, EventEmitter); + + +StatWatcher.prototype.start = function(filename, persistent, interval) { + nullCheck(filename); + this._handle.start(pathModule._makeLong(filename), persistent, interval); +}; + + +StatWatcher.prototype.stop = function() { + this._handle.stop(); +}; + + +var statWatchers = {}; +function inStatWatchers(filename) { + return Object.prototype.hasOwnProperty.call(statWatchers, filename) && + statWatchers[filename]; +} + + +fs.watchFile = function(filename) { + nullCheck(filename); + var stat; + var listener; + + var options = { + // Poll interval in milliseconds. 5007 is what libev used to use. It's + // a little on the slow side but let's stick with it for now to keep + // behavioral changes to a minimum. + interval: 5007, + persistent: true + }; + + if ('object' == typeof arguments[1]) { + options = util._extend(options, arguments[1]); + listener = arguments[2]; + } else { + listener = arguments[1]; + } + + if (!listener) { + throw new Error('watchFile requires a listener function'); + } + + if (inStatWatchers(filename)) { + stat = statWatchers[filename]; + } else { + stat = statWatchers[filename] = new StatWatcher(); + stat.start(filename, options.persistent, options.interval); + } + stat.addListener('change', listener); + return stat; +}; + +fs.unwatchFile = function(filename, listener) { + nullCheck(filename); + if (!inStatWatchers(filename)) return; + + var stat = statWatchers[filename]; + + if (typeof listener === 'function') { + stat.removeListener('change', listener); + } else { + stat.removeAllListeners('change'); + } + + if (stat.listeners('change').length === 0) { + stat.stop(); + statWatchers[filename] = undefined; + } +}; + +// Realpath +// Not using realpath(2) because it's bad. +// See: http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html + +var normalize = pathModule.normalize; + +// Regexp that finds the next partion of a (partial) path +// result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] +if (isWindows) { + var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; +} else { + var nextPartRe = /(.*?)(?:[\/]+|$)/g; +} + +// Regex to find the device root, including trailing slash. E.g. 'c:\\'. +if (isWindows) { + var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; +} else { + var splitRootRe = /^[\/]*/; +} + +fs.realpathSync = function realpathSync(p, cache) { + // make p is absolute + p = pathModule.resolve(p); + + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return cache[p]; + } + + var original = p, + seenLinks = {}, + knownHard = {}; + + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; + + start(); + + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; + + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs.lstatSync(base); + knownHard[base] = true; + } + } + + // walk down the path, swapping out linked pathparts for their real + // values + // NB: p.length changes. + while (pos < p.length) { + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; + + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + continue; + } + + var resolvedLink; + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // some known symbolic link. no need to stat again. + resolvedLink = cache[base]; + } else { + var stat = fs.lstatSync(base); + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + continue; + } + + // read the link if it wasn't read before + // dev/ino always return 0 on windows, so skip the check. + var linkTarget = null; + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + linkTarget = seenLinks[id]; + } + } + if (linkTarget === null) { + fs.statSync(base); + linkTarget = fs.readlinkSync(base); + } + resolvedLink = pathModule.resolve(previous, linkTarget); + // track this, if given a cache. + if (cache) cache[base] = resolvedLink; + if (!isWindows) seenLinks[id] = linkTarget; + } + + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } + + if (cache) cache[original] = p; + + return p; +}; + + +fs.realpath = function realpath(p, cache, cb) { + if (typeof cb !== 'function') { + cb = maybeCallback(cache); + cache = null; + } + + // make p is absolute + p = pathModule.resolve(p); + + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return process.nextTick(cb.bind(null, null, cache[p])); + } + + var original = p, + seenLinks = {}, + knownHard = {}; + + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; + + start(); + + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; + + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs.lstat(base, function(err) { + if (err) return cb(err); + knownHard[base] = true; + LOOP(); + }); + } else { + process.nextTick(LOOP); + } + } + + // walk down the path, swapping out linked pathparts for their real + // values + function LOOP() { + // stop if scanned past end of path + if (pos >= p.length) { + if (cache) cache[original] = p; + return cb(null, p); + } + + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; + + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + return process.nextTick(LOOP); + } + + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // known symbolic link. no need to stat again. + return gotResolvedLink(cache[base]); + } + + return fs.lstat(base, gotStat); + } + + function gotStat(err, stat) { + if (err) return cb(err); + + // if not a symlink, skip to the next path part + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + return process.nextTick(LOOP); + } + + // stat & read the link if not read before + // call gotTarget as soon as the link target is known + // dev/ino always return 0 on windows, so skip the check. + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + return gotTarget(null, seenLinks[id], base); + } + } + fs.stat(base, function(err) { + if (err) return cb(err); + + fs.readlink(base, function(err, target) { + if (!isWindows) seenLinks[id] = target; + gotTarget(err, target); + }); + }); + } + + function gotTarget(err, target, base) { + if (err) return cb(err); + + var resolvedLink = pathModule.resolve(previous, target); + if (cache) cache[base] = resolvedLink; + gotResolvedLink(resolvedLink); + } + + function gotResolvedLink(resolvedLink) { + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } +}; + + + +var pool; + +function allocNewPool() { + pool = new Buffer(kPoolSize); + pool.used = 0; +} + + + +fs.createReadStream = function(path, options) { + return new ReadStream(path, options); +}; + +util.inherits(ReadStream, Readable); +fs.ReadStream = ReadStream; + +function ReadStream(path, options) { + if (!(this instanceof ReadStream)) + return new ReadStream(path, options); + + // a little bit bigger buffer and water marks by default + options = util._extend({ + bufferSize: 64 * 1024, + lowWaterMark: 16 * 1024, + highWaterMark: 64 * 1024 + }, options || {}); + + Readable.call(this, options); + + this.path = path; + this.fd = options.hasOwnProperty('fd') ? options.fd : null; + this.flags = options.hasOwnProperty('flags') ? options.flags : 'r'; + this.mode = options.hasOwnProperty('mode') ? options.mode : 438; /*=0666*/ + + this.start = options.hasOwnProperty('start') ? options.start : undefined; + this.end = options.hasOwnProperty('start') ? options.end : undefined; + this.pos = undefined; + + if (this.start !== undefined) { + if ('number' !== typeof this.start) { + throw TypeError('start must be a Number'); + } + if (this.end === undefined) { + this.end = Infinity; + } else if ('number' !== typeof this.end) { + throw TypeError('end must be a Number'); + } + + if (this.start > this.end) { + throw new Error('start must be <= end'); + } + + this.pos = this.start; + } + + if (typeof this.fd !== 'number') + this.open(); + + this.on('end', function() { + this.destroy(); + }); +} + +fs.FileReadStream = fs.ReadStream; // support the legacy name + +ReadStream.prototype.open = function() { + var self = this; + fs.open(this.path, this.flags, this.mode, function(er, fd) { + if (er) { + self.destroy(); + self.emit('error', er); + return; + } + + self.fd = fd; + self.emit('open', fd); + // start the flow of data. + self.read(); + }); +}; + +ReadStream.prototype._read = function(n, cb) { + if (typeof this.fd !== 'number') + return this.once('open', function() { + this._read(n, cb); + }); + + if (this.destroyed) + return; + + if (!pool || pool.length - pool.used < kMinPoolSpace) { + // discard the old pool. Can't add to the free list because + // users might have refernces to slices on it. + pool = null; + allocNewPool(); + } + + // Grab another reference to the pool in the case that while we're + // in the thread pool another read() finishes up the pool, and + // allocates a new one. + var thisPool = pool; + var toRead = Math.min(pool.length - pool.used, n); + var start = pool.used; + + if (this.pos !== undefined) + toRead = Math.min(this.end - this.pos + 1, toRead); + + // already read everything we were supposed to read! + // treat as EOF. + if (toRead <= 0) + return cb(); + + // the actual read. + var self = this; + fs.read(this.fd, pool, pool.used, toRead, this.pos, onread); + + // move the pool positions, and internal position for reading. + if (this.pos !== undefined) + this.pos += toRead; + pool.used += toRead; + + function onread(er, bytesRead) { + if (er) { + self.destroy(); + return cb(er); + } + + var b = null; + if (bytesRead > 0) + b = thisPool.slice(start, start + bytesRead); + + cb(null, b); + } +}; + + +ReadStream.prototype.destroy = function() { + if (this.destroyed) + return; + this.destroyed = true; + if ('number' === typeof this.fd) + this.close(); +}; + + +ReadStream.prototype.close = function(cb) { + if (cb) + this.once('close', cb); + if (this.closed || 'number' !== typeof this.fd) { + if ('number' !== typeof this.fd) + this.once('open', close); + return process.nextTick(this.emit.bind(this, 'close')); + } + this.closed = true; + var self = this; + close(); + + function close() { + fs.close(self.fd, function(er) { + if (er) + self.emit('error', er); + else + self.emit('close'); + }); + } +}; + + + + +fs.createWriteStream = function(path, options) { + return new WriteStream(path, options); +}; + +util.inherits(WriteStream, Writable); +fs.WriteStream = WriteStream; +function WriteStream(path, options) { + if (!(this instanceof WriteStream)) + return new WriteStream(path, options); + + // a little bit bigger buffer and water marks by default + options = util._extend({ + bufferSize: 64 * 1024, + lowWaterMark: 16 * 1024, + highWaterMark: 64 * 1024 + }, options || {}); + + Writable.call(this, options); + + this.path = path; + this.fd = null; + + this.fd = options.hasOwnProperty('fd') ? options.fd : null; + this.flags = options.hasOwnProperty('flags') ? options.flags : 'w'; + this.mode = options.hasOwnProperty('mode') ? options.mode : 438; /*=0666*/ + + this.start = options.hasOwnProperty('start') ? options.start : undefined; + this.pos = undefined; + this.bytesWritten = 0; + + if (this.start !== undefined) { + if ('number' !== typeof this.start) { + throw TypeError('start must be a Number'); + } + if (this.start < 0) { + throw new Error('start must be >= zero'); + } + + this.pos = this.start; + } + + if ('number' !== typeof this.fd) + this.open(); + + // dispose on finish. + this.once('finish', this.close); +} + +fs.FileWriteStream = fs.WriteStream; // support the legacy name + + +WriteStream.prototype.open = function() { + fs.open(this.path, this.flags, this.mode, function(er, fd) { + if (er) { + this.destroy(); + this.emit('error', er); + return; + } + + this.fd = fd; + this.emit('open', fd); + }.bind(this)); +}; + + +WriteStream.prototype._write = function(data, cb) { + if (!Buffer.isBuffer(data)) + return this.emit('error', new Error('Invalid data')); + + if (typeof this.fd !== 'number') + return this.once('open', this._write.bind(this, data, cb)); + + fs.write(this.fd, data, 0, data.length, this.pos, function(er, bytes) { + if (er) { + this.destroy(); + return cb(er); + } + this.bytesWritten += bytes; + cb(); + }.bind(this)); + + if (this.pos !== undefined) + this.pos += data.length; +}; + + +WriteStream.prototype.destroy = ReadStream.prototype.destroy; +WriteStream.prototype.close = ReadStream.prototype.close; + +// There is no shutdown() for files. +WriteStream.prototype.destroySoon = WriteStream.prototype.end; + + +// SyncWriteStream is internal. DO NOT USE. +// Temporary hack for process.stdout and process.stderr when piped to files. +function SyncWriteStream(fd) { + Stream.call(this); + + this.fd = fd; + this.writable = true; + this.readable = false; +} + +util.inherits(SyncWriteStream, Stream); + + +// Export +fs.SyncWriteStream = SyncWriteStream; + + +SyncWriteStream.prototype.write = function(data, arg1, arg2) { + var encoding, cb; + + // parse arguments + if (arg1) { + if (typeof arg1 === 'string') { + encoding = arg1; + cb = arg2; + } else if (typeof arg1 === 'function') { + cb = arg1; + } else { + throw new Error('bad arg'); + } + } + assertEncoding(encoding); + + // Change strings to buffers. SLOW + if (typeof data == 'string') { + data = new Buffer(data, encoding); + } + + fs.writeSync(this.fd, data, 0, data.length); + + if (cb) { + process.nextTick(cb); + } + + return true; +}; + + +SyncWriteStream.prototype.end = function(data, arg1, arg2) { + if (data) { + this.write(data, arg1, arg2); + } + this.destroy(); +}; + + +SyncWriteStream.prototype.destroy = function() { + fs.closeSync(this.fd); + this.fd = null; + this.emit('close'); + return true; +}; + +SyncWriteStream.prototype.destroySoon = SyncWriteStream.prototype.destroy; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js new file mode 100644 index 00000000..a2e0d8e0 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js @@ -0,0 +1,69 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +module.exports = Duplex; +var util = require('util'); +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +Object.keys(Writable.prototype).forEach(function(method) { + if (!Duplex.prototype[method]) + Duplex.prototype[method] = Writable.prototype[method]; +}); + +function Duplex(options) { + if (!(this instanceof Duplex)) + return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) + this.readable = false; + + if (options && options.writable === false) + this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) + this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) + return; + + // no more data can be written. + // But allow more writes to happen in this tick. + process.nextTick(this.end.bind(this)); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js new file mode 100644 index 00000000..3c9da084 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js @@ -0,0 +1,927 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +module.exports = Readable; +Readable.ReadableState = ReadableState; + +var EE = require('events').EventEmitter; +if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { + return emitter.listeners(type).length; +}; +var Stream = require('stream'); +var util = require('util'); +var StringDecoder; + +util.inherits(Readable, Stream); + +function ReadableState(options, stream) { + options = options || {}; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = false; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // In streams that never have any data, and do push(null) right away, + // the consumer can miss the 'end' event if they do some I/O before + // consuming the stream. So, we don't emit('end') until some reading + // happens. + this.calledRead = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, becuase any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) + StringDecoder = require('string_decoder').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + if (!(this instanceof Readable)) + return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function(chunk, encoding) { + var state = this._readableState; + + if (typeof chunk === 'string' && !state.objectMode) { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function(chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null || chunk === undefined) { + state.reading = false; + if (!state.ended) + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + if (state.decoder && !addToFront && !encoding) + chunk = state.decoder.write(chunk); + + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) { + state.buffer.unshift(chunk); + } else { + state.reading = false; + state.buffer.push(chunk); + } + + if (state.needReadable) + emitReadable(stream); + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + + + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && + (state.needReadable || + state.length < state.highWaterMark || + state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function(enc) { + if (!StringDecoder) + StringDecoder = require('string_decoder').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; +}; + +// Don't raise the hwm > 128MB +var MAX_HWM = 0x800000; +function roundUpToNextPowerOf2(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + for (var p = 1; p < 32; p <<= 1) n |= n >> p; + n++; + } + return n; +} + +function howMuchToRead(n, state) { + if (state.length === 0 && state.ended) + return 0; + + if (state.objectMode) + return n === 0 ? 0 : 1; + + if (isNaN(n) || n === null) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) + return state.buffer[0].length; + else + return state.length; + } + + if (n <= 0) + return 0; + + // If we're asking for more than the target buffer level, + // then raise the water mark. Bump up to the next highest + // power of 2, to prevent increasing it excessively in tiny + // amounts. + if (n > state.highWaterMark) + state.highWaterMark = roundUpToNextPowerOf2(n); + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else + return state.length; + } + + return n; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function(n) { + var state = this._readableState; + state.calledRead = true; + var nOrig = n; + + if (typeof n !== 'number' || n > 0) + state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && + state.needReadable && + (state.length >= state.highWaterMark || state.ended)) { + emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) + endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + + // if we currently have less than the highWaterMark, then also read some + if (state.length - n <= state.highWaterMark) + doRead = true; + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) + doRead = false; + + if (doRead) { + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) + state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + } + + // If _read called its callback synchronously, then `reading` + // will be false, and we need to re-evaluate how much data we + // can return to the user. + if (doRead && !state.reading) + n = howMuchToRead(nOrig, state); + + var ret; + if (n > 0) + ret = fromList(n, state); + else + ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } + + state.length -= n; + + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (state.length === 0 && !state.ended) + state.needReadable = true; + + // If we happened to read() exactly the remaining amount in the + // buffer, and the EOF has been seen at this point, then make sure + // that we emit 'end' on the very next tick. + if (state.ended && !state.endEmitted && state.length === 0) + endReadable(this); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!Buffer.isBuffer(chunk) && + 'string' !== typeof chunk && + chunk !== null && + chunk !== undefined && + !state.objectMode && + !er) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + + +function onEofChunk(stream, state) { + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // if we've ended and we have some data left, then emit + // 'readable' now to make sure it gets picked up. + if (state.length > 0) + emitReadable(stream); + else + endReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (state.emittedReadable) + return; + + state.emittedReadable = true; + if (state.sync) + process.nextTick(function() { + emitReadable_(stream); + }); + else + emitReadable_(stream); +} + +function emitReadable_(stream) { + stream.emit('readable'); +} + + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(function() { + maybeReadMore_(stream, state); + }); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && + state.length < state.highWaterMark) { + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break; + else + len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function(n) { + this.emit('error', new Error('not implemented')); +}; + +Readable.prototype.pipe = function(dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && + dest !== process.stdout && + dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) + process.nextTick(endFn); + else + src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + if (readable !== src) return; + cleanup(); + } + + function onend() { + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + function cleanup() { + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (!dest._writableState || dest._writableState.needDrain) + ondrain(); + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + unpipe(); + dest.removeListener('error', onerror); + if (EE.listenerCount(dest, 'error') === 0) + dest.emit('error', er); + } + // This is a brutally ugly hack to make sure that our error handler + // is attached before any userland ones. NEVER DO THIS. + if (!dest._events.error) + dest.on('error', onerror); + else if (Array.isArray(dest._events.error)) + dest._events.error.unshift(onerror); + else + dest._events.error = [onerror, dest._events.error]; + + + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + // the handler that waits for readable events after all + // the data gets sucked out in flow. + // This would be easier to follow with a .once() handler + // in flow(), but that is too slow. + this.on('readable', pipeOnReadable); + + state.flowing = true; + process.nextTick(function() { + flow(src); + }); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function() { + var dest = this; + var state = src._readableState; + state.awaitDrain--; + if (state.awaitDrain === 0) + flow(src); + }; +} + +function flow(src) { + var state = src._readableState; + var chunk; + state.awaitDrain = 0; + + function write(dest, i, list) { + var written = dest.write(chunk); + if (false === written) { + state.awaitDrain++; + } + } + + while (state.pipesCount && null !== (chunk = src.read())) { + + if (state.pipesCount === 1) + write(state.pipes, 0, null); + else + state.pipes.forEach(write); + + src.emit('data', chunk); + + // if anyone needs a drain, then we have to wait for that. + if (state.awaitDrain > 0) + return; + } + + // if every destination was unpiped, either before entering this + // function, or in the while loop, then stop flowing. + // + // NB: This is a pretty rare edge case. + if (state.pipesCount === 0) { + state.flowing = false; + + // if there were data event listeners added, then switch to old mode. + if (EE.listenerCount(src, 'data') > 0) + emitDataEvents(src); + return; + } + + // at this point, no one needed a drain, so we just ran out of data + // on the next readable event, start it over again. + state.ranOut = true; +} + +function pipeOnReadable() { + if (this._readableState.ranOut) { + this._readableState.ranOut = false; + flow(this); + } +} + + +Readable.prototype.unpipe = function(dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) + return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) + return this; + + if (!dest) + dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + this.removeListener('readable', pipeOnReadable); + state.flowing = false; + if (dest) + dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + this.removeListener('readable', pipeOnReadable); + state.flowing = false; + + for (var i = 0; i < len; i++) + dests[i].emit('unpipe', this); + return this; + } + + // try to find the right one. + var i = state.pipes.indexOf(dest); + if (i === -1) + return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) + state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function(ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data' && !this._readableState.flowing) + emitDataEvents(this); + + if (ev === 'readable' && this.readable) { + var state = this._readableState; + if (!state.readableListening) { + state.readableListening = true; + state.emittedReadable = false; + state.needReadable = true; + if (!state.reading) { + this.read(0); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function() { + emitDataEvents(this); + this.read(0); + this.emit('resume'); +}; + +Readable.prototype.pause = function() { + emitDataEvents(this, true); + this.emit('pause'); +}; + +function emitDataEvents(stream, startPaused) { + var state = stream._readableState; + + if (state.flowing) { + // https://github.com/isaacs/readable-stream/issues/16 + throw new Error('Cannot switch to old mode now.'); + } + + var paused = startPaused || false; + var readable = false; + + // convert to an old-style stream. + stream.readable = true; + stream.pipe = Stream.prototype.pipe; + stream.on = stream.addListener = Stream.prototype.on; + + stream.on('readable', function() { + readable = true; + + var c; + while (!paused && (null !== (c = stream.read()))) + stream.emit('data', c); + + if (c === null) { + readable = false; + stream._readableState.needReadable = true; + } + }); + + stream.pause = function() { + paused = true; + this.emit('pause'); + }; + + stream.resume = function() { + paused = false; + if (readable) + process.nextTick(function() { + stream.emit('readable'); + }); + else + this.read(0); + this.emit('resume'); + }; + + // now make it start, just in case it hadn't already. + stream.emit('readable'); +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function(stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function() { + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) + self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function(chunk) { + if (state.decoder) + chunk = state.decoder.write(chunk); + if (!chunk || !state.objectMode && !chunk.length) + return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (typeof stream[i] === 'function' && + typeof this[i] === 'undefined') { + this[i] = function(method) { return function() { + return stream[method].apply(stream, arguments); + }}(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + events.forEach(function(ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function(n) { + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + + + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +function fromList(n, state) { + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; + var ret; + + // nothing in the list, definitely empty. + if (list.length === 0) + return null; + + if (length === 0) + ret = null; + else if (objectMode) + ret = list.shift(); + else if (!n || n >= length) { + // read it all, truncate the array. + if (stringMode) + ret = list.join(''); + else + ret = Buffer.concat(list, length); + list.length = 0; + } else { + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) + ret = ''; + else + ret = new Buffer(n); + + var c = 0; + for (var i = 0, l = list.length; i < l && c < n; i++) { + var buf = list[0]; + var cpy = Math.min(n - c, buf.length); + + if (stringMode) + ret += buf.slice(0, cpy); + else + buf.copy(ret, c, 0, cpy); + + if (cpy < buf.length) + list[0] = buf.slice(cpy); + else + list.shift(); + + c += cpy; + } + } + } + + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) + throw new Error('endReadable called on non-empty stream'); + + if (!state.endEmitted && state.calledRead) { + state.ended = true; + process.nextTick(function() { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } + }); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js new file mode 100644 index 00000000..f08b05e5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js @@ -0,0 +1,205 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); +var util = require('util'); +util.inherits(Transform, Duplex); + + +function TransformState(options, stream) { + this.afterTransform = function(er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) + return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (data !== null && data !== undefined) + stream.push(data); + + if (cb) + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + + +function Transform(options) { + if (!(this instanceof Transform)) + return new Transform(options); + + Duplex.call(this, options); + + var ts = this._transformState = new TransformState(options, this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + this.once('finish', function() { + if ('function' === typeof this._flush) + this._flush(function(er) { + done(stream, er); + }); + else + done(stream); + }); +} + +Transform.prototype.push = function(chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function(chunk, encoding, cb) { + throw new Error('not implemented'); +}; + +Transform.prototype._write = function(chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || + rs.needReadable || + rs.length < rs.highWaterMark) + this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function(n) { + var ts = this._transformState; + + if (ts.writechunk && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + + +function done(stream, er) { + if (er) + return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var rs = stream._readableState; + var ts = stream._transformState; + + if (ws.length) + throw new Error('calling transform done when ws.length != 0'); + + if (ts.transforming) + throw new Error('calling transform done when still transforming'); + + return stream.push(null); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js new file mode 100644 index 00000000..56ca47dd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js @@ -0,0 +1,367 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, cb), and it'll handle all +// the drain event emission and buffering. + +module.exports = Writable; +Writable.WritableState = WritableState; + +var util = require('util'); +var assert = require('assert'); +var Stream = require('stream'); + +util.inherits(Writable, Stream); + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; +} + +function WritableState(options, stream) { + options = options || {}; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, becuase any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function(er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.buffer = []; +} + +function Writable(options) { + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof require('./_stream_duplex'))) + return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function() { + this.emit('error', new Error('Cannot pipe. Not readable.')); +}; + + +function writeAfterEnd(stream, state, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); +} + +// If we get something that is not a buffer, string, null, or undefined, +// and we're not in objectMode, then that's an error. +// Otherwise stream chunks are all considered to be of length=1, and the +// watermarks determine how many objects to keep in the buffer, rather than +// how many bytes or characters. +function validChunk(stream, state, chunk, cb) { + var valid = true; + if (!Buffer.isBuffer(chunk) && + 'string' !== typeof chunk && + chunk !== null && + chunk !== undefined && + !state.objectMode) { + var er = new TypeError('Invalid non-string/buffer chunk'); + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); + valid = false; + } + return valid; +} + +Writable.prototype.write = function(chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (Buffer.isBuffer(chunk)) + encoding = 'buffer'; + else if (!encoding) + encoding = state.defaultEncoding; + + if (typeof cb !== 'function') + cb = function() {}; + + if (state.ended) + writeAfterEnd(this, state, cb); + else if (validChunk(this, state, chunk, cb)) + ret = writeOrBuffer(this, state, chunk, encoding, cb); + + return ret; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && + state.decodeStrings !== false && + typeof chunk === 'string') { + chunk = new Buffer(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + state.needDrain = !ret; + + if (state.writing) + state.buffer.push(new WriteReq(chunk, encoding, cb)); + else + doWrite(stream, state, len, chunk, encoding, cb); + + return ret; +} + +function doWrite(stream, state, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + if (sync) + process.nextTick(function() { + cb(er); + }); + else + cb(er); + + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) + onwriteError(stream, state, sync, er, cb); + else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(stream, state); + + if (!finished && !state.bufferProcessing && state.buffer.length) + clearBuffer(stream, state); + + if (sync) { + process.nextTick(function() { + afterWrite(stream, state, finished, cb); + }); + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) + onwriteDrain(stream, state); + cb(); + if (finished) + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + + for (var c = 0; c < state.buffer.length; c++) { + var entry = state.buffer[c]; + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, len, chunk, encoding, cb); + + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + c++; + break; + } + } + + state.bufferProcessing = false; + if (c < state.buffer.length) + state.buffer = state.buffer.slice(c); + else + state.buffer.length = 0; +} + +Writable.prototype._write = function(chunk, encoding, cb) { + cb(new Error('not implemented')); +}; + +Writable.prototype.end = function(chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (typeof chunk !== 'undefined' && chunk !== null) + this.write(chunk, encoding); + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) + endWritable(this, state, cb); +}; + + +function needFinish(stream, state) { + return (state.ending && + state.length === 0 && + !state.finished && + !state.writing); +} + +function finishMaybe(stream, state) { + var need = needFinish(stream, state); + if (need) { + state.finished = true; + stream.emit('finish'); + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) + process.nextTick(cb); + else + stream.once('finish', cb); + } + state.ended = true; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/package.json new file mode 100644 index 00000000..1a721d32 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/package.json @@ -0,0 +1,36 @@ +{ + "name": "readable-stream", + "version": "1.0.17", + "description": "An exploration of a new kind of readable streams for Node.js", + "main": "readable.js", + "dependencies": {}, + "devDependencies": { + "tap": "~0.2.6" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/readable-stream" + }, + "keywords": [ + "readable", + "stream", + "pipe" + ], + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "BSD", + "readme": "# readable-stream\n\nA new class of streams for Node.js\n\nThis module provides the new Stream base classes introduced in Node\nv0.10, for use in Node v0.8. You can use it to have programs that\nhave to work with node v0.8, while being forward-compatible for v0.10\nand beyond. When you drop support for v0.8, you can remove this\nmodule, and only use the native streams.\n\nThis is almost exactly the same codebase as appears in Node v0.10.\nHowever:\n\n1. The exported object is actually the Readable class. Decorating the\n native `stream` module would be global pollution.\n2. In v0.10, you can safely use `base64` as an argument to\n `setEncoding` in Readable streams. However, in v0.8, the\n StringDecoder class has no `end()` method, which is problematic for\n Base64. So, don't use that, because it'll break and be weird.\n\nOther than that, the API is the same as `require('stream')` in v0.10,\nso the API docs are reproduced below.\n\n----------\n\n Stability: 2 - Unstable\n\nA stream is an abstract interface implemented by various objects in\nNode. For example a request to an HTTP server is a stream, as is\nstdout. Streams are readable, writable, or both. All streams are\ninstances of [EventEmitter][]\n\nYou can load the Stream base classes by doing `require('stream')`.\nThere are base classes provided for Readable streams, Writable\nstreams, Duplex streams, and Transform streams.\n\n## Compatibility\n\nIn earlier versions of Node, the Readable stream interface was\nsimpler, but also less powerful and less useful.\n\n* Rather than waiting for you to call the `read()` method, `'data'`\n events would start emitting immediately. If you needed to do some\n I/O to decide how to handle data, then you had to store the chunks\n in some kind of buffer so that they would not be lost.\n* The `pause()` method was advisory, rather than guaranteed. This\n meant that you still had to be prepared to receive `'data'` events\n even when the stream was in a paused state.\n\nIn Node v0.10, the Readable class described below was added. For\nbackwards compatibility with older Node programs, Readable streams\nswitch into \"old mode\" when a `'data'` event handler is added, or when\nthe `pause()` or `resume()` methods are called. The effect is that,\neven if you are not using the new `read()` method and `'readable'`\nevent, you no longer have to worry about losing `'data'` chunks.\n\nMost programs will continue to function normally. However, this\nintroduces an edge case in the following conditions:\n\n* No `'data'` event handler is added.\n* The `pause()` and `resume()` methods are never called.\n\nFor example, consider the following code:\n\n```javascript\n// WARNING! BROKEN!\nnet.createServer(function(socket) {\n\n // we add an 'end' method, but never consume the data\n socket.on('end', function() {\n // It will never get here.\n socket.end('I got your message (but didnt read it)\\n');\n });\n\n}).listen(1337);\n```\n\nIn versions of node prior to v0.10, the incoming message data would be\nsimply discarded. However, in Node v0.10 and beyond, the socket will\nremain paused forever.\n\nThe workaround in this situation is to call the `resume()` method to\ntrigger \"old mode\" behavior:\n\n```javascript\n// Workaround\nnet.createServer(function(socket) {\n\n socket.on('end', function() {\n socket.end('I got your message (but didnt read it)\\n');\n });\n\n // start the flow of data, discarding it.\n socket.resume();\n\n}).listen(1337);\n```\n\nIn addition to new Readable streams switching into old-mode, pre-v0.10\nstyle streams can be wrapped in a Readable class using the `wrap()`\nmethod.\n\n## Class: stream.Readable\n\n\n\nA `Readable Stream` has the following methods, members, and events.\n\nNote that `stream.Readable` is an abstract class designed to be\nextended with an underlying implementation of the `_read(size)`\nmethod. (See below.)\n\n### new stream.Readable([options])\n\n* `options` {Object}\n * `highWaterMark` {Number} The maximum number of bytes to store in\n the internal buffer before ceasing to read from the underlying\n resource. Default=16kb\n * `encoding` {String} If specified, then buffers will be decoded to\n strings using the specified encoding. Default=null\n * `objectMode` {Boolean} Whether this stream should behave\n as a stream of objects. Meaning that stream.read(n) returns\n a single value instead of a Buffer of size n\n\nIn classes that extend the Readable class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n### readable.\\_read(size)\n\n* `size` {Number} Number of bytes to read asynchronously\n\nNote: **This function should NOT be called directly.** It should be\nimplemented by child classes, and called by the internal Readable\nclass methods only.\n\nAll Readable stream implementations must provide a `_read` method\nto fetch data from the underlying resource.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\nWhen data is available, put it into the read queue by calling\n`readable.push(chunk)`. If `push` returns false, then you should stop\nreading. When `_read` is called again, you should start pushing more\ndata.\n\nThe `size` argument is advisory. Implementations where a \"read\" is a\nsingle call that returns data can use this to know how much data to\nfetch. Implementations where that is not relevant, such as TCP or\nTLS, may ignore this argument, and simply provide data whenever it\nbecomes available. There is no need, for example to \"wait\" until\n`size` bytes are available before calling `stream.push(chunk)`.\n\n### readable.push(chunk)\n\n* `chunk` {Buffer | null | String} Chunk of data to push into the read queue\n* return {Boolean} Whether or not more pushes should be performed\n\nNote: **This function should be called by Readable implementors, NOT\nby consumers of Readable subclasses.** The `_read()` function will not\nbe called again until at least one `push(chunk)` call is made. If no\ndata is available, then you MAY call `push('')` (an empty string) to\nallow a future `_read` call, without adding any data to the queue.\n\nThe `Readable` class works by putting data into a read queue to be\npulled out later by calling the `read()` method when the `'readable'`\nevent fires.\n\nThe `push()` method will explicitly insert some data into the read\nqueue. If it is called with `null` then it will signal the end of the\ndata.\n\nIn some cases, you may be wrapping a lower-level source which has some\nsort of pause/resume mechanism, and a data callback. In those cases,\nyou could wrap the low-level source object by doing something like\nthis:\n\n```javascript\n// source is an object with readStop() and readStart() methods,\n// and an `ondata` member that gets called when it has data, and\n// an `onend` member that gets called when the data is over.\n\nvar stream = new Readable();\n\nsource.ondata = function(chunk) {\n // if push() returns false, then we need to stop reading from source\n if (!stream.push(chunk))\n source.readStop();\n};\n\nsource.onend = function() {\n stream.push(null);\n};\n\n// _read will be called when the stream wants to pull more data in\n// the advisory size argument is ignored in this case.\nstream._read = function(n) {\n source.readStart();\n};\n```\n\n### readable.unshift(chunk)\n\n* `chunk` {Buffer | null | String} Chunk of data to unshift onto the read queue\n* return {Boolean} Whether or not more pushes should be performed\n\nThis is the corollary of `readable.push(chunk)`. Rather than putting\nthe data at the *end* of the read queue, it puts it at the *front* of\nthe read queue.\n\nThis is useful in certain use-cases where a stream is being consumed\nby a parser, which needs to \"un-consume\" some data that it has\noptimistically pulled out of the source.\n\n```javascript\n// A parser for a simple data protocol.\n// The \"header\" is a JSON object, followed by 2 \\n characters, and\n// then a message body.\n//\n// Note: This can be done more simply as a Transform stream. See below.\n\nfunction SimpleProtocol(source, options) {\n if (!(this instanceof SimpleProtocol))\n return new SimpleProtocol(options);\n\n Readable.call(this, options);\n this._inBody = false;\n this._sawFirstCr = false;\n\n // source is a readable stream, such as a socket or file\n this._source = source;\n\n var self = this;\n source.on('end', function() {\n self.push(null);\n });\n\n // give it a kick whenever the source is readable\n // read(0) will not consume any bytes\n source.on('readable', function() {\n self.read(0);\n });\n\n this._rawHeader = [];\n this.header = null;\n}\n\nSimpleProtocol.prototype = Object.create(\n Readable.prototype, { constructor: { value: SimpleProtocol }});\n\nSimpleProtocol.prototype._read = function(n) {\n if (!this._inBody) {\n var chunk = this._source.read();\n\n // if the source doesn't have data, we don't have data yet.\n if (chunk === null)\n return this.push('');\n\n // check if the chunk has a \\n\\n\n var split = -1;\n for (var i = 0; i < chunk.length; i++) {\n if (chunk[i] === 10) { // '\\n'\n if (this._sawFirstCr) {\n split = i;\n break;\n } else {\n this._sawFirstCr = true;\n }\n } else {\n this._sawFirstCr = false;\n }\n }\n\n if (split === -1) {\n // still waiting for the \\n\\n\n // stash the chunk, and try again.\n this._rawHeader.push(chunk);\n this.push('');\n } else {\n this._inBody = true;\n var h = chunk.slice(0, split);\n this._rawHeader.push(h);\n var header = Buffer.concat(this._rawHeader).toString();\n try {\n this.header = JSON.parse(header);\n } catch (er) {\n this.emit('error', new Error('invalid simple protocol data'));\n return;\n }\n // now, because we got some extra data, unshift the rest\n // back into the read queue so that our consumer will see it.\n var b = chunk.slice(split);\n this.unshift(b);\n\n // and let them know that we are done parsing the header.\n this.emit('header', this.header);\n }\n } else {\n // from there on, just provide the data to our consumer.\n // careful not to push(null), since that would indicate EOF.\n var chunk = this._source.read();\n if (chunk) this.push(chunk);\n }\n};\n\n// Usage:\nvar parser = new SimpleProtocol(source);\n// Now parser is a readable stream that will emit 'header'\n// with the parsed header data.\n```\n\n### readable.wrap(stream)\n\n* `stream` {Stream} An \"old style\" readable stream\n\nIf you are using an older Node library that emits `'data'` events and\nhas a `pause()` method that is advisory only, then you can use the\n`wrap()` method to create a Readable stream that uses the old stream\nas its data source.\n\nFor example:\n\n```javascript\nvar OldReader = require('./old-api-module.js').OldReader;\nvar oreader = new OldReader;\nvar Readable = require('stream').Readable;\nvar myReader = new Readable().wrap(oreader);\n\nmyReader.on('readable', function() {\n myReader.read(); // etc.\n});\n```\n\n### Event: 'readable'\n\nWhen there is data ready to be consumed, this event will fire.\n\nWhen this event emits, call the `read()` method to consume the data.\n\n### Event: 'end'\n\nEmitted when the stream has received an EOF (FIN in TCP terminology).\nIndicates that no more `'data'` events will happen. If the stream is\nalso writable, it may be possible to continue writing.\n\n### Event: 'data'\n\nThe `'data'` event emits either a `Buffer` (by default) or a string if\n`setEncoding()` was used.\n\nNote that adding a `'data'` event listener will switch the Readable\nstream into \"old mode\", where data is emitted as soon as it is\navailable, rather than waiting for you to call `read()` to consume it.\n\n### Event: 'error'\n\nEmitted if there was an error receiving data.\n\n### Event: 'close'\n\nEmitted when the underlying resource (for example, the backing file\ndescriptor) has been closed. Not all streams will emit this.\n\n### readable.setEncoding(encoding)\n\nMakes the `'data'` event emit a string instead of a `Buffer`. `encoding`\ncan be `'utf8'`, `'utf16le'` (`'ucs2'`), `'ascii'`, or `'hex'`.\n\nThe encoding can also be set by specifying an `encoding` field to the\nconstructor.\n\n### readable.read([size])\n\n* `size` {Number | null} Optional number of bytes to read.\n* Return: {Buffer | String | null}\n\nNote: **This function SHOULD be called by Readable stream users.**\n\nCall this method to consume data once the `'readable'` event is\nemitted.\n\nThe `size` argument will set a minimum number of bytes that you are\ninterested in. If not set, then the entire content of the internal\nbuffer is returned.\n\nIf there is no data to consume, or if there are fewer bytes in the\ninternal buffer than the `size` argument, then `null` is returned, and\na future `'readable'` event will be emitted when more is available.\n\nCalling `stream.read(0)` will always return `null`, and will trigger a\nrefresh of the internal buffer, but otherwise be a no-op.\n\n### readable.pipe(destination, [options])\n\n* `destination` {Writable Stream}\n* `options` {Object} Optional\n * `end` {Boolean} Default=true\n\nConnects this readable stream to `destination` WriteStream. Incoming\ndata on this stream gets written to `destination`. Properly manages\nback-pressure so that a slow destination will not be overwhelmed by a\nfast readable stream.\n\nThis function returns the `destination` stream.\n\nFor example, emulating the Unix `cat` command:\n\n process.stdin.pipe(process.stdout);\n\nBy default `end()` is called on the destination when the source stream\nemits `end`, so that `destination` is no longer writable. Pass `{ end:\nfalse }` as `options` to keep the destination stream open.\n\nThis keeps `writer` open so that \"Goodbye\" can be written at the\nend.\n\n reader.pipe(writer, { end: false });\n reader.on(\"end\", function() {\n writer.end(\"Goodbye\\n\");\n });\n\nNote that `process.stderr` and `process.stdout` are never closed until\nthe process exits, regardless of the specified options.\n\n### readable.unpipe([destination])\n\n* `destination` {Writable Stream} Optional\n\nUndo a previously established `pipe()`. If no destination is\nprovided, then all previously established pipes are removed.\n\n### readable.pause()\n\nSwitches the readable stream into \"old mode\", where data is emitted\nusing a `'data'` event rather than being buffered for consumption via\nthe `read()` method.\n\nCeases the flow of data. No `'data'` events are emitted while the\nstream is in a paused state.\n\n### readable.resume()\n\nSwitches the readable stream into \"old mode\", where data is emitted\nusing a `'data'` event rather than being buffered for consumption via\nthe `read()` method.\n\nResumes the incoming `'data'` events after a `pause()`.\n\n\n## Class: stream.Writable\n\n\n\nA `Writable` Stream has the following methods, members, and events.\n\nNote that `stream.Writable` is an abstract class designed to be\nextended with an underlying implementation of the\n`_write(chunk, encoding, cb)` method. (See below.)\n\n### new stream.Writable([options])\n\n* `options` {Object}\n * `highWaterMark` {Number} Buffer level when `write()` starts\n returning false. Default=16kb\n * `decodeStrings` {Boolean} Whether or not to decode strings into\n Buffers before passing them to `_write()`. Default=true\n\nIn classes that extend the Writable class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n### writable.\\_write(chunk, encoding, callback)\n\n* `chunk` {Buffer | String} The chunk to be written. Will always\n be a buffer unless the `decodeStrings` option was set to `false`.\n* `encoding` {String} If the chunk is a string, then this is the\n encoding type. Ignore chunk is a buffer. Note that chunk will\n **always** be a buffer unless the `decodeStrings` option is\n explicitly set to `false`.\n* `callback` {Function} Call this function (optionally with an error\n argument) when you are done processing the supplied chunk.\n\nAll Writable stream implementations must provide a `_write` method to\nsend data to the underlying resource.\n\nNote: **This function MUST NOT be called directly.** It should be\nimplemented by child classes, and called by the internal Writable\nclass methods only.\n\nCall the callback using the standard `callback(error)` pattern to\nsignal that the write completed successfully or with an error.\n\nIf the `decodeStrings` flag is set in the constructor options, then\n`chunk` may be a string rather than a Buffer, and `encoding` will\nindicate the sort of string that it is. This is to support\nimplementations that have an optimized handling for certain string\ndata encodings. If you do not explicitly set the `decodeStrings`\noption to `false`, then you can safely ignore the `encoding` argument,\nand assume that `chunk` will always be a Buffer.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\n\n### writable.write(chunk, [encoding], [callback])\n\n* `chunk` {Buffer | String} Data to be written\n* `encoding` {String} Optional. If `chunk` is a string, then encoding\n defaults to `'utf8'`\n* `callback` {Function} Optional. Called when this chunk is\n successfully written.\n* Returns {Boolean}\n\nWrites `chunk` to the stream. Returns `true` if the data has been\nflushed to the underlying resource. Returns `false` to indicate that\nthe buffer is full, and the data will be sent out in the future. The\n`'drain'` event will indicate when the buffer is empty again.\n\nThe specifics of when `write()` will return false, is determined by\nthe `highWaterMark` option provided to the constructor.\n\n### writable.end([chunk], [encoding], [callback])\n\n* `chunk` {Buffer | String} Optional final data to be written\n* `encoding` {String} Optional. If `chunk` is a string, then encoding\n defaults to `'utf8'`\n* `callback` {Function} Optional. Called when the final chunk is\n successfully written.\n\nCall this method to signal the end of the data being written to the\nstream.\n\n### Event: 'drain'\n\nEmitted when the stream's write queue empties and it's safe to write\nwithout buffering again. Listen for it when `stream.write()` returns\n`false`.\n\n### Event: 'close'\n\nEmitted when the underlying resource (for example, the backing file\ndescriptor) has been closed. Not all streams will emit this.\n\n### Event: 'finish'\n\nWhen `end()` is called and there are no more chunks to write, this\nevent is emitted.\n\n### Event: 'pipe'\n\n* `source` {Readable Stream}\n\nEmitted when the stream is passed to a readable stream's pipe method.\n\n### Event 'unpipe'\n\n* `source` {Readable Stream}\n\nEmitted when a previously established `pipe()` is removed using the\nsource Readable stream's `unpipe()` method.\n\n## Class: stream.Duplex\n\n\n\nA \"duplex\" stream is one that is both Readable and Writable, such as a\nTCP socket connection.\n\nNote that `stream.Duplex` is an abstract class designed to be\nextended with an underlying implementation of the `_read(size)`\nand `_write(chunk, encoding, callback)` methods as you would with a Readable or\nWritable stream class.\n\nSince JavaScript doesn't have multiple prototypal inheritance, this\nclass prototypally inherits from Readable, and then parasitically from\nWritable. It is thus up to the user to implement both the lowlevel\n`_read(n)` method as well as the lowlevel `_write(chunk, encoding, cb)` method\non extension duplex classes.\n\n### new stream.Duplex(options)\n\n* `options` {Object} Passed to both Writable and Readable\n constructors. Also has the following fields:\n * `allowHalfOpen` {Boolean} Default=true. If set to `false`, then\n the stream will automatically end the readable side when the\n writable side ends and vice versa.\n\nIn classes that extend the Duplex class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n## Class: stream.Transform\n\nA \"transform\" stream is a duplex stream where the output is causally\nconnected in some way to the input, such as a zlib stream or a crypto\nstream.\n\nThere is no requirement that the output be the same size as the input,\nthe same number of chunks, or arrive at the same time. For example, a\nHash stream will only ever have a single chunk of output which is\nprovided when the input is ended. A zlib stream will either produce\nmuch smaller or much larger than its input.\n\nRather than implement the `_read()` and `_write()` methods, Transform\nclasses must implement the `_transform()` method, and may optionally\nalso implement the `_flush()` method. (See below.)\n\n### new stream.Transform([options])\n\n* `options` {Object} Passed to both Writable and Readable\n constructors.\n\nIn classes that extend the Transform class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n### transform.\\_transform(chunk, encoding, callback)\n\n* `chunk` {Buffer | String} The chunk to be transformed. Will always\n be a buffer unless the `decodeStrings` option was set to `false`.\n* `encoding` {String} If the chunk is a string, then this is the\n encoding type. (Ignore if `decodeStrings` chunk is a buffer.)\n* `callback` {Function} Call this function (optionally with an error\n argument) when you are done processing the supplied chunk.\n\nNote: **This function MUST NOT be called directly.** It should be\nimplemented by child classes, and called by the internal Transform\nclass methods only.\n\nAll Transform stream implementations must provide a `_transform`\nmethod to accept input and produce output.\n\n`_transform` should do whatever has to be done in this specific\nTransform class, to handle the bytes being written, and pass them off\nto the readable portion of the interface. Do asynchronous I/O,\nprocess things, and so on.\n\nCall `transform.push(outputChunk)` 0 or more times to generate output\nfrom this input chunk, depending on how much data you want to output\nas a result of this chunk.\n\nCall the callback function only when the current chunk is completely\nconsumed. Note that there may or may not be output as a result of any\nparticular input chunk.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\n### transform.\\_flush(callback)\n\n* `callback` {Function} Call this function (optionally with an error\n argument) when you are done flushing any remaining data.\n\nNote: **This function MUST NOT be called directly.** It MAY be implemented\nby child classes, and if so, will be called by the internal Transform\nclass methods only.\n\nIn some cases, your transform operation may need to emit a bit more\ndata at the end of the stream. For example, a `Zlib` compression\nstream will store up some internal state so that it can optimally\ncompress the output. At the end, however, it needs to do the best it\ncan with what is left, so that the data will be complete.\n\nIn those cases, you can implement a `_flush` method, which will be\ncalled at the very end, after all the written data is consumed, but\nbefore emitting `end` to signal the end of the readable side. Just\nlike with `_transform`, call `transform.push(chunk)` zero or more\ntimes, as appropriate, and call `callback` when the flush operation is\ncomplete.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\n### Example: `SimpleProtocol` parser\n\nThe example above of a simple protocol parser can be implemented much\nmore simply by using the higher level `Transform` stream class.\n\nIn this example, rather than providing the input as an argument, it\nwould be piped into the parser, which is a more idiomatic Node stream\napproach.\n\n```javascript\nfunction SimpleProtocol(options) {\n if (!(this instanceof SimpleProtocol))\n return new SimpleProtocol(options);\n\n Transform.call(this, options);\n this._inBody = false;\n this._sawFirstCr = false;\n this._rawHeader = [];\n this.header = null;\n}\n\nSimpleProtocol.prototype = Object.create(\n Transform.prototype, { constructor: { value: SimpleProtocol }});\n\nSimpleProtocol.prototype._transform = function(chunk, encoding, done) {\n if (!this._inBody) {\n // check if the chunk has a \\n\\n\n var split = -1;\n for (var i = 0; i < chunk.length; i++) {\n if (chunk[i] === 10) { // '\\n'\n if (this._sawFirstCr) {\n split = i;\n break;\n } else {\n this._sawFirstCr = true;\n }\n } else {\n this._sawFirstCr = false;\n }\n }\n\n if (split === -1) {\n // still waiting for the \\n\\n\n // stash the chunk, and try again.\n this._rawHeader.push(chunk);\n } else {\n this._inBody = true;\n var h = chunk.slice(0, split);\n this._rawHeader.push(h);\n var header = Buffer.concat(this._rawHeader).toString();\n try {\n this.header = JSON.parse(header);\n } catch (er) {\n this.emit('error', new Error('invalid simple protocol data'));\n return;\n }\n // and let them know that we are done parsing the header.\n this.emit('header', this.header);\n\n // now, because we got some extra data, emit this first.\n this.push(b);\n }\n } else {\n // from there on, just provide the data to our consumer as-is.\n this.push(b);\n }\n done();\n};\n\nvar parser = new SimpleProtocol();\nsource.pipe(parser)\n\n// Now parser is a readable stream that will emit 'header'\n// with the parsed header data.\n```\n\n\n## Class: stream.PassThrough\n\nThis is a trivial implementation of a `Transform` stream that simply\npasses the input bytes across to the output. Its purpose is mainly\nfor examples and testing, but there are occasionally use cases where\nit can come in handy.\n\n\n[EventEmitter]: events.html#events_class_events_eventemitter\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/isaacs/readable-stream/issues" + }, + "homepage": "https://github.com/isaacs/readable-stream", + "_id": "readable-stream@1.0.17", + "_from": "readable-stream@~1.0.2" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/passthrough.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/passthrough.js new file mode 100644 index 00000000..27e8d8a5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/passthrough.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_passthrough.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/readable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/readable.js new file mode 100644 index 00000000..4d1ddfc7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/readable.js @@ -0,0 +1,6 @@ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/test/common.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/test/common.js new file mode 100644 index 00000000..1dec2e35 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/test/common.js @@ -0,0 +1,191 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var path = require('path'); +var assert = require('assert'); + +exports.testDir = path.dirname(__filename); +exports.fixturesDir = path.join(exports.testDir, 'fixtures'); +exports.libDir = path.join(exports.testDir, '../lib'); +exports.tmpDir = path.join(exports.testDir, 'tmp'); +exports.PORT = 12346; + +if (process.platform === 'win32') { + exports.PIPE = '\\\\.\\pipe\\libuv-test'; +} else { + exports.PIPE = exports.tmpDir + '/test.sock'; +} + +var util = require('util'); +for (var i in util) exports[i] = util[i]; +//for (var i in exports) global[i] = exports[i]; + +function protoCtrChain(o) { + var result = []; + for (; o; o = o.__proto__) { result.push(o.constructor); } + return result.join(); +} + +exports.indirectInstanceOf = function(obj, cls) { + if (obj instanceof cls) { return true; } + var clsChain = protoCtrChain(cls.prototype); + var objChain = protoCtrChain(obj); + return objChain.slice(-clsChain.length) === clsChain; +}; + + +exports.ddCommand = function(filename, kilobytes) { + if (process.platform === 'win32') { + var p = path.resolve(exports.fixturesDir, 'create-file.js'); + return '"' + process.argv[0] + '" "' + p + '" "' + + filename + '" ' + (kilobytes * 1024); + } else { + return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes; + } +}; + + +exports.spawnPwd = function(options) { + var spawn = require('child_process').spawn; + + if (process.platform === 'win32') { + return spawn('cmd.exe', ['/c', 'cd'], options); + } else { + return spawn('pwd', [], options); + } +}; + + +// Turn this off if the test should not check for global leaks. +exports.globalCheck = true; + +process.on('exit', function() { + if (!exports.globalCheck) return; + var knownGlobals = [setTimeout, + setInterval, + global.setImmediate, + clearTimeout, + clearInterval, + global.clearImmediate, + console, + Buffer, + process, + global]; + + if (global.errno) { + knownGlobals.push(errno); + } + + if (global.gc) { + knownGlobals.push(gc); + } + + if (global.DTRACE_HTTP_SERVER_RESPONSE) { + knownGlobals.push(DTRACE_HTTP_SERVER_RESPONSE); + knownGlobals.push(DTRACE_HTTP_SERVER_REQUEST); + knownGlobals.push(DTRACE_HTTP_CLIENT_RESPONSE); + knownGlobals.push(DTRACE_HTTP_CLIENT_REQUEST); + knownGlobals.push(DTRACE_NET_STREAM_END); + knownGlobals.push(DTRACE_NET_SERVER_CONNECTION); + knownGlobals.push(DTRACE_NET_SOCKET_READ); + knownGlobals.push(DTRACE_NET_SOCKET_WRITE); + } + if (global.COUNTER_NET_SERVER_CONNECTION) { + knownGlobals.push(COUNTER_NET_SERVER_CONNECTION); + knownGlobals.push(COUNTER_NET_SERVER_CONNECTION_CLOSE); + knownGlobals.push(COUNTER_HTTP_SERVER_REQUEST); + knownGlobals.push(COUNTER_HTTP_SERVER_RESPONSE); + knownGlobals.push(COUNTER_HTTP_CLIENT_REQUEST); + knownGlobals.push(COUNTER_HTTP_CLIENT_RESPONSE); + } + + if (global.ArrayBuffer) { + knownGlobals.push(ArrayBuffer); + knownGlobals.push(Int8Array); + knownGlobals.push(Uint8Array); + knownGlobals.push(Uint8ClampedArray); + knownGlobals.push(Int16Array); + knownGlobals.push(Uint16Array); + knownGlobals.push(Int32Array); + knownGlobals.push(Uint32Array); + knownGlobals.push(Float32Array); + knownGlobals.push(Float64Array); + knownGlobals.push(DataView); + } + + for (var x in global) { + var found = false; + + for (var y in knownGlobals) { + if (global[x] === knownGlobals[y]) { + found = true; + break; + } + } + + if (!found) { + console.error('Unknown global: %s', x); + assert.ok(false, 'Unknown global found'); + } + } +}); + + +var mustCallChecks = []; + + +function runCallChecks() { + var failed = mustCallChecks.filter(function(context) { + return context.actual !== context.expected; + }); + + failed.forEach(function(context) { + console.log('Mismatched %s function calls. Expected %d, actual %d.', + context.name, + context.expected, + context.actual); + console.log(context.stack.split('\n').slice(2).join('\n')); + }); + + if (failed.length) process.exit(1); +} + + +exports.mustCall = function(fn, expected) { + if (typeof expected !== 'number') expected = 1; + + var context = { + expected: expected, + actual: 0, + stack: (new Error).stack, + name: fn.name || '' + }; + + // add the exit listener only once to avoid listener leak warnings + if (mustCallChecks.length === 0) process.on('exit', runCallChecks); + + mustCallChecks.push(context); + + return function() { + context.actual++; + return fn.apply(this, arguments); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/test/fixtures/x1024.txt b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/test/fixtures/x1024.txt new file mode 100644 index 00000000..c6a9d2f1 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/test/fixtures/x1024.txt @@ -0,0 +1 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/transform.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/transform.js new file mode 100644 index 00000000..5d482f07 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/transform.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_transform.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/writable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/writable.js new file mode 100644 index 00000000..e1e9efdf --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/writable.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_writable.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/zlib.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/zlib.js new file mode 100644 index 00000000..a30ca209 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/node_modules/readable-stream/zlib.js @@ -0,0 +1,452 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var Transform = require('./lib/_stream_transform.js'); + +var binding = process.binding('zlib'); +var util = require('util'); +var assert = require('assert').ok; + +// zlib doesn't provide these, so kludge them in following the same +// const naming scheme zlib uses. +binding.Z_MIN_WINDOWBITS = 8; +binding.Z_MAX_WINDOWBITS = 15; +binding.Z_DEFAULT_WINDOWBITS = 15; + +// fewer than 64 bytes per chunk is stupid. +// technically it could work with as few as 8, but even 64 bytes +// is absurdly low. Usually a MB or more is best. +binding.Z_MIN_CHUNK = 64; +binding.Z_MAX_CHUNK = Infinity; +binding.Z_DEFAULT_CHUNK = (16 * 1024); + +binding.Z_MIN_MEMLEVEL = 1; +binding.Z_MAX_MEMLEVEL = 9; +binding.Z_DEFAULT_MEMLEVEL = 8; + +binding.Z_MIN_LEVEL = -1; +binding.Z_MAX_LEVEL = 9; +binding.Z_DEFAULT_LEVEL = binding.Z_DEFAULT_COMPRESSION; + +// expose all the zlib constants +Object.keys(binding).forEach(function(k) { + if (k.match(/^Z/)) exports[k] = binding[k]; +}); + +// translation table for return codes. +exports.codes = { + Z_OK: binding.Z_OK, + Z_STREAM_END: binding.Z_STREAM_END, + Z_NEED_DICT: binding.Z_NEED_DICT, + Z_ERRNO: binding.Z_ERRNO, + Z_STREAM_ERROR: binding.Z_STREAM_ERROR, + Z_DATA_ERROR: binding.Z_DATA_ERROR, + Z_MEM_ERROR: binding.Z_MEM_ERROR, + Z_BUF_ERROR: binding.Z_BUF_ERROR, + Z_VERSION_ERROR: binding.Z_VERSION_ERROR +}; + +Object.keys(exports.codes).forEach(function(k) { + exports.codes[exports.codes[k]] = k; +}); + +exports.Deflate = Deflate; +exports.Inflate = Inflate; +exports.Gzip = Gzip; +exports.Gunzip = Gunzip; +exports.DeflateRaw = DeflateRaw; +exports.InflateRaw = InflateRaw; +exports.Unzip = Unzip; + +exports.createDeflate = function(o) { + return new Deflate(o); +}; + +exports.createInflate = function(o) { + return new Inflate(o); +}; + +exports.createDeflateRaw = function(o) { + return new DeflateRaw(o); +}; + +exports.createInflateRaw = function(o) { + return new InflateRaw(o); +}; + +exports.createGzip = function(o) { + return new Gzip(o); +}; + +exports.createGunzip = function(o) { + return new Gunzip(o); +}; + +exports.createUnzip = function(o) { + return new Unzip(o); +}; + + +// Convenience methods. +// compress/decompress a string or buffer in one step. +exports.deflate = function(buffer, callback) { + zlibBuffer(new Deflate(), buffer, callback); +}; + +exports.gzip = function(buffer, callback) { + zlibBuffer(new Gzip(), buffer, callback); +}; + +exports.deflateRaw = function(buffer, callback) { + zlibBuffer(new DeflateRaw(), buffer, callback); +}; + +exports.unzip = function(buffer, callback) { + zlibBuffer(new Unzip(), buffer, callback); +}; + +exports.inflate = function(buffer, callback) { + zlibBuffer(new Inflate(), buffer, callback); +}; + +exports.gunzip = function(buffer, callback) { + zlibBuffer(new Gunzip(), buffer, callback); +}; + +exports.inflateRaw = function(buffer, callback) { + zlibBuffer(new InflateRaw(), buffer, callback); +}; + +function zlibBuffer(engine, buffer, callback) { + var buffers = []; + var nread = 0; + + engine.on('error', onError); + engine.on('end', onEnd); + + engine.end(buffer); + flow(); + + function flow() { + var chunk; + while (null !== (chunk = engine.read())) { + buffers.push(chunk); + nread += chunk.length; + } + engine.once('readable', flow); + } + + function onError(err) { + engine.removeListener('end', onEnd); + engine.removeListener('readable', flow); + callback(err); + } + + function onEnd() { + var buf = Buffer.concat(buffers, nread); + buffers = []; + callback(null, buf); + } +} + + +// generic zlib +// minimal 2-byte header +function Deflate(opts) { + if (!(this instanceof Deflate)) return new Deflate(opts); + Zlib.call(this, opts, binding.DEFLATE); +} + +function Inflate(opts) { + if (!(this instanceof Inflate)) return new Inflate(opts); + Zlib.call(this, opts, binding.INFLATE); +} + + + +// gzip - bigger header, same deflate compression +function Gzip(opts) { + if (!(this instanceof Gzip)) return new Gzip(opts); + Zlib.call(this, opts, binding.GZIP); +} + +function Gunzip(opts) { + if (!(this instanceof Gunzip)) return new Gunzip(opts); + Zlib.call(this, opts, binding.GUNZIP); +} + + + +// raw - no header +function DeflateRaw(opts) { + if (!(this instanceof DeflateRaw)) return new DeflateRaw(opts); + Zlib.call(this, opts, binding.DEFLATERAW); +} + +function InflateRaw(opts) { + if (!(this instanceof InflateRaw)) return new InflateRaw(opts); + Zlib.call(this, opts, binding.INFLATERAW); +} + + +// auto-detect header. +function Unzip(opts) { + if (!(this instanceof Unzip)) return new Unzip(opts); + Zlib.call(this, opts, binding.UNZIP); +} + + +// the Zlib class they all inherit from +// This thing manages the queue of requests, and returns +// true or false if there is anything in the queue when +// you call the .write() method. + +function Zlib(opts, mode) { + this._opts = opts = opts || {}; + this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK; + + Transform.call(this, opts); + + // means a different thing there. + this._readableState.chunkSize = null; + + if (opts.chunkSize) { + if (opts.chunkSize < exports.Z_MIN_CHUNK || + opts.chunkSize > exports.Z_MAX_CHUNK) { + throw new Error('Invalid chunk size: ' + opts.chunkSize); + } + } + + if (opts.windowBits) { + if (opts.windowBits < exports.Z_MIN_WINDOWBITS || + opts.windowBits > exports.Z_MAX_WINDOWBITS) { + throw new Error('Invalid windowBits: ' + opts.windowBits); + } + } + + if (opts.level) { + if (opts.level < exports.Z_MIN_LEVEL || + opts.level > exports.Z_MAX_LEVEL) { + throw new Error('Invalid compression level: ' + opts.level); + } + } + + if (opts.memLevel) { + if (opts.memLevel < exports.Z_MIN_MEMLEVEL || + opts.memLevel > exports.Z_MAX_MEMLEVEL) { + throw new Error('Invalid memLevel: ' + opts.memLevel); + } + } + + if (opts.strategy) { + if (opts.strategy != exports.Z_FILTERED && + opts.strategy != exports.Z_HUFFMAN_ONLY && + opts.strategy != exports.Z_RLE && + opts.strategy != exports.Z_FIXED && + opts.strategy != exports.Z_DEFAULT_STRATEGY) { + throw new Error('Invalid strategy: ' + opts.strategy); + } + } + + if (opts.dictionary) { + if (!Buffer.isBuffer(opts.dictionary)) { + throw new Error('Invalid dictionary: it should be a Buffer instance'); + } + } + + this._binding = new binding.Zlib(mode); + + var self = this; + this._hadError = false; + this._binding.onerror = function(message, errno) { + // there is no way to cleanly recover. + // continuing only obscures problems. + self._binding = null; + self._hadError = true; + + var error = new Error(message); + error.errno = errno; + error.code = exports.codes[errno]; + self.emit('error', error); + }; + + this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, + opts.level || exports.Z_DEFAULT_COMPRESSION, + opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, + opts.strategy || exports.Z_DEFAULT_STRATEGY, + opts.dictionary); + + this._buffer = new Buffer(this._chunkSize); + this._offset = 0; + this._closed = false; + + this.once('end', this.close); +} + +util.inherits(Zlib, Transform); + +Zlib.prototype.reset = function reset() { + return this._binding.reset(); +}; + +Zlib.prototype._flush = function(output, callback) { + var rs = this._readableState; + var self = this; + this._transform(null, output, function(er) { + if (er) + return callback(er); + + // now a weird thing happens... it could be that you called flush + // but everything had already actually been consumed, but it wasn't + // enough to get over the Readable class's lowWaterMark. + // In that case, we emit 'readable' now to make sure it's consumed. + if (rs.length && + rs.length < rs.lowWaterMark && + !rs.ended && + rs.needReadable) + self.emit('readable'); + + callback(); + }); +}; + +Zlib.prototype.flush = function(callback) { + var ws = this._writableState; + var ts = this._transformState; + + if (ws.writing) { + ws.needDrain = true; + var self = this; + this.once('drain', function() { + self._flush(ts.output, callback); + }); + return; + } + + this._flush(ts.output, callback || function() {}); +}; + +Zlib.prototype.close = function(callback) { + if (callback) + process.nextTick(callback); + + if (this._closed) + return; + + this._closed = true; + + this._binding.close(); + + var self = this; + process.nextTick(function() { + self.emit('close'); + }); +}; + +Zlib.prototype._transform = function(chunk, output, cb) { + var flushFlag; + var ws = this._writableState; + var ending = ws.ending || ws.ended; + var last = ending && (!chunk || ws.length === chunk.length); + + if (chunk !== null && !Buffer.isBuffer(chunk)) + return cb(new Error('invalid input')); + + // If it's the last chunk, or a final flush, we use the Z_FINISH flush flag. + // If it's explicitly flushing at some other time, then we use + // Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression + // goodness. + if (last) + flushFlag = binding.Z_FINISH; + else if (chunk === null) + flushFlag = binding.Z_FULL_FLUSH; + else + flushFlag = binding.Z_NO_FLUSH; + + var availInBefore = chunk && chunk.length; + var availOutBefore = this._chunkSize - this._offset; + var inOff = 0; + + var req = this._binding.write(flushFlag, + chunk, // in + inOff, // in_off + availInBefore, // in_len + this._buffer, // out + this._offset, //out_off + availOutBefore); // out_len + + req.buffer = chunk; + req.callback = callback; + + var self = this; + function callback(availInAfter, availOutAfter, buffer) { + if (self._hadError) + return; + + var have = availOutBefore - availOutAfter; + assert(have >= 0, 'have should not go down'); + + if (have > 0) { + var out = self._buffer.slice(self._offset, self._offset + have); + self._offset += have; + // serve some output to the consumer. + output(out); + } + + // exhausted the output buffer, or used all the input create a new one. + if (availOutAfter === 0 || self._offset >= self._chunkSize) { + availOutBefore = self._chunkSize; + self._offset = 0; + self._buffer = new Buffer(self._chunkSize); + } + + if (availOutAfter === 0) { + // Not actually done. Need to reprocess. + // Also, update the availInBefore to the availInAfter value, + // so that if we have to hit it a third (fourth, etc.) time, + // it'll have the correct byte counts. + inOff += (availInBefore - availInAfter); + availInBefore = availInAfter; + + var newReq = self._binding.write(flushFlag, + chunk, + inOff, + availInBefore, + self._buffer, + self._offset, + self._chunkSize); + newReq.callback = callback; // this same function + newReq.buffer = chunk; + return; + } + + // finished with the chunk. + cb(); + } +}; + +util.inherits(Deflate, Zlib); +util.inherits(Inflate, Zlib); +util.inherits(Gzip, Zlib); +util.inherits(Gunzip, Zlib); +util.inherits(DeflateRaw, Zlib); +util.inherits(InflateRaw, Zlib); +util.inherits(Unzip, Zlib); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/package.json new file mode 100644 index 00000000..7f81a35f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/package.json @@ -0,0 +1,39 @@ +{ + "name": "bl", + "version": "0.6.0", + "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!", + "main": "bl.js", + "scripts": { + "test": "tape test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/rvagg/bl.git" + }, + "homepage": "https://github.com/rvagg/bl", + "authors": [ + "Rod Vagg (https://github.com/rvagg)", + "Matteo Collina (https://github.com/mcollina)" + ], + "keywords": [ + "buffer", + "buffers", + "stream", + "awesomesauce" + ], + "license": "MIT", + "dependencies": { + "readable-stream": "~1.0.2" + }, + "devDependencies": { + "tape": "*", + "hash_file": "*" + }, + "readme": "# bl *(BufferList)*\n\n[![Build Status](https://secure.travis-ci.org/rvagg/bl.png)](http://travis-ci.org/rvagg/bl)\n\n**A Node.js Buffer list collector, reader and streamer thingy.**\n\n**bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them!\n\nThe original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently.\n\n```js\nconst BufferList = require('bl')\n\nvar bl = new BufferList()\nbl.append(new Buffer('abcd'))\nbl.append(new Buffer('efg'))\nbl.append('hi') // bl will also accept & convert Strings\nbl.append(new Buffer('j'))\nbl.append(new Buffer([ 0x3, 0x4 ]))\n\nconsole.log(bl.length) // 12\n\nconsole.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij'\nconsole.log(bl.slice(3, 10).toString('ascii')) // 'defghij'\nconsole.log(bl.slice(3, 6).toString('ascii')) // 'def'\nconsole.log(bl.slice(3, 8).toString('ascii')) // 'defgh'\nconsole.log(bl.slice(5, 10).toString('ascii')) // 'fghij'\n\n// or just use toString!\nconsole.log(bl.toString()) // 'abcdefghij\\u0003\\u0004'\nconsole.log(bl.toString('ascii', 3, 8)) // 'defgh'\nconsole.log(bl.toString('ascii', 5, 10)) // 'fghij'\n\n// other standard Buffer readables\nconsole.log(bl.readUInt16BE(10)) // 0x0304\nconsole.log(bl.readUInt16LE(10)) // 0x0403\n```\n\nGive it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**:\n\n```js\nconst bl = require('bl')\n , fs = require('fs')\n\nfs.createReadStream('README.md')\n .pipe(bl(function (err, data) { // note 'new' isn't strictly required\n // `data` is a complete Buffer object containing the full data\n console.log(data.toString())\n })\n```\n\nNote that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream.\n\nOr to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!):\n```js\nconst hyperquest = require('hyperquest')\n , bl = require('bl')\n , url = 'https://raw.github.com/rvagg/bl/master/README.md'\n\nhyperquest(url).pipe(bl(function (err, data) {\n console.log(data.toString())\n}))\n```\n\nOr, use it as a readable stream to recompose a list of Buffers to an output source:\n\n```js\nconst BufferList = require('bl')\n , fs = require('fs')\n\nvar bl = new BufferList()\nbl.append(new Buffer('abcd'))\nbl.append(new Buffer('efg'))\nbl.append(new Buffer('hi'))\nbl.append(new Buffer('j'))\n\nbl.pipe(fs.createWriteStream('gibberish.txt'))\n```\n\n## API\n\n * new BufferList([ callback ])\n * bl.length\n * bl.append(buffer)\n * bl.get(index)\n * bl.slice([ start[, end ] ])\n * bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])\n * bl.duplicate()\n * bl.consume(bytes)\n * bl.toString([encoding, [ start, [ end ]]])\n * bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()\n * Streams\n\n--------------------------------------------------------\n\n### new BufferList([ callback | buffer | buffer array ])\nThe constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream.\n\nNormally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object.\n\n`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with:\n\n```js\nvar bl = require('bl')\nvar myinstance = bl()\n\n// equivilant to:\n\nvar BufferList = require('bl')\nvar myinstance = new BufferList()\n```\n\n--------------------------------------------------------\n\n### bl.length\nGet the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list.\n\n--------------------------------------------------------\n\n### bl.append(buffer)\n`append(buffer)` adds an additional buffer to the internal list.\n\n--------------------------------------------------------\n\n### bl.get(index)\n`get()` will return the byte at the specified index.\n\n--------------------------------------------------------\n\n### bl.slice([ start, [ end ] ])\n`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.\n\nIf the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.\n\n--------------------------------------------------------\n\n### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])\n`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively.\n\n--------------------------------------------------------\n\n### bl.duplicate()\n`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example:\n\n```js\nvar bl = new BufferList()\n\nbl.append('hello')\nbl.append(' world')\nbl.append('\\n')\n\nbl.duplicate().pipe(process.stdout, { end: false })\n\nconsole.log(bl.toString())\n```\n\n--------------------------------------------------------\n\n### bl.consume(bytes)\n`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers—initial offsets will be calculated accordingly in order to give you a consistent view of the data.\n\n--------------------------------------------------------\n\n### bl.toString([encoding, [ start, [ end ]]])\n`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information.\n\n--------------------------------------------------------\n\n### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()\n\nAll of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently.\n\nSee the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.\n\n--------------------------------------------------------\n\n### Streams\n**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance.\n\n--------------------------------------------------------\n\n## Contributors\n\n**bl** is brought to you by the following hackers:\n\n * [Rod Vagg](https://github.com/rvagg)\n * [Matteo Collina](https://github.com/mcollina)\n\n=======\n\n## License\n\n**bl** is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/rvagg/bl/issues" + }, + "_id": "bl@0.6.0", + "_from": "bl@" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/test.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/test.js new file mode 100644 index 00000000..1831a11a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/bl/test.js @@ -0,0 +1,442 @@ +const tape = require('tape') + , crypto = require('crypto') + , fs = require('fs') + , hash = require('hash_file') + , BufferList = require('./') + +tape('single bytes from single buffer', function (t) { + var bl = new BufferList() + bl.append(new Buffer('abcd')) + + t.equal(bl.length, 4) + + t.equal(bl.get(0), 97) + t.equal(bl.get(1), 98) + t.equal(bl.get(2), 99) + t.equal(bl.get(3), 100) + + t.end() +}) + +tape('single bytes from multiple buffers', function (t) { + var bl = new BufferList() + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.length, 10) + + t.equal(bl.get(0), 97) + t.equal(bl.get(1), 98) + t.equal(bl.get(2), 99) + t.equal(bl.get(3), 100) + t.equal(bl.get(4), 101) + t.equal(bl.get(5), 102) + t.equal(bl.get(6), 103) + t.equal(bl.get(7), 104) + t.equal(bl.get(8), 105) + t.equal(bl.get(9), 106) + t.end() +}) + +tape('multi bytes from single buffer', function (t) { + var bl = new BufferList() + bl.append(new Buffer('abcd')) + + t.equal(bl.length, 4) + + t.equal(bl.slice(0, 4).toString('ascii'), 'abcd') + t.equal(bl.slice(0, 3).toString('ascii'), 'abc') + t.equal(bl.slice(1, 4).toString('ascii'), 'bcd') + + t.end() +}) + +tape('multiple bytes from multiple buffers', function (t) { + var bl = new BufferList() + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.length, 10) + + t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij') + t.equal(bl.slice(3, 10).toString('ascii'), 'defghij') + t.equal(bl.slice(3, 6).toString('ascii'), 'def') + t.equal(bl.slice(3, 8).toString('ascii'), 'defgh') + t.equal(bl.slice(5, 10).toString('ascii'), 'fghij') + + t.end() +}) + +tape('consuming from multiple buffers', function (t) { + var bl = new BufferList() + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.length, 10) + + t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij') + + bl.consume(3) + t.equal(bl.length, 7) + t.equal(bl.slice(0, 7).toString('ascii'), 'defghij') + + bl.consume(2) + t.equal(bl.length, 5) + t.equal(bl.slice(0, 5).toString('ascii'), 'fghij') + + bl.consume(1) + t.equal(bl.length, 4) + t.equal(bl.slice(0, 4).toString('ascii'), 'ghij') + + bl.consume(1) + t.equal(bl.length, 3) + t.equal(bl.slice(0, 3).toString('ascii'), 'hij') + + bl.consume(2) + t.equal(bl.length, 1) + t.equal(bl.slice(0, 1).toString('ascii'), 'j') + + t.end() +}) + +tape('test readUInt8 / readInt8', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x3 + buf2[2] = 0x4 + buf3[0] = 0x23 + buf3[1] = 0x42 + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readUInt8(2), 0x3) + t.equal(bl.readInt8(2), 0x3) + t.equal(bl.readUInt8(3), 0x4) + t.equal(bl.readInt8(3), 0x4) + t.equal(bl.readUInt8(4), 0x23) + t.equal(bl.readInt8(4), 0x23) + t.equal(bl.readUInt8(5), 0x42) + t.equal(bl.readInt8(5), 0x42) + t.end() +}) + +tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x3 + buf2[2] = 0x4 + buf3[0] = 0x23 + buf3[1] = 0x42 + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readUInt16BE(2), 0x0304) + t.equal(bl.readUInt16LE(2), 0x0403) + t.equal(bl.readInt16BE(2), 0x0304) + t.equal(bl.readInt16LE(2), 0x0403) + t.equal(bl.readUInt16BE(3), 0x0423) + t.equal(bl.readUInt16LE(3), 0x2304) + t.equal(bl.readInt16BE(3), 0x0423) + t.equal(bl.readInt16LE(3), 0x2304) + t.equal(bl.readUInt16BE(4), 0x2342) + t.equal(bl.readUInt16LE(4), 0x4223) + t.equal(bl.readInt16BE(4), 0x2342) + t.equal(bl.readInt16LE(4), 0x4223) + t.end() +}) + +tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x3 + buf2[2] = 0x4 + buf3[0] = 0x23 + buf3[1] = 0x42 + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readUInt32BE(2), 0x03042342) + t.equal(bl.readUInt32LE(2), 0x42230403) + t.equal(bl.readInt32BE(2), 0x03042342) + t.equal(bl.readInt32LE(2), 0x42230403) + t.end() +}) + +tape('test readFloatLE / readFloatBE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x00 + buf2[2] = 0x00 + buf3[0] = 0x80 + buf3[1] = 0x3f + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readFloatLE(2), 0x01) + t.end() +}) + +tape('test readDoubleLE / readDoubleBE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(10) + , bl = new BufferList() + + buf2[1] = 0x55 + buf2[2] = 0x55 + buf3[0] = 0x55 + buf3[1] = 0x55 + buf3[2] = 0x55 + buf3[3] = 0x55 + buf3[4] = 0xd5 + buf3[5] = 0x3f + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readDoubleLE(2), 0.3333333333333333) + t.end() +}) + +tape('test toString', function (t) { + var bl = new BufferList() + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.toString('ascii', 0, 10), 'abcdefghij') + t.equal(bl.toString('ascii', 3, 10), 'defghij') + t.equal(bl.toString('ascii', 3, 6), 'def') + t.equal(bl.toString('ascii', 3, 8), 'defgh') + t.equal(bl.toString('ascii', 5, 10), 'fghij') + + t.end() +}) + +tape('test toString encoding', function (t) { + var bl = new BufferList() + , b = new Buffer('abcdefghij\xff\x00') + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + bl.append(new Buffer('\xff\x00')) + + 'hex utf8 utf-8 ascii binary base64 ucs2 ucs-2 utf16le utf-16le' + .split(' ') + .forEach(function (enc) { + t.equal(bl.toString(enc), b.toString(enc)) + }) + + t.end() +}) + +tape('test stream', function (t) { + var random = crypto.randomBytes(1024 * 1024) + , rndhash = hash(random, 'md5') + , md5sum = crypto.createHash('md5') + , bl = new BufferList(function (err, buf) { + t.ok(Buffer.isBuffer(buf)) + t.ok(err === null) + t.equal(rndhash, hash(bl.slice(), 'md5')) + t.equal(rndhash, hash(buf, 'md5')) + + bl.pipe(fs.createWriteStream('/tmp/bl_test_rnd_out.dat')) + .on('close', function () { + var s = fs.createReadStream('/tmp/bl_test_rnd_out.dat') + s.on('data', md5sum.update.bind(md5sum)) + s.on('end', function() { + t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!') + t.end() + }) + }) + + }) + + fs.writeFileSync('/tmp/bl_test_rnd.dat', random) + fs.createReadStream('/tmp/bl_test_rnd.dat').pipe(bl) +}) + +tape('instantiation with Buffer', function (t) { + var buf = crypto.randomBytes(1024) + , buf2 = crypto.randomBytes(1024) + , b = BufferList(buf) + + t.equal(hash(buf, 'md5'), hash(b.slice(), 'md5'), 'same hash!') + b = BufferList([ buf, buf2 ]) + t.equal(hash(b.slice(), 'md5'), hash(Buffer.concat([ buf, buf2 ]), 'md5'), 'same hash!') + t.end() +}) + +tape('test String appendage', function (t) { + var bl = new BufferList() + , b = new Buffer('abcdefghij\xff\x00') + + bl.append('abcd') + bl.append('efg') + bl.append('hi') + bl.append('j') + bl.append('\xff\x00') + + 'hex utf8 utf-8 ascii binary base64 ucs2 ucs-2 utf16le utf-16le' + .split(' ') + .forEach(function (enc) { + t.equal(bl.toString(enc), b.toString(enc)) + }) + + t.end() +}) + +tape('write nothing, should get empty buffer', function (t) { + t.plan(3) + BufferList(function (err, data) { + t.notOk(err, 'no error') + t.ok(Buffer.isBuffer(data), 'got a buffer') + t.equal(0, data.length, 'got a zero-length buffer') + t.end() + }).end() +}) + +tape('unicode string', function (t) { + t.plan(2) + var inp1 = '\u2600' + , inp2 = '\u2603' + , exp = inp1 + ' and ' + inp2 + , bl = BufferList() + bl.write(inp1) + bl.write(' and ') + bl.write(inp2) + t.equal(exp, bl.toString()) + t.equal(new Buffer(exp).toString('hex'), bl.toString('hex')) +}) + +tape('should emit finish', function (t) { + var source = BufferList() + , dest = BufferList() + + source.write('hello') + source.pipe(dest) + + dest.on('finish', function () { + t.equal(dest.toString('utf8'), 'hello') + t.end() + }) +}) + +tape('basic copy', function (t) { + var buf = crypto.randomBytes(1024) + , buf2 = new Buffer(1024) + , b = BufferList(buf) + + b.copy(buf2) + t.equal(hash(b.slice(), 'md5'), hash(buf2, 'md5'), 'same hash!') + t.end() +}) + +tape('copy after many appends', function (t) { + var buf = crypto.randomBytes(512) + , buf2 = new Buffer(1024) + , b = BufferList(buf) + + b.append(buf) + b.copy(buf2) + t.equal(hash(b.slice(), 'md5'), hash(buf2, 'md5'), 'same hash!') + t.end() +}) + +tape('copy at a precise position', function (t) { + var buf = crypto.randomBytes(1004) + , buf2 = new Buffer(1024) + , b = BufferList(buf) + + b.copy(buf2, 20) + t.equal(hash(b.slice(), 'md5'), hash(buf2.slice(20), 'md5'), 'same hash!') + t.end() +}) + +tape('copy starting from a precise location', function (t) { + var buf = crypto.randomBytes(10) + , buf2 = new Buffer(5) + , b = BufferList(buf) + + b.copy(buf2, 0, 5) + t.equal(hash(b.slice(5), 'md5'), hash(buf2, 'md5'), 'same hash!') + t.end() +}) + +tape('copy in an interval', function (t) { + var buf = crypto.randomBytes(10) + , buf2 = new Buffer(3) + , b = BufferList(buf) + , expected = new Buffer(3) + + // put the same old data there + buf2.copy(expected) + buf.copy(expected, 0, 5, 7) + + b.copy(buf2, 0, 5, 7) + t.equal(hash(expected, 'md5'), hash(buf2, 'md5'), 'same hash!') + t.end() +}) + +tape('copy an interval between two buffers', function (t) { + var buf = crypto.randomBytes(10) + , buf2 = new Buffer(10) + , b = BufferList(buf) + + b.append(buf) + b.copy(buf2, 0, 5, 15) + + t.equal(hash(b.slice(5, 15), 'md5'), hash(buf2, 'md5'), 'same hash!') + t.end() +}) + +tape('duplicate', function (t) { + t.plan(2) + + var bl = new BufferList('abcdefghij\xff\x00') + , dup = bl.duplicate() + + t.equal(bl.prototype, dup.prototype) + t.equal(bl.toString('hex'), dup.toString('hex')) +}) + +tape('handle error', function (t) { + t.plan(2) + fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) { + t.ok(err instanceof Error, 'has error') + t.notOk(data, 'no data') + })) +}) \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.jshintrc b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.jshintrc new file mode 100644 index 00000000..db1ddbf3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.jshintrc @@ -0,0 +1,15 @@ +{ + "indent": 2, + "eqnull": true, + "laxbreak": true, + "proto": true, + "undef": true, + "node": true, + "quotmark": "single", + "globals": { + "expect": true, + "it": true, + "describe": true, + "beforeEach": true + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.npmignore new file mode 100644 index 00000000..64b7e3f2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.npmignore @@ -0,0 +1,8 @@ +src/ +support/ +tests/ +examples/ +*.sock +*.tmproj +coverage.html +lib-cov diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.travis.yml new file mode 100644 index 00000000..bff44acc --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - 0.8 + - "0.10" + - 0.11 +matrix: + fast_finish: true + allow_failures: + - node_js: 0.11 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/CONTRIBUTING.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/CONTRIBUTING.md new file mode 100644 index 00000000..cc38bb8d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# Contributing to Cheerio + +Thanks for your interest in contributing to the project! Here's a rundown of +how we'd like to work with you: + +1. File an issue on GitHub describing the contribution you'd like to make. This + will help us to get you started on the right foot. +2. Create a single commit that addresses the issue: + 1. Follow the project's code style (see below) + 2. Add enough unit tests to "prove" that your patch is correct + 3. Update the project documentation as needed (see below) + 4. Describe your approach with as much detail as necessary in the git + commit message +3. Open a pull request, and reference the initial issue in the pull request + message. + +# Documentation + +Any API change should be reflected in the project's README.md file. Reuse +[jQuery's documentation](http://api.jquery.com) wherever possible, but take +care to note aspects that make Cheerio distinct. + +# Code Style + +This section is by no means complete. For undocumented stylistic choices, +please try to maintain consistency with the code base. + +- Single quotes: `'` +- Whitespace + - Two-space "soft" tabs + - Once space following control flow statements (`if (condition) {` rather + than `if(condition) {`) + - Remove trailing spaces + - [End each file with a newline + character.](https://github.com/editorconfig/editorconfig/wiki/Newline-at-End-of-File-Support) +- Terminate every statement with a semicolon +- Private functionality (for re-using functionality that isn't part of the + jQuery API) + - *Static methods*: If the functionality does not require a reference to a + Cheerio instance, simply define a named function within the module it is + needed. + - *Instance methods*: If the functionality requires a reference to a Cheerio + instance, informally define the method as "private" using the following + conventions: + - Define the method as a function on the Cheerio prototype + - Prefix the method name with an underscore (`_`) character + - Include `@api private` in the code comment the documents the method diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/History.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/History.md new file mode 100644 index 00000000..f5be0de5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/History.md @@ -0,0 +1,321 @@ + +0.13.1 / 2014-01-07 +================== + + * Fix select with context in Cheerio function (@jugglinmike) + * Remove unecessary DOM maintenance logic (@jugglinmike) + * Deprecate support for node 0.6 + +0.13.0 / 2013-12-30 +================== + + * Remove "root" node (@jugglinmike) + * Fix bug in `prevAll`, `prev`, `nextAll`, `next`, `prevUntil`, `nextUntil` (@jugglinmike) + * Fix `replaceWith` method (@jugglinmike) + * added nextUntil() and prevUntil() (@finspin) + * Remove internal `connect` function (@jugglinmike) + * Rename `Cheerio#make` to document private status (@jugginmike) + * Remove extraneous call to `_.uniq` (@jugglinmike) + * Use CSSselect library directly (@jugglinmike) + * Run CI against Node v0.11 as an allowed failure (@jugginmike) + * Correct bug in `Cheerio#parents` (@jugglinmike) + * Implement `$.fn.end` (@jugginmike) + * Ignore colons inside of url(.*) when parsing css (@Meekohi) + * Introduce rudimentary benchmark suite (@jugglinmike) + * Update HtmlParser2 version (@jugglinmike) + * Correct inconsistency in `$.fn.map` (@jugglinmike) + * fixed traversing tests (@finspin) + * Simplify `make` method (@jugglinmike) + * Avoid shadowing instance methods from arrays (@jugglinmike) + +0.12.4 / 2013-11-12 +================== + + * Coerce JSON values returned by `data` (@jugglinmike) + * issue #284: when rendering HTML, use original data attributes (@Trott) + * Introduce JSHint for automated code linting (@jugglinmike) + * Prevent `find` from returning duplicate elements (@jugglinmike) + * Implement function signature of `replaceWith` (@jugglinmike) + * Implement function signature of `before` (@jugglinmike) + * Implement function signature of `after` (@jugglinmike) + * Implement function signature of `append`/`prepend` (@jugglinmike) + * Extend iteration methods to accept nodes (@jugglinmike) + * Improve `removeClass` (@jugglinmike) + * Complete function signature of `addClass` (@jugglinmike) + * Fix bug in `removeClass` (@jugglinmike) + * Improve contributing.md (@jugglinmike) + * Fix and document .css() (@jugglinmike) + +0.12.3 / 2013-10-04 +=================== + + * Add .toggleClass() function (@cyberthom) + * Add contributing guidelines (@jugglinmike) + * Fix bug in `siblings` (@jugglinmike) + * Correct the implementation `filter` and `is` (@jugglinmike) + * add .data() function (@andi-neck) + * add .css() (@yields) + * Implements contents() (@jlep) + +0.12.2 / 2013-09-04 +================== + + * Correct implementation of `$.fn.text` (@jugglinmike) + * Refactor Cheerio array creation (@jugglinmike) + * Extend manipulation methods to accept Arrays (@jugglinmike) + * support .attr(attributeName, function(index, attr)) (@xiaohwan) + +0.12.1 / 2013-07-30 +================== + + * Correct behavior of `Cheerio#parents` (@jugglinmike) + * Double quotes inside attributes kills HTML (@khoomeister) + * Making next({}) and prev({}) return empty object (@absentTelegraph) + * Implement $.parseHTML (@jugglinmike) + * Correct bug in jQuery.fn.closest (@jugglinmike) + * Correct behavior of $.fn.val on 'option' elements (@jugglinmike) + +0.12.0 / 2013-06-09 +=================== + + * Breaking Change: Changed context from parent to the actual passed one (@swissmanu) + * Fixed: jquery checkbox val behavior (@jhubble) + * Added: output xml with $.xml() (@Maciek416) + * Bumped: htmlparser2 to 3.1.1 + * Fixed: bug in attr(key, val) on empty objects (@farhadi) + * Added: prevAll, nextAll (@lessmind) + * Fixed: Safety check in parents and closest (@zero21xxx) + * Added: .is(sel) (@zero21xxx) + +0.11.0 / 2013-04-22 +================== + +* Added: .closest() (@jeremy-dentel) +* Added: .parents() (@zero21xxx) +* Added: .val() (@rschmukler & @leahciMic) +* Added: Travis support for node 0.10.0 (@jeremy-dentel) +* Fixed: .find() if no selector (@davidchambers) +* Fixed: Propagate syntax errors caused by invalid selectors (@davidchambers) + +0.10.8 / 2013-03-11 +================== + +* Add slice method (SBoudrias) + +0.10.7 / 2013-02-10 +================== + +* Code & doc cleanup (davidchambers) +* Fixed bug in filter (jugglinmike) + +0.10.6 / 2013-01-29 +================== + +* Added `$.contains(...)` (jugglinmike) +* formatting cleanup (davidchambers) +* Bug fix for `.children()` (jugglinmike & davidchambers) +* Remove global `render` bug (wvl) + +0.10.5 / 2012-12-18 +=================== + +* Fixed botched publish from 0.10.4 - changes should now be present + +0.10.4 / 2012-12-16 +================== + +* $.find should query descendants only (@jugglinmike) +* Tighter underscore dependency + +0.10.3 / 2012-11-18 +=================== + +* fixed outer html bug +* Updated documentation for $(...).html() and $.html() + +0.10.2 / 2012-11-17 +=================== + +* Added a toString() method (@bensheldon) +* use `_.each` and `_.map` to simplify cheerio namesakes (@davidchambers) +* Added filter() with tests and updated readme (@bensheldon & @davidchambers) +* Added spaces between attributes rewritten by removeClass (@jos3000) +* updated docs to remove reference to size method (@ironchefpython) +* removed tidy from cheerio + +0.10.1 / 2012-10-04 +=================== + +* Fixed regression, filtering with a context (#106) + +0.10.0 / 2012-09-24 +=================== + +* Greatly simplified and reorganized the library, reducing the loc by 30% +* Now supports mocha's test-coverage +* Deprecated self-closing tags (HTML5 doesn't require them) +* Fixed error thrown in removeClass(...) @robashton + +0.9.2 / 2012-08-10 +================== + +* added $(...).map(fn) +* manipulation: refactor `makeCheerioArray` +* make .removeClass() remove *all* occurrences (#64) + +0.9.1 / 2012-08-03 +================== + +* fixed bug causing options not to make it to the parser + +0.9.0 / 2012-07-24 +================== + +* Added node 8.x support +* Removed node 4.x support +* Add html(dom) support (@wvl) +* fixed xss vulnerabilities on .attr(), .text(), & .html() (@benatkin, @FB55) +* Rewrote tests into javascript, removing coffeescript dependency (@davidchambers) +* Tons of cleanup (@davidchambers) + +0.8.3 / 2012-06-12 +================== + +* Fixed minor package regression (closes #60) + +0.8.2 / 2012-06-11 +================== + +* Now fails gracefully in cases that involve special chars, which is inline with jQuery (closes #59) +* text() now decode special entities (closes #52) +* updated travis.yml to test node 4.x + +0.8.1 / 2012-06-02 +================== + +* fixed regression where if you created an element, it would update the root +* compatible with node 4.x (again) + +0.8.0 / 2012-05-27 +================== + +* Updated CSS parser to use FB55/CSSselect. Cheerio now supports most CSS3 psuedo selectors thanks to @FB55. +* ignoreWhitespace now on by default again. See #55 for context. +* Changed $(':root') to $.root(), cleaned up $.clone() +* Support for .eq(i) thanks to @alexbardas +* Removed support for node 0.4.x +* Fixed memory leak where package.json was continually loaded +* Tons more tests + +0.7.0 / 2012-04-08 +================== + +* Now testing with node v0.7.7 +* Added travis-ci integration +* Replaced should.js with expect.js. Browser testing to come +* Fixed spacing between attributes and their values +* Added HTML pretty print +* Exposed node-htmlparser2 parsing options +* Revert .replaceWith(...) to be consistent with jQuery + +0.6.2 / 2012-02-12 +================== + +* Fixed .replaceWith(...) regression + +0.6.1 / 2012-02-12 +================== + +* Added .first(), .last(), and .clone() commands. +* Option to parse using whitespace added to `.load`. +* Many bug fixes to make cheerio more aligned with jQuery. +* Added $(':root') to select the highest level element. + +Many thanks to the contributors that made this release happen: @ironchefpython and @siddMahen + +0.6.0 / 2012-02-07 +================== + +* *Important:* `$(...).html()` now returns inner HTML, which is in line with the jQuery spec +* `$.html()` returns the full HTML string. `$.html([cheerioObject])` will return the outer(selected element's tag) and inner HTML of that object +* Fixed bug that prevented HTML strings with depth (eg. `append('
    ')`) from getting `parent`, `next`, `prev` attributes. +* Halted [htmlparser2](https://github.com/FB55/node-htmlparser) at v2.2.2 until single attributes bug gets fixed. + +0.5.1 / 2012-02-05 +================== + +* Fixed minor regression: $(...).text(fn) would fail + +0.5.1 / 2012-02-05 +================== + +* Fixed regression: HTML pages with comments would fail + +0.5.0 / 2012-02-04 +================== + +* Transitioned from Coffeescript back to Javascript +* Parser now ignores whitespace +* Fixed issue with double slashes on self-enclosing tags +* Added boolean attributes to html rendering + +0.4.2 / 2012-01-16 +================== + +* Multiple selectors support: $('.apple, .orange'). Thanks @siddMahen! +* Update package.json to always use latest cheerio-soupselect +* Fix memory leak in index.js + +0.4.1 / 2011-12-19 +================== +* Minor packaging changes to allow `make test` to work from npm installation + +0.4.0 / 2011-12-19 +================== + +* Rewrote all unit tests as cheerio transitioned from vows -> mocha +* Internally, renderer.render -> render(...), parser.parse -> parse(...) +* Append, prepend, html, before, after all work with only text (no tags) +* Bugfix: Attributes can now be removed from script and style tags +* Added yield as a single tag +* Cheerio now compatible with node >=0.4.7 + +0.3.2 / 2011-12-1 +================= + +* Fixed $(...).text(...) to work with "root" element + +0.3.1 / 2011-11-25 +================== + +* Now relying on cheerio-soupselect instead of node-soupselect +* Removed all lingering htmlparser dependencies +* parser now returns parent "root" element. Root now never needs to be updated when there is multiple roots. This fixes ongoing issues with before(...), after(...) and other manipulation functions +* Added jQuery's $(...).replaceWith(...) + +0.3.0 / 2011-11-19 +================== + +* Now using htmlparser2 for parsing (2x speed increase, cleaner, actively developed) +* Added benchmark directory for future speed tests +* $('...').dom() was funky, so it was removed in favor of $('...').get(). $.dom() still works the same. +* $.root now correctly static across all instances of $ +* Added a screencast + +0.2.2 / 2011-11-9 +================= + +* Traversing will select ` + + + + jQuery() | jQuery API Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + + + + +
    + +
    +
    + +
    +
    +

    jQuery()

    +
    + +
    + +
    + Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string.

    +jQuery( selector [, context ] )Returns: jQuery +

    +
    +

    Description: Accepts a string containing a CSS selector which is then used to match a set of elements.

    + +
    +

    In the first formulation listed above, jQuery() — which can also be written as $() — searches through the DOM for any elements that match the provided selector and creates a new jQuery object that references these elements:

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( "div.foo" );
    +
    +
    + +

    If no elements match the provided selector, the new jQuery object is "empty"; that is, it contains no elements and has .length property of 0.

    +

    Selector Context

    +

    By default, selectors perform their searches within the DOM starting at the document root. However, an alternate context can be given for the search by using the optional second parameter to the $() function. For example, to do a search within an event handler, the search can be restricted like so:

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    +
    $( "div.foo" ).click(function() {
    $( "span", this ).addClass( "bar" );
    });
    +
    +
    + +

    When the search for the span selector is restricted to the context of this, only spans within the clicked element will get the additional class.

    +

    Internally, selector context is implemented with the .find() method, so $( "span", this ) is equivalent to $( this ).find( "span" ).

    + +

    Using DOM elements

    +

    The second and third formulations of this function create a jQuery object using one or more DOM elements that were already selected in some other way.

    +

    Note: These formulations are meant to consume only DOM elements; feeding mixed data to the elementArray form is particularly discouraged.

    +

    A common use of this facility is to call jQuery methods on an element that has been passed to a callback function through the keyword this:

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    +
    $( "div.foo" ).click(function() {
    $( this ).slideUp();
    });
    +
    +
    + +

    This example causes elements to be hidden with a sliding animation when clicked. Because the handler receives the clicked item in the this keyword as a bare DOM element, the element must be passed to the $() function before applying jQuery methods to it.

    +

    XML data returned from an Ajax call can be passed to the $() function so individual elements of the XML structure can be retrieved using .find() and other DOM traversal methods.

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    +
    $.post( "url.xml", function( data ) {
    var $child = $( data ).find( "child" );
    });
    +
    +
    + + +

    Cloning jQuery Objects

    +

    When a jQuery object is passed to the $() function, a clone of the object is created. This new jQuery object references the same DOM elements as the initial one.

    + +

    Returning an Empty Set

    +

    As of jQuery 1.4, calling the jQuery() method with no arguments returns an empty jQuery set (with a .length property of 0). In previous versions of jQuery, this would return a set containing the document node.

    +

    Working With Plain Objects

    +

    At present, the only operations supported on plain JavaScript objects wrapped in jQuery are: .data(),.prop(),.on(), .off(), .trigger() and .triggerHandler(). The use of .data() (or any method requiring .data()) on a plain object will result in a new property on the object called jQuery{randomNumber} (eg. jQuery123456789).

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    4
    + +
    5
    + +
    6
    + +
    7
    + +
    8
    + +
    9
    + +
    10
    + +
    11
    + +
    12
    + +
    13
    + +
    14
    + +
    15
    + +
    16
    + +
    17
    + +
    18
    + +
    19
    + +
    20
    + +
    21
    + +
    22
    + +
    23
    + +
    +
    // Define a plain object
    var foo = { foo: "bar", hello: "world" };
    // Pass it to the jQuery function
    var $foo = $( foo );
    // Test accessing property values
    var test1 = $foo.prop( "foo" ); // bar
    // Test setting property values
    $foo.prop( "foo", "foobar" );
    var test2 = $foo.prop( "foo" ); // foobar
    // Test using .data() as summarized above
    $foo.data( "keyName", "someValue" );
    console.log( $foo ); // will now contain a jQuery{randomNumber} property
    // Test binding an event name and triggering
    $foo.on( "eventName", function () {
    console.log( "eventName was called" );
    });
    $foo.trigger( "eventName" ); // Logs "eventName was called"
    +
    +
    + +

    Should .trigger( "eventName" ) be used, it will search for an "eventName" property on the object and attempt to execute it after any attached jQuery handlers are executed. It does not check whether the property is a function or not. To avoid this behavior, .triggerHandler( "eventName" ) should be used instead.

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $foo.triggerHandler( "eventName" ); // Also logs "eventName was called"
    +
    +
    + +
    +

    Examples:

    +

    Example: Find all p elements that are children of a div element and apply a border to them. +

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    4
    + +
    5
    + +
    6
    + +
    7
    + +
    8
    + +
    9
    + +
    10
    + +
    11
    + +
    12
    + +
    13
    + +
    14
    + +
    15
    + +
    16
    + +
    17
    + +
    18
    + +
    19
    + +
    +
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>jQuery demo</title>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    </head>
    <body>
    <p>one</p>
    <div><p>two</p></div>
    <p>three</p>
    <script>
    $( "div > p" ).css( "border", "1px solid gray" );
    </script>
    </body>
    </html>
    +
    +
    + +

    Demo:

    +
    +
    +
    +

    Example: Find all inputs of type radio within the first form in the document. +

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( "input:radio", document.forms[ 0 ] );
    +
    +
    + +
    +
    +

    Example: Find all div elements within an XML document from an Ajax response. +

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( "div", xml.responseXML );
    +
    +
    + +
    +
    +

    Example: Set the background color of the page to black. +

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( document.body ).css( "background", "black" );
    +
    +
    + +
    +
    +

    Example: Hide all the input elements within a form. +

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( myForm.elements ).hide();
    +
    +
    + +
    +

    +jQuery( html [, ownerDocument ] )Returns: jQuery +

    +
    +

    Description: Creates DOM elements on the fly from the provided string of raw HTML.

    +
      +
    • +

      +version added: 1.0jQuery( html [, ownerDocument ] ) +

      +
        +
      • +
        html
        +
        Type: htmlString +
        +
        A string of HTML to create on the fly. Note that this parses HTML, not XML.
        +
      • +
      • +
        ownerDocument
        +
        Type: document +
        +
        A document in which the new elements will be created.
        +
      • +
      +
    • +
    • +

      +version added: 1.4jQuery( html, attributes ) +

      +
        +
      • +
        html
        +
        Type: htmlString +
        +
        A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).
        +
      • +
      • +
        attributes
        +
        Type: PlainObject +
        +
        An object of attributes, events, and methods to call on the newly-created element.
        +
      • +
      +
    • +
    +
    +

    Creating New Elements

    +

    If a string is passed as the parameter to $(), jQuery examines the string to see if it looks like HTML (i.e., it starts with <tag ... >). If not, the string is interpreted as a selector expression, as explained above. But if the string appears to be an HTML snippet, jQuery attempts to create new DOM elements as described by the HTML. Then a jQuery object is created and returned that refers to these elements. You can perform any of the usual jQuery methods on this object:

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( "<p id='test'>My <em>new</em> text</p>" ).appendTo( "body" );
    +
    +
    + +

    For explicit parsing of a string to HTML, use the $.parseHTML() method.

    +

    By default, elements are created with an ownerDocument matching the document into which the jQuery library was loaded. Elements being injected into a different document should be created using that document, e.g., $("<p>hello iframe</p>", $("#myiframe").prop("contentWindow").document).

    +

    If the HTML is more complex than a single tag without attributes, as it is in the above example, the actual creation of the elements is handled by the browser's innerHTML mechanism. In most cases, jQuery creates a new <div> element and sets the innerHTML property of the element to the HTML snippet that was passed in. When the parameter has a single tag (with optional closing tag or quick-closing) — $( "<img />" ) or $( "<img>" ), $( "<a></a>" ) or $( "<a>" ) — jQuery creates the element using the native JavaScript createElement() function.

    +

    When passing in complex HTML, some browsers may not generate a DOM that exactly replicates the HTML source provided. As mentioned, jQuery uses the browser"s .innerHTML property to parse the passed HTML and insert it into the current document. During this process, some browsers filter out certain elements such as <html>, <title>, or <head> elements. As a result, the elements inserted may not be representative of the original string passed.

    +

    Filtering isn't, however, limited to these tags. For example, Internet Explorer prior to version 8 will also convert all href properties on links to absolute URLs, and Internet Explorer prior to version 9 will not correctly handle HTML5 elements without the addition of a separate compatibility layer.

    +

    To ensure cross-platform compatibility, the snippet must be well-formed. Tags that can contain other elements should be paired with a closing tag:

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( "<a href='http://jquery.com'></a>" );
    +
    +
    + +

    Tags that cannot contain elements may be quick-closed or not:

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    +
    $( "<img>" );
    $( "<input>" );
    +
    +
    + +

    When passing HTML to jQuery(), please also note that text nodes are not treated as DOM elements. With the exception of a few methods (such as .content()), they are generally otherwise ignored or removed. E.g:

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    +
    var el = $( "1<br>2<br>3" ); // returns [<br>, "2", <br>]
    el = $( "1<br>2<br>3 >" ); // returns [<br>, "2", <br>, "3 &gt;"]
    +
    +
    + +

    This behavior is expected.

    +

    As of jQuery 1.4, the second argument to jQuery() can accept a plain object consisting of a superset of the properties that can be passed to the .attr() method.

    +

    Important: If the second argument is passed, the HTML string in the first argument must represent a a simple element with no attributes. As of jQuery 1.4, any event type can be passed in, and the following jQuery methods can be called: val, css, html, text, data, width, height, or offset.

    +

    As of jQuery 1.8, any jQuery instance method (a method of jQuery.fn) can be used as a property of the object passed to the second parameter:

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    4
    + +
    5
    + +
    6
    + +
    7
    + +
    8
    + +
    +
    $( "<div></div>", {
    "class": "my-div",
    on: {
    touchstart: function( event ) {
    // Do something
    }
    }
    }).appendTo( "body" );
    +
    +
    + +

    The name "class" must be quoted in the object since it is a JavaScript reserved word, and "className" cannot be used since it refers to the DOM property, not the attribute.

    +

    While the second argument is convenient, its flexibility can lead to unintended consequences (e.g. $( "<input>", {size: "4"} ) calling the .size() method instead of setting the size attribute). The previous code block could thus be written instead as:

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    4
    + +
    5
    + +
    6
    + +
    7
    + +
    8
    + +
    +
    $( "<div></div>" )
    .addClass( "my-div" )
    .on({
    touchstart: function( event ) {
    // Do something
    }
    })
    .appendTo( "body" );
    +
    +
    + +
    +

    Examples:

    +

    Example: Create a div element (and all of its contents) dynamically and append it to the body element. Internally, an element is created and its innerHTML property set to the given markup. +

    +
    + + + + + + + +
    + +
    1
    + +
    +
    $( "<div><p>Hello</p></div>" ).appendTo( "body" )
    +
    +
    + +
    +
    +

    Example: Create some DOM elements. +

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    4
    + +
    5
    + +
    6
    + +
    7
    + +
    8
    + +
    +
    $( "<div/>", {
    "class": "test",
    text: "Click me!",
    click: function() {
    $( this ).toggleClass( "test" );
    }
    })
    .appendTo( "body" );
    +
    +
    + +
    +

    +jQuery( callback )Returns: jQuery +

    +
    +

    Description: Binds a function to be executed when the DOM has finished loading.

    + +
    +

    This function behaves just like $( document ).ready(), in that it should be used to wrap other $() operations on your page that depend on the DOM being ready. While this function is, technically, chainable, there really isn"t much use for chaining against it.

    +
    +

    Examples:

    +

    Example: Execute the function when the DOM is ready to be used. +

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    +
    $(function() {
    // Document is ready
    });
    +
    +
    + +
    +
    +

    Example: Use both the shortcut for $(document).ready() and the argument to write failsafe jQuery code using the $ alias, without relying on the global alias. +

    +
    + + + + + + + +
    + +
    1
    + +
    2
    + +
    3
    + +
    +
    jQuery(function( $ ) {
    // Your code using failsafe $ alias here...
    });
    +
    +
    + +
    +
    + +
    +
    + + +
    +
    +
    + + + + + + + + + + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/benchmark/jquery-2.0.3.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/benchmark/jquery-2.0.3.js new file mode 100644 index 00000000..ebc6c187 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/benchmark/jquery-2.0.3.js @@ -0,0 +1,8829 @@ +/*! + * jQuery JavaScript Library v2.0.3 + * http://jquery.com/ + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * + * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2013-07-03T13:30Z + */ +(function( window, undefined ) { + +// Can't do this because several apps including ASP.NET trace +// the stack via arguments.caller.callee and Firefox dies if +// you try to trace through "use strict" call chains. (#13335) +// Support: Firefox 18+ +//"use strict"; +var + // A central reference to the root jQuery(document) + rootjQuery, + + // The deferred used on DOM ready + readyList, + + // Support: IE9 + // For `typeof xmlNode.method` instead of `xmlNode.method !== undefined` + core_strundefined = typeof undefined, + + // Use the correct document accordingly with window argument (sandbox) + location = window.location, + document = window.document, + docElem = document.documentElement, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // [[Class]] -> type pairs + class2type = {}, + + // List of deleted data cache ids, so we can reuse them + core_deletedIds = [], + + core_version = "2.0.3", + + // Save a reference to some core methods + core_concat = core_deletedIds.concat, + core_push = core_deletedIds.push, + core_slice = core_deletedIds.slice, + core_indexOf = core_deletedIds.indexOf, + core_toString = class2type.toString, + core_hasOwn = class2type.hasOwnProperty, + core_trim = core_version.trim, + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Used for matching numbers + core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, + + // Used for splitting on whitespace + core_rnotwhite = /\S+/g, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, + + // Matches dashed string for camelizing + rmsPrefix = /^-ms-/, + rdashAlpha = /-([\da-z])/gi, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return letter.toUpperCase(); + }, + + // The ready event handler and self cleanup method + completed = function() { + document.removeEventListener( "DOMContentLoaded", completed, false ); + window.removeEventListener( "load", completed, false ); + jQuery.ready(); + }; + +jQuery.fn = jQuery.prototype = { + // The current version of jQuery being used + jquery: core_version, + + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + + // scripts is true for back-compat + jQuery.merge( this, jQuery.parseHTML( + match[1], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The default length of a jQuery object is 0 + length: 0, + + toArray: function() { + return core_slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + ret.context = this.context; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Add the callback + jQuery.ready.promise().done( fn ); + + return this; + }, + + slice: function() { + return this.pushStack( core_slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: core_push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ), + + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger("ready").off("ready"); + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray, + + isWindow: function( obj ) { + return obj != null && obj === obj.window; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + if ( obj == null ) { + return String( obj ); + } + // Support: Safari <= 5.1 (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ core_toString.call(obj) ] || "object" : + typeof obj; + }, + + isPlainObject: function( obj ) { + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + // Support: Firefox <20 + // The try/catch suppresses exceptions thrown when attempting to access + // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 + try { + if ( obj.constructor && + !core_hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { + return false; + } + } catch ( e ) { + return false; + } + + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; + }, + + isEmptyObject: function( obj ) { + var name; + for ( name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + // data: string of html + // context (optional): If specified, the fragment will be created in this context, defaults to document + // keepScripts (optional): If true, will include scripts passed in the html string + parseHTML: function( data, context, keepScripts ) { + if ( !data || typeof data !== "string" ) { + return null; + } + if ( typeof context === "boolean" ) { + keepScripts = context; + context = false; + } + context = context || document; + + var parsed = rsingleTag.exec( data ), + scripts = !keepScripts && []; + + // Single tag + if ( parsed ) { + return [ context.createElement( parsed[1] ) ]; + } + + parsed = jQuery.buildFragment( [ data ], context, scripts ); + + if ( scripts ) { + jQuery( scripts ).remove(); + } + + return jQuery.merge( [], parsed.childNodes ); + }, + + parseJSON: JSON.parse, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + if ( !data || typeof data !== "string" ) { + return null; + } + + // Support: IE9 + try { + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } catch ( e ) { + xml = undefined; + } + + if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + globalEval: function( code ) { + var script, + indirect = eval; + + code = jQuery.trim( code ); + + if ( code ) { + // If the code includes a valid, prologue position + // strict mode pragma, execute code by injecting a + // script tag into the document. + if ( code.indexOf("use strict") === 1 ) { + script = document.createElement("script"); + script.text = code; + document.head.appendChild( script ).parentNode.removeChild( script ); + } else { + // Otherwise, avoid the DOM node creation, insertion + // and removal by using an indirect global eval + indirect( code ); + } + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + }, + + // args is for internal usage only + each: function( obj, callback, args ) { + var value, + i = 0, + length = obj.length, + isArray = isArraylike( obj ); + + if ( args ) { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } + } + + return obj; + }, + + trim: function( text ) { + return text == null ? "" : core_trim.call( text ); + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArraylike( Object(arr) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + core_push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + return arr == null ? -1 : core_indexOf.call( arr, elem, i ); + }, + + merge: function( first, second ) { + var l = second.length, + i = first.length, + j = 0; + + if ( typeof l === "number" ) { + for ( ; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var retVal, + ret = [], + i = 0, + length = elems.length; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, + i = 0, + length = elems.length, + isArray = isArraylike( elems ), + ret = []; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return core_concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + var tmp, args, proxy; + + if ( typeof context === "string" ) { + tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + args = core_slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || jQuery.guid++; + + return proxy; + }, + + // Multifunctional method to get and set values of a collection + // The value/s can optionally be executed if it's a function + access: function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + length = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < length; i++ ) { + fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + } + } + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + length ? fn( elems[0], key ) : emptyGet; + }, + + now: Date.now, + + // A method for quickly swapping in/out CSS properties to get correct calculations. + // Note: this method belongs to the css module but it's needed here for the support module. + // If support gets modularized, this method should be moved back to the css module. + swap: function( elem, options, callback, args ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.apply( elem, args || [] ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; + } +}); + +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { + + readyList = jQuery.Deferred(); + + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( jQuery.ready ); + + } else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed, false ); + } + } + return readyList.promise( obj ); +}; + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +function isArraylike( obj ) { + var length = obj.length, + type = jQuery.type( obj ); + + if ( jQuery.isWindow( obj ) ) { + return false; + } + + if ( obj.nodeType === 1 && length ) { + return true; + } + + return type === "array" || type !== "function" && + ( length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj ); +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); +/*! + * Sizzle CSS Selector Engine v1.9.4-pre + * http://sizzlejs.com/ + * + * Copyright 2013 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2013-06-03 + */ +(function( window, undefined ) { + +var i, + support, + cachedruns, + Expr, + getText, + isXML, + compile, + outermostContext, + sortInput, + + // Local document vars + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + // Instance-specific data + expando = "sizzle" + -(new Date()), + preferredDoc = window.document, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + hasDuplicate = false, + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + return 0; + }, + + // General-purpose constants + strundefined = typeof undefined, + MAX_NEGATIVE = 1 << 31, + + // Instance methods + hasOwn = ({}).hasOwnProperty, + arr = [], + pop = arr.pop, + push_native = arr.push, + push = arr.push, + slice = arr.slice, + // Use a stripped-down indexOf if we can't use a native one + indexOf = arr.indexOf || function( elem ) { + var i = 0, + len = this.length; + for ( ; i < len; i++ ) { + if ( this[i] === elem ) { + return i; + } + } + return -1; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + // http://www.w3.org/TR/css3-syntax/#characters + characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", + + // Loosely modeled on CSS identifier characters + // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors + // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + identifier = characterEncoding.replace( "w", "w#" ), + + // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + + "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", + + // Prefer arguments quoted, + // then not containing pseudos/brackets, + // then attribute selectors/non-parenthetical expressions, + // then anything else + // These preferences are here to reduce the number of selectors + // needing tokenize in the PSEUDO preFilter + pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), + + rsibling = new RegExp( whitespace + "*[+~]" ), + rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rnative = /^[^{]+\{\s*\[native \w/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rescape = /'|\\/g, + + // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), + funescape = function( _, escaped, escapedWhitespace ) { + var high = "0x" + escaped - 0x10000; + // NaN means non-codepoint + // Support: Firefox + // Workaround erroneous numeric interpretation of +"0x" + return high !== high || escapedWhitespace ? + escaped : + // BMP codepoint + high < 0 ? + String.fromCharCode( high + 0x10000 ) : + // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }; + +// Optimize for push.apply( _, NodeList ) +try { + push.apply( + (arr = slice.call( preferredDoc.childNodes )), + preferredDoc.childNodes + ); + // Support: Android<4.0 + // Detect silently failing push.apply + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { apply: arr.length ? + + // Leverage slice if possible + function( target, els ) { + push_native.apply( target, slice.call(els) ); + } : + + // Support: IE<9 + // Otherwise append directly + function( target, els ) { + var j = target.length, + i = 0; + // Can't trust NodeList.length + while ( (target[j++] = els[i++]) ) {} + target.length = j - 1; + } + }; +} + +function Sizzle( selector, context, results, seed ) { + var match, elem, m, nodeType, + // QSA vars + i, groups, old, nid, newContext, newSelector; + + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); + } + + context = context || document; + results = results || []; + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { + return []; + } + + if ( documentIsHTML && !seed ) { + + // Shortcuts + if ( (match = rquickExpr.exec( selector )) ) { + // Speed-up: Sizzle("#ID") + if ( (m = match[1]) ) { + if ( nodeType === 9 ) { + elem = context.getElementById( m ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE, Opera, and Webkit return items + // by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + } else { + // Context is not a document + if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && + contains( context, elem ) && elem.id === m ) { + results.push( elem ); + return results; + } + } + + // Speed-up: Sizzle("TAG") + } else if ( match[2] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Speed-up: Sizzle(".CLASS") + } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // QSA path + if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { + nid = old = expando; + newContext = context; + newSelector = nodeType === 9 && selector; + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + groups = tokenize( selector ); + + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; + + i = groups.length; + while ( i-- ) { + groups[i] = nid + toSelector( groups[i] ); + } + newContext = rsibling.test( selector ) && context.parentNode || context; + newSelector = groups.join(","); + } + + if ( newSelector ) { + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} + +/** + * Create key-value caches of limited size + * @returns {Function(string, Object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; + + function cache( key, value ) { + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key += " " ) > Expr.cacheLength ) { + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return (cache[ key ] = value); + } + return cache; +} + +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created div and expects a boolean result + */ +function assert( fn ) { + var div = document.createElement("div"); + + try { + return !!fn( div ); + } catch (e) { + return false; + } finally { + // Remove from its parent by default + if ( div.parentNode ) { + div.parentNode.removeChild( div ); + } + // release memory in IE + div = null; + } +} + +/** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ +function addHandle( attrs, handler ) { + var arr = attrs.split("|"), + i = attrs.length; + + while ( i-- ) { + Expr.attrHandle[ arr[i] ] = handler; + } +} + +/** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + ( ~b.sourceIndex || MAX_NEGATIVE ) - + ( ~a.sourceIndex || MAX_NEGATIVE ); + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( (cur = cur.nextSibling) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; +} + +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction(function( argument ) { + argument = +argument; + return markFunction(function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ (j = matchIndexes[i]) ] ) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); +} + +/** + * Detect xml + * @param {Element|Object} elem An element or a document + */ +isXML = Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = elem && (elem.ownerDocument || elem).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +// Expose support vars for convenience +support = Sizzle.support = {}; + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var doc = node ? node.ownerDocument || node : preferredDoc, + parent = doc.defaultView; + + // If no document and documentElement is available, return + if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Set our document + document = doc; + docElem = doc.documentElement; + + // Support tests + documentIsHTML = !isXML( doc ); + + // Support: IE>8 + // If iframe document is assigned to "document" variable and if iframe has been reloaded, + // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 + // IE6-8 do not support the defaultView property so parent will be undefined + if ( parent && parent.attachEvent && parent !== parent.top ) { + parent.attachEvent( "onbeforeunload", function() { + setDocument(); + }); + } + + /* Attributes + ---------------------------------------------------------------------- */ + + // Support: IE<8 + // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) + support.attributes = assert(function( div ) { + div.className = "i"; + return !div.getAttribute("className"); + }); + + /* getElement(s)By* + ---------------------------------------------------------------------- */ + + // Check if getElementsByTagName("*") returns only elements + support.getElementsByTagName = assert(function( div ) { + div.appendChild( doc.createComment("") ); + return !div.getElementsByTagName("*").length; + }); + + // Check if getElementsByClassName can be trusted + support.getElementsByClassName = assert(function( div ) { + div.innerHTML = "
    "; + + // Support: Safari<4 + // Catch class over-caching + div.firstChild.className = "i"; + // Support: Opera<10 + // Catch gEBCN failure to find non-leading classes + return div.getElementsByClassName("i").length === 2; + }); + + // Support: IE<10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert(function( div ) { + docElem.appendChild( div ).id = expando; + return !doc.getElementsByName || !doc.getElementsByName( expando ).length; + }); + + // ID find and filter + if ( support.getById ) { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && documentIsHTML ) { + var m = context.getElementById( id ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute("id") === attrId; + }; + }; + } else { + // Support: IE6/7 + // getElementById is not reliable as a find shortcut + delete Expr.find["ID"]; + + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } + + // Tag + Expr.find["TAG"] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== strundefined ) { + return context.getElementsByTagName( tag ); + } + } : + function( tag, context ) { + var elem, + tmp = [], + i = 0, + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( (elem = results[i++]) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Class + Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21) + // We allow this because of a bug in IE8/9 that throws an error + // whenever `document.activeElement` is accessed on an iframe + // So, we allow :focus to pass through QSA all the time to avoid the IE error + // See http://bugs.jquery.com/ticket/13378 + rbuggyQSA = []; + + if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert(function( div ) { + // Select is set to empty string on purpose + // This is to test IE's treatment of not explicitly + // setting a boolean content attribute, + // since its presence should be enough + // http://bugs.jquery.com/ticket/12359 + div.innerHTML = ""; + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); + } + }); + + assert(function( div ) { + + // Support: Opera 10-12/IE8 + // ^= $= *= and empty values + // Should not select anything + // Support: Windows 8 Native Apps + // The type attribute is restricted during .innerHTML assignment + var input = doc.createElement("input"); + input.setAttribute( "type", "hidden" ); + div.appendChild( input ).setAttribute( "t", "" ); + + if ( div.querySelectorAll("[t^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Opera 10-11 does not throw on post-comma invalid pseudos + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } + + if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { + + assert(function( div ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( div, "div" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); + + /* Contains + ---------------------------------------------------------------------- */ + + // Element contains another + // Purposefully does not implement inclusive descendent + // As in, an element does not contain itself + contains = rnative.test( docElem.contains ) || docElem.compareDocumentPosition ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + )); + } : + function( a, b ) { + if ( b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = docElem.compareDocumentPosition ? + function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b ); + + if ( compare ) { + // Disconnected nodes + if ( compare & 1 || + (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + + // Choose the first element that is related to our preferred document + if ( a === doc || contains(preferredDoc, a) ) { + return -1; + } + if ( b === doc || contains(preferredDoc, b) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + } + + // Not directly comparable, sort on existence of method + return a.compareDocumentPosition ? -1 : 1; + } : + function( a, b ) { + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Parentless nodes are either documents or disconnected + } else if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( (cur = cur.parentNode) ) { + ap.unshift( cur ); + } + cur = b; + while ( (cur = cur.parentNode) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[i] === bp[i] ) { + i++; + } + + return i ? + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[i], bp[i] ) : + + // Otherwise nodes in our document sort first + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; + + return doc; +}; + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); + + if ( support.matchesSelector && documentIsHTML && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch(e) {} + } + + return Sizzle( expr, document, null, [elem] ).length > 0; +}; + +Sizzle.contains = function( context, elem ) { + // Set document vars if needed + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; + +Sizzle.attr = function( elem, name ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + // Don't get fooled by Object.prototype properties (jQuery #13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val === undefined ? + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + (val = elem.getAttributeNode(name)) && val.specified ? + val.value : + null : + val; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( (elem = results[i++]) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + return results; +}; + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + // If no nodeType, this is expected to be an array + for ( ; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (see #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + // Do not include comment or processing instruction nodes + + return ret; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); + + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1].slice( 0, 3 ) === "nth" ) { + // nth-* requires argument + if ( !match[3] ) { + Sizzle.error( match[0] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); + match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); + + // other types prohibit arguments + } else if ( match[3] ) { + Sizzle.error( match[0] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[5] && match[2]; + + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[3] && match[4] !== undefined ) { + match[2] = match[4]; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + // Get excess from tokenize (recursively) + (excess = tokenize( unquoted, true )) && + // advance to the next closing parenthesis + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + + // excess is a negative index + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { return true; } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); + }); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; + }, + + "CHILD": function( type, what, argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, context, xml ) { + var cache, outerCache, node, diff, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( (node = node[ dir ]) ) { + if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + return false; + } + } + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + // Seek `elem` from a previously-cached index + outerCache = parent[ expando ] || (parent[ expando ] = {}); + cache = outerCache[ type ] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( (node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + (diff = nodeIndex = 0) || start.pop()) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + // Use previously-cached element index if available + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; + + // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) + } else { + // Use the same loop as above to seek `elem` from the start + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { + + if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { + // Cache the index of each encountered element + if ( useCache ) { + (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + // Potentially complex pseudos + "not": markFunction(function( selector ) { + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } + } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + // lang value must be a valid identifier + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + }, + + // Boolean properties + "enabled": function( elem ) { + return elem.disabled === false; + }, + + "disabled": function( elem ) { + return elem.disabled === true; + }, + + "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, + + "selected": function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), + // not comment, processing instructions, or others + // Thanks to Diego Perini for the nodeName shortcut + // Greater than "@" means alpha characters (specifically not starting with "#" or "?") + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type ); + }, + + // Position-in-collection + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), + + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), + + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), + + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; + +Expr.pseudos["nth"] = Expr.pseudos["eq"]; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +// Easy API for creating new setFilters +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); + +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + // Don't consume trailing commas as valid + soFar = soFar.slice( match[0].length ) || soFar; + } + groups.push( tokens = [] ); + } + + matched = false; + + // Combinators + if ( (match = rcombinators.exec( soFar )) ) { + matched = match.shift(); + tokens.push({ + value: matched, + // Cast descendant combinators to space + type: match[0].replace( rtrim, " " ) + }); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + (match = preFilters[ type ]( match ))) ) { + matched = match.shift(); + tokens.push({ + value: matched, + type: type, + matches: match + }); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +} + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; + + return combinator.first ? + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var data, cache, outerCache, + dirkey = dirruns + " " + doneName; + + // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + if ( xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) { + if ( (data = cache[1]) === true || data === cachedruns ) { + return data === true; + } + } else { + cache = outerCache[ dir ] = [ dirkey ]; + cache[1] = matcher( elem, context, xml ) || cachedruns; + if ( cache[1] === true ) { + return true; + } + } + } + } + } + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( (elem = temp[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + // Restore matcherIn since elem is not yet a final match + temp.push( (matcherIn[i] = elem) ); + } + } + postFinder( null, (matcherOut = []), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { + + seed[temp] = !(results[temp] = elem); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + } else { + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + // A counter to specify which element is currently being matched + var matcherCachedRuns = 0, + bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, expandContext ) { + var elem, j, matcher, + setMatched = [], + matchedCount = 0, + i = "0", + unmatched = seed && [], + outermost = expandContext != null, + contextBackup = outermostContext, + // We must always have either seed elements or context + elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1); + + if ( outermost ) { + outermostContext = context !== document && context; + cachedruns = matcherCachedRuns; + } + + // Add elements passing elementMatchers directly to results + // Keep `i` a string if there are no elements so `matchedCount` will be "00" below + for ( ; (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + cachedruns = ++matcherCachedRuns; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element + if ( !group ) { + group = tokenize( selector ); + } + i = group.length; + while ( i-- ) { + cached = matcherFromTokens( group[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + } + return cached; +}; + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); + } + return results; +} + +function select( selector, context, results, seed ) { + var i, tokens, token, type, find, + match = tokenize( selector ); + + if ( !seed ) { + // Try to minimize operations if there is only one group + if ( match.length === 1 ) { + + // Take a shortcut and set the context if the root selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + support.getById && context.nodeType === 9 && documentIsHTML && + Expr.relative[ tokens[1].type ] ) { + + context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + if ( !context ) { + return results; + } + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && context.parentNode || context + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + } + + // Compile and execute a filtering function + // Provide `match` to avoid retokenization if we modified the selector above + compile( selector, match )( + seed, + context, + !documentIsHTML, + results, + rsibling.test( selector ) + ); + return results; +} + +// One-time assignments + +// Sort stability +support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; + +// Support: Chrome<14 +// Always assume duplicates if they aren't passed to the comparison function +support.detectDuplicates = hasDuplicate; + +// Initialize against the default document +setDocument(); + +// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) +// Detached nodes confoundingly follow *each other* +support.sortDetached = assert(function( div1 ) { + // Should return 1, but returns 4 (following) + return div1.compareDocumentPosition( document.createElement("div") ) & 1; +}); + +// Support: IE<8 +// Prevent attribute/property "interpolation" +// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +if ( !assert(function( div ) { + div.innerHTML = ""; + return div.firstChild.getAttribute("href") === "#" ; +}) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + }); +} + +// Support: IE<9 +// Use defaultValue in place of getAttribute("value") +if ( !support.attributes || !assert(function( div ) { + div.innerHTML = ""; + div.firstChild.setAttribute( "value", "" ); + return div.firstChild.getAttribute( "value" ) === ""; +}) ) { + addHandle( "value", function( elem, name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + }); +} + +// Support: IE<9 +// Use getAttributeNode to fetch booleans when getAttribute lies +if ( !assert(function( div ) { + return div.getAttribute("disabled") == null; +}) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return (val = elem.getAttributeNode( name )) && val.specified ? + val.value : + elem[ name ] === true ? name.toLowerCase() : null; + } + }); +} + +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.pseudos; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})( window ); +// String to Object options format cache +var optionsCache = {}; + +// Convert String-formatted options into Object-formatted ones and store in cache +function createOptions( options ) { + var object = optionsCache[ options ] = {}; + jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + }); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); + + var // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = !options.once && [], + // Fire callbacks + fire = function( data ) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { + memory = false; // To prevent further calls using add + break; + } + } + firing = false; + if ( list ) { + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); + } + } else if ( memory ) { + list = []; + } else { + self.disable(); + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + // First, we save the current length + var start = list.length; + (function add( args ) { + jQuery.each( args, function( _, arg ) { + var type = jQuery.type( arg ); + if ( type === "function" ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && type !== "string" ) { + // Inspect recursively + add( arg ); + } + }); + })( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + jQuery.each( arguments, function( _, arg ) { + var index; + while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + // Handle firing indexes + if ( firing ) { + if ( index <= firingLength ) { + firingLength--; + } + if ( index <= firingIndex ) { + firingIndex--; + } + } + } + }); + } + return this; + }, + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); + }, + // Remove all callbacks from the list + empty: function() { + list = []; + firingLength = 0; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( list && ( !fired || stack ) ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( firing ) { + stack.push( args ); + } else { + fire( args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; +jQuery.extend({ + + Deferred: function( func ) { + var tuples = [ + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], + [ "notify", "progress", jQuery.Callbacks("memory") ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred(function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var action = tuple[ 0 ], + fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[1] ](function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .done( newDefer.resolve ) + .fail( newDefer.reject ) + .progress( newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); + } + }); + }); + fns = null; + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Keep pipe for back-compat + promise.pipe = promise.then; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; + + // promise[ done | fail | progress ] = list.add + promise[ tuple[1] ] = list.add; + + // Handle state + if ( stateString ) { + list.add(function() { + // state = [ resolved | rejected ] + state = stateString; + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + } + + // deferred[ resolve | reject | notify ] + deferred[ tuple[0] ] = function() { + deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + return this; + }; + deferred[ tuple[0] + "With" ] = list.fireWith; + }); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = core_slice.call( arguments ), + length = resolveValues.length, + + // the count of uncompleted subordinates + remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; + if( values === progressValues ) { + deferred.notifyWith( contexts, values ); + } else if ( !( --remaining ) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ) + .progress( updateFunc( i, progressContexts, progressValues ) ); + } else { + --remaining; + } + } + } + + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + + return deferred.promise(); + } +}); +jQuery.support = (function( support ) { + var input = document.createElement("input"), + fragment = document.createDocumentFragment(), + div = document.createElement("div"), + select = document.createElement("select"), + opt = select.appendChild( document.createElement("option") ); + + // Finish early in limited environments + if ( !input.type ) { + return support; + } + + input.type = "checkbox"; + + // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 + // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere) + support.checkOn = input.value !== ""; + + // Must access the parent to make an option select properly + // Support: IE9, IE10 + support.optSelected = opt.selected; + + // Will be defined later + support.reliableMarginRight = true; + support.boxSizingReliable = true; + support.pixelPosition = false; + + // Make sure checked status is properly cloned + // Support: IE9, IE10 + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Check if an input maintains its value after becoming a radio + // Support: IE9, IE10 + input = document.createElement("input"); + input.value = "t"; + input.type = "radio"; + support.radioValue = input.value === "t"; + + // #11217 - WebKit loses check when the name is after the checked attribute + input.setAttribute( "checked", "t" ); + input.setAttribute( "name", "t" ); + + fragment.appendChild( input ); + + // Support: Safari 5.1, Android 4.x, Android 2.3 + // old WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Support: Firefox, Chrome, Safari + // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) + support.focusinBubbles = "onfocusin" in window; + + div.style.backgroundClip = "content-box"; + div.cloneNode( true ).style.backgroundClip = ""; + support.clearCloneStyle = div.style.backgroundClip === "content-box"; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, marginDiv, + // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). + divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box", + body = document.getElementsByTagName("body")[ 0 ]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + container = document.createElement("div"); + container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; + + // Check box-sizing and margin behavior. + body.appendChild( container ).appendChild( div ); + div.innerHTML = ""; + // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). + div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%"; + + // Workaround failing boxSizing test due to offsetWidth returning wrong value + // with some non-1 values of body zoom, ticket #13543 + jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() { + support.boxSizing = div.offsetWidth === 4; + }); + + // Use window.getComputedStyle because jsdom on node.js will break without it. + if ( window.getComputedStyle ) { + support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; + support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; + + // Support: Android 2.3 + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. (#3333) + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + marginDiv = div.appendChild( document.createElement("div") ); + marginDiv.style.cssText = div.style.cssText = divReset; + marginDiv.style.marginRight = marginDiv.style.width = "0"; + div.style.width = "1px"; + + support.reliableMarginRight = + !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); + } + + body.removeChild( container ); + }); + + return support; +})( {} ); + +/* + Implementation Summary + + 1. Enforce API surface and semantic compatibility with 1.9.x branch + 2. Improve the module's maintainability by reducing the storage + paths to a single mechanism. + 3. Use the same single mechanism to support "private" and "user" data. + 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) + 5. Avoid exposing implementation details on user objects (eg. expando properties) + 6. Provide a clear path for implementation upgrade to WeakMap in 2014 +*/ +var data_user, data_priv, + rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, + rmultiDash = /([A-Z])/g; + +function Data() { + // Support: Android < 4, + // Old WebKit does not have Object.preventExtensions/freeze method, + // return new empty object instead with no [[set]] accessor + Object.defineProperty( this.cache = {}, 0, { + get: function() { + return {}; + } + }); + + this.expando = jQuery.expando + Math.random(); +} + +Data.uid = 1; + +Data.accepts = function( owner ) { + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + return owner.nodeType ? + owner.nodeType === 1 || owner.nodeType === 9 : true; +}; + +Data.prototype = { + key: function( owner ) { + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return the key for a frozen object. + if ( !Data.accepts( owner ) ) { + return 0; + } + + var descriptor = {}, + // Check if the owner object already has a cache key + unlock = owner[ this.expando ]; + + // If not, create one + if ( !unlock ) { + unlock = Data.uid++; + + // Secure it in a non-enumerable, non-writable property + try { + descriptor[ this.expando ] = { value: unlock }; + Object.defineProperties( owner, descriptor ); + + // Support: Android < 4 + // Fallback to a less secure definition + } catch ( e ) { + descriptor[ this.expando ] = unlock; + jQuery.extend( owner, descriptor ); + } + } + + // Ensure the cache object + if ( !this.cache[ unlock ] ) { + this.cache[ unlock ] = {}; + } + + return unlock; + }, + set: function( owner, data, value ) { + var prop, + // There may be an unlock assigned to this node, + // if there is no entry for this "owner", create one inline + // and set the unlock as though an owner entry had always existed + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + // Handle: [ owner, key, value ] args + if ( typeof data === "string" ) { + cache[ data ] = value; + + // Handle: [ owner, { properties } ] args + } else { + // Fresh assignments by object are shallow copied + if ( jQuery.isEmptyObject( cache ) ) { + jQuery.extend( this.cache[ unlock ], data ); + // Otherwise, copy the properties one-by-one to the cache object + } else { + for ( prop in data ) { + cache[ prop ] = data[ prop ]; + } + } + } + return cache; + }, + get: function( owner, key ) { + // Either a valid cache is found, or will be created. + // New caches will be created and the unlock returned, + // allowing direct access to the newly created + // empty data object. A valid owner object must be provided. + var cache = this.cache[ this.key( owner ) ]; + + return key === undefined ? + cache : cache[ key ]; + }, + access: function( owner, key, value ) { + var stored; + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ((key && typeof key === "string") && value === undefined) ) { + + stored = this.get( owner, key ); + + return stored !== undefined ? + stored : this.get( owner, jQuery.camelCase(key) ); + } + + // [*]When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); + + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, name, camel, + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + if ( key === undefined ) { + this.cache[ unlock ] = {}; + + } else { + // Support array or space separated string of keys + if ( jQuery.isArray( key ) ) { + // If "name" is an array of keys... + // When data is initially created, via ("key", "val") signature, + // keys will be converted to camelCase. + // Since there is no way to tell _how_ a key was added, remove + // both plain key and camelCase key. #12786 + // This will only penalize the array argument path. + name = key.concat( key.map( jQuery.camelCase ) ); + } else { + camel = jQuery.camelCase( key ); + // Try the string as a key before any manipulation + if ( key in cache ) { + name = [ key, camel ]; + } else { + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + name = camel; + name = name in cache ? + [ name ] : ( name.match( core_rnotwhite ) || [] ); + } + } + + i = name.length; + while ( i-- ) { + delete cache[ name[ i ] ]; + } + } + }, + hasData: function( owner ) { + return !jQuery.isEmptyObject( + this.cache[ owner[ this.expando ] ] || {} + ); + }, + discard: function( owner ) { + if ( owner[ this.expando ] ) { + delete this.cache[ owner[ this.expando ] ]; + } + } +}; + +// These may be used throughout the jQuery core codebase +data_user = new Data(); +data_priv = new Data(); + + +jQuery.extend({ + acceptData: Data.accepts, + + hasData: function( elem ) { + return data_user.hasData( elem ) || data_priv.hasData( elem ); + }, + + data: function( elem, name, data ) { + return data_user.access( elem, name, data ); + }, + + removeData: function( elem, name ) { + data_user.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to data_priv methods, these can be deprecated. + _data: function( elem, name, data ) { + return data_priv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + data_priv.remove( elem, name ); + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var attrs, name, + elem = this[ 0 ], + i = 0, + data = null; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = data_user.get( elem ); + + if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { + attrs = elem.attributes; + for ( ; i < attrs.length; i++ ) { + name = attrs[ i ].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.slice(5) ); + dataAttr( elem, name, data[ name ] ); + } + } + data_priv.set( elem, "hasDataAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + data_user.set( this, key ); + }); + } + + return jQuery.access( this, function( value ) { + var data, + camelKey = jQuery.camelCase( key ); + + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { + // Attempt to get data from the cache + // with the key as-is + data = data_user.get( elem, key ); + if ( data !== undefined ) { + return data; + } + + // Attempt to get data from the cache + // with the key camelized + data = data_user.get( elem, camelKey ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, camelKey, undefined ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; + } + + // Set the data... + this.each(function() { + // First, attempt to store a copy or reference of any + // data that might've been store with a camelCased key. + var data = data_user.get( this, camelKey ); + + // For HTML5 data-* attribute interop, we have to + // store property names with dashes in a camelCase form. + // This might not apply to all properties...* + data_user.set( this, camelKey, value ); + + // *... In the case of properties that might _actually_ + // have dashes, we need to also store a copy of that + // unchanged property. + if ( key.indexOf("-") !== -1 && data !== undefined ) { + data_user.set( this, key, value ); + } + }); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each(function() { + data_user.remove( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? JSON.parse( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + data_user.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; +} +jQuery.extend({ + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = data_priv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray( data ) ) { + queue = data_priv.access( elem, type, jQuery.makeArray(data) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // not intended for public consumption - generates a queueHooks object, or returns the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return data_priv.get( elem, key ) || data_priv.access( elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + data_priv.remove( elem, [ type + "queue", key ] ); + }) + }); + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + // ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while( i-- ) { + tmp = data_priv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +}); +var nodeHook, boolHook, + rclass = /[\t\r\n\f]/g, + rreturn = /\r/g, + rfocusable = /^(?:input|select|textarea|button)$/i; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); + }, + + removeProp: function( name ) { + return this.each(function() { + delete this[ jQuery.propFix[ name ] || name ]; + }); + }, + + addClass: function( value ) { + var classes, elem, cur, clazz, j, + i = 0, + len = this.length, + proceed = typeof value === "string" && value; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call( this, j, this.className ) ); + }); + } + + if ( proceed ) { + // The disjunction here is for better compressibility (see removeClass) + classes = ( value || "" ).match( core_rnotwhite ) || []; + + for ( ; i < len; i++ ) { + elem = this[ i ]; + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + " " + ); + + if ( cur ) { + j = 0; + while ( (clazz = classes[j++]) ) { + if ( cur.indexOf( " " + clazz + " " ) < 0 ) { + cur += clazz + " "; + } + } + elem.className = jQuery.trim( cur ); + + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classes, elem, cur, clazz, j, + i = 0, + len = this.length, + proceed = arguments.length === 0 || typeof value === "string" && value; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call( this, j, this.className ) ); + }); + } + if ( proceed ) { + classes = ( value || "" ).match( core_rnotwhite ) || []; + + for ( ; i < len; i++ ) { + elem = this[ i ]; + // This expression is here for better compressibility (see addClass) + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + "" + ); + + if ( cur ) { + j = 0; + while ( (clazz = classes[j++]) ) { + // Remove *all* instances + while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { + cur = cur.replace( " " + clazz + " ", " " ); + } + } + elem.className = value ? jQuery.trim( cur ) : ""; + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value; + + if ( typeof stateVal === "boolean" && type === "string" ) { + return stateVal ? this.addClass( value ) : this.removeClass( value ); + } + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + classNames = value.match( core_rnotwhite ) || []; + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space separated list + if ( self.hasClass( className ) ) { + self.removeClass( className ); + } else { + self.addClass( className ); + } + } + + // Toggle whole class name + } else if ( type === core_strundefined || type === "boolean" ) { + if ( this.className ) { + // store className if set + data_priv.set( this, "__className__", this.className ); + } + + // If the element has a class name or if we're passed "false", + // then remove the whole classname (if there was one, the above saved it). + // Otherwise bring back whatever was previously saved (if anything), + // falling back to the empty string if nothing was stored. + this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, jQuery( this ).val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, option, + options = elem.options, + index = elem.selectedIndex, + one = elem.type === "select-one" || index < 0, + values = one ? null : [], + max = one ? index + 1 : options.length, + i = index < 0 ? + max : + one ? index : 0; + + // Loop through all the selected options + for ( ; i < max; i++ ) { + option = options[ i ]; + + // IE6-9 doesn't update selected after form reset (#2551) + if ( ( option.selected || i === index ) && + // Don't return options that are disabled or in a disabled optgroup + ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && + ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + }, + + set: function( elem, value ) { + var optionSet, option, + options = elem.options, + values = jQuery.makeArray( value ), + i = options.length; + + while ( i-- ) { + option = options[ i ]; + if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) { + optionSet = true; + } + } + + // force browsers to behave consistently when non-matching value is set + if ( !optionSet ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attr: function( elem, name, value ) { + var hooks, ret, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === core_strundefined ) { + return jQuery.prop( elem, name, value ); + } + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || + ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + + } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, value + "" ); + return value; + } + + } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + ret = jQuery.find.attr( elem, name ); + + // Non-existent attributes return null, we normalize to undefined + return ret == null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var name, propName, + i = 0, + attrNames = value && value.match( core_rnotwhite ); + + if ( attrNames && elem.nodeType === 1 ) { + while ( (name = attrNames[i++]) ) { + propName = jQuery.propFix[ name ] || name; + + // Boolean attributes get special treatment (#10870) + if ( jQuery.expr.match.bool.test( name ) ) { + // Set corresponding property to false + elem[ propName ] = false; + } + + elem.removeAttribute( name ); + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to default in case type is set after value during creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + } + }, + + propFix: { + "for": "htmlFor", + "class": "className" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? + ret : + ( elem[ name ] = value ); + + } else { + return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? + ret : + elem[ name ]; + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ? + elem.tabIndex : + -1; + } + } + } +}); + +// Hooks for boolean attributes +boolHook = { + set: function( elem, value, name ) { + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + elem.setAttribute( name, name ); + } + return name; + } +}; +jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { + var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr; + + jQuery.expr.attrHandle[ name ] = function( elem, name, isXML ) { + var fn = jQuery.expr.attrHandle[ name ], + ret = isXML ? + undefined : + /* jshint eqeqeq: false */ + // Temporarily disable this handler to check existence + (jQuery.expr.attrHandle[ name ] = undefined) != + getter( elem, name, isXML ) ? + + name.toLowerCase() : + null; + + // Restore handler + jQuery.expr.attrHandle[ name ] = fn; + + return ret; + }; +}); + +// Support: IE9+ +// Selectedness for an option in an optgroup can be inaccurate +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = { + get: function( elem ) { + var parent = elem.parentNode; + if ( parent && parent.parentNode ) { + parent.parentNode.selectedIndex; + } + return null; + } + }; +} + +jQuery.each([ + "tabIndex", + "readOnly", + "maxLength", + "cellSpacing", + "cellPadding", + "rowSpan", + "colSpan", + "useMap", + "frameBorder", + "contentEditable" +], function() { + jQuery.propFix[ this.toLowerCase() ] = this; +}); + +// Radios and checkboxes getter/setter +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }; + if ( !jQuery.support.checkOn ) { + jQuery.valHooks[ this ].get = function( elem ) { + // Support: Webkit + // "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + }; + } +}); +var rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.get( elem ); + + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !(events = elemData.events) ) { + events = elemData.events = {}; + } + if ( !(eventHandle = elemData.handle) ) { + eventHandle = elemData.handle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( core_rnotwhite ) || [""]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !(handlers = events[ type ]) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.hasData( elem ) && data_priv.get( elem ); + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( core_rnotwhite ) || [""]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + delete elemData.handle; + data_priv.remove( elem, "events" ); + } + }, + + trigger: function( event, data, elem, onlyHandlers ) { + + var i, cur, tmp, bubbleType, ontype, handle, special, + eventPath = [ elem || document ], + type = core_hasOwn.call( event, "type" ) ? event.type : event, + namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; + + cur = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf(":") < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join("."); + event.namespace_re = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === (elem.ownerDocument || document) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { + + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && + jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event ); + + var i, j, ret, matched, handleObj, + handlerQueue = [], + args = core_slice.call( arguments ), + handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { + + // Triggered event must either 1) have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( (event.result = ret) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var i, matches, sel, handleObj, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + // Black-hole SVG instance trees (#13180) + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { + + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.disabled !== true || event.type !== "click" ) { + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matches[ sel ] === undefined ) { + matches[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) >= 0 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matches[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, handlers: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( delegateCount < handlers.length ) { + handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); + } + + return handlerQueue; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, copy, + type = event.type, + originalEvent = event, + fixHook = this.fixHooks[ type ]; + + if ( !fixHook ) { + this.fixHooks[ type ] = fixHook = + rmouseEvent.test( type ) ? this.mouseHooks : + rkeyEvent.test( type ) ? this.keyHooks : + {}; + } + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = new jQuery.Event( originalEvent ); + + i = copy.length; + while ( i-- ) { + prop = copy[ i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Support: Cordova 2.5 (WebKit) (#13255) + // All events should have a target; Cordova deviceready doesn't + if ( !event.target ) { + event.target = document; + } + + // Support: Safari 6.0+, Chrome < 28 + // Target should not be a text node (#504, #13143) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + focus: { + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== safeActiveElement() && this.focus ) { + this.focus(); + return false; + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if ( this === safeActiveElement() && this.blur ) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + click: { + // For checkbox, fire native event so checked state will be right + trigger: function() { + if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { + this.click(); + return false; + } + }, + + // For cross-browser consistency, don't fire native .click() on links + _default: function( event ) { + return jQuery.nodeName( event.target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined ) { + event.originalEvent.returnValue = event.result; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +jQuery.removeEvent = function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } +}; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + + if ( e && e.preventDefault ) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + + if ( e && e.stopPropagation ) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + } +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +// Support: Chrome 15+ +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// Create "bubbling" focus and blur events +// Support: Firefox, Chrome, Safari +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + var elem = this[0]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +}); +var isSimple = /^.[^:#\[\.,]*$/, + rparentsprev = /^(?:parents|prev(?:Until|All))/, + rneedsContext = jQuery.expr.match.needsContext, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var i, + ret = [], + self = this, + len = self.length; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }) ); + } + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + // Needed because $( selector, context ) becomes $( context ).find( selector ) + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; + }, + + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; + + return this.filter(function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector || [], true) ); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector || [], false) ); + }, + + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + pos = ( rneedsContext.test( selectors ) || typeof selectors !== "string" ) ? + jQuery( selectors, context || this.context ) : + 0; + + for ( ; i < l; i++ ) { + for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { + // Always skip document fragments + if ( cur.nodeType < 11 && (pos ? + pos.index(cur) > -1 : + + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector(cur, selectors)) ) { + + cur = matched.push( cur ); + break; + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return core_indexOf.call( jQuery( elem ), this[ 0 ] ); + } + + // Locate the position of the desired element + return core_indexOf.call( this, + + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( jQuery.unique(all) ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); + } +}); + +function sibling( cur, dir ) { + while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} + + return cur; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return elem.contentDocument || jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); + } + + if ( this.length > 1 ) { + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.unique( matched ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } + } + + return this.pushStack( matched ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 && elem.nodeType === 1 ? + jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : + jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + })); + }, + + dir: function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; + + while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; + }, + + sibling: function( n, elem ) { + var matched = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + /* jshint -W018 */ + return !!qualifier.call( elem, i, elem ) !== not; + }); + + } + + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + }); + + } + + if ( typeof qualifier === "string" ) { + if ( isSimple.test( qualifier ) ) { + return jQuery.filter( qualifier, elements, not ); + } + + qualifier = jQuery.filter( qualifier, elements ); + } + + return jQuery.grep( elements, function( elem ) { + return ( core_indexOf.call( qualifier, elem ) >= 0 ) !== not; + }); +} +var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + rtagName = /<([\w:]+)/, + rhtml = /<|&#?\w+;/, + rnoInnerhtml = /<(?:script|style|link)/i, + manipulation_rcheckableType = /^(?:checkbox|radio)$/i, + // checked="checked" or checked + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, + rscriptType = /^$|\/(?:java|ecma)script/i, + rscriptTypeMasked = /^true\/(.*)/, + rcleanScript = /^\s*\s*$/g, + + // We have to close these tags to support XHTML (#13200) + wrapMap = { + + // Support: IE 9 + option: [ 1, "" ], + + thead: [ 1, "", "
    " ], + col: [ 2, "", "
    " ], + tr: [ 2, "", "
    " ], + td: [ 3, "", "
    " ], + + _default: [ 0, "", "" ] + }; + +// Support: IE 9 +wrapMap.optgroup = wrapMap.option; + +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +jQuery.fn.extend({ + text: function( value ) { + return jQuery.access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().append( ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value ) ); + }, null, value, arguments.length ); + }, + + append: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + }); + }, + + prepend: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + }); + }, + + before: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + }); + }, + + after: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + }); + }, + + // keepData is for internal use only--do not document + remove: function( selector, keepData ) { + var elem, + elems = selector ? jQuery.filter( selector, this ) : this, + i = 0; + + for ( ; (elem = elems[i]) != null; i++ ) { + if ( !keepData && elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem ) ); + } + + if ( elem.parentNode ) { + if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { + setGlobalEval( getAll( elem, "script" ) ); + } + elem.parentNode.removeChild( elem ); + } + } + + return this; + }, + + empty: function() { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + if ( elem.nodeType === 1 ) { + + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); + + // Remove any remaining nodes + elem.textContent = ""; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map( function () { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + }); + }, + + html: function( value ) { + return jQuery.access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { + + value = value.replace( rxhtmlTag, "<$1>" ); + + try { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch( e ) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var + // Snapshot the DOM in case .domManip sweeps something relevant into its fragment + args = jQuery.map( this, function( elem ) { + return [ elem.nextSibling, elem.parentNode ]; + }), + i = 0; + + // Make the changes, replacing each context element with the new content + this.domManip( arguments, function( elem ) { + var next = args[ i++ ], + parent = args[ i++ ]; + + if ( parent ) { + // Don't use the snapshot next if it has moved (#13810) + if ( next && next.parentNode !== parent ) { + next = this.nextSibling; + } + jQuery( this ).remove(); + parent.insertBefore( elem, next ); + } + // Allow new content to include elements from the context set + }, true ); + + // Force removal if there was no new content (e.g., from empty arguments) + return i ? this : this.remove(); + }, + + detach: function( selector ) { + return this.remove( selector, true ); + }, + + domManip: function( args, callback, allowIntersection ) { + + // Flatten any nested arrays + args = core_concat.apply( [], args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = this.length, + set = this, + iNoClone = l - 1, + value = args[ 0 ], + isFunction = jQuery.isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) { + return this.each(function( index ) { + var self = set.eq( index ); + if ( isFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + self.domManip( args, callback, allowIntersection ); + }); + } + + if ( l ) { + fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + if ( first ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + // Support: QtWebKit + // jQuery.merge because core_push.apply(_, arraylike) throws + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( this[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + + if ( node.src ) { + // Hope ajax is available... + jQuery._evalUrl( node.src ); + } else { + jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); + } + } + } + } + } + } + + return this; + } +}); + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); + + // Support: QtWebKit + // .get() because core_push.apply(_, arraylike) throws + core_push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +}); + +jQuery.extend({ + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = jQuery.contains( elem.ownerDocument, elem ); + + // Support: IE >= 9 + // Fix Cloning issues + if ( !jQuery.support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) { + + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + buildFragment: function( elems, context, scripts, selection ) { + var elem, tmp, tag, wrap, contains, j, + i = 0, + l = elems.length, + fragment = context.createDocumentFragment(), + nodes = []; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( jQuery.type( elem ) === "object" ) { + // Support: QtWebKit + // jQuery.merge because core_push.apply(_, arraylike) throws + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement("div") ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || ["", ""] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[ 2 ]; + + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Support: QtWebKit + // jQuery.merge because core_push.apply(_, arraylike) throws + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Fixes #12346 + // Support: Webkit, IE + tmp.textContent = ""; + } + } + } + + // Remove wrapper from fragment + fragment.textContent = ""; + + i = 0; + while ( (elem = nodes[ i++ ]) ) { + + // #4087 - If origin and destination elements are the same, and this is + // that element, do not do anything + if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { + continue; + } + + contains = jQuery.contains( elem.ownerDocument, elem ); + + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( contains ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( (elem = tmp[ j++ ]) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + return fragment; + }, + + cleanData: function( elems ) { + var data, elem, events, type, key, j, + special = jQuery.event.special, + i = 0; + + for ( ; (elem = elems[ i ]) !== undefined; i++ ) { + if ( Data.accepts( elem ) ) { + key = elem[ data_priv.expando ]; + + if ( key && (data = data_priv.cache[ key ]) ) { + events = Object.keys( data.events || {} ); + if ( events.length ) { + for ( j = 0; (type = events[j]) !== undefined; j++ ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + if ( data_priv.cache[ key ] ) { + // Discard any remaining `private` data + delete data_priv.cache[ key ]; + } + } + } + // Discard any remaining `user` data + delete data_user.cache[ elem[ data_user.expando ] ]; + } + }, + + _evalUrl: function( url ) { + return jQuery.ajax({ + url: url, + type: "GET", + dataType: "script", + async: false, + global: false, + "throws": true + }); + } +}); + +// Support: 1.x compatibility +// Manipulating tables requires a tbody +function manipulationTarget( elem, content ) { + return jQuery.nodeName( elem, "table" ) && + jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ? + + elem.getElementsByTagName("tbody")[0] || + elem.appendChild( elem.ownerDocument.createElement("tbody") ) : + elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + var match = rscriptTypeMasked.exec( elem.type ); + + if ( match ) { + elem.type = match[ 1 ]; + } else { + elem.removeAttribute("type"); + } + + return elem; +} + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var l = elems.length, + i = 0; + + for ( ; i < l; i++ ) { + data_priv.set( + elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) + ); + } +} + +function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( data_priv.hasData( src ) ) { + pdataOld = data_priv.access( src ); + pdataCur = data_priv.set( dest, pdataOld ); + events = pdataOld.events; + + if ( events ) { + delete pdataCur.handle; + pdataCur.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( data_user.hasData( src ) ) { + udataOld = data_user.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + data_user.set( dest, udataCur ); + } +} + + +function getAll( context, tag ) { + var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : + context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : + []; + + return tag === undefined || tag && jQuery.nodeName( context, tag ) ? + jQuery.merge( [ context ], ret ) : + ret; +} + +// Support: IE >= 9 +function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} +jQuery.fn.extend({ + wrapAll: function( html ) { + var wrap; + + if ( jQuery.isFunction( html ) ) { + return this.each(function( i ) { + jQuery( this ).wrapAll( html.call(this, i) ); + }); + } + + if ( this[ 0 ] ) { + + // The elements to wrap the target around + wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); + + if ( this[ 0 ].parentNode ) { + wrap.insertBefore( this[ 0 ] ); + } + + wrap.map(function() { + var elem = this; + + while ( elem.firstElementChild ) { + elem = elem.firstElementChild; + } + + return elem; + }).append( this ); + } + + return this; + }, + + wrapInner: function( html ) { + if ( jQuery.isFunction( html ) ) { + return this.each(function( i ) { + jQuery( this ).wrapInner( html.call(this, i) ); + }); + } + + return this.each(function() { + var self = jQuery( this ), + contents = self.contents(); + + if ( contents.length ) { + contents.wrapAll( html ); + + } else { + self.append( html ); + } + }); + }, + + wrap: function( html ) { + var isFunction = jQuery.isFunction( html ); + + return this.each(function( i ) { + jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); + }); + }, + + unwrap: function() { + return this.parent().each(function() { + if ( !jQuery.nodeName( this, "body" ) ) { + jQuery( this ).replaceWith( this.childNodes ); + } + }).end(); + } +}); +var curCSS, iframe, + // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" + // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rmargin = /^margin/, + rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), + rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), + rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ), + elemdisplay = { BODY: "block" }, + + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: 0, + fontWeight: 400 + }, + + cssExpand = [ "Top", "Right", "Bottom", "Left" ], + cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; + +// return a css property mapped to a potentially vendor prefixed property +function vendorPropName( style, name ) { + + // shortcut for names that are not vendor prefixed + if ( name in style ) { + return name; + } + + // check for vendor prefixed names + var capName = name.charAt(0).toUpperCase() + name.slice(1), + origName = name, + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in style ) { + return name; + } + } + + return origName; +} + +function isHidden( elem, el ) { + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); +} + +// NOTE: we've included the "window" in window.getComputedStyle +// because jsdom on node.js will break without it. +function getStyles( elem ) { + return window.getComputedStyle( elem, null ); +} + +function showHide( elements, show ) { + var display, elem, hidden, + values = [], + index = 0, + length = elements.length; + + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + + values[ index ] = data_priv.get( elem, "olddisplay" ); + display = elem.style.display; + if ( show ) { + // Reset the inline display of this element to learn if it is + // being hidden by cascaded rules or not + if ( !values[ index ] && display === "none" ) { + elem.style.display = ""; + } + + // Set elements which have been overridden with display: none + // in a stylesheet to whatever the default browser style is + // for such an element + if ( elem.style.display === "" && isHidden( elem ) ) { + values[ index ] = data_priv.access( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); + } + } else { + + if ( !values[ index ] ) { + hidden = isHidden( elem ); + + if ( display && display !== "none" || !hidden ) { + data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") ); + } + } + } + } + + // Set the display of most of the elements in a second loop + // to avoid the constant reflow + for ( index = 0; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + if ( !show || elem.style.display === "none" || elem.style.display === "" ) { + elem.style.display = show ? values[ index ] || "" : "none"; + } + } + + return elements; +} + +jQuery.fn.extend({ + css: function( name, value ) { + return jQuery.access( this, function( elem, name, value ) { + var styles, len, + map = {}, + i = 0; + + if ( jQuery.isArray( name ) ) { + styles = getStyles( elem ); + len = name.length; + + for ( ; i < len; i++ ) { + map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); + } + + return map; + } + + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); + }, name, value, arguments.length > 1 ); + }, + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + if ( typeof state === "boolean" ) { + return state ? this.show() : this.hide(); + } + + return this.each(function() { + if ( isHidden( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + }); + } +}); + +jQuery.extend({ + // Add in style property hooks for overriding the default + // behavior of getting and setting a style property + cssHooks: { + opacity: { + get: function( elem, computed ) { + if ( computed ) { + // We should always get a number back from opacity + var ret = curCSS( elem, "opacity" ); + return ret === "" ? "1" : ret; + } + } + } + }, + + // Don't automatically add "px" to these possibly-unitless properties + cssNumber: { + "columnCount": true, + "fillOpacity": true, + "fontWeight": true, + "lineHeight": true, + "opacity": true, + "order": true, + "orphans": true, + "widows": true, + "zIndex": true, + "zoom": true + }, + + // Add in properties whose names you wish to fix before + // setting or getting the value + cssProps: { + // normalize float css property + "float": "cssFloat" + }, + + // Get and set the style property on a DOM Node + style: function( elem, name, value, extra ) { + // Don't set styles on text and comment nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { + return; + } + + // Make sure that we're working with the right name + var ret, type, hooks, + origName = jQuery.camelCase( name ), + style = elem.style; + + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); + + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // Check if we're setting a value + if ( value !== undefined ) { + type = typeof value; + + // convert relative number strings (+= or -=) to relative numbers. #7345 + if ( type === "string" && (ret = rrelNum.exec( value )) ) { + value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); + // Fixes bug #9237 + type = "number"; + } + + // Make sure that NaN and null values aren't set. See: #7116 + if ( value == null || type === "number" && isNaN( value ) ) { + return; + } + + // If a number was passed in, add 'px' to the (except for certain CSS properties) + if ( type === "number" && !jQuery.cssNumber[ origName ] ) { + value += "px"; + } + + // Fixes #8908, it can be done more correctly by specifying setters in cssHooks, + // but it would mean to define eight (for every problematic property) identical functions + if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { + style[ name ] = "inherit"; + } + + // If a hook was provided, use that value, otherwise just set the specified value + if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { + style[ name ] = value; + } + + } else { + // If a hook was provided get the non-computed value from there + if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { + return ret; + } + + // Otherwise just get the value from the style object + return style[ name ]; + } + }, + + css: function( elem, name, extra, styles ) { + var val, num, hooks, + origName = jQuery.camelCase( name ); + + // Make sure that we're working with the right name + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); + + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // If a hook was provided get the computed value from there + if ( hooks && "get" in hooks ) { + val = hooks.get( elem, true, extra ); + } + + // Otherwise, if a way to get the computed value exists, use that + if ( val === undefined ) { + val = curCSS( elem, name, styles ); + } + + //convert "normal" to computed value + if ( val === "normal" && name in cssNormalTransform ) { + val = cssNormalTransform[ name ]; + } + + // Return, converting to number if forced or a qualifier was provided and val looks numeric + if ( extra === "" || extra ) { + num = parseFloat( val ); + return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; + } + return val; + } +}); + +curCSS = function( elem, name, _computed ) { + var width, minWidth, maxWidth, + computed = _computed || getStyles( elem ), + + // Support: IE9 + // getPropertyValue is only needed for .css('filter') in IE9, see #12537 + ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, + style = elem.style; + + if ( computed ) { + + if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { + ret = jQuery.style( elem, name ); + } + + // Support: Safari 5.1 + // A tribute to the "awesome hack by Dean Edwards" + // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels + // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values + if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { + + // Remember the original values + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; + + // Put in the new values to get a computed value out + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + // Revert the changed values + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; + } + } + + return ret; +}; + + +function setPositiveNumber( elem, value, subtract ) { + var matches = rnumsplit.exec( value ); + return matches ? + // Guard against undefined "subtract", e.g., when used as in cssHooks + Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : + value; +} + +function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { + var i = extra === ( isBorderBox ? "border" : "content" ) ? + // If we already have the right measurement, avoid augmentation + 4 : + // Otherwise initialize for horizontal or vertical properties + name === "width" ? 1 : 0, + + val = 0; + + for ( ; i < 4; i += 2 ) { + // both box models exclude margin, so add it if we want it + if ( extra === "margin" ) { + val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); + } + + if ( isBorderBox ) { + // border-box includes padding, so remove it if we want content + if ( extra === "content" ) { + val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + } + + // at this point, extra isn't border nor margin, so remove border + if ( extra !== "margin" ) { + val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } else { + // at this point, extra isn't content, so add padding + val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + + // at this point, extra isn't content nor padding, so add border + if ( extra !== "padding" ) { + val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } + } + + return val; +} + +function getWidthOrHeight( elem, name, extra ) { + + // Start with offset property, which is equivalent to the border-box value + var valueIsBorderBox = true, + val = name === "width" ? elem.offsetWidth : elem.offsetHeight, + styles = getStyles( elem ), + isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + + // some non-html elements return undefined for offsetWidth, so check for null/undefined + // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 + // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 + if ( val <= 0 || val == null ) { + // Fall back to computed then uncomputed css if necessary + val = curCSS( elem, name, styles ); + if ( val < 0 || val == null ) { + val = elem.style[ name ]; + } + + // Computed unit is not pixels. Stop here and return. + if ( rnumnonpx.test(val) ) { + return val; + } + + // we need the check for style in case a browser which returns unreliable values + // for getComputedStyle silently falls back to the reliable elem.style + valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); + + // Normalize "", auto, and prepare for extra + val = parseFloat( val ) || 0; + } + + // use the active box-sizing model to add/subtract irrelevant styles + return ( val + + augmentWidthOrHeight( + elem, + name, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox, + styles + ) + ) + "px"; +} + +// Try to determine the default display value of an element +function css_defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; + + if ( !display ) { + display = actualDisplay( nodeName, doc ); + + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { + // Use the already-created iframe if possible + iframe = ( iframe || + jQuery(" + + + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/qwery/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/qwery/index.js new file mode 100644 index 00000000..345d503d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/qwery/index.js @@ -0,0 +1,549 @@ +"use strict"; + +var expect = require("expect.js"), + DomUtils = require("htmlparser2").DomUtils, + helper = require("../tools/helper.js"), + path = require("path"), + document = helper.getDocument(path.join(__dirname, "index.html")), + CSSselect = helper.CSSselect; + +var location = {hash: ""}; +CSSselect.pseudos.target = function(elem){ + return elem.attribs && elem.attribs.id === location.hash.substr(1); +}; + +//--- + +/* + The following is taken from https://github.com/ded/qwery/blob/master/tests/tests.js +*/ + +CSSselect.pseudos.humanoid = function(e) { return CSSselect.is(e, 'li:contains(human)') || CSSselect.is(e, 'ol:contains(human)'); }; + +var frag = helper.getDOM( + '
    ' + + '

    ' + + '
    ' + + '

    ' + + '

    ' + + '

    ' +); + +var doc = helper.getDOM( + '
    ' + + '
    ' + + '

    ' + + '' + + '' + + '
    ' + + '

    ' + + '
    ' + + '
    ' +); + +var el = DomUtils.getElementById('attr-child-boosh', document); + +var pseudos = DomUtils.getElementById('pseudos', document).children.filter(DomUtils.isTag); + +module.exports = { + +'Contexts': { + + 'should be able to pass optional context': function () { + expect(CSSselect('.a', document)).to.have.length(3); //no context found 3 elements (.a) + expect(CSSselect('.a', CSSselect('#boosh', document))).to.have.length(2); //context found 2 elements (#boosh .a) + }, + +/* + 'should be able to pass string as context': function() { + expect(CSSselect('.a', '#boosh')).to.have.length(2); //context found 2 elements(.a, #boosh) + expect(CSSselect('.a', '.a')).to.be.empty(); //context found 0 elements(.a, .a) + expect(CSSselect('.a', '.b')).to.have.length(1); //context found 1 elements(.a, .b) + expect(CSSselect('.a', '#boosh .b')).to.have.length(1); //context found 1 elements(.a, #boosh .b) + expect(CSSselect('.b', '#boosh .b')).to.be.empty(); //context found 0 elements(.b, #boosh .b) + }, +*/ +/* + 'should be able to pass qwery result as context': function() { + expect(CSSselect('.a', CSSselect('#boosh', document))).to.have.length(2); //context found 2 elements(.a, #boosh) + expect(CSSselect('.a', CSSselect('.a', document))).to.be.empty(); //context found 0 elements(.a, .a) + expect(CSSselect('.a', CSSselect('.b', document))).to.have.length(1); //context found 1 elements(.a, .b) + expect(CSSselect('.a', CSSselect('#boosh .b', document))).to.have.length(1); //context found 1 elements(.a, #boosh .b) + expect(CSSselect('.b', CSSselect('#boosh .b', document))).to.be.empty(); //context found 0 elements(.b, #boosh .b) + }, +*/ + 'should not return duplicates from combinators': function () { + expect(CSSselect('#boosh,#boosh', document)).to.have.length(1); //two booshes dont make a thing go right + expect(CSSselect('#boosh,.apples,#boosh', document)).to.have.length(1); //two booshes and an apple dont make a thing go right + }, + + 'byId sub-queries within context': function() { + expect(CSSselect('#booshTest', CSSselect('#boosh', document))).to.have.length(1); //found "#id #id" + expect(CSSselect('.a.b #booshTest', CSSselect('#boosh', document))).to.have.length(1); //found ".class.class #id" + expect(CSSselect('.a>#booshTest', CSSselect('#boosh', document))).to.have.length(1); //found ".class>#id" + expect(CSSselect('>.a>#booshTest', CSSselect('#boosh', document))).to.have.length(1); //found ">.class>#id" + expect(CSSselect('#boosh', CSSselect('#booshTest', document)).length).to.not.be.ok(); //shouldn't find #boosh (ancestor) within #booshTest (descendent) + expect(CSSselect('#boosh', CSSselect('#lonelyBoosh', document)).length).to.not.be.ok(); //shouldn't find #boosh within #lonelyBoosh (unrelated) + } +}, + +'CSS 1': { + 'get element by id': function () { + var result = CSSselect('#boosh', document); + expect(result[0]).to.be.ok(); //found element with id=boosh + expect(CSSselect('h1', document)[0]).to.be.ok(); //found 1 h1 + }, + + 'byId sub-queries': function() { + expect(CSSselect('#boosh #booshTest', document)).to.have.length(1); //found "#id #id" + expect(CSSselect('.a.b #booshTest', document)).to.have.length(1); //found ".class.class #id" + expect(CSSselect('#boosh>.a>#booshTest', document)).to.have.length(1); //found "#id>.class>#id" + expect(CSSselect('.a>#booshTest', document)).to.have.length(1); //found ".class>#id" + }, + + 'get elements by class': function () { + expect(CSSselect('#boosh .a', document)).to.have.length(2); //found two elements + expect(CSSselect('#boosh div.a', document)[0]).to.be.ok(); //found one element + expect(CSSselect('#boosh div', document)).to.have.length(2); //found two {div} elements + expect(CSSselect('#boosh span', document)[0]).to.be.ok(); //found one {span} element + expect(CSSselect('#boosh div div', document)[0]).to.be.ok(); //found a single div + expect(CSSselect('a.odd', document)).to.have.length(1); //found single a + }, + + 'combos': function () { + expect(CSSselect('#boosh div,#boosh span', document)).to.have.length(3); //found 2 divs and 1 span + }, + + 'class with dashes': function() { + expect(CSSselect('.class-with-dashes', document)).to.have.length(1); //found something + }, + + 'should ignore comment nodes': function() { + expect(CSSselect('#boosh *', document)).to.have.length(4); //found only 4 elements under #boosh + }, + + 'deep messy relationships': function() { + // these are mostly characterised by a combination of tight relationships and loose relationships + // on the right side of the query it's easy to find matches but they tighten up quickly as you + // go to the left + // they are useful for making sure the dom crawler doesn't stop short or over-extend as it works + // up the tree the crawl needs to be comprehensive + expect(CSSselect('div#fixtures > div a', document)).to.have.length(5); //found four results for "div#fixtures > div a" + expect(CSSselect('.direct-descend > .direct-descend .lvl2', document)).to.have.length(1); //found one result for ".direct-descend > .direct-descend .lvl2" + expect(CSSselect('.direct-descend > .direct-descend div', document)).to.have.length(1); //found one result for ".direct-descend > .direct-descend div" + expect(CSSselect('.direct-descend > .direct-descend div', document)).to.have.length(1); //found one result for ".direct-descend > .direct-descend div" + expect(CSSselect('div#fixtures div ~ a div', document)).to.be.empty(); //found no results for odd query + expect(CSSselect('.direct-descend > .direct-descend > .direct-descend ~ .lvl2', document)).to.be.empty(); //found no results for another odd query + } +}, + +'CSS 2': { + + 'get elements by attribute': function () { + var wanted = CSSselect('#boosh div[test]', document)[0]; + var expected = DomUtils.getElementById('booshTest', document); + expect(wanted).to.be(expected); //found attribute + expect(CSSselect('#boosh div[test=fg]', document)[0]).to.be(expected); //found attribute with value + expect(CSSselect('em[rel~="copyright"]', document)).to.have.length(1); //found em[rel~="copyright"] + expect(CSSselect('em[nopass~="copyright"]', document)).to.be.empty(); //found em[nopass~="copyright"] + }, + + 'should not throw error by attribute selector': function () { + expect(CSSselect('[foo^="bar"]', document)).to.have.length(1); //found 1 element + }, + + 'crazy town': function () { + var el = DomUtils.getElementById('attr-test3', document); + expect(CSSselect('div#attr-test3.found.you[title="whatup duders"]', document)[0]).to.be(el); //found the right element + } + +}, + +'attribute selectors': { + + /* CSS 2 SPEC */ + + '[attr]': function () { + var expected = DomUtils.getElementById('attr-test-1', document); + expect(CSSselect('#attributes div[unique-test]', document)[0]).to.be(expected); //found attribute with [attr] + }, + + '[attr=val]': function () { + var expected = DomUtils.getElementById('attr-test-2', document); + expect(CSSselect('#attributes div[test="two-foo"]', document)[0]).to.be(expected); //found attribute with = + expect(CSSselect("#attributes div[test='two-foo']", document)[0]).to.be(expected); //found attribute with = + expect(CSSselect('#attributes div[test=two-foo]', document)[0]).to.be(expected); //found attribute with = + }, + + '[attr~=val]': function () { + var expected = DomUtils.getElementById('attr-test-3', document); + expect(CSSselect('#attributes div[test~=three]', document)[0]).to.be(expected); //found attribute with ~= + }, + + '[attr|=val]': function () { + var expected = DomUtils.getElementById('attr-test-2', document); + expect(CSSselect('#attributes div[test|="two-foo"]', document)[0]).to.be(expected); //found attribute with |= + expect(CSSselect('#attributes div[test|=two]', document)[0]).to.be(expected); //found attribute with |= + }, + + '[href=#x] special case': function () { + var expected = DomUtils.getElementById('attr-test-4', document); + expect(CSSselect('#attributes a[href="#aname"]', document)[0]).to.be(expected); //found attribute with href=#x + }, + + /* CSS 3 SPEC */ + + '[attr^=val]': function () { + var expected = DomUtils.getElementById('attr-test-2', document); + expect(CSSselect('#attributes div[test^=two]', document)[0]).to.be(expected); //found attribute with ^= + }, + + '[attr$=val]': function () { + var expected = DomUtils.getElementById('attr-test-2', document); + expect(CSSselect('#attributes div[test$=foo]', document)[0]).to.be(expected); //found attribute with $= + }, + + '[attr*=val]': function () { + var expected = DomUtils.getElementById('attr-test-3', document); + expect(CSSselect('#attributes div[test*=hree]', document)[0]).to.be(expected); //found attribute with *= + }, + + 'direct descendants': function () { + expect(CSSselect('#direct-descend > .direct-descend', document)).to.have.length(2); //found two direct descendents + expect(CSSselect('#direct-descend > .direct-descend > .lvl2', document)).to.have.length(3); //found three second-level direct descendents + }, + + 'sibling elements': function () { + expect(CSSselect('#sibling-selector ~ .sibling-selector', document)).to.have.length(2); //found two siblings + expect(CSSselect('#sibling-selector ~ div.sibling-selector', document)).to.have.length(2); //found two siblings + expect(CSSselect('#sibling-selector + div.sibling-selector', document)).to.have.length(1); //found one sibling + expect(CSSselect('#sibling-selector + .sibling-selector', document)).to.have.length(1); //found one sibling + + expect(CSSselect('.parent .oldest ~ .sibling', document)).to.have.length(4); //found four younger siblings + expect(CSSselect('.parent .middle ~ .sibling', document)).to.have.length(2); //found two younger siblings + expect(CSSselect('.parent .middle ~ h4', document)).to.have.length(1); //found next sibling by tag + expect(CSSselect('.parent .middle ~ h4.younger', document)).to.have.length(1); //found next sibling by tag and class + expect(CSSselect('.parent .middle ~ h3', document)).to.be.empty(); //an element can't be its own sibling + expect(CSSselect('.parent .middle ~ h2', document)).to.be.empty(); //didn't find an older sibling + expect(CSSselect('.parent .youngest ~ .sibling', document)).to.be.empty(); //found no younger siblings + + expect(CSSselect('.parent .oldest + .sibling', document)).to.have.length(1); //found next sibling + expect(CSSselect('.parent .middle + .sibling', document)).to.have.length(1); //found next sibling + expect(CSSselect('.parent .middle + h4', document)).to.have.length(1); //found next sibling by tag + expect(CSSselect('.parent .middle + h3', document)).to.be.empty(); //an element can't be its own sibling + expect(CSSselect('.parent .middle + h2', document)).to.be.empty(); //didn't find an older sibling + expect(CSSselect('.parent .youngest + .sibling', document)).to.be.empty(); //found no younger siblings + } + +}, + +/* +'Uniq': { + 'duplicates arent found in arrays': function () { + expect(CSSselect.uniq(['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e'])).to.have.length(5); //result should be a, b, c, d, e + expect(CSSselect.uniq(['a', 'b', 'c', 'c', 'c'])).to.have.length(3); //result should be a, b, c + } +}, +*/ + + +'element-context queries': { + +/* + 'relationship-first queries': function() { + expect(CSSselect('> .direct-descend', CSSselect('#direct-descend', document))).to.have.length(2); //found two direct descendents using > first + expect(CSSselect('~ .sibling-selector', CSSselect('#sibling-selector', document))).to.have.length(2); //found two siblings with ~ first + expect(CSSselect('+ .sibling-selector', CSSselect('#sibling-selector', document))).to.have.length(1); //found one sibling with + first + expect(CSSselect('> .tokens a', CSSselect('.idless', document)[0])).to.have.length(1); //found one sibling from a root with no id + }, +*/ + + // should be able to query on an element that hasn't been inserted into the dom + 'detached fragments': function() { + expect(CSSselect('.a span', frag)).to.have.length(1); //should find child elements of fragment + //expect(CSSselect('> div p em', frag)).to.have.length(2); //should find child elements of fragment, relationship first + }, + + 'byId sub-queries within detached fragment': function () { + expect(CSSselect('#emem', frag)).to.have.length(1); //found "#id" in fragment + expect(CSSselect('.d.i #emem', frag)).to.have.length(1); //found ".class.class #id" in fragment + expect(CSSselect('.d #oooo #emem', frag)).to.have.length(1); //found ".class #id #id" in fragment + //expect(CSSselect('> div #oooo', frag)).to.have.length(1); //found "> .class #id" in fragment + expect(CSSselect('#oooo', CSSselect('#emem', frag)).length).to.not.be.ok(); //shouldn't find #oooo (ancestor) within #emem (descendent) + expect(CSSselect('#sep', CSSselect('#emem', frag)).length).to.not.be.ok(); //shouldn't find #sep within #emem (unrelated) + }, + +/* + 'exclude self in match': function() { + expect(CSSselect('.order-matters', CSSselect('#order-matters', document))).to.have.length(4); //should not include self in element-context queries + }, +*/ + + // because form's have .length + 'forms can be used as contexts': function() { + expect(CSSselect('*', CSSselect('form', document)[0])).to.have.length(3); //found 3 elements under <form> + } +}, + +'tokenizer': { + + 'should not get weird tokens': function () { + expect(CSSselect('div .tokens[title="one"]', document)[0]).to.be(DomUtils.getElementById('token-one', document)); //found div .tokens[title="one"] + expect(CSSselect('div .tokens[title="one two"]', document)[0]).to.be(DomUtils.getElementById('token-two', document)); //found div .tokens[title="one two"] + expect(CSSselect('div .tokens[title="one two three #%"]', document)[0]).to.be(DomUtils.getElementById('token-three', document)); //found div .tokens[title="one two three #%"] + expect(CSSselect("div .tokens[title='one two three #%'] a", document)[0]).to.be(DomUtils.getElementById('token-four', document)); //found div .tokens[title=\'one two three #%\'] a + expect(CSSselect('div .tokens[title="one two three #%"] a[href$=foo] div', document)[0]).to.be(DomUtils.getElementById('token-five', document)); //found div .tokens[title="one two three #%"] a[href=foo] div + } + +}, + +'interesting syntaxes': { + 'should parse bad selectors': function () { + expect(CSSselect('#spaced-tokens p em a', document).length).to.be.ok(); //found element with funny tokens + } +}, + +'order matters': { + + //
    + //

    + // + // + // + //
    + + 'the order of elements return matters': function () { + function tag(el) { + return el.name.toLowerCase(); + } + var els = CSSselect('#order-matters .order-matters', document); + expect(tag(els[0])).to.be('p'); //first element matched is a {p} tag + expect(tag(els[1])).to.be('a'); //first element matched is a {a} tag + expect(tag(els[2])).to.be('em'); //first element matched is a {em} tag + expect(tag(els[3])).to.be('b'); //first element matched is a {b} tag + } + +}, + +'pseudo-selectors': { + ':contains': function() { + expect(CSSselect('li:contains(humans)', document)).to.have.length(1); //found by "element:contains(text)" + expect(CSSselect(':contains(humans)', document)).to.have.length(5); //found by ":contains(text)", including all ancestors + // * is an important case, can cause weird errors + expect(CSSselect('*:contains(humans)', document)).to.have.length(5); //found by "*:contains(text)", including all ancestors + expect(CSSselect('ol:contains(humans)', document)).to.have.length(1); //found by "ancestor:contains(text)" + }, + + ':not': function() { + expect(CSSselect('.odd:not(div)', document)).to.have.length(1); //found one .odd :not an <a> + }, + + ':first-child': function () { + expect(CSSselect('#pseudos div:first-child', document)[0]).to.be(pseudos[0]); //found first child + expect(CSSselect('#pseudos div:first-child', document)).to.have.length(1); //found only 1 + }, + + ':last-child': function () { + var all = DomUtils.getElementsByTagName('div', pseudos); + expect(CSSselect('#pseudos div:last-child', document)[0]).to.be(all[all.length - 1]); //found last child + expect(CSSselect('#pseudos div:last-child', document)).to.have.length(1); //found only 1 + }, + + 'ol > li[attr="boosh"]:last-child': function () { + var expected = DomUtils.getElementById('attr-child-boosh', document); + expect(CSSselect('ol > li[attr="boosh"]:last-child', document)).to.have.length(1); //only 1 element found + expect(CSSselect('ol > li[attr="boosh"]:last-child', document)[0]).to.be(expected); //found correct element + }, + + ':nth-child(odd|even|x)': function () { + var second = DomUtils.getElementsByTagName('div', pseudos)[1]; + expect(CSSselect('#pseudos :nth-child(odd)', document)).to.have.length(4); //found 4 odd elements + expect(CSSselect('#pseudos div:nth-child(odd)', document)).to.have.length(3); //found 3 odd elements with div tag + expect(CSSselect('#pseudos div:nth-child(even)', document)).to.have.length(3); //found 3 even elements with div tag + expect(CSSselect('#pseudos div:nth-child(2)', document)[0]).to.be(second); //found 2nd nth-child of pseudos + }, + + ':nth-child(expr)': function () { + var fifth = DomUtils.getElementsByTagName('a', pseudos)[0]; + var sixth = DomUtils.getElementsByTagName('div', pseudos)[4]; + + expect(CSSselect('#pseudos :nth-child(3n+1)', document)).to.have.length(3); //found 3 elements + expect(CSSselect('#pseudos :nth-child(+3n-2)', document)).to.have.length(3); //found 3 elements' + expect(CSSselect('#pseudos :nth-child(-n+6)', document)).to.have.length(6); //found 6 elements + expect(CSSselect('#pseudos :nth-child(-n+5)', document)).to.have.length(5); //found 5 elements + expect(CSSselect('#pseudos :nth-child(3n+2)', document)[1]).to.be(fifth); //second :nth-child(3n+2) is the fifth child + expect(CSSselect('#pseudos :nth-child(3n)', document)[1]).to.be(sixth); //second :nth-child(3n) is the sixth child + }, + + ':nth-last-child(odd|even|x)': function () { + var second = DomUtils.getElementsByTagName('div', pseudos)[1]; + expect(CSSselect('#pseudos :nth-last-child(odd)', document)).to.have.length(4); //found 4 odd elements + expect(CSSselect('#pseudos div:nth-last-child(odd)', document)).to.have.length(3); //found 3 odd elements with div tag + expect(CSSselect('#pseudos div:nth-last-child(even)', document)).to.have.length(3); //found 3 even elements with div tag + expect(CSSselect('#pseudos div:nth-last-child(6)', document)[0]).to.be(second); //6th nth-last-child should be 2nd of 7 elements + }, + + ':nth-last-child(expr)': function () { + var third = DomUtils.getElementsByTagName('div', pseudos)[2]; + + expect(CSSselect('#pseudos :nth-last-child(3n+1)', document)).to.have.length(3); //found 3 elements + expect(CSSselect('#pseudos :nth-last-child(3n-2)', document)).to.have.length(3); //found 3 elements + expect(CSSselect('#pseudos :nth-last-child(-n+6)', document)).to.have.length(6); //found 6 elements + expect(CSSselect('#pseudos :nth-last-child(-n+5)', document)).to.have.length(5); //found 5 elements + expect(CSSselect('#pseudos :nth-last-child(3n+2)', document)[0]).to.be(third); //first :nth-last-child(3n+2) is the third child + }, + + ':nth-of-type(expr)': function () { + var a = DomUtils.getElementsByTagName('a', pseudos)[0]; + + expect(CSSselect('#pseudos div:nth-of-type(3n+1)', document)).to.have.length(2); //found 2 div elements + expect(CSSselect('#pseudos a:nth-of-type(3n+1)', document)).to.have.length(1); //found 1 a element + expect(CSSselect('#pseudos a:nth-of-type(3n+1)', document)[0]).to.be(a); //found the right a element + expect(CSSselect('#pseudos a:nth-of-type(3n)', document)).to.be.empty(); //no matches for every third a + expect(CSSselect('#pseudos a:nth-of-type(odd)', document)).to.have.length(1); //found the odd a + expect(CSSselect('#pseudos a:nth-of-type(1)', document)).to.have.length(1); //found the first a + }, + + ':nth-last-of-type(expr)': function () { + var second = DomUtils.getElementsByTagName('div', pseudos)[1]; + + expect(CSSselect('#pseudos div:nth-last-of-type(3n+1)', document)).to.have.length(2); //found 2 div elements + expect(CSSselect('#pseudos a:nth-last-of-type(3n+1)', document)).to.have.length(1); //found 1 a element + expect(CSSselect('#pseudos div:nth-last-of-type(5)', document)[0]).to.be(second); //5th nth-last-of-type should be 2nd of 7 elements + }, + + ':first-of-type': function () { + expect(CSSselect('#pseudos a:first-of-type', document)[0]).to.be(DomUtils.getElementsByTagName('a', pseudos)[0]); //found first a element + expect(CSSselect('#pseudos a:first-of-type', document)).to.have.length(1); //found only 1 + }, + + ':last-of-type': function () { + var all = DomUtils.getElementsByTagName('div', pseudos); + expect(CSSselect('#pseudos div:last-of-type', document)[0]).to.be(all[all.length - 1]); //found last div element + expect(CSSselect('#pseudos div:last-of-type', document)).to.have.length(1); //found only 1 + }, + + ':only-of-type': function () { + expect(CSSselect('#pseudos a:only-of-type', document)[0]).to.be(DomUtils.getElementsByTagName('a', pseudos)[0]); //found the only a element + expect(CSSselect('#pseudos a:first-of-type', document)).to.have.length(1); //found only 1 + }, + + ':target': function () { + location.hash = ''; + expect(CSSselect('#pseudos:target', document)).to.be.empty(); //#pseudos is not the target + location.hash = '#pseudos'; + expect(CSSselect('#pseudos:target', document)).to.have.length(1); //now #pseudos is the target + location.hash = ''; + }, + + 'custom pseudos': function() { + // :humanoid implemented just for testing purposes + expect(CSSselect(':humanoid', document)).to.have.length(2); //selected using custom pseudo + } + +}, + +/* +'argument types': { + + 'should be able to pass in nodes as arguments': function () { + var el = DomUtils.getElementById('boosh', document); + expect(CSSselect(el)[0]).to.be(el); //CSSselect(el)[0] == el + expect(CSSselect(el, 'body')[0]).to.be(el); //CSSselect(el, 'body')[0] == el + expect(CSSselect(el, document)[0]).to.be(el); //CSSselect(el, document)[0] == el + expect(CSSselect(window)[0]).to.be(window); //CSSselect(window)[0] == window + expect(CSSselect(document)[0]).to.be(document); //CSSselect(document)[0] == document + }, + + 'should be able to pass in an array of results as arguments': function () { + var el = DomUtils.getElementById('boosh', document); + var result = CSSselect([CSSselect('#boosh', document), CSSselect(document), CSSselect(window)]); + expect(result).to.have.length(3); //3 elements in the combined set + expect(result[0]).to.be(el); //result[0] == el + expect(result[1]).to.be(document); //result[0] == document + expect(result[2]).to.be(window); //result[0] == window + expect(CSSselect([CSSselect('#pseudos div.odd', document), CSSselect('#pseudos div.even', document)])).to.have.length(6); //found all the odd and even divs + } + +}, +*/ + +'is()': { + 'simple selectors': function () { + expect(CSSselect.is(el, 'li')).to.be.ok(); //tag + expect(CSSselect.is(el, '*')).to.be.ok(); //wildcard + expect(CSSselect.is(el, '#attr-child-boosh')).to.be.ok(); //#id + expect(CSSselect.is(el, '[attr]')).to.be.ok(); //[attr] + expect(CSSselect.is(el, '[attr=boosh]')).to.be.ok(); //[attr=val] + expect(CSSselect.is(el, 'div')).to.not.be.ok(); //wrong tag + expect(CSSselect.is(el, '#foo')).to.not.be.ok(); //wrong #id + expect(CSSselect.is(el, '[foo]')).to.not.be.ok(); //wrong [attr] + expect(CSSselect.is(el, '[attr=foo]')).to.not.be.ok(); //wrong [attr=val] + }, + 'selector sequences': function () { + expect(CSSselect.is(el, 'li#attr-child-boosh[attr=boosh]')).to.be.ok(); //tag#id[attr=val] + expect(CSSselect.is(el, 'div#attr-child-boosh[attr=boosh]')).to.not.be.ok(); //wrong tag#id[attr=val] + }, + 'selector sequences combinators': function () { + expect(CSSselect.is(el, 'ol li')).to.be.ok(); //tag tag + expect(CSSselect.is(el, 'ol>li')).to.be.ok(); //tag>tag + expect(CSSselect.is(el, 'ol>li+li')).to.be.ok(); //tab>tag+tag + expect(CSSselect.is(el, 'ol#list li#attr-child-boosh[attr=boosh]')).to.be.ok(); //tag#id tag#id[attr=val] + expect(CSSselect.is(el, 'ol#list>li#attr-child-boosh[attr=boosh]')).to.not.be.ok(); //wrong tag#id>tag#id[attr=val] + expect(CSSselect.is(el, 'ol ol li#attr-child-boosh[attr=boosh]')).to.be.ok(); //tag tag tag#id[attr=val] + expect(CSSselect.is(CSSselect('#token-four', document)[0], 'div#fixtures>div a')).to.be.ok(); //tag#id>tag tag where ambiguous middle tag requires backtracking + }, + 'pseudos': function() { + //TODO: more tests! + expect(CSSselect.is(el, 'li:contains(hello)')).to.be.ok(); //matching :contains(text) + expect(CSSselect.is(el, 'li:contains(human)')).to.not.be.ok(); //non-matching :contains(text) + expect(CSSselect.is(CSSselect('#list>li', document)[2], ':humanoid')).to.be.ok(); //matching custom pseudo + expect(CSSselect.is(CSSselect('#list>li', document)[1], ':humanoid')).to.not.be.ok(); //non-matching custom pseudo + }/*, + 'context': function () { + expect(CSSselect.is(el, 'li#attr-child-boosh[attr=boosh]', CSSselect('#list', document)[0])).to.be.ok(); //context + expect(CSSselect.is(el, 'ol#list li#attr-child-boosh[attr=boosh]', CSSselect('#boosh', document)[0])).to.not.be.ok(); //wrong context + }*/ +}, + +'selecting elements in other documents': { + 'get element by id': function () { + var result = CSSselect('#hsoob', doc); + expect(result[0]).to.be.ok(); //found element with id=hsoob + }, + + 'get elements by class': function () { + expect(CSSselect('#hsoob .a', doc)).to.have.length(2); //found two elements + expect(CSSselect('#hsoob div.a', doc)[0]).to.be.ok(); //found one element + expect(CSSselect('#hsoob div', doc)).to.have.length(2); //found two {div} elements + expect(CSSselect('#hsoob span', doc)[0]).to.be.ok(); //found one {span} element + expect(CSSselect('#hsoob div div', doc)[0]).to.be.ok(); //found a single div + expect(CSSselect('p.odd', doc)).to.have.length(1); //found single br + }, + + 'complex selectors': function () { + expect(CSSselect('.d ~ .sib', doc)).to.have.length(2); //found one ~ sibling + expect(CSSselect('.a .d + .sib', doc)).to.have.length(1); //found 2 + siblings + expect(CSSselect('#hsoob > div > .h', doc)).to.have.length(1); //found span using child selectors + expect(CSSselect('.a .d ~ .sib[test="f g"]', doc)).to.have.length(1); //found 1 ~ sibling with test attribute + }, + + 'byId sub-queries': function () { + expect(CSSselect('#hsoob #spanny', doc)).to.have.length(1); //found "#id #id" in frame + expect(CSSselect('.a #spanny', doc)).to.have.length(1); //found ".class #id" in frame + expect(CSSselect('.a #booshTest #spanny', doc)).to.have.length(1); //found ".class #id #id" in frame + //expect(CSSselect('> #hsoob', doc)).to.have.length(1) //found "> #id" in frame + }, + + 'byId sub-queries within sub-context': function () { + expect(CSSselect('#spanny', CSSselect('#hsoob', doc))).to.have.length(1); //found "#id -> #id" in frame + expect(CSSselect('.a #spanny', CSSselect('#hsoob', doc))).to.have.length(1); //found ".class #id" in frame + expect(CSSselect('.a #booshTest #spanny', CSSselect('#hsoob', doc))).to.have.length(1); //found ".class #id #id" in frame + expect(CSSselect('.a > #booshTest', CSSselect('#hsoob', doc))).to.have.length(1); //found "> .class #id" in frame + expect(CSSselect('#booshTest', CSSselect('#spanny', doc)).length).to.not.be.ok(); //shouldn't find #booshTest (ancestor) within #spanny (descendent) + expect(CSSselect('#booshTest', CSSselect('#lonelyHsoob', doc)).length).to.not.be.ok(); //shouldn't find #booshTest within #lonelyHsoob (unrelated) + } + +} + +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/sizzle/selector.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/sizzle/selector.js new file mode 100644 index 00000000..b7de5162 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/sizzle/selector.js @@ -0,0 +1,1211 @@ +var DomUtils = require("domutils"), + helper = require("../tools/helper.js"), + CSSselect = helper.CSSselect, + assert = require("assert"), + equal = assert.equal, + deepEqual = assert.deepEqual, + ok = assert.ok, + testInit = require("./data/testinit.js"), + q = testInit.q, + t = testInit.t, + document = testInit.loadDoc(), + createWithFriesXML = testInit.createWithFriesXML; + +function Sizzle(str, doc){ + return CSSselect(str, doc || document); +} + +function jQuery(dom){ + if(typeof dom === "string") dom = helper.getDOM(dom); + var ret = { + appendTo: function(elem){ + if(typeof elem === "string") elem = Sizzle(elem)[0]; + dom.forEach(function(child){ + DomUtils.appendChild(elem, child); + }); + return this; + }, + remove: function(){ + dom.forEach(DomUtils.removeElement); + return this; + }, + prev: function(){ + dom = dom.map(function(elem){ + return elem.prev; + }); + return this; + }, + before: function(str){ + dom.forEach(function(elem){ + helper.getDOM(str).forEach(function(child){ + DomUtils.prepend(elem, child); + }); + }); + return this; + } + }; + + dom.forEach(function(elem, i){ + ret[i] = elem; + }); + + return ret; +} + +Sizzle.matches = function(selector, elements){ + return elements.filter(CSSselect.compile(selector)); +}; + +Sizzle.matchesSelector = CSSselect.is; + +function noop(){} + +var expect = noop; + +var raises = assert.throws; + +function asyncTest(name, _, func){ + it(name, func); +} + +//add an `appendTo` method to cheerio +jQuery.prototype.appendTo = function(elem){ + if(typeof elem === "string") elem = Sizzle(elem)[0]; + Array.prototype.push.apply(elem.children, this); + this.each(function(i, child){ + child.parent = elem; + }); + return this; +}; + +var test = it; + +beforeEach(function(){ + document = testInit.loadDoc(); +}); + +// #### NOTE: #### +// jQuery should not be used in this module +// except for DOM manipulation +// If jQuery is mandatory for the selection, move the test to jquery/test/unit/selector.js +// Use t() or Sizzle() +// ############### + +/* + ======== QUnit Reference ======== + http://docs.jquery.com/QUnit + + Test methods: + expect(numAssertions) + stop() + start() + note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite + so that start and stop can be passed as callbacks without worrying about + their parameters + Test assertions: + ok(value, [message]) + equal(actual, expected, [message]) + notEqual(actual, expected, [message]) + deepEqual(actual, expected, [message]) + notDeepEqual(actual, expected, [message]) + strictEqual(actual, expected, [message]) + notStrictEqual(actual, expected, [message]) + raises(block, [expected], [message]) + + ======== testinit.js reference ======== + See data/testinit.js + + q(...); + Returns an array of elements with the given IDs + @example q("main", "foo", "bar") => [
    , , ] + + t( testName, selector, [ "array", "of", "ids" ] ); + Asserts that a select matches the given IDs + @example t("Check for something", "//[a]", ["foo", "baar"]); + + url( "some/url.php" ); + Add random number to url to stop caching + @example url("data/test.html") => "data/test.html?10538358428943" + @example url("data/test.php?foo=bar") => "data/test.php?foo=bar&10538358345554" +*/ + +test("element", function() { + expect( 38 ); + + var form, all, good, i, obj1, lengthtest, + siblingTest, iframe, iframeDoc, html; + + equal( Sizzle("").length, 0, "Empty selector returns an empty array" ); + deepEqual( Sizzle("div", document.createTextNode("")), [], "Text element as context fails silently" ); + form = document.getElementById("form"); + ok( !Sizzle.matchesSelector( form, "" ), "Empty string passed to matchesSelector does not match" ); + equal( Sizzle(" ").length, 0, "Empty selector returns an empty array" ); + equal( Sizzle("\t").length, 0, "Empty selector returns an empty array" ); + + ok( Sizzle("*").length >= 30, "Select all" ); + all = Sizzle("*"); + good = true; + for ( i = 0; i < all.length; i++ ) { + if ( all[i].nodeType === 8 ) { + good = false; + } + } + ok( good, "Select all elements, no comment nodes" ); + t( "Element Selector", "html", ["html"] ); + t( "Element Selector", "body", ["body"] ); + t( "Element Selector", "#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] ); + + t( "Leading space", " #qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] ); + t( "Leading tab", "\t#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] ); + t( "Leading carriage return", "\r#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] ); + t( "Leading line feed", "\n#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] ); + t( "Leading form feed", "\f#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] ); + t( "Trailing space", "#qunit-fixture p ", ["firstp","ap","sndp","en","sap","first"] ); + t( "Trailing tab", "#qunit-fixture p\t", ["firstp","ap","sndp","en","sap","first"] ); + t( "Trailing carriage return", "#qunit-fixture p\r", ["firstp","ap","sndp","en","sap","first"] ); + t( "Trailing line feed", "#qunit-fixture p\n", ["firstp","ap","sndp","en","sap","first"] ); + t( "Trailing form feed", "#qunit-fixture p\f", ["firstp","ap","sndp","en","sap","first"] ); + + t( "Parent Element", "dl ol", ["empty", "listWithTabIndex"] ); + t( "Parent Element (non-space descendant combinator)", "dl\tol", ["empty", "listWithTabIndex"] ); + obj1 = document.getElementById("object1"); + equal( Sizzle("param", obj1).length, 2, "Object/param as context" ); + + deepEqual( Sizzle("select", form), q("select1","select2","select3","select4","select5"), "Finding selects with a context." ); + + // Check for unique-ness and sort order + deepEqual( Sizzle("p, div p"), Sizzle("p"), "Check for duplicates: p, div p" ); + + t( "Checking sort order", "h2, h1", ["qunit-header", "qunit-banner", "qunit-userAgent"] ); + // t( "Checking sort order", "h2:first, h1:first", ["qunit-header", "qunit-banner"] ); + t( "Checking sort order", "#qunit-fixture p, #qunit-fixture p a", ["firstp", "simon1", "ap", "google", "groups", "anchor1", "mark", "sndp", "en", "yahoo", "sap", "anchor2", "simon", "first"] ); + + // Test Conflict ID + lengthtest = document.getElementById("lengthtest"); + deepEqual( Sizzle("#idTest", lengthtest), q("idTest"), "Finding element with id of ID." ); + deepEqual( Sizzle("[name='id']", lengthtest), q("idTest"), "Finding element with id of ID." ); + deepEqual( Sizzle("input[id='idTest']", lengthtest), q("idTest"), "Finding elements with id of ID." ); + + siblingTest = document.getElementById("siblingTest"); // TODO + // deepEqual( Sizzle("div em", siblingTest), [], "Element-rooted QSA does not select based on document context" ); + // deepEqual( Sizzle("div em, div em, div em:not(div em)", siblingTest), [], "Element-rooted QSA does not select based on document context" ); + // deepEqual( Sizzle("div em, em\\,", siblingTest), [], "Escaped commas do not get treated with an id in element-rooted QSA" ); + + iframe = document.getElementById("iframe"); + //iframeDoc.open(); + iframe.children = helper.getDOM("

    bar

    "); + //iframeDoc.close(); + deepEqual( + Sizzle( "p:contains(bar)", iframe ), + [ DomUtils.getElementById("foo", iframe.children) ], + "Other document as context" + ); + iframe.children = []; + + html = ""; + for ( i = 0; i < 100; i++ ) { + html = "
    " + html + "
    "; + } + html = jQuery( html ).appendTo( document.body ); + ok( !!Sizzle("body div div div").length, "No stack or performance problems with large amounts of descendents" ); + ok( !!Sizzle("body>div div div").length, "No stack or performance problems with large amounts of descendents" ); + html.remove(); + + // Real use case would be using .watch in browsers with window.watch (see Issue #157) + var elem = document.createElement("tostring"); + elem.attribs.id = "toString"; + var siblings = q("qunit-fixture")[0].children; + siblings.push( elem ); + t( "Element name matches Object.prototype property", "tostring#toString", ["toString"] ); + siblings.pop(); +}); + +test("XML Document Selectors", function() { + var xml = createWithFriesXML(); + expect( 11 ); + + equal( Sizzle("foo_bar", xml).length, 1, "Element Selector with underscore" ); + equal( Sizzle(".component", xml).length, 1, "Class selector" ); + equal( Sizzle("[class*=component]", xml).length, 1, "Attribute selector for class" ); + equal( Sizzle("property[name=prop2]", xml).length, 1, "Attribute selector with name" ); + equal( Sizzle("[name=prop2]", xml).length, 1, "Attribute selector with name" ); + equal( Sizzle("#seite1", xml).length, 1, "Attribute selector with ID" ); + equal( Sizzle("component#seite1", xml).length, 1, "Attribute selector with ID" ); + equal( Sizzle.matches( "#seite1", Sizzle("component", xml) ).length, 1, "Attribute selector filter with ID" ); + equal( Sizzle("meta property thing", xml).length, 2, "Descendent selector and dir caching" ); + ok( Sizzle.matchesSelector( xml.lastChild, "soap\\:Envelope", { xmlMode: true } ), "Check for namespaced element" ); + + xml = helper.getDOM("", { xmlMode: true }); + equal( Sizzle( "elem:not(:has(*))", xml ).length, 1, + "Non-qSA path correctly handles numeric ids (jQuery #14142)" ); +}); + +test("broken", function() { + expect( 26 ); + + var attrbad, + broken = function( name, selector ) { + raises(function() { + // Setting context to null here somehow avoids QUnit's window.error handling + // making the e & e.message correct + // For whatever reason, without this, + // Sizzle.error will be called but no error will be seen in oldIE + Sizzle.call( null, selector ); + }, SyntaxError, name + ": " + selector ); + }; + + // broken( "Broken Selector", "[" ); + // broken( "Broken Selector", "(" ); + // broken( "Broken Selector", "{" ); + // broken( "Broken Selector", "<" ); + // broken( "Broken Selector", "()" ); + // broken( "Broken Selector", "<>" ); + broken( "Broken Selector", "{}" ); + broken( "Broken Selector", "," ); + broken( "Broken Selector", ",a" ); + broken( "Broken Selector", "a," ); + // Hangs on IE 9 if regular expression is inefficient + // broken( "Broken Selector", "[id=012345678901234567890123456789"); + broken( "Doesn't exist", ":visble" ); + broken( "Nth-child", ":nth-child" ); + // Sigh again. IE 9 thinks this is also a real selector + // not super critical that we fix this case + broken( "Nth-child", ":nth-child(-)" ); + // Sigh. WebKit thinks this is a real selector in qSA + // They've already fixed this and it'll be coming into + // current browsers soon. Currently, Safari 5.0 still has this problem + broken( "Nth-child", ":nth-child(asdf)", [] ); + broken( "Nth-child", ":nth-child(2n+-0)" ); + broken( "Nth-child", ":nth-child(2+0)" ); + broken( "Nth-child", ":nth-child(- 1n)" ); + broken( "Nth-child", ":nth-child(-1 n)" ); + broken( "First-child", ":first-child(n)" ); + broken( "Last-child", ":last-child(n)" ); + broken( "Only-child", ":only-child(n)" ); + broken( "Nth-last-last-child", ":nth-last-last-child(1)" ); + broken( "First-last-child", ":first-last-child" ); + broken( "Last-last-child", ":last-last-child" ); + broken( "Only-last-child", ":only-last-child" ); + + // Make sure attribute value quoting works correctly. See: #6093 + attrbad = jQuery("").appendTo("#qunit-fixture"); + + // broken( "Attribute not escaped", "input[name=foo.baz]", [] ); + // Shouldn't be matching those inner brackets + // broken( "Attribute not escaped", "input[name=foo[baz]]", [] ); +}); + +test("id", function() { + expect( 34 ); + + var fiddle, a; + + t( "ID Selector", "#body", ["body"] ); + t( "ID Selector w/ Element", "body#body", ["body"] ); + t( "ID Selector w/ Element", "ul#first", [] ); + t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] ); + t( "ID selector with non-existant descendant", "#firstp #foobar", [] ); + t( "ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"] ); + t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi","台北"] ); + t( "Descendant ID selector using UTF8", "div #台北", ["台北"] ); + t( "Child ID selector using UTF8", "form > #台北", ["台北"] ); + + t( "Escaped ID", "#foo\\:bar", ["foo:bar"] ); + t( "Escaped ID with descendent", "#foo\\:bar span:not(:input)", ["foo_descendent"] ); + t( "Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Descendant escaped ID", "div #foo\\:bar", ["foo:bar"] ); + t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] ); + t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + + fiddle = jQuery("
    ").appendTo("#qunit-fixture"); + // deepEqual( Sizzle( "> span", Sizzle("#fiddle\\\\Foo")[0] ), q([ "fiddleSpan" ]), "Escaped ID as context" ); + fiddle.remove(); + + t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267 + t( "ID Selector, not an ancestor ID", "#form #first", [] ); + t( "ID Selector, not a child ID", "#form > #option1a", [] ); + + t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] ); + t( "All Children of ID with no children", "#firstUL > *", [] ); + + equal( Sizzle("#tName1")[0].attribs.id, "tName1", "ID selector with same value for a name attribute" ); + t( "ID selector non-existing but name attribute on an A tag", "#tName2", [] ); + t( "Leading ID selector non-existing but name attribute on an A tag", "#tName2 span", [] ); + t( "Leading ID selector existing, retrieving the child", "#tName1 span", ["tName1-span"] ); + equal( Sizzle("div > div #tName1")[0].attribs.id, Sizzle("#tName1-span")[0].parent.attribs.id, "Ending with ID" ); + + a = jQuery("").appendTo("#qunit-fixture"); + t( "ID Selector contains backslash", "#backslash\\\\foo", ["backslash\\foo"] ); + + t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", ["lengthtest"] ); + + t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986 + + deepEqual( Sizzle("div#form", document.body), [], "ID selector within the context of another element" ); + + t( "Underscore ID", "#types_all", ["types_all"] ); + t( "Dash ID", "#qunit-fixture", ["qunit-fixture"] ); + + t( "ID with weird characters in it", "#name\\+value", ["name+value"] ); +}); + +test("class", function() { + expect( 26 ); + + t( "Class Selector", ".blog", ["mark","simon"] ); + t( "Class Selector", ".GROUPS", ["groups"] ); + t( "Class Selector", ".blog.link", ["simon"] ); + t( "Class Selector w/ Element", "a.blog", ["mark","simon"] ); + t( "Parent Class Selector", "p .blog", ["mark","simon"] ); + + t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] ); + t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] ); + t( "Class selector using UTF8", ".台北Táiběi.台北", ["utf8class1"] ); + t( "Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1","utf8class2"] ); + t( "Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"] ); + t( "Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"] ); + + t( "Escaped Class", ".foo\\:bar", ["foo:bar"] ); + t( "Escaped Class", ".test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Descendant escaped Class", "div .foo\\:bar", ["foo:bar"] ); + t( "Descendant escaped Class", "div .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Child escaped Class", "form > .foo\\:bar", ["foo:bar"] ); + t( "Child escaped Class", "form > .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + + var div = document.createElement("div"); + div.children = helper.getDOM("
    "); + div.children.forEach(function(e){ + e.parent = div; + }); + deepEqual( Sizzle(".e", div), [ div.children[0] ], "Finding a second class." ); + + var lastChild = div.children[div.children.length - 1]; + lastChild.attribs.class = "e"; + + deepEqual( Sizzle(".e", div), [ div.children[0], lastChild ], "Finding a modified class." ); + + ok( !Sizzle.matchesSelector( div, ".null"), ".null does not match an element with no class" ); + ok( !Sizzle.matchesSelector( div.children[0], ".null div"), ".null does not match an element with no class" ); + div.attribs.class = "null"; + ok( Sizzle.matchesSelector( div, ".null"), ".null matches element with class 'null'" ); + ok( Sizzle.matchesSelector( div.children[0], ".null div"), "caching system respects DOM changes" ); + ok( !Sizzle.matchesSelector( document, ".foo" ), "testing class on document doesn't error" ); + //ok( !Sizzle.matchesSelector( window, ".foo" ), "testing class on window doesn't error" ); + + lastChild.attribs.class += " hasOwnProperty toString"; + deepEqual( Sizzle(".e.hasOwnProperty.toString", div), [ lastChild ], "Classes match Object.prototype properties" ); + + div = jQuery("
    ")[0]; + equal( Sizzle(".foo", div).length, 1, "Class selector against SVG" ); +}); + +test("name", function() { + expect( 13 ); + + var form; + + t( "Name selector", "input[name=action]", ["text1"] ); + t( "Name selector with single quotes", "input[name='action']", ["text1"] ); + t( "Name selector with double quotes", "input[name=\"action\"]", ["text1"] ); + + t( "Name selector non-input", "[name=example]", ["name-is-example"] ); + t( "Name selector non-input", "[name=div]", ["name-is-div"] ); + t( "Name selector non-input", "*[name=iframe]", ["iframe"] ); + + t( "Name selector for grouped input", "input[name='types[]']", ["types_all", "types_anime", "types_movie"] ); + + form = document.getElementById("form"); + deepEqual( Sizzle("input[name=action]", form), q("text1"), "Name selector within the context of another element" ); + deepEqual( Sizzle("input[name='foo[bar]']", form), q("hidden2"), "Name selector for grouped form element within the context of another element" ); + + form = jQuery("
    ").appendTo("body"); + equal( Sizzle("input", form[0]).length, 1, "Make sure that rooted queries on forms (with possible expandos) work." ); + + form.remove(); + + t( "Find elements that have similar IDs", "[name=tName1]", ["tName1ID"] ); + t( "Find elements that have similar IDs", "[name=tName2]", ["tName2ID"] ); + t( "Find elements that have similar IDs", "#tName2ID", ["tName2ID"] ); +}); + +test("multiple", function() { + expect(6); + + t( "Comma Support", "h2, #qunit-fixture p", ["qunit-banner","qunit-userAgent","firstp","ap","sndp","en","sap","first"] ); + t( "Comma Support", "h2 , #qunit-fixture p", ["qunit-banner","qunit-userAgent","firstp","ap","sndp","en","sap","first"] ); + t( "Comma Support", "h2 , #qunit-fixture p", ["qunit-banner","qunit-userAgent","firstp","ap","sndp","en","sap","first"] ); + t( "Comma Support", "h2,#qunit-fixture p", ["qunit-banner","qunit-userAgent","firstp","ap","sndp","en","sap","first"] ); + t( "Comma Support", "h2,#qunit-fixture p ", ["qunit-banner","qunit-userAgent","firstp","ap","sndp","en","sap","first"] ); + t( "Comma Support", "h2\t,\r#qunit-fixture p\n", ["qunit-banner","qunit-userAgent","firstp","ap","sndp","en","sap","first"] ); +}); + +test("child and adjacent", function() { + expect( 42 ); + + var siblingFirst, en, nothiddendiv; + + t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] ); + t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] ); + t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] ); + t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] ); + t( "Child w/ Class", "p > a.blog", ["mark","simon"] ); + t( "All Children", "code > *", ["anchor1","anchor2"] ); + t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] ); + t( "Adjacent", "#qunit-fixture a + a", ["groups", "tName2ID"] ); + t( "Adjacent", "#qunit-fixture a +a", ["groups", "tName2ID"] ); + t( "Adjacent", "#qunit-fixture a+ a", ["groups", "tName2ID"] ); + t( "Adjacent", "#qunit-fixture a+a", ["groups", "tName2ID"] ); + t( "Adjacent", "p + p", ["ap","en","sap"] ); + t( "Adjacent", "p#firstp + p", ["ap"] ); + t( "Adjacent", "p[lang=en] + p", ["sap"] ); + t( "Adjacent", "a.GROUPS + code + a", ["mark"] ); + t( "Comma, Child, and Adjacent", "#qunit-fixture a + a, code > a", ["groups","anchor1","anchor2","tName2ID"] ); + t( "Element Preceded By", "#qunit-fixture p ~ div", ["foo", "nothiddendiv", "moretests","tabindex-tests", "liveHandlerOrder", "siblingTest"] ); + t( "Element Preceded By", "#first ~ div", ["moretests","tabindex-tests", "liveHandlerOrder", "siblingTest"] ); + t( "Element Preceded By", "#groups ~ a", ["mark"] ); + t( "Element Preceded By", "#length ~ input", ["idTest"] ); + t( "Element Preceded By", "#siblingfirst ~ em", ["siblingnext", "siblingthird"] ); + t( "Element Preceded By (multiple)", "#siblingTest em ~ em ~ em ~ span", ["siblingspan"] ); + t( "Element Preceded By, Containing", "#liveHandlerOrder ~ div em:contains('1')", ["siblingfirst"] ); + + siblingFirst = document.getElementById("siblingfirst"); + + //deepEqual( Sizzle("~ em", siblingFirst), q("siblingnext", "siblingthird"), "Element Preceded By with a context." ); + //deepEqual( Sizzle("+ em", siblingFirst), q("siblingnext"), "Element Directly Preceded By with a context." ); + //deepEqual( Sizzle("~ em:first", siblingFirst), q("siblingnext"), "Element Preceded By positional with a context." ); + + en = document.getElementById("en"); + //deepEqual( Sizzle("+ p, a", en), q("yahoo", "sap"), "Compound selector with context, beginning with sibling test." ); + //deepEqual( Sizzle("a, + p", en), q("yahoo", "sap"), "Compound selector with context, containing sibling test." ); + + t( "Multiple combinators selects all levels", "#siblingTest em *", ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] ); + t( "Multiple combinators selects all levels", "#siblingTest > em *", ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] ); + t( "Multiple sibling combinators doesn't miss general siblings", "#siblingTest > em:first-child + em ~ span", ["siblingspan"] ); + t( "Combinators are not skipped when mixing general and specific", "#siblingTest > em:contains('x') + em ~ span", [] ); + + equal( Sizzle("#listWithTabIndex").length, 1, "Parent div for next test is found via ID (#8310)" ); + //equal( Sizzle("#listWithTabIndex li:eq(2) ~ li").length, 1, "Find by general sibling combinator (#8310)" ); + equal( Sizzle("#__sizzle__").length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" ); + equal( Sizzle("#listWithTabIndex").length, 1, "Parent div for previous test is still found via ID (#8310)" ); + + t( "Verify deep class selector", "div.blah > p > a", [] ); + + t( "No element deep selector", "div.foo > span > a", [] ); + + nothiddendiv = document.getElementById("nothiddendiv"); + //deepEqual( Sizzle("> :first", nothiddendiv), q("nothiddendivchild"), "Verify child context positional selector" ); + //deepEqual( Sizzle("> :eq(0)", nothiddendiv), q("nothiddendivchild"), "Verify child context positional selector" ); + //deepEqual( Sizzle("> *:first", nothiddendiv), q("nothiddendivchild"), "Verify child context positional selector" ); + + t( "Non-existant ancestors", ".fototab > .thumbnails > a", [] ); +}); + +test("attributes", function() { + expect( 76 ); + + var opt, input, attrbad, div; + + t( "Attribute Exists", "#qunit-fixture a[title]", ["google"] ); + t( "Attribute Exists (case-insensitive)", "#qunit-fixture a[TITLE]", ["google"] ); + t( "Attribute Exists", "#qunit-fixture *[title]", ["google"] ); + t( "Attribute Exists", "#qunit-fixture [title]", ["google"] ); + t( "Attribute Exists", "#qunit-fixture a[ title ]", ["google"] ); + + t( "Boolean attribute exists", "#select2 option[selected]", ["option2d"]); + t( "Boolean attribute equals", "#select2 option[selected='selected']", ["option2d"]); + + t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", ["simon1"] ); + t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", ["simon1"] ); + t( "Attribute Equals", "#qunit-fixture a[rel=bookmark]", ["simon1"] ); + t( "Attribute Equals", "#qunit-fixture a[href='http://www.google.com/']", ["google"] ); + t( "Attribute Equals", "#qunit-fixture a[ rel = 'bookmark' ]", ["simon1"] ); + t( "Attribute Equals Number", "#qunit-fixture option[value=1]", ["option1b","option2b","option3b","option4b","option5c"] ); + t( "Attribute Equals Number", "#qunit-fixture li[tabIndex=-1]", ["foodWithNegativeTabIndex"] ); + + document.getElementById("anchor2").href = "#2"; + t( "href Attribute", "p a[href^=#]", ["anchor2"] ); + t( "href Attribute", "p a[href*=#]", ["simon1", "anchor2"] ); + + t( "for Attribute", "form label[for]", ["label-for"] ); + t( "for Attribute in form", "#form [for=action]", ["label-for"] ); + + t( "Attribute containing []", "input[name^='foo[']", ["hidden2"] ); + t( "Attribute containing []", "input[name^='foo[bar]']", ["hidden2"] ); + t( "Attribute containing []", "input[name*='[bar]']", ["hidden2"] ); + t( "Attribute containing []", "input[name$='bar]']", ["hidden2"] ); + t( "Attribute containing []", "input[name$='[bar]']", ["hidden2"] ); + t( "Attribute containing []", "input[name$='foo[bar]']", ["hidden2"] ); + t( "Attribute containing []", "input[name*='foo[bar]']", ["hidden2"] ); + + deepEqual( Sizzle( "input[data-comma='0,1']" ), [ document.getElementById("el12087") ], "Without context, single-quoted attribute containing ','" ); + deepEqual( Sizzle( "input[data-comma=\"0,1\"]" ), [ document.getElementById("el12087") ], "Without context, double-quoted attribute containing ','" ); + deepEqual( Sizzle( "input[data-comma='0,1']", document.getElementById("t12087") ), [ document.getElementById("el12087") ], "With context, single-quoted attribute containing ','" ); + deepEqual( Sizzle( "input[data-comma=\"0,1\"]", document.getElementById("t12087") ), [ document.getElementById("el12087") ], "With context, double-quoted attribute containing ','" ); + + t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type='hidden']", ["radio1", "radio2", "hidden1"] ); + t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=\"hidden\"]", ["radio1", "radio2", "hidden1"] ); + t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=hidden]", ["radio1", "radio2", "hidden1"] ); + + t( "Attribute selector using UTF8", "span[lang=中文]", ["台北"] ); + + t( "Attribute Begins With", "a[href ^= 'http://www']", ["google","yahoo"] ); + t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] ); + t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] ); + t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", ["google","groups","anchor1"] ); + + opt = document.getElementById("option1a"); + opt.attribs.test = ""; + + ok( Sizzle.matchesSelector( opt, "[id*=option1][type!=checkbox]" ), "Attribute Is Not Equal Matches" ); + ok( Sizzle.matchesSelector( opt, "[id*=option1]" ), "Attribute With No Quotes Contains Matches" ); + ok( Sizzle.matchesSelector( opt, "[test=]" ), "Attribute With No Quotes No Content Matches" ); + ok( !Sizzle.matchesSelector( opt, "[test^='']" ), "Attribute with empty string value does not match startsWith selector (^=)" ); + ok( Sizzle.matchesSelector( opt, "[id=option1a]" ), "Attribute With No Quotes Equals Matches" ); + ok( Sizzle.matchesSelector( document.getElementById("simon1"), "a[href*=#]" ), "Attribute With No Quotes Href Contains Matches" ); + + t( "Empty values", "#select1 option[value='']", ["option1a"] ); + t( "Empty values", "#select1 option[value!='']", ["option1b","option1c","option1d"] ); + + t( "Select options via :selected", "#select1 option:selected", ["option1a"] ); + t( "Select options via :selected", "#select2 option:selected", ["option2d"] ); + t( "Select options via :selected", "#select3 option:selected", ["option3b", "option3c"] ); + t( "Select options via :selected", "select[name='select2'] option:selected", ["option2d"] ); + + t( "Grouped Form Elements", "input[name='foo[bar]']", ["hidden2"] ); + + input = document.getElementById("text1"); + input.attribs.title = "Don't click me"; + + ok( Sizzle.matchesSelector( input, "input[title=\"Don't click me\"]" ), "Quote within attribute value does not mess up tokenizer" ); + + // Uncomment if the boolHook is removed + // var check2 = document.getElementById("check2"); + // check2.checked = true; + // ok( !Sizzle.matches("[checked]", [ check2 ] ), "Dynamic boolean attributes match when they should with Sizzle.matches (#11115)" ); + + // jQuery #12303 + input.attribs["data-pos"] = ":first"; + ok( Sizzle.matchesSelector( input, "input[data-pos=\\:first]"), "POS within attribute value is treated as an attribute value" ); + ok( Sizzle.matchesSelector( input, "input[data-pos=':first']"), "POS within attribute value is treated as an attribute value" ); + ok( Sizzle.matchesSelector( input, ":input[data-pos=':first']"), "POS within attribute value after pseudo is treated as an attribute value" ); + delete input.attribs["data-pos"]; + + // Make sure attribute value quoting works correctly. See jQuery #6093; #6428; #13894 + // Use seeded results to bypass querySelectorAll optimizations + attrbad = jQuery( + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + ).appendTo("#qunit-fixture"); + + t( "Underscores don't need escaping", "input[id=types_all]", ["types_all"] ); + + deepEqual( Sizzle( "input[name=foo\\ bar]", null, null, attrbad ), q("attrbad_space"), + "Escaped space" ); + deepEqual( Sizzle( "input[name=foo\\.baz]", null, null, attrbad ), q("attrbad_dot"), + "Escaped dot" ); + deepEqual( Sizzle( "input[name=foo\\[baz\\]]", null, null, attrbad ), q("attrbad_brackets"), + "Escaped brackets" ); + // deepEqual( Sizzle( "input[data-attr='foo_baz\\']']", null, null, attrbad ), q("attrbad_injection"), + // "Escaped quote + right bracket" ); + + // deepEqual( Sizzle( "input[data-attr='\\'']", null, null, attrbad ), q("attrbad_quote"), + // "Quoted quote" ); + // deepEqual( Sizzle( "input[data-attr='\\\\']", null, null, attrbad ), q("attrbad_backslash"), + // "Quoted backslash" ); + // deepEqual( Sizzle( "input[data-attr='\\\\\\'']", null, null, attrbad ), q("attrbad_backslash_quote"), + // "Quoted backslash quote" ); + // deepEqual( Sizzle( "input[data-attr='\\\\\\\\']", null, null, attrbad ), q("attrbad_backslash_backslash"), + // "Quoted backslash backslash" ); + + // deepEqual( Sizzle( "input[data-attr='\\5C\\\\']", null, null, attrbad ), q("attrbad_backslash_backslash"), + // "Quoted backslash backslash (numeric escape)" ); + // deepEqual( Sizzle( "input[data-attr='\\5C \\\\']", null, null, attrbad ), q("attrbad_backslash_backslash"), + // "Quoted backslash backslash (numeric escape with trailing space)" ); + // deepEqual( Sizzle( "input[data-attr='\\5C\t\\\\']", null, null, attrbad ), q("attrbad_backslash_backslash"), + // "Quoted backslash backslash (numeric escape with trailing tab)" ); + // deepEqual( Sizzle( "input[data-attr='\\04e00']", null, null, attrbad ), q("attrbad_unicode"), + // "Long numeric escape (BMP)" );*/ + document.getElementById("attrbad_unicode").attribs["data-attr"] = "\uD834\uDF06A"; + // It was too much code to fix Safari 5.x Supplemental Plane crashes (see ba5f09fa404379a87370ec905ffa47f8ac40aaa3) + deepEqual( Sizzle( "input[data-attr='\\01D306A']", null, null, attrbad ), q("attrbad_unicode"), + "Long numeric escape (non-BMP)" ); + + attrbad.remove(); + + t( "input[type=text]", "#form input[type=text]", ["text1", "text2", "hidden2", "name"] ); + t( "input[type=search]", "#form input[type=search]", ["search"] ); + t( "script[src] (jQuery #13777)", "#moretests script[src]", ["script-src"] ); + + // #3279 + div = document.createElement("div"); + div.children = helper.getDOM("
    "); + + deepEqual( Sizzle( "[xml\\:test]", div ), [ div.children[0] ], "Finding by attribute with escaped characters." ); + + div = document.getElementById("foo"); + t( "Object.prototype property \"constructor\" (negative)", "[constructor]", [] ); + t( "Gecko Object.prototype property \"watch\" (negative)", "[watch]", [] ); + div.attribs.constructor = "foo"; + div.attribs.watch = "bar"; + t( "Object.prototype property \"constructor\"", "[constructor='foo']", ["foo"] ); + t( "Gecko Object.prototype property \"watch\"", "[watch='bar']", ["foo"] ); + + t( "Value attribute is retrieved correctly", "input[value=Test]", ["text1", "text2"] ); +}); + +test("pseudo - (parent|empty)", function() { + expect( 3 ); + t( "Empty", "ul:empty", ["firstUL"] ); + t( "Empty with comment node", "ol:empty", ["empty"] ); + t( "Is A Parent", "#qunit-fixture p:parent", ["firstp","ap","sndp","en","sap","first"] ); +}); + +test("pseudo - (first|last|only)-(child|of-type)", function() { + expect( 12 ); + + t( "First Child", "p:first-child", ["firstp","sndp"] ); + t( "First Child (leading id)", "#qunit-fixture p:first-child", ["firstp","sndp"] ); + t( "First Child (leading class)", ".nothiddendiv div:first-child", ["nothiddendivchild"] ); + t( "First Child (case-insensitive)", "#qunit-fixture p:FIRST-CHILD", ["firstp","sndp"] ); + + t( "Last Child", "p:last-child", ["sap"] ); + t( "Last Child (leading id)", "#qunit-fixture a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon","liveLink1","liveLink2"] ); + + t( "Only Child", "#qunit-fixture a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] ); + + t( "First-of-type", "#qunit-fixture > p:first-of-type", ["firstp"] ); + t( "Last-of-type", "#qunit-fixture > p:last-of-type", ["first"] ); + t( "Only-of-type", "#qunit-fixture > :only-of-type", ["name+value", "firstUL", "empty", "floatTest", "iframe", "table"] ); + + // Verify that the child position isn't being cached improperly + var secondChildren = jQuery(Sizzle("p:nth-child(2)")).before("
    "); + + t( "No longer second child", "p:nth-child(2)", [] ); + secondChildren.prev().remove(); + // t( "Restored second child", "p:nth-child(2)", ["ap","en"] ); +}); + +test("pseudo - nth-child", function() { + expect( 30 ); + + t( "Nth-child", "p:nth-child(1)", ["firstp","sndp"] ); + t( "Nth-child (with whitespace)", "p:nth-child( 1 )", ["firstp","sndp"] ); + t( "Nth-child (case-insensitive)", "#select1 option:NTH-child(3)", ["option1c"] ); + t( "Not nth-child", "#qunit-fixture p:not(:nth-child(1))", ["ap","en","sap","first"] ); + + t( "Nth-child(2)", "#qunit-fixture form#form > *:nth-child(2)", ["text1"] ); + t( "Nth-child(2)", "#qunit-fixture form#form > :nth-child(2)", ["text1"] ); + + t( "Nth-child(-1)", "#select1 option:nth-child(-1)", [] ); + t( "Nth-child(3)", "#select1 option:nth-child(3)", ["option1c"] ); + // t( "Nth-child(0n+3)", "#select1 option:nth-child(0n+3)", ["option1c"] ); + t( "Nth-child(1n+0)", "#select1 option:nth-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] ); + t( "Nth-child(1n)", "#select1 option:nth-child(1n)", ["option1a", "option1b", "option1c", "option1d"] ); + t( "Nth-child(n)", "#select1 option:nth-child(n)", ["option1a", "option1b", "option1c", "option1d"] ); + t( "Nth-child(even)", "#select1 option:nth-child(even)", ["option1b", "option1d"] ); + t( "Nth-child(odd)", "#select1 option:nth-child(odd)", ["option1a", "option1c"] ); + t( "Nth-child(2n)", "#select1 option:nth-child(2n)", ["option1b", "option1d"] ); + t( "Nth-child(2n+1)", "#select1 option:nth-child(2n+1)", ["option1a", "option1c"] ); + t( "Nth-child(2n + 1)", "#select1 option:nth-child(2n + 1)", ["option1a", "option1c"] ); + t( "Nth-child(+2n + 1)", "#select1 option:nth-child(+2n + 1)", ["option1a", "option1c"] ); + t( "Nth-child(3n)", "#select1 option:nth-child(3n)", ["option1c"] ); + t( "Nth-child(3n+1)", "#select1 option:nth-child(3n+1)", ["option1a", "option1d"] ); + t( "Nth-child(3n+2)", "#select1 option:nth-child(3n+2)", ["option1b"] ); + t( "Nth-child(3n+3)", "#select1 option:nth-child(3n+3)", ["option1c"] ); + t( "Nth-child(3n-1)", "#select1 option:nth-child(3n-1)", ["option1b"] ); + t( "Nth-child(3n-2)", "#select1 option:nth-child(3n-2)", ["option1a", "option1d"] ); + t( "Nth-child(3n-3)", "#select1 option:nth-child(3n-3)", ["option1c"] ); + t( "Nth-child(3n+0)", "#select1 option:nth-child(3n+0)", ["option1c"] ); + t( "Nth-child(-1n+3)", "#select1 option:nth-child(-1n+3)", ["option1a", "option1b", "option1c"] ); + t( "Nth-child(-n+3)", "#select1 option:nth-child(-n+3)", ["option1a", "option1b", "option1c"] ); + t( "Nth-child(-1n + 3)", "#select1 option:nth-child(-1n + 3)", ["option1a", "option1b", "option1c"] ); + + // deepEqual( Sizzle( ":nth-child(n)", null, null, [ document.createElement("a") ].concat( q("ap") ) ), q("ap"), "Seeded nth-child" ); +}); + +test("pseudo - nth-last-child", function() { + expect( 30 ); + + t( "Nth-last-child", "form:nth-last-child(5)", ["testForm"] ); + t( "Nth-last-child (with whitespace)", "form:nth-last-child( 5 )", ["testForm"] ); + t( "Nth-last-child (case-insensitive)", "#select1 option:NTH-last-child(3)", ["option1b"] ); + t( "Not nth-last-child", "#qunit-fixture p:not(:nth-last-child(1))", ["firstp", "ap", "sndp", "en", "first"] ); + + t( "Nth-last-child(-1)", "#select1 option:nth-last-child(-1)", [] ); + t( "Nth-last-child(3)", "#select1 :nth-last-child(3)", ["option1b"] ); + t( "Nth-last-child(3)", "#select1 *:nth-last-child(3)", ["option1b"] ); + t( "Nth-last-child(3)", "#select1 option:nth-last-child(3)", ["option1b"] ); + // t( "Nth-last-child(0n+3)", "#select1 option:nth-last-child(0n+3)", ["option1b"] ); + t( "Nth-last-child(1n+0)", "#select1 option:nth-last-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] ); + t( "Nth-last-child(1n)", "#select1 option:nth-last-child(1n)", ["option1a", "option1b", "option1c", "option1d"] ); + t( "Nth-last-child(n)", "#select1 option:nth-last-child(n)", ["option1a", "option1b", "option1c", "option1d"] ); + t( "Nth-last-child(even)", "#select1 option:nth-last-child(even)", ["option1a", "option1c"] ); + t( "Nth-last-child(odd)", "#select1 option:nth-last-child(odd)", ["option1b", "option1d"] ); + t( "Nth-last-child(2n)", "#select1 option:nth-last-child(2n)", ["option1a", "option1c"] ); + t( "Nth-last-child(2n+1)", "#select1 option:nth-last-child(2n+1)", ["option1b", "option1d"] ); + t( "Nth-last-child(2n + 1)", "#select1 option:nth-last-child(2n + 1)", ["option1b", "option1d"] ); + t( "Nth-last-child(+2n + 1)", "#select1 option:nth-last-child(+2n + 1)", ["option1b", "option1d"] ); + t( "Nth-last-child(3n)", "#select1 option:nth-last-child(3n)", ["option1b"] ); + t( "Nth-last-child(3n+1)", "#select1 option:nth-last-child(3n+1)", ["option1a", "option1d"] ); + t( "Nth-last-child(3n+2)", "#select1 option:nth-last-child(3n+2)", ["option1c"] ); + t( "Nth-last-child(3n+3)", "#select1 option:nth-last-child(3n+3)", ["option1b"] ); + t( "Nth-last-child(3n-1)", "#select1 option:nth-last-child(3n-1)", ["option1c"] ); + t( "Nth-last-child(3n-2)", "#select1 option:nth-last-child(3n-2)", ["option1a", "option1d"] ); + t( "Nth-last-child(3n-3)", "#select1 option:nth-last-child(3n-3)", ["option1b"] ); + t( "Nth-last-child(3n+0)", "#select1 option:nth-last-child(3n+0)", ["option1b"] ); + t( "Nth-last-child(-1n+3)", "#select1 option:nth-last-child(-1n+3)", ["option1b", "option1c", "option1d"] ); + t( "Nth-last-child(-n+3)", "#select1 option:nth-last-child(-n+3)", ["option1b", "option1c", "option1d"] ); + t( "Nth-last-child(-1n + 3)", "#select1 option:nth-last-child(-1n + 3)", ["option1b", "option1c", "option1d"] ); + + // deepEqual( Sizzle( ":nth-last-child(n)", null, null, [ document.createElement("a") ].concat( q("ap") ) ), q("ap"), "Seeded nth-last-child" ); +}); + +test("pseudo - nth-of-type", function() { + expect( 9 ); + t( "Nth-of-type(-1)", ":nth-of-type(-1)", [] ); + t( "Nth-of-type(3)", "#ap :nth-of-type(3)", ["mark"] ); + t( "Nth-of-type(n)", "#ap :nth-of-type(n)", ["google", "groups", "code1", "anchor1", "mark"] ); + t( "Nth-of-type(0n+3)", "#ap :nth-of-type(0n+3)", ["mark"] ); + t( "Nth-of-type(2n)", "#ap :nth-of-type(2n)", ["groups"] ); + t( "Nth-of-type(even)", "#ap :nth-of-type(even)", ["groups"] ); + t( "Nth-of-type(2n+1)", "#ap :nth-of-type(2n+1)", ["google", "code1", "anchor1", "mark"] ); + t( "Nth-of-type(odd)", "#ap :nth-of-type(odd)", ["google", "code1", "anchor1", "mark"] ); + t( "Nth-of-type(-n+2)", "#qunit-fixture > :nth-of-type(-n+2)", ["firstp", "ap", "foo", "nothiddendiv", "name+value", "firstUL", "empty", "form", "floatTest", "iframe", "lengthtest", "table"] ); +}); + +test("pseudo - nth-last-of-type", function() { + expect( 9 ); + t( "Nth-last-of-type(-1)", ":nth-last-of-type(-1)", [] ); + t( "Nth-last-of-type(3)", "#ap :nth-last-of-type(3)", ["google"] ); + t( "Nth-last-of-type(n)", "#ap :nth-last-of-type(n)", ["google", "groups", "code1", "anchor1", "mark"] ); + t( "Nth-last-of-type(0n+3)", "#ap :nth-last-of-type(0n+3)", ["google"] ); + t( "Nth-last-of-type(2n)", "#ap :nth-last-of-type(2n)", ["groups"] ); + t( "Nth-last-of-type(even)", "#ap :nth-last-of-type(even)", ["groups"] ); + t( "Nth-last-of-type(2n+1)", "#ap :nth-last-of-type(2n+1)", ["google", "code1", "anchor1", "mark"] ); + t( "Nth-last-of-type(odd)", "#ap :nth-last-of-type(odd)", ["google", "code1", "anchor1", "mark"] ); + t( "Nth-last-of-type(-n+2)", "#qunit-fixture > :nth-last-of-type(-n+2)", ["ap", "name+value", "first", "firstUL", "empty", "floatTest", "iframe", "table", "name-tests", "testForm", "liveHandlerOrder", "siblingTest"] ); +}); + +test("pseudo - has", function() { + expect( 3 ); + + t( "Basic test", "p:has(a)", ["firstp","ap","en","sap"] ); + t( "Basic test (irrelevant whitespace)", "p:has( a )", ["firstp","ap","en","sap"] ); + t( "Nested with overlapping candidates", "#qunit-fixture div:has(div:has(div:not([id])))", [ "moretests", "t2037" ] ); +}); + +test("pseudo - misc", function() { + expect( 39 ); + + var select, tmp, input; + + t( "Headers", ":header", ["qunit-header", "qunit-banner", "qunit-userAgent"] ); + t( "Headers(case-insensitive)", ":Header", ["qunit-header", "qunit-banner", "qunit-userAgent"] ); + t( "Multiple matches with the same context (cache check)", "#form select:has(option:first-child:contains('o'))", ["select1", "select2", "select3", "select4"] ); + + ok( Sizzle("#qunit-fixture :not(:has(:has(*)))").length, "All not grandparents" ); + + select = document.getElementById("select1"); + ok( Sizzle.matchesSelector( select, ":has(option)" ), "Has Option Matches" ); + + ok( Sizzle("a:contains('')").length, "Empty string contains" ); + t( "Text Contains", "a:contains(Google)", ["google","groups"] ); + t( "Text Contains", "a:contains(Google Groups)", ["groups"] ); + + t( "Text Contains", "a:contains('Google Groups (Link)')", ["groups"] ); + t( "Text Contains", "a:contains(\"(Link)\")", ["groups"] ); + t( "Text Contains", "a:contains(Google Groups (Link))", ["groups"] ); + t( "Text Contains", "a:contains((Link))", ["groups"] ); + + + tmp = document.createElement("div"); + tmp.attribs.id = "tmp_input"; + document.body.children.push( tmp ); + + [ "button", "submit", "reset" ].forEach(function( type ) { + var els = jQuery( + "" + .replace( /%/g, type ) + ).appendTo( tmp ); + + t( "Input Buttons :" + type, "#tmp_input :" + type, [ "input_" + type, "button_" + type ] ); + + ok( Sizzle.matchesSelector( els[0], ":" + type ), "Input Matches :" + type ); + ok( Sizzle.matchesSelector( els[1], ":" + type ), "Button Matches :" + type ); + }); + + document.body.children.pop(); + + // Recreate tmp + tmp = document.createElement("div"); + tmp.attribs.id = "tmp_input"; + tmp.children = helper.getDOM("Hello I am focusable."); + // Setting tabIndex should make the element focusable + // http://dev.w3.org/html5/spec/single-page.html#focus-management + document.body.children.push( tmp ); + tmp.tabIndex = 0; + //tmp.focus(); + if ( document.activeElement !== tmp || (document.hasFocus && !document.hasFocus()) || + (document.querySelectorAll && !document.querySelectorAll("div:focus").length) ) { + ok( true, "The div was not focused. Skip checking the :focus match." ); + ok( true, "The div was not focused. Skip checking the :focus match." ); + } else { + t( "tabIndex element focused", ":focus", [ "tmp_input" ] ); + ok( Sizzle.matchesSelector( tmp, ":focus" ), ":focus matches tabIndex div" ); + } + + // Blur tmp + //tmp.blur(); + //document.body.focus(); + //ok( !Sizzle.matchesSelector( tmp, ":focus" ), ":focus doesn't match tabIndex div" ); + document.body.children.pop(); + + // Input focus/active + input = document.createElement("input"); + input.attribs.type = "text"; + input.attribs.id = "focus-input"; + + document.body.children.push( input ); + //input.focus(); + + // Inputs can't be focused unless the document has focus + if ( document.activeElement !== input || (document.hasFocus && !document.hasFocus()) || + (document.querySelectorAll && !document.querySelectorAll("input:focus").length) ) { + ok( true, "The input was not focused. Skip checking the :focus match." ); + ok( true, "The input was not focused. Skip checking the :focus match." ); + } else { + t( "Element focused", "input:focus", [ "focus-input" ] ); + ok( Sizzle.matchesSelector( input, ":focus" ), ":focus matches" ); + } + + //input.blur(); + + // When IE is out of focus, blur does not work. Force it here. + if ( document.activeElement === input ) { + document.body.focus(); + } + + //ok( !Sizzle.matchesSelector( input, ":focus" ), ":focus doesn't match" ); + document.body.children.pop(); + + + + deepEqual( + Sizzle( "[id='select1'] *:not(:last-child), [id='select2'] *:not(:last-child)", q("qunit-fixture")[0] ), + q( "option1a", "option1b", "option1c", "option2a", "option2b", "option2c" ), + "caching system tolerates recursive selection" + ); + + // Tokenization edge cases + t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code)", ["ap"] ); + t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code):contains(This link)", ["ap"] ); + + // t( "Pseudo argument containing ')'", "p:has(>a.GROUPS[src!=')'])", ["ap"] ); + // t( "Pseudo argument containing ')'", "p:has(>a.GROUPS[src!=')'])", ["ap"] ); + t( "Pseudo followed by token containing ')'", "p:contains(id=\"foo\")[id!=\\)]", ["sndp"] ); + t( "Pseudo followed by token containing ')'", "p:contains(id=\"foo\")[id!=')']", ["sndp"] ); + + t( "Multi-pseudo", "#ap:has(*), #ap:has(*)", ["ap"] ); + //t( "Multi-positional", "#ap:gt(0), #ap:lt(1)", ["ap"] ); + t( "Multi-pseudo with leading nonexistent id", "#nonexistent:has(*), #ap:has(*)", ["ap"] ); + //t( "Multi-positional with leading nonexistent id", "#nonexistent:gt(0), #ap:lt(1)", ["ap"] ); + + t( "Tokenization stressor", "a[class*=blog]:not(:has(*, :contains(!)), :contains(!)), br:contains(]), p:contains(]), :not(:empty):not(:parent)", ["ap", "mark","yahoo","simon"] ); +}); + + +test("pseudo - :not", function() { + expect( 43 ); + + t( "Not", "a.blog:not(.link)", ["mark"] ); + //t( ":not() with :first", "#foo p:not(:first) .link", ["simon"] ); + + t( "Not - multiple", "#form option:not(:contains(Nothing),#option1b,:selected)", ["option1c", "option1d", "option2b", "option2c", "option3d", "option3e", "option4e", "option5b", "option5c"] ); + t( "Not - recursive", "#form option:not(:not(:selected))[id^='option3']", [ "option3b", "option3c"] ); + + t( ":not() failing interior", "#qunit-fixture p:not(.foo)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "#qunit-fixture p:not(div.foo)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "#qunit-fixture p:not(p.foo)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "#qunit-fixture p:not(#blargh)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "#qunit-fixture p:not(div#blargh)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "#qunit-fixture p:not(p#blargh)", ["firstp","ap","sndp","en","sap","first"] ); + + t( ":not Multiple", "#qunit-fixture p:not(a)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not Multiple", "#qunit-fixture p:not( a )", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not Multiple", "#qunit-fixture p:not( p )", [] ); + t( ":not Multiple", "#qunit-fixture p:not(a, b)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not Multiple", "#qunit-fixture p:not(a, b, div)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not Multiple", "p:not(p)", [] ); + t( ":not Multiple", "p:not(a,p)", [] ); + t( ":not Multiple", "p:not(p,a)", [] ); + t( ":not Multiple", "p:not(a,p,b)", [] ); + t( ":not Multiple", ":input:not(:image,:input,:submit)", [] ); + t( ":not Multiple", "#qunit-fixture p:not(:has(a), :nth-child(1))", ["first"] ); + + t( "No element not selector", ".container div:not(.excluded) div", [] ); + + t( ":not() Existing attribute", "#form select:not([multiple])", ["select1", "select2", "select5"]); + t( ":not() Equals attribute", "#form select:not([name=select1])", ["select2", "select3", "select4","select5"]); + t( ":not() Equals quoted attribute", "#form select:not([name='select1'])", ["select2", "select3", "select4", "select5"]); + + t( ":not() Multiple Class", "#foo a:not(.blog)", ["yahoo", "anchor2"] ); + t( ":not() Multiple Class", "#foo a:not(.link)", ["yahoo", "anchor2"] ); + t( ":not() Multiple Class", "#foo a:not(.blog.link)", ["yahoo", "anchor2"] ); + + t( ":not chaining (compound)", "#qunit-fixture div[id]:not(:has(div, span)):not(:has(*))", ["nothiddendivchild", "divWithNoTabIndex"] ); + t( ":not chaining (with attribute)", "#qunit-fixture form[id]:not([action$='formaction']):not(:button)", ["lengthtest", "name-tests", "testForm"] ); + t( ":not chaining (colon in attribute)", "#qunit-fixture form[id]:not([action='form:action']):not(:button)", ["form", "lengthtest", "name-tests", "testForm"] ); + t( ":not chaining (colon in attribute and nested chaining)", "#qunit-fixture form[id]:not([action='form:action']:button):not(:input)", ["form", "lengthtest", "name-tests", "testForm"] ); + t( ":not chaining", "#form select:not(.select1):contains(Nothing) > option:not(option)", [] ); + + /* + t( "positional :not()", "#foo p:not(:last)", ["sndp", "en"] ); + t( "positional :not() prefix", "#foo p:not(:last) a", ["yahoo"] ); + t( "compound positional :not()", "#foo p:not(:first, :last)", ["en"] ); + t( "compound positional :not()", "#foo p:not(:first, :even)", ["en"] ); + t( "compound positional :not()", "#foo p:not(:first, :odd)", ["sap"] ); + t( "reordered compound positional :not()", "#foo p:not(:odd, :first)", ["sap"] ); + + t( "positional :not() with pre-filter", "#foo p:not([id]:first)", ["en", "sap"] ); + t( "positional :not() with post-filter", "#foo p:not(:first[id])", ["en", "sap"] ); + t( "positional :not() with pre-filter", "#foo p:not([lang]:first)", ["sndp", "sap"] ); + t( "positional :not() with post-filter", "#foo p:not(:first[lang])", ["sndp", "en", "sap"] ); + */ +}); + +/* +test("pseudo - position", function() { + expect( 33 ); + + t( "First element", "div:first", ["qunit"] ); + t( "First element(case-insensitive)", "div:fiRst", ["qunit"] ); + t( "nth Element", "#qunit-fixture p:nth(1)", ["ap"] ); + t( "First Element", "#qunit-fixture p:first", ["firstp"] ); + t( "Last Element", "p:last", ["first"] ); + t( "Even Elements", "#qunit-fixture p:even", ["firstp","sndp","sap"] ); + t( "Odd Elements", "#qunit-fixture p:odd", ["ap","en","first"] ); + t( "Position Equals", "#qunit-fixture p:eq(1)", ["ap"] ); + t( "Position Equals (negative)", "#qunit-fixture p:eq(-1)", ["first"] ); + t( "Position Greater Than", "#qunit-fixture p:gt(0)", ["ap","sndp","en","sap","first"] ); + t( "Position Less Than", "#qunit-fixture p:lt(3)", ["firstp","ap","sndp"] ); + + t( "Check position filtering", "div#nothiddendiv:eq(0)", ["nothiddendiv"] ); + t( "Check position filtering", "div#nothiddendiv:last", ["nothiddendiv"] ); + t( "Check position filtering", "div#nothiddendiv:not(:gt(0))", ["nothiddendiv"] ); + t( "Check position filtering", "#foo > :not(:first)", ["en", "sap"] ); + t( "Check position filtering", "#qunit-fixture select > :not(:gt(2))", ["option1a", "option1b", "option1c"] ); + t( "Check position filtering", "#qunit-fixture select:lt(2) :not(:first)", ["option1b", "option1c", "option1d", "option2a", "option2b", "option2c", "option2d"] ); + t( "Check position filtering", "div.nothiddendiv:eq(0)", ["nothiddendiv"] ); + t( "Check position filtering", "div.nothiddendiv:last", ["nothiddendiv"] ); + t( "Check position filtering", "div.nothiddendiv:not(:lt(0))", ["nothiddendiv"] ); + + t( "Check element position", "#qunit-fixture div div:eq(0)", ["nothiddendivchild"] ); + t( "Check element position", "#select1 option:eq(3)", ["option1d"] ); + t( "Check element position", "#qunit-fixture div div:eq(10)", ["names-group"] ); + t( "Check element position", "#qunit-fixture div div:first", ["nothiddendivchild"] ); + t( "Check element position", "#qunit-fixture div > div:first", ["nothiddendivchild"] ); + t( "Check element position", "#dl div:first div:first", ["foo"] ); + t( "Check element position", "#dl div:first > div:first", ["foo"] ); + t( "Check element position", "div#nothiddendiv:first > div:first", ["nothiddendivchild"] ); + t( "Chained pseudo after a pos pseudo", "#listWithTabIndex li:eq(0):contains(Rice)", ["foodWithNegativeTabIndex"] ); + + t( "Check sort order with POS and comma", "#qunit-fixture em>em>em>em:first-child,div>em:first", ["siblingfirst", "siblinggreatgrandchild"] ); + + t( "Isolated position", ":last", ["last"] ); + + deepEqual( Sizzle( "*:lt(2) + *", null, [], Sizzle("#qunit-fixture > p") ), q("ap"), "Seeded pos with trailing relative" ); + + // jQuery #12526 + var context = jQuery("#qunit-fixture").append("
    ")[0]; + deepEqual( Sizzle( ":last", context ), q("jquery12526"), "Post-manipulation positional" ); +}); +*/ + +test("pseudo - form", function() { + expect( 10 ); + + var extraTexts = jQuery("").appendTo("#form"); + + t( "Form element :input", "#form :input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "search", "button", "area1", "select1", "select2", "select3", "select4", "select5", "impliedText", "capitalText"] ); + t( "Form element :radio", "#form :radio", ["radio1", "radio2"] ); + t( "Form element :checkbox", "#form :checkbox", ["check1", "check2"] ); + t( "Form element :text", "#form :text", ["text1", "text2", "hidden2", "name", "impliedText", "capitalText"] ); + t( "Form element :radio:checked", "#form :radio:checked", ["radio2"] ); + t( "Form element :checkbox:checked", "#form :checkbox:checked", ["check1"] ); + t( "Form element :radio:checked, :checkbox:checked", "#form :radio:checked, #form :checkbox:checked", ["radio2", "check1"] ); + + t( "Selected Option Element", "#form option:selected", ["option1a","option2d","option3b","option3c","option4b","option4c","option4d","option5a"] ); + t( "Selected Option Element are also :checked", "#form option:checked", ["option1a","option2d","option3b","option3c","option4b","option4c","option4d","option5a"] ); + t( "Hidden inputs should be treated as enabled. See QSA test.", "#hidden1:enabled", ["hidden1"] ); + + extraTexts.remove(); +}); + +test("pseudo - :target and :root", function() { + expect( 2 ); + /* // TODO add shim from qwery tests + // Target + var oldHash, + $link = jQuery("").attr({ + href: "#", + id: "new-link" + }).appendTo("#qunit-fixture"); + + oldHash = window.location.hash; + window.location.hash = "new-link"; + + t( ":target", ":target", ["new-link"] ); + + $link.remove(); + window.location.hash = oldHash;*/ + + // Root + equal( Sizzle(":root")[0], document.documentElement, ":root selector" ); +}); + +/* +// TODO +test("pseudo - :lang", function() { + expect( 105 ); + + var docElem = document.documentElement, + docXmlLang = docElem.getAttribute("xml:lang"), + docLang = docElem.lang, + foo = document.getElementById("foo"), + anchor = document.getElementById("anchor2"), + xml = createWithFriesXML(), + testLang = function( text, elem, container, lang, extra ) { + var message, + full = lang + "-" + extra; + + message = "lang=" + lang + " " + text; + container.setAttribute( container.ownerDocument.documentElement.nodeName === "HTML" ? "lang" : "xml:lang", lang ); + assertMatch( message, elem, ":lang(" + lang + ")" ); + assertMatch( message, elem, ":lang(" + mixCase(lang) + ")" ); + assertNoMatch( message, elem, ":lang(" + full + ")" ); + assertNoMatch( message, elem, ":lang(" + mixCase(full) + ")" ); + assertNoMatch( message, elem, ":lang(" + lang + "-)" ); + assertNoMatch( message, elem, ":lang(" + full + "-)" ); + assertNoMatch( message, elem, ":lang(" + lang + "glish)" ); + assertNoMatch( message, elem, ":lang(" + full + "glish)" ); + + message = "lang=" + full + " " + text; + container.setAttribute( container.ownerDocument.documentElement.nodeName === "HTML" ? "lang" : "xml:lang", full ); + assertMatch( message, elem, ":lang(" + lang + ")" ); + assertMatch( message, elem, ":lang(" + mixCase(lang) + ")" ); + assertMatch( message, elem, ":lang(" + full + ")" ); + assertMatch( message, elem, ":lang(" + mixCase(full) + ")" ); + assertNoMatch( message, elem, ":lang(" + lang + "-)" ); + assertNoMatch( message, elem, ":lang(" + full + "-)" ); + assertNoMatch( message, elem, ":lang(" + lang + "glish)" ); + assertNoMatch( message, elem, ":lang(" + full + "glish)" ); + }, + mixCase = function( str ) { + var ret = str.split(""), + i = ret.length; + while ( i-- ) { + if ( i & 1 ) { + ret[i] = ret[i].toUpperCase(); + } + } + return ret.join(""); + }, + assertMatch = function( text, elem, selector ) { + ok( Sizzle.matchesSelector( elem, selector ), text + " match " + selector ); + }, + assertNoMatch = function( text, elem, selector ) { + ok( !Sizzle.matchesSelector( elem, selector ), text + " fail " + selector ); + }; + + // Prefixing and inheritance + ok( Sizzle.matchesSelector( docElem, ":lang(" + docElem.lang + ")" ), "starting :lang" ); + testLang( "document", anchor, docElem, "en", "us" ); + testLang( "grandparent", anchor, anchor.parentNode.parentNode, "yue", "hk" ); + ok( !Sizzle.matchesSelector( anchor, ":lang(en), :lang(en-us)" ), + ":lang does not look above an ancestor with specified lang" ); + testLang( "self", anchor, anchor, "es", "419" ); + ok( !Sizzle.matchesSelector( anchor, ":lang(en), :lang(en-us), :lang(yue), :lang(yue-hk)" ), + ":lang does not look above self with specified lang" ); + + // Searching by language tag + anchor.parentNode.parentNode.lang = "arab"; + anchor.parentNode.lang = anchor.parentNode.id = "ara-sa"; + anchor.lang = "ara"; + deepEqual( Sizzle( ":lang(ara)", foo ), [ anchor.parentNode, anchor ], "Find by :lang" ); + + // Selector validity + anchor.parentNode.lang = "ara"; + anchor.lang = "ara\\b"; + deepEqual( Sizzle( ":lang(ara\\b)", foo ), [], ":lang respects backslashes" ); + deepEqual( Sizzle( ":lang(ara\\\\b)", foo ), [ anchor ], ":lang respects escaped backslashes" ); + raises(function() { + Sizzle.call( null, "dl:lang(c++)" ); + }, function( e ) { + return e.message.indexOf("Syntax error") >= 0; + }, ":lang value must be a valid identifier" ); + + // XML + foo = jQuery( "response", xml )[0]; + anchor = jQuery( "#seite1", xml )[0]; + testLang( "XML document", anchor, xml.documentElement, "en", "us" ); + testLang( "XML grandparent", anchor, foo, "yue", "hk" ); + ok( !Sizzle.matchesSelector( anchor, ":lang(en), :lang(en-us)" ), + "XML :lang does not look above an ancestor with specified lang" ); + testLang( "XML self", anchor, anchor, "es", "419" ); + ok( !Sizzle.matchesSelector( anchor, ":lang(en), :lang(en-us), :lang(yue), :lang(yue-hk)" ), + "XML :lang does not look above self with specified lang" ); + + // Cleanup + if ( docXmlLang == null ) { + docElem.removeAttribute("xml:lang"); + } else { + docElem.setAttribute( "xml:lang", docXmlLang ); + } + docElem.lang = docLang; +}); +*/ + +test("caching", function() { + expect( 1 ); + Sizzle( ":not(code)", document.getElementById("ap") ); + deepEqual( Sizzle( ":not(code)", document.getElementById("foo") ), q("sndp", "en", "yahoo", "sap", "anchor2", "simon"), "Reusing selector with new context" ); +}); +/* +asyncTest( "Iframe dispatch should not affect Sizzle, see jQuery #13936", 1, function() { + var i = 0, + thrown = false, + iframe = document.getElementById("iframe"), + iframeDoc = iframe.contentDocument || iframe.contentWindow.document; + + jQuery( iframe ).on( "load", function() { + var doc; + + try { + i++; + doc = this.contentDocument || this.contentWindow.document; + Sizzle( "form", doc ).pop().submit(); + + } catch ( e ) { + thrown = true; + } + + if ( i === 2 ) { + jQuery( this ).off("load"); + ok( !thrown, "Iframe reload should not affect Sizzle, see jQuery #13936" ); + start(); + } + }); + + iframeDoc.open(); + iframeDoc.write("
    "); + iframeDoc.close(); +}); +*/ \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/test.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/test.js new file mode 100644 index 00000000..99a486d4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/test.js @@ -0,0 +1,22 @@ +describe("nwmatcher", function(){ + require("./nwmatcher/"); +}); + +describe("sizzle", function(){ + describe("selector", function(){ + require("./sizzle/selector"); + }); +}); + +describe("qwery", function(){ + exportsRun(require("./qwery/")); +}); + +function exportsRun(mod){ + Object.keys(mod).forEach(function(name){ + if(typeof mod[name] === "object") describe(name, function(){ + exportsRun(mod[name]); + }); + else it(name, mod[name]); + }); +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/bench.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/bench.js new file mode 100644 index 00000000..ef251b19 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/bench.js @@ -0,0 +1,10 @@ +var ben = require("ben"), + testString = "doo, *#foo > elem.bar[class$=bAz i]:not([ id *= \"2\" ]):nth-child(2n)", + helper = require("./helper.js"), + CSSselect = helper.CSSselect, + compile = CSSselect.compile, + dom = helper.getDefaultDom(); + +//console.log("Parsing took:", ben(1e5, function(){compile(testString);})); +var compiled = compile(testString); +console.log("Executing took:", ben(1e6, function(){CSSselect(compiled, dom);})*1e3); \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/helper.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/helper.js new file mode 100644 index 00000000..0b08e98a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/helper.js @@ -0,0 +1,51 @@ +var fs = require("fs"), + path = require("path"), + htmlparser2 = require("htmlparser2"), + DomUtils = htmlparser2.DomUtils, + CSSselect = require("../../"); + +function getDOMFromPath(path, options){ + return htmlparser2.parseDOM(fs.readFileSync(path).toString(), options); +} + +module.exports = { + CSSselect: CSSselect, + getFile: function(name, options){ + return getDOMFromPath(path.join(__dirname, "docs", name), options); + }, + getDOMFromPath: getDOMFromPath, + getDOM: htmlparser2.parseDOM, + getDefaultDom: function(){ + return htmlparser2.parseDOM( + " This is some simple text " + ); + }, + getDocument: function(path){ + var document = getDOMFromPath(path); + + document.getElementsByTagName = function(name){ + return DomUtils.getElementsByTagName("*", document); + }; + document.getElementById = function(id){ + return DomUtils.getElementById(id, document); + }; + document.createTextNode = function(content){ + return { + type: "text", + data: "content" + }; + }; + document.createElement = function(name){ + return { + type: "tag", + name: name, + children: [], + attribs: {} + }; + }; + document.body = DomUtils.getElementsByTagName("body", document, true, 1)[0]; + document.documentElement = document.filter(DomUtils.isTag)[0]; + + return document; + } +}; \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/slickspeed.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/slickspeed.js new file mode 100644 index 00000000..86027754 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/CSSselect/test/tools/slickspeed.js @@ -0,0 +1,76 @@ +var helper = require("./helper.js"), + doc = helper.getFile("W3C_Selectors.html"), + CSSselect = helper.CSSselect, + soupselect = require("cheerio-soupselect"), + selectors = ["body", "div", "body div", "div p", "div > p", "div + p", "div ~ p", "div[class^=exa][class$=mple]", "div p a", "div, p, a", ".note", "div.example", "ul .tocline2", "div.example, div.note", "#title", "h1#title", "div #title", "ul.toc li.tocline2", "ul.toc > li.tocline2", "h1#title + div > p", "h1[id]:contains(Selectors)", "a[href][lang][class]", "div[class]", "div[class=example]", "div[class^=exa]", "div[class$=mple]", "div[class*=e]", "div[class|=dialog]", "div[class!=made_up]", "div[class~=example]"/*, "div:not(.example)", "p:contains(selectors)", "p:nth-child(even)", "p:nth-child(2n)", "p:nth-child(odd)", "p:nth-child(2n+1)", "p:nth-child(n)", "p:only-child", "p:last-child", "p:first-child"*/]; + +var engines = [function(a,b){return CSSselect(b,a);}, soupselect.select]; + +//returns true when an error occurs +function testResult(rule, index){ + var results = engines + .map(function(func){ return func(doc, rule); }); + + //check if both had the same result + for(var i = 1; i < results.length; i++){ + //TODO: might be hard to debug with more engines + if(results[i-1].length !== results[i].length){ + //console.log(rule, results[i-1].length, results[i].length); + return true; + } + for(var j = 0; j < results[i].length; j++){ + if(results[i-1][j] !== results[i][j]){ + if(results[i-1].indexOf(results[i][j]) === -1){ + return true; + } + } + } + //require("assert").deepEqual(results[i-1], results[i], rule + ": not the same elements"); + } + + return false; +} + +selectors.filter(testResult).forEach(function(rule){ print(rule, "failed!\n"); }); + +process.exit(0); //don't run speed tests + +print("-----\n\nChecking performance\n\n"); + +//test the speed +var ben = require("ben"); + +function testSpeed(rule){ + print(rule, Array(28-rule.length).join(" ")); + + var results = engines + .map(function(func){ return function(){ return func(doc, rule); }}); + + //also add a precompiled CSSselect test + var compiled = CSSselect(rule); + results.unshift(function(){ return CSSselect.iterate(compiled, doc); }); + + results = results.map(ben); + + var min = Math.min.apply(null, results); + var max = Math.max.apply(null, results); + + results.forEach(function(result){ + if(result === min) return print(" +", result, "+"); + if(result === max) return print(" !", result, "!"); + if(Math.abs(result-min) > Math.abs(result-max)){ + return print(" =", result, "="); + } + print(" ~", result, "~"); + }); + + print("\n"); +} + +print("RULE ", "CSSselect (pc)", "CSSselect", "soupselect\n"); + +selectors.forEach(testSpeed); + +function print(){ + process.stdout.write(Array.prototype.join.call(arguments, " ")); +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/LICENSE new file mode 100644 index 00000000..c464f863 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/html4.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/html4.json new file mode 100644 index 00000000..0253d1aa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/html4.json @@ -0,0 +1 @@ +{"Aacute;":"\u00C1","Aacute":"\u00C1","aacute;":"\u00E1","aacute":"\u00E1","Acirc;":"\u00C2","Acirc":"\u00C2","acirc;":"\u00E2","acirc":"\u00E2","acute;":"\u00B4","acute":"\u00B4","AElig;":"\u00C6","AElig":"\u00C6","aelig;":"\u00E6","aelig":"\u00E6","Agrave;":"\u00C0","Agrave":"\u00C0","agrave;":"\u00E0","agrave":"\u00E0","alefsym;":"\u2135","Alpha;":"\u0391","alpha;":"\u03B1","amp":"\u0026","and;":"\u2227","ang;":"\u2220","apos":"\u0027","Aring;":"\u00C5","Aring":"\u00C5","aring;":"\u00E5","aring":"\u00E5","asymp;":"\u2248","Atilde;":"\u00C3","Atilde":"\u00C3","atilde;":"\u00E3","atilde":"\u00E3","Auml;":"\u00C4","Auml":"\u00C4","auml;":"\u00E4","auml":"\u00E4","bdquo;":"\u201E","Beta;":"\u0392","beta;":"\u03B2","brvbar;":"\u00A6","brvbar":"\u00A6","bull;":"\u2022","cap;":"\u2229","Ccedil;":"\u00C7","Ccedil":"\u00C7","ccedil;":"\u00E7","ccedil":"\u00E7","cedil;":"\u00B8","cedil":"\u00B8","cent;":"\u00A2","cent":"\u00A2","Chi;":"\u03A7","chi;":"\u03C7","circ;":"\u02C6","clubs;":"\u2663","cong;":"\u2245","copy;":"\u00A9","copy":"\u00A9","crarr;":"\u21B5","cup;":"\u222A","curren;":"\u00A4","curren":"\u00A4","dagger;":"\u2020","Dagger;":"\u2021","darr;":"\u2193","dArr;":"\u21D3","deg;":"\u00B0","deg":"\u00B0","Delta;":"\u0394","delta;":"\u03B4","diams;":"\u2666","divide;":"\u00F7","divide":"\u00F7","Eacute;":"\u00C9","Eacute":"\u00C9","eacute;":"\u00E9","eacute":"\u00E9","Ecirc;":"\u00CA","Ecirc":"\u00CA","ecirc;":"\u00EA","ecirc":"\u00EA","Egrave;":"\u00C8","Egrave":"\u00C8","egrave;":"\u00E8","egrave":"\u00E8","empty;":"\u2205","emsp;":"\u2003","ensp;":"\u2002","Epsilon;":"\u0395","epsilon;":"\u03B5","equiv;":"\u2261","Eta;":"\u0397","eta;":"\u03B7","ETH;":"\u00D0","ETH":"\u00D0","eth;":"\u00F0","eth":"\u00F0","Euml;":"\u00CB","Euml":"\u00CB","euml;":"\u00EB","euml":"\u00EB","euro;":"\u20AC","exist;":"\u2203","fnof;":"\u0192","forall;":"\u2200","frac12;":"\u00BD","frac12":"\u00BD","frac14;":"\u00BC","frac14":"\u00BC","frac34;":"\u00BE","frac34":"\u00BE","frasl;":"\u2044","Gamma;":"\u0393","gamma;":"\u03B3","ge;":"\u2265","gt":"\u003E","harr;":"\u2194","hArr;":"\u21D4","hearts;":"\u2665","hellip;":"\u2026","Iacute;":"\u00CD","Iacute":"\u00CD","iacute;":"\u00ED","iacute":"\u00ED","Icirc;":"\u00CE","Icirc":"\u00CE","icirc;":"\u00EE","icirc":"\u00EE","iexcl;":"\u00A1","iexcl":"\u00A1","Igrave;":"\u00CC","Igrave":"\u00CC","igrave;":"\u00EC","igrave":"\u00EC","image;":"\u2111","infin;":"\u221E","int;":"\u222B","Iota;":"\u0399","iota;":"\u03B9","iquest;":"\u00BF","iquest":"\u00BF","isin;":"\u2208","Iuml;":"\u00CF","Iuml":"\u00CF","iuml;":"\u00EF","iuml":"\u00EF","Kappa;":"\u039A","kappa;":"\u03BA","Lambda;":"\u039B","lambda;":"\u03BB","lang;":"\u27E8","laquo;":"\u00AB","laquo":"\u00AB","larr;":"\u2190","lArr;":"\u21D0","lceil;":"\u2308","ldquo;":"\u201C","le;":"\u2264","lfloor;":"\u230A","lowast;":"\u2217","loz;":"\u25CA","lrm;":"\u200E","lsaquo;":"\u2039","lsquo;":"\u2018","lt":"\u003C","macr;":"\u00AF","macr":"\u00AF","mdash;":"\u2014","micro;":"\u00B5","micro":"\u00B5","middot;":"\u00B7","middot":"\u00B7","minus;":"\u2212","Mu;":"\u039C","mu;":"\u03BC","nabla;":"\u2207","nbsp;":"\u00A0","nbsp":"\u00A0","ndash;":"\u2013","ne;":"\u2260","ni;":"\u220B","not;":"\u00AC","not":"\u00AC","notin;":"\u2209","nsub;":"\u2284","Ntilde;":"\u00D1","Ntilde":"\u00D1","ntilde;":"\u00F1","ntilde":"\u00F1","Nu;":"\u039D","nu;":"\u03BD","Oacute;":"\u00D3","Oacute":"\u00D3","oacute;":"\u00F3","oacute":"\u00F3","Ocirc;":"\u00D4","Ocirc":"\u00D4","ocirc;":"\u00F4","ocirc":"\u00F4","OElig;":"\u0152","oelig;":"\u0153","Ograve;":"\u00D2","Ograve":"\u00D2","ograve;":"\u00F2","ograve":"\u00F2","oline;":"\u203E","Omega;":"\u03A9","omega;":"\u03C9","Omicron;":"\u039F","omicron;":"\u03BF","oplus;":"\u2295","or;":"\u2228","ordf;":"\u00AA","ordf":"\u00AA","ordm;":"\u00BA","ordm":"\u00BA","Oslash;":"\u00D8","Oslash":"\u00D8","oslash;":"\u00F8","oslash":"\u00F8","Otilde;":"\u00D5","Otilde":"\u00D5","otilde;":"\u00F5","otilde":"\u00F5","otimes;":"\u2297","Ouml;":"\u00D6","Ouml":"\u00D6","ouml;":"\u00F6","ouml":"\u00F6","para;":"\u00B6","para":"\u00B6","part;":"\u2202","permil;":"\u2030","perp;":"\u22A5","Phi;":"\u03A6","phi;":"\u03C6","Pi;":"\u03A0","pi;":"\u03C0","piv;":"\u03D6","plusmn;":"\u00B1","plusmn":"\u00B1","pound;":"\u00A3","pound":"\u00A3","prime;":"\u2032","Prime;":"\u2033","prod;":"\u220F","prop;":"\u221D","Psi;":"\u03A8","psi;":"\u03C8","quot":"\u0022","radic;":"\u221A","rang;":"\u27E9","raquo;":"\u00BB","raquo":"\u00BB","rarr;":"\u2192","rArr;":"\u21D2","rceil;":"\u2309","rdquo;":"\u201D","real;":"\u211C","reg;":"\u00AE","reg":"\u00AE","rfloor;":"\u230B","Rho;":"\u03A1","rho;":"\u03C1","rlm;":"\u200F","rsaquo;":"\u203A","rsquo;":"\u2019","sbquo;":"\u201A","Scaron;":"\u0160","scaron;":"\u0161","sdot;":"\u22C5","sect;":"\u00A7","sect":"\u00A7","shy;":"\u00AD","shy":"\u00AD","Sigma;":"\u03A3","sigma;":"\u03C3","sigmaf;":"\u03C2","sim;":"\u223C","spades;":"\u2660","sub;":"\u2282","sube;":"\u2286","sum;":"\u2211","sup1;":"\u00B9","sup1":"\u00B9","sup2;":"\u00B2","sup2":"\u00B2","sup3;":"\u00B3","sup3":"\u00B3","sup;":"\u2283","supe;":"\u2287","szlig;":"\u00DF","szlig":"\u00DF","Tau;":"\u03A4","tau;":"\u03C4","there4;":"\u2234","Theta;":"\u0398","theta;":"\u03B8","thetasym;":"\u03D1","thinsp;":"\u2009","THORN;":"\u00DE","THORN":"\u00DE","thorn;":"\u00FE","thorn":"\u00FE","tilde;":"\u02DC","times;":"\u00D7","times":"\u00D7","trade;":"\u2122","Uacute;":"\u00DA","Uacute":"\u00DA","uacute;":"\u00FA","uacute":"\u00FA","uarr;":"\u2191","uArr;":"\u21D1","Ucirc;":"\u00DB","Ucirc":"\u00DB","ucirc;":"\u00FB","ucirc":"\u00FB","Ugrave;":"\u00D9","Ugrave":"\u00D9","ugrave;":"\u00F9","ugrave":"\u00F9","uml;":"\u00A8","uml":"\u00A8","upsih;":"\u03D2","Upsilon;":"\u03A5","upsilon;":"\u03C5","Uuml;":"\u00DC","Uuml":"\u00DC","uuml;":"\u00FC","uuml":"\u00FC","weierp;":"\u2118","Xi;":"\u039E","xi;":"\u03BE","Yacute;":"\u00DD","Yacute":"\u00DD","yacute;":"\u00FD","yacute":"\u00FD","yen;":"\u00A5","yen":"\u00A5","yuml;":"\u00FF","yuml":"\u00FF","Yuml;":"\u0178","Zeta;":"\u0396","zeta;":"\u03B6","zwj;":"\u200D","zwnj;":"\u200C"} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/html5.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/html5.json new file mode 100644 index 00000000..61dd35aa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/html5.json @@ -0,0 +1 @@ +{"Abreve;":"\u0102","abreve;":"\u0103","ac;":"\u223E","acd;":"\u223F","acE;":"\u223E\u0333","Acy;":"\u0410","acy;":"\u0430","af;":"\u2061","Afr;":"\uD835\uDD04","afr;":"\uD835\uDD1E","aleph;":"\u2135","Amacr;":"\u0100","amacr;":"\u0101","amalg;":"\u2A3F","AMP;":"\u0026","AMP":"\u0026","andand;":"\u2A55","And;":"\u2A53","andd;":"\u2A5C","andslope;":"\u2A58","andv;":"\u2A5A","ange;":"\u29A4","angle;":"\u2220","angmsdaa;":"\u29A8","angmsdab;":"\u29A9","angmsdac;":"\u29AA","angmsdad;":"\u29AB","angmsdae;":"\u29AC","angmsdaf;":"\u29AD","angmsdag;":"\u29AE","angmsdah;":"\u29AF","angmsd;":"\u2221","angrt;":"\u221F","angrtvb;":"\u22BE","angrtvbd;":"\u299D","angsph;":"\u2222","angst;":"\u00C5","angzarr;":"\u237C","Aogon;":"\u0104","aogon;":"\u0105","Aopf;":"\uD835\uDD38","aopf;":"\uD835\uDD52","apacir;":"\u2A6F","ap;":"\u2248","apE;":"\u2A70","ape;":"\u224A","apid;":"\u224B","ApplyFunction;":"\u2061","approx;":"\u2248","approxeq;":"\u224A","Ascr;":"\uD835\uDC9C","ascr;":"\uD835\uDCB6","Assign;":"\u2254","ast;":"\u002A","asympeq;":"\u224D","awconint;":"\u2233","awint;":"\u2A11","backcong;":"\u224C","backepsilon;":"\u03F6","backprime;":"\u2035","backsim;":"\u223D","backsimeq;":"\u22CD","Backslash;":"\u2216","Barv;":"\u2AE7","barvee;":"\u22BD","barwed;":"\u2305","Barwed;":"\u2306","barwedge;":"\u2305","bbrk;":"\u23B5","bbrktbrk;":"\u23B6","bcong;":"\u224C","Bcy;":"\u0411","bcy;":"\u0431","becaus;":"\u2235","because;":"\u2235","Because;":"\u2235","bemptyv;":"\u29B0","bepsi;":"\u03F6","bernou;":"\u212C","Bernoullis;":"\u212C","beth;":"\u2136","between;":"\u226C","Bfr;":"\uD835\uDD05","bfr;":"\uD835\uDD1F","bigcap;":"\u22C2","bigcirc;":"\u25EF","bigcup;":"\u22C3","bigodot;":"\u2A00","bigoplus;":"\u2A01","bigotimes;":"\u2A02","bigsqcup;":"\u2A06","bigstar;":"\u2605","bigtriangledown;":"\u25BD","bigtriangleup;":"\u25B3","biguplus;":"\u2A04","bigvee;":"\u22C1","bigwedge;":"\u22C0","bkarow;":"\u290D","blacklozenge;":"\u29EB","blacksquare;":"\u25AA","blacktriangle;":"\u25B4","blacktriangledown;":"\u25BE","blacktriangleleft;":"\u25C2","blacktriangleright;":"\u25B8","blank;":"\u2423","blk12;":"\u2592","blk14;":"\u2591","blk34;":"\u2593","block;":"\u2588","bne;":"\u003D\u20E5","bnequiv;":"\u2261\u20E5","bNot;":"\u2AED","bnot;":"\u2310","Bopf;":"\uD835\uDD39","bopf;":"\uD835\uDD53","bot;":"\u22A5","bottom;":"\u22A5","bowtie;":"\u22C8","boxbox;":"\u29C9","boxdl;":"\u2510","boxdL;":"\u2555","boxDl;":"\u2556","boxDL;":"\u2557","boxdr;":"\u250C","boxdR;":"\u2552","boxDr;":"\u2553","boxDR;":"\u2554","boxh;":"\u2500","boxH;":"\u2550","boxhd;":"\u252C","boxHd;":"\u2564","boxhD;":"\u2565","boxHD;":"\u2566","boxhu;":"\u2534","boxHu;":"\u2567","boxhU;":"\u2568","boxHU;":"\u2569","boxminus;":"\u229F","boxplus;":"\u229E","boxtimes;":"\u22A0","boxul;":"\u2518","boxuL;":"\u255B","boxUl;":"\u255C","boxUL;":"\u255D","boxur;":"\u2514","boxuR;":"\u2558","boxUr;":"\u2559","boxUR;":"\u255A","boxv;":"\u2502","boxV;":"\u2551","boxvh;":"\u253C","boxvH;":"\u256A","boxVh;":"\u256B","boxVH;":"\u256C","boxvl;":"\u2524","boxvL;":"\u2561","boxVl;":"\u2562","boxVL;":"\u2563","boxvr;":"\u251C","boxvR;":"\u255E","boxVr;":"\u255F","boxVR;":"\u2560","bprime;":"\u2035","breve;":"\u02D8","Breve;":"\u02D8","bscr;":"\uD835\uDCB7","Bscr;":"\u212C","bsemi;":"\u204F","bsim;":"\u223D","bsime;":"\u22CD","bsolb;":"\u29C5","bsol;":"\u005C","bsolhsub;":"\u27C8","bullet;":"\u2022","bump;":"\u224E","bumpE;":"\u2AAE","bumpe;":"\u224F","Bumpeq;":"\u224E","bumpeq;":"\u224F","Cacute;":"\u0106","cacute;":"\u0107","capand;":"\u2A44","capbrcup;":"\u2A49","capcap;":"\u2A4B","Cap;":"\u22D2","capcup;":"\u2A47","capdot;":"\u2A40","CapitalDifferentialD;":"\u2145","caps;":"\u2229\uFE00","caret;":"\u2041","caron;":"\u02C7","Cayleys;":"\u212D","ccaps;":"\u2A4D","Ccaron;":"\u010C","ccaron;":"\u010D","Ccirc;":"\u0108","ccirc;":"\u0109","Cconint;":"\u2230","ccups;":"\u2A4C","ccupssm;":"\u2A50","Cdot;":"\u010A","cdot;":"\u010B","Cedilla;":"\u00B8","cemptyv;":"\u29B2","centerdot;":"\u00B7","CenterDot;":"\u00B7","cfr;":"\uD835\uDD20","Cfr;":"\u212D","CHcy;":"\u0427","chcy;":"\u0447","check;":"\u2713","checkmark;":"\u2713","circeq;":"\u2257","circlearrowleft;":"\u21BA","circlearrowright;":"\u21BB","circledast;":"\u229B","circledcirc;":"\u229A","circleddash;":"\u229D","CircleDot;":"\u2299","circledR;":"\u00AE","circledS;":"\u24C8","CircleMinus;":"\u2296","CirclePlus;":"\u2295","CircleTimes;":"\u2297","cir;":"\u25CB","cirE;":"\u29C3","cire;":"\u2257","cirfnint;":"\u2A10","cirmid;":"\u2AEF","cirscir;":"\u29C2","ClockwiseContourIntegral;":"\u2232","CloseCurlyDoubleQuote;":"\u201D","CloseCurlyQuote;":"\u2019","clubsuit;":"\u2663","colon;":"\u003A","Colon;":"\u2237","Colone;":"\u2A74","colone;":"\u2254","coloneq;":"\u2254","comma;":"\u002C","commat;":"\u0040","comp;":"\u2201","compfn;":"\u2218","complement;":"\u2201","complexes;":"\u2102","congdot;":"\u2A6D","Congruent;":"\u2261","conint;":"\u222E","Conint;":"\u222F","ContourIntegral;":"\u222E","copf;":"\uD835\uDD54","Copf;":"\u2102","coprod;":"\u2210","Coproduct;":"\u2210","COPY;":"\u00A9","COPY":"\u00A9","copysr;":"\u2117","CounterClockwiseContourIntegral;":"\u2233","cross;":"\u2717","Cross;":"\u2A2F","Cscr;":"\uD835\uDC9E","cscr;":"\uD835\uDCB8","csub;":"\u2ACF","csube;":"\u2AD1","csup;":"\u2AD0","csupe;":"\u2AD2","ctdot;":"\u22EF","cudarrl;":"\u2938","cudarrr;":"\u2935","cuepr;":"\u22DE","cuesc;":"\u22DF","cularr;":"\u21B6","cularrp;":"\u293D","cupbrcap;":"\u2A48","cupcap;":"\u2A46","CupCap;":"\u224D","Cup;":"\u22D3","cupcup;":"\u2A4A","cupdot;":"\u228D","cupor;":"\u2A45","cups;":"\u222A\uFE00","curarr;":"\u21B7","curarrm;":"\u293C","curlyeqprec;":"\u22DE","curlyeqsucc;":"\u22DF","curlyvee;":"\u22CE","curlywedge;":"\u22CF","curvearrowleft;":"\u21B6","curvearrowright;":"\u21B7","cuvee;":"\u22CE","cuwed;":"\u22CF","cwconint;":"\u2232","cwint;":"\u2231","cylcty;":"\u232D","daleth;":"\u2138","Darr;":"\u21A1","dash;":"\u2010","Dashv;":"\u2AE4","dashv;":"\u22A3","dbkarow;":"\u290F","dblac;":"\u02DD","Dcaron;":"\u010E","dcaron;":"\u010F","Dcy;":"\u0414","dcy;":"\u0434","ddagger;":"\u2021","ddarr;":"\u21CA","DD;":"\u2145","dd;":"\u2146","DDotrahd;":"\u2911","ddotseq;":"\u2A77","Del;":"\u2207","demptyv;":"\u29B1","dfisht;":"\u297F","Dfr;":"\uD835\uDD07","dfr;":"\uD835\uDD21","dHar;":"\u2965","dharl;":"\u21C3","dharr;":"\u21C2","DiacriticalAcute;":"\u00B4","DiacriticalDot;":"\u02D9","DiacriticalDoubleAcute;":"\u02DD","DiacriticalGrave;":"\u0060","DiacriticalTilde;":"\u02DC","diam;":"\u22C4","diamond;":"\u22C4","Diamond;":"\u22C4","diamondsuit;":"\u2666","die;":"\u00A8","DifferentialD;":"\u2146","digamma;":"\u03DD","disin;":"\u22F2","div;":"\u00F7","divideontimes;":"\u22C7","divonx;":"\u22C7","DJcy;":"\u0402","djcy;":"\u0452","dlcorn;":"\u231E","dlcrop;":"\u230D","dollar;":"\u0024","Dopf;":"\uD835\uDD3B","dopf;":"\uD835\uDD55","Dot;":"\u00A8","dot;":"\u02D9","DotDot;":"\u20DC","doteq;":"\u2250","doteqdot;":"\u2251","DotEqual;":"\u2250","dotminus;":"\u2238","dotplus;":"\u2214","dotsquare;":"\u22A1","doublebarwedge;":"\u2306","DoubleContourIntegral;":"\u222F","DoubleDot;":"\u00A8","DoubleDownArrow;":"\u21D3","DoubleLeftArrow;":"\u21D0","DoubleLeftRightArrow;":"\u21D4","DoubleLeftTee;":"\u2AE4","DoubleLongLeftArrow;":"\u27F8","DoubleLongLeftRightArrow;":"\u27FA","DoubleLongRightArrow;":"\u27F9","DoubleRightArrow;":"\u21D2","DoubleRightTee;":"\u22A8","DoubleUpArrow;":"\u21D1","DoubleUpDownArrow;":"\u21D5","DoubleVerticalBar;":"\u2225","DownArrowBar;":"\u2913","downarrow;":"\u2193","DownArrow;":"\u2193","Downarrow;":"\u21D3","DownArrowUpArrow;":"\u21F5","DownBreve;":"\u0311","downdownarrows;":"\u21CA","downharpoonleft;":"\u21C3","downharpoonright;":"\u21C2","DownLeftRightVector;":"\u2950","DownLeftTeeVector;":"\u295E","DownLeftVectorBar;":"\u2956","DownLeftVector;":"\u21BD","DownRightTeeVector;":"\u295F","DownRightVectorBar;":"\u2957","DownRightVector;":"\u21C1","DownTeeArrow;":"\u21A7","DownTee;":"\u22A4","drbkarow;":"\u2910","drcorn;":"\u231F","drcrop;":"\u230C","Dscr;":"\uD835\uDC9F","dscr;":"\uD835\uDCB9","DScy;":"\u0405","dscy;":"\u0455","dsol;":"\u29F6","Dstrok;":"\u0110","dstrok;":"\u0111","dtdot;":"\u22F1","dtri;":"\u25BF","dtrif;":"\u25BE","duarr;":"\u21F5","duhar;":"\u296F","dwangle;":"\u29A6","DZcy;":"\u040F","dzcy;":"\u045F","dzigrarr;":"\u27FF","easter;":"\u2A6E","Ecaron;":"\u011A","ecaron;":"\u011B","ecir;":"\u2256","ecolon;":"\u2255","Ecy;":"\u042D","ecy;":"\u044D","eDDot;":"\u2A77","Edot;":"\u0116","edot;":"\u0117","eDot;":"\u2251","ee;":"\u2147","efDot;":"\u2252","Efr;":"\uD835\uDD08","efr;":"\uD835\uDD22","eg;":"\u2A9A","egs;":"\u2A96","egsdot;":"\u2A98","el;":"\u2A99","Element;":"\u2208","elinters;":"\u23E7","ell;":"\u2113","els;":"\u2A95","elsdot;":"\u2A97","Emacr;":"\u0112","emacr;":"\u0113","emptyset;":"\u2205","EmptySmallSquare;":"\u25FB","emptyv;":"\u2205","EmptyVerySmallSquare;":"\u25AB","emsp13;":"\u2004","emsp14;":"\u2005","ENG;":"\u014A","eng;":"\u014B","Eogon;":"\u0118","eogon;":"\u0119","Eopf;":"\uD835\uDD3C","eopf;":"\uD835\uDD56","epar;":"\u22D5","eparsl;":"\u29E3","eplus;":"\u2A71","epsi;":"\u03B5","epsiv;":"\u03F5","eqcirc;":"\u2256","eqcolon;":"\u2255","eqsim;":"\u2242","eqslantgtr;":"\u2A96","eqslantless;":"\u2A95","Equal;":"\u2A75","equals;":"\u003D","EqualTilde;":"\u2242","equest;":"\u225F","Equilibrium;":"\u21CC","equivDD;":"\u2A78","eqvparsl;":"\u29E5","erarr;":"\u2971","erDot;":"\u2253","escr;":"\u212F","Escr;":"\u2130","esdot;":"\u2250","Esim;":"\u2A73","esim;":"\u2242","excl;":"\u0021","Exists;":"\u2203","expectation;":"\u2130","exponentiale;":"\u2147","ExponentialE;":"\u2147","fallingdotseq;":"\u2252","Fcy;":"\u0424","fcy;":"\u0444","female;":"\u2640","ffilig;":"\uFB03","fflig;":"\uFB00","ffllig;":"\uFB04","Ffr;":"\uD835\uDD09","ffr;":"\uD835\uDD23","filig;":"\uFB01","FilledSmallSquare;":"\u25FC","FilledVerySmallSquare;":"\u25AA","fjlig;":"\u0066\u006A","flat;":"\u266D","fllig;":"\uFB02","fltns;":"\u25B1","Fopf;":"\uD835\uDD3D","fopf;":"\uD835\uDD57","ForAll;":"\u2200","fork;":"\u22D4","forkv;":"\u2AD9","Fouriertrf;":"\u2131","fpartint;":"\u2A0D","frac13;":"\u2153","frac15;":"\u2155","frac16;":"\u2159","frac18;":"\u215B","frac23;":"\u2154","frac25;":"\u2156","frac35;":"\u2157","frac38;":"\u215C","frac45;":"\u2158","frac56;":"\u215A","frac58;":"\u215D","frac78;":"\u215E","frown;":"\u2322","fscr;":"\uD835\uDCBB","Fscr;":"\u2131","gacute;":"\u01F5","Gammad;":"\u03DC","gammad;":"\u03DD","gap;":"\u2A86","Gbreve;":"\u011E","gbreve;":"\u011F","Gcedil;":"\u0122","Gcirc;":"\u011C","gcirc;":"\u011D","Gcy;":"\u0413","gcy;":"\u0433","Gdot;":"\u0120","gdot;":"\u0121","gE;":"\u2267","gEl;":"\u2A8C","gel;":"\u22DB","geq;":"\u2265","geqq;":"\u2267","geqslant;":"\u2A7E","gescc;":"\u2AA9","ges;":"\u2A7E","gesdot;":"\u2A80","gesdoto;":"\u2A82","gesdotol;":"\u2A84","gesl;":"\u22DB\uFE00","gesles;":"\u2A94","Gfr;":"\uD835\uDD0A","gfr;":"\uD835\uDD24","gg;":"\u226B","Gg;":"\u22D9","ggg;":"\u22D9","gimel;":"\u2137","GJcy;":"\u0403","gjcy;":"\u0453","gla;":"\u2AA5","gl;":"\u2277","glE;":"\u2A92","glj;":"\u2AA4","gnap;":"\u2A8A","gnapprox;":"\u2A8A","gne;":"\u2A88","gnE;":"\u2269","gneq;":"\u2A88","gneqq;":"\u2269","gnsim;":"\u22E7","Gopf;":"\uD835\uDD3E","gopf;":"\uD835\uDD58","grave;":"\u0060","GreaterEqual;":"\u2265","GreaterEqualLess;":"\u22DB","GreaterFullEqual;":"\u2267","GreaterGreater;":"\u2AA2","GreaterLess;":"\u2277","GreaterSlantEqual;":"\u2A7E","GreaterTilde;":"\u2273","Gscr;":"\uD835\uDCA2","gscr;":"\u210A","gsim;":"\u2273","gsime;":"\u2A8E","gsiml;":"\u2A90","gtcc;":"\u2AA7","gtcir;":"\u2A7A","GT;":"\u003E","GT":"\u003E","Gt;":"\u226B","gtdot;":"\u22D7","gtlPar;":"\u2995","gtquest;":"\u2A7C","gtrapprox;":"\u2A86","gtrarr;":"\u2978","gtrdot;":"\u22D7","gtreqless;":"\u22DB","gtreqqless;":"\u2A8C","gtrless;":"\u2277","gtrsim;":"\u2273","gvertneqq;":"\u2269\uFE00","gvnE;":"\u2269\uFE00","Hacek;":"\u02C7","hairsp;":"\u200A","half;":"\u00BD","hamilt;":"\u210B","HARDcy;":"\u042A","hardcy;":"\u044A","harrcir;":"\u2948","harrw;":"\u21AD","Hat;":"\u005E","hbar;":"\u210F","Hcirc;":"\u0124","hcirc;":"\u0125","heartsuit;":"\u2665","hercon;":"\u22B9","hfr;":"\uD835\uDD25","Hfr;":"\u210C","HilbertSpace;":"\u210B","hksearow;":"\u2925","hkswarow;":"\u2926","hoarr;":"\u21FF","homtht;":"\u223B","hookleftarrow;":"\u21A9","hookrightarrow;":"\u21AA","hopf;":"\uD835\uDD59","Hopf;":"\u210D","horbar;":"\u2015","HorizontalLine;":"\u2500","hscr;":"\uD835\uDCBD","Hscr;":"\u210B","hslash;":"\u210F","Hstrok;":"\u0126","hstrok;":"\u0127","HumpDownHump;":"\u224E","HumpEqual;":"\u224F","hybull;":"\u2043","hyphen;":"\u2010","ic;":"\u2063","Icy;":"\u0418","icy;":"\u0438","Idot;":"\u0130","IEcy;":"\u0415","iecy;":"\u0435","iff;":"\u21D4","ifr;":"\uD835\uDD26","Ifr;":"\u2111","ii;":"\u2148","iiiint;":"\u2A0C","iiint;":"\u222D","iinfin;":"\u29DC","iiota;":"\u2129","IJlig;":"\u0132","ijlig;":"\u0133","Imacr;":"\u012A","imacr;":"\u012B","ImaginaryI;":"\u2148","imagline;":"\u2110","imagpart;":"\u2111","imath;":"\u0131","Im;":"\u2111","imof;":"\u22B7","imped;":"\u01B5","Implies;":"\u21D2","incare;":"\u2105","in;":"\u2208","infintie;":"\u29DD","inodot;":"\u0131","intcal;":"\u22BA","Int;":"\u222C","integers;":"\u2124","Integral;":"\u222B","intercal;":"\u22BA","Intersection;":"\u22C2","intlarhk;":"\u2A17","intprod;":"\u2A3C","InvisibleComma;":"\u2063","InvisibleTimes;":"\u2062","IOcy;":"\u0401","iocy;":"\u0451","Iogon;":"\u012E","iogon;":"\u012F","Iopf;":"\uD835\uDD40","iopf;":"\uD835\uDD5A","iprod;":"\u2A3C","iscr;":"\uD835\uDCBE","Iscr;":"\u2110","isindot;":"\u22F5","isinE;":"\u22F9","isins;":"\u22F4","isinsv;":"\u22F3","isinv;":"\u2208","it;":"\u2062","Itilde;":"\u0128","itilde;":"\u0129","Iukcy;":"\u0406","iukcy;":"\u0456","Jcirc;":"\u0134","jcirc;":"\u0135","Jcy;":"\u0419","jcy;":"\u0439","Jfr;":"\uD835\uDD0D","jfr;":"\uD835\uDD27","jmath;":"\u0237","Jopf;":"\uD835\uDD41","jopf;":"\uD835\uDD5B","Jscr;":"\uD835\uDCA5","jscr;":"\uD835\uDCBF","Jsercy;":"\u0408","jsercy;":"\u0458","Jukcy;":"\u0404","jukcy;":"\u0454","kappav;":"\u03F0","Kcedil;":"\u0136","kcedil;":"\u0137","Kcy;":"\u041A","kcy;":"\u043A","Kfr;":"\uD835\uDD0E","kfr;":"\uD835\uDD28","kgreen;":"\u0138","KHcy;":"\u0425","khcy;":"\u0445","KJcy;":"\u040C","kjcy;":"\u045C","Kopf;":"\uD835\uDD42","kopf;":"\uD835\uDD5C","Kscr;":"\uD835\uDCA6","kscr;":"\uD835\uDCC0","lAarr;":"\u21DA","Lacute;":"\u0139","lacute;":"\u013A","laemptyv;":"\u29B4","lagran;":"\u2112","Lang;":"\u27EA","langd;":"\u2991","langle;":"\u27E8","lap;":"\u2A85","Laplacetrf;":"\u2112","larrb;":"\u21E4","larrbfs;":"\u291F","Larr;":"\u219E","larrfs;":"\u291D","larrhk;":"\u21A9","larrlp;":"\u21AB","larrpl;":"\u2939","larrsim;":"\u2973","larrtl;":"\u21A2","latail;":"\u2919","lAtail;":"\u291B","lat;":"\u2AAB","late;":"\u2AAD","lates;":"\u2AAD\uFE00","lbarr;":"\u290C","lBarr;":"\u290E","lbbrk;":"\u2772","lbrace;":"\u007B","lbrack;":"\u005B","lbrke;":"\u298B","lbrksld;":"\u298F","lbrkslu;":"\u298D","Lcaron;":"\u013D","lcaron;":"\u013E","Lcedil;":"\u013B","lcedil;":"\u013C","lcub;":"\u007B","Lcy;":"\u041B","lcy;":"\u043B","ldca;":"\u2936","ldquor;":"\u201E","ldrdhar;":"\u2967","ldrushar;":"\u294B","ldsh;":"\u21B2","lE;":"\u2266","LeftAngleBracket;":"\u27E8","LeftArrowBar;":"\u21E4","leftarrow;":"\u2190","LeftArrow;":"\u2190","Leftarrow;":"\u21D0","LeftArrowRightArrow;":"\u21C6","leftarrowtail;":"\u21A2","LeftCeiling;":"\u2308","LeftDoubleBracket;":"\u27E6","LeftDownTeeVector;":"\u2961","LeftDownVectorBar;":"\u2959","LeftDownVector;":"\u21C3","LeftFloor;":"\u230A","leftharpoondown;":"\u21BD","leftharpoonup;":"\u21BC","leftleftarrows;":"\u21C7","leftrightarrow;":"\u2194","LeftRightArrow;":"\u2194","Leftrightarrow;":"\u21D4","leftrightarrows;":"\u21C6","leftrightharpoons;":"\u21CB","leftrightsquigarrow;":"\u21AD","LeftRightVector;":"\u294E","LeftTeeArrow;":"\u21A4","LeftTee;":"\u22A3","LeftTeeVector;":"\u295A","leftthreetimes;":"\u22CB","LeftTriangleBar;":"\u29CF","LeftTriangle;":"\u22B2","LeftTriangleEqual;":"\u22B4","LeftUpDownVector;":"\u2951","LeftUpTeeVector;":"\u2960","LeftUpVectorBar;":"\u2958","LeftUpVector;":"\u21BF","LeftVectorBar;":"\u2952","LeftVector;":"\u21BC","lEg;":"\u2A8B","leg;":"\u22DA","leq;":"\u2264","leqq;":"\u2266","leqslant;":"\u2A7D","lescc;":"\u2AA8","les;":"\u2A7D","lesdot;":"\u2A7F","lesdoto;":"\u2A81","lesdotor;":"\u2A83","lesg;":"\u22DA\uFE00","lesges;":"\u2A93","lessapprox;":"\u2A85","lessdot;":"\u22D6","lesseqgtr;":"\u22DA","lesseqqgtr;":"\u2A8B","LessEqualGreater;":"\u22DA","LessFullEqual;":"\u2266","LessGreater;":"\u2276","lessgtr;":"\u2276","LessLess;":"\u2AA1","lesssim;":"\u2272","LessSlantEqual;":"\u2A7D","LessTilde;":"\u2272","lfisht;":"\u297C","Lfr;":"\uD835\uDD0F","lfr;":"\uD835\uDD29","lg;":"\u2276","lgE;":"\u2A91","lHar;":"\u2962","lhard;":"\u21BD","lharu;":"\u21BC","lharul;":"\u296A","lhblk;":"\u2584","LJcy;":"\u0409","ljcy;":"\u0459","llarr;":"\u21C7","ll;":"\u226A","Ll;":"\u22D8","llcorner;":"\u231E","Lleftarrow;":"\u21DA","llhard;":"\u296B","lltri;":"\u25FA","Lmidot;":"\u013F","lmidot;":"\u0140","lmoustache;":"\u23B0","lmoust;":"\u23B0","lnap;":"\u2A89","lnapprox;":"\u2A89","lne;":"\u2A87","lnE;":"\u2268","lneq;":"\u2A87","lneqq;":"\u2268","lnsim;":"\u22E6","loang;":"\u27EC","loarr;":"\u21FD","lobrk;":"\u27E6","longleftarrow;":"\u27F5","LongLeftArrow;":"\u27F5","Longleftarrow;":"\u27F8","longleftrightarrow;":"\u27F7","LongLeftRightArrow;":"\u27F7","Longleftrightarrow;":"\u27FA","longmapsto;":"\u27FC","longrightarrow;":"\u27F6","LongRightArrow;":"\u27F6","Longrightarrow;":"\u27F9","looparrowleft;":"\u21AB","looparrowright;":"\u21AC","lopar;":"\u2985","Lopf;":"\uD835\uDD43","lopf;":"\uD835\uDD5D","loplus;":"\u2A2D","lotimes;":"\u2A34","lowbar;":"\u005F","LowerLeftArrow;":"\u2199","LowerRightArrow;":"\u2198","lozenge;":"\u25CA","lozf;":"\u29EB","lpar;":"\u0028","lparlt;":"\u2993","lrarr;":"\u21C6","lrcorner;":"\u231F","lrhar;":"\u21CB","lrhard;":"\u296D","lrtri;":"\u22BF","lscr;":"\uD835\uDCC1","Lscr;":"\u2112","lsh;":"\u21B0","Lsh;":"\u21B0","lsim;":"\u2272","lsime;":"\u2A8D","lsimg;":"\u2A8F","lsqb;":"\u005B","lsquor;":"\u201A","Lstrok;":"\u0141","lstrok;":"\u0142","ltcc;":"\u2AA6","ltcir;":"\u2A79","LT;":"\u003C","LT":"\u003C","Lt;":"\u226A","ltdot;":"\u22D6","lthree;":"\u22CB","ltimes;":"\u22C9","ltlarr;":"\u2976","ltquest;":"\u2A7B","ltri;":"\u25C3","ltrie;":"\u22B4","ltrif;":"\u25C2","ltrPar;":"\u2996","lurdshar;":"\u294A","luruhar;":"\u2966","lvertneqq;":"\u2268\uFE00","lvnE;":"\u2268\uFE00","male;":"\u2642","malt;":"\u2720","maltese;":"\u2720","Map;":"\u2905","map;":"\u21A6","mapsto;":"\u21A6","mapstodown;":"\u21A7","mapstoleft;":"\u21A4","mapstoup;":"\u21A5","marker;":"\u25AE","mcomma;":"\u2A29","Mcy;":"\u041C","mcy;":"\u043C","mDDot;":"\u223A","measuredangle;":"\u2221","MediumSpace;":"\u205F","Mellintrf;":"\u2133","Mfr;":"\uD835\uDD10","mfr;":"\uD835\uDD2A","mho;":"\u2127","midast;":"\u002A","midcir;":"\u2AF0","mid;":"\u2223","minusb;":"\u229F","minusd;":"\u2238","minusdu;":"\u2A2A","MinusPlus;":"\u2213","mlcp;":"\u2ADB","mldr;":"\u2026","mnplus;":"\u2213","models;":"\u22A7","Mopf;":"\uD835\uDD44","mopf;":"\uD835\uDD5E","mp;":"\u2213","mscr;":"\uD835\uDCC2","Mscr;":"\u2133","mstpos;":"\u223E","multimap;":"\u22B8","mumap;":"\u22B8","Nacute;":"\u0143","nacute;":"\u0144","nang;":"\u2220\u20D2","nap;":"\u2249","napE;":"\u2A70\u0338","napid;":"\u224B\u0338","napos;":"\u0149","napprox;":"\u2249","natural;":"\u266E","naturals;":"\u2115","natur;":"\u266E","nbump;":"\u224E\u0338","nbumpe;":"\u224F\u0338","ncap;":"\u2A43","Ncaron;":"\u0147","ncaron;":"\u0148","Ncedil;":"\u0145","ncedil;":"\u0146","ncong;":"\u2247","ncongdot;":"\u2A6D\u0338","ncup;":"\u2A42","Ncy;":"\u041D","ncy;":"\u043D","nearhk;":"\u2924","nearr;":"\u2197","neArr;":"\u21D7","nearrow;":"\u2197","nedot;":"\u2250\u0338","NegativeMediumSpace;":"\u200B","NegativeThickSpace;":"\u200B","NegativeThinSpace;":"\u200B","NegativeVeryThinSpace;":"\u200B","nequiv;":"\u2262","nesear;":"\u2928","nesim;":"\u2242\u0338","NestedGreaterGreater;":"\u226B","NestedLessLess;":"\u226A","NewLine;":"\u000A","nexist;":"\u2204","nexists;":"\u2204","Nfr;":"\uD835\uDD11","nfr;":"\uD835\uDD2B","ngE;":"\u2267\u0338","nge;":"\u2271","ngeq;":"\u2271","ngeqq;":"\u2267\u0338","ngeqslant;":"\u2A7E\u0338","nges;":"\u2A7E\u0338","nGg;":"\u22D9\u0338","ngsim;":"\u2275","nGt;":"\u226B\u20D2","ngt;":"\u226F","ngtr;":"\u226F","nGtv;":"\u226B\u0338","nharr;":"\u21AE","nhArr;":"\u21CE","nhpar;":"\u2AF2","nis;":"\u22FC","nisd;":"\u22FA","niv;":"\u220B","NJcy;":"\u040A","njcy;":"\u045A","nlarr;":"\u219A","nlArr;":"\u21CD","nldr;":"\u2025","nlE;":"\u2266\u0338","nle;":"\u2270","nleftarrow;":"\u219A","nLeftarrow;":"\u21CD","nleftrightarrow;":"\u21AE","nLeftrightarrow;":"\u21CE","nleq;":"\u2270","nleqq;":"\u2266\u0338","nleqslant;":"\u2A7D\u0338","nles;":"\u2A7D\u0338","nless;":"\u226E","nLl;":"\u22D8\u0338","nlsim;":"\u2274","nLt;":"\u226A\u20D2","nlt;":"\u226E","nltri;":"\u22EA","nltrie;":"\u22EC","nLtv;":"\u226A\u0338","nmid;":"\u2224","NoBreak;":"\u2060","NonBreakingSpace;":"\u00A0","nopf;":"\uD835\uDD5F","Nopf;":"\u2115","Not;":"\u2AEC","NotCongruent;":"\u2262","NotCupCap;":"\u226D","NotDoubleVerticalBar;":"\u2226","NotElement;":"\u2209","NotEqual;":"\u2260","NotEqualTilde;":"\u2242\u0338","NotExists;":"\u2204","NotGreater;":"\u226F","NotGreaterEqual;":"\u2271","NotGreaterFullEqual;":"\u2267\u0338","NotGreaterGreater;":"\u226B\u0338","NotGreaterLess;":"\u2279","NotGreaterSlantEqual;":"\u2A7E\u0338","NotGreaterTilde;":"\u2275","NotHumpDownHump;":"\u224E\u0338","NotHumpEqual;":"\u224F\u0338","notindot;":"\u22F5\u0338","notinE;":"\u22F9\u0338","notinva;":"\u2209","notinvb;":"\u22F7","notinvc;":"\u22F6","NotLeftTriangleBar;":"\u29CF\u0338","NotLeftTriangle;":"\u22EA","NotLeftTriangleEqual;":"\u22EC","NotLess;":"\u226E","NotLessEqual;":"\u2270","NotLessGreater;":"\u2278","NotLessLess;":"\u226A\u0338","NotLessSlantEqual;":"\u2A7D\u0338","NotLessTilde;":"\u2274","NotNestedGreaterGreater;":"\u2AA2\u0338","NotNestedLessLess;":"\u2AA1\u0338","notni;":"\u220C","notniva;":"\u220C","notnivb;":"\u22FE","notnivc;":"\u22FD","NotPrecedes;":"\u2280","NotPrecedesEqual;":"\u2AAF\u0338","NotPrecedesSlantEqual;":"\u22E0","NotReverseElement;":"\u220C","NotRightTriangleBar;":"\u29D0\u0338","NotRightTriangle;":"\u22EB","NotRightTriangleEqual;":"\u22ED","NotSquareSubset;":"\u228F\u0338","NotSquareSubsetEqual;":"\u22E2","NotSquareSuperset;":"\u2290\u0338","NotSquareSupersetEqual;":"\u22E3","NotSubset;":"\u2282\u20D2","NotSubsetEqual;":"\u2288","NotSucceeds;":"\u2281","NotSucceedsEqual;":"\u2AB0\u0338","NotSucceedsSlantEqual;":"\u22E1","NotSucceedsTilde;":"\u227F\u0338","NotSuperset;":"\u2283\u20D2","NotSupersetEqual;":"\u2289","NotTilde;":"\u2241","NotTildeEqual;":"\u2244","NotTildeFullEqual;":"\u2247","NotTildeTilde;":"\u2249","NotVerticalBar;":"\u2224","nparallel;":"\u2226","npar;":"\u2226","nparsl;":"\u2AFD\u20E5","npart;":"\u2202\u0338","npolint;":"\u2A14","npr;":"\u2280","nprcue;":"\u22E0","nprec;":"\u2280","npreceq;":"\u2AAF\u0338","npre;":"\u2AAF\u0338","nrarrc;":"\u2933\u0338","nrarr;":"\u219B","nrArr;":"\u21CF","nrarrw;":"\u219D\u0338","nrightarrow;":"\u219B","nRightarrow;":"\u21CF","nrtri;":"\u22EB","nrtrie;":"\u22ED","nsc;":"\u2281","nsccue;":"\u22E1","nsce;":"\u2AB0\u0338","Nscr;":"\uD835\uDCA9","nscr;":"\uD835\uDCC3","nshortmid;":"\u2224","nshortparallel;":"\u2226","nsim;":"\u2241","nsime;":"\u2244","nsimeq;":"\u2244","nsmid;":"\u2224","nspar;":"\u2226","nsqsube;":"\u22E2","nsqsupe;":"\u22E3","nsubE;":"\u2AC5\u0338","nsube;":"\u2288","nsubset;":"\u2282\u20D2","nsubseteq;":"\u2288","nsubseteqq;":"\u2AC5\u0338","nsucc;":"\u2281","nsucceq;":"\u2AB0\u0338","nsup;":"\u2285","nsupE;":"\u2AC6\u0338","nsupe;":"\u2289","nsupset;":"\u2283\u20D2","nsupseteq;":"\u2289","nsupseteqq;":"\u2AC6\u0338","ntgl;":"\u2279","ntlg;":"\u2278","ntriangleleft;":"\u22EA","ntrianglelefteq;":"\u22EC","ntriangleright;":"\u22EB","ntrianglerighteq;":"\u22ED","num;":"\u0023","numero;":"\u2116","numsp;":"\u2007","nvap;":"\u224D\u20D2","nvdash;":"\u22AC","nvDash;":"\u22AD","nVdash;":"\u22AE","nVDash;":"\u22AF","nvge;":"\u2265\u20D2","nvgt;":"\u003E\u20D2","nvHarr;":"\u2904","nvinfin;":"\u29DE","nvlArr;":"\u2902","nvle;":"\u2264\u20D2","nvlt;":"\u003C\u20D2","nvltrie;":"\u22B4\u20D2","nvrArr;":"\u2903","nvrtrie;":"\u22B5\u20D2","nvsim;":"\u223C\u20D2","nwarhk;":"\u2923","nwarr;":"\u2196","nwArr;":"\u21D6","nwarrow;":"\u2196","nwnear;":"\u2927","oast;":"\u229B","ocir;":"\u229A","Ocy;":"\u041E","ocy;":"\u043E","odash;":"\u229D","Odblac;":"\u0150","odblac;":"\u0151","odiv;":"\u2A38","odot;":"\u2299","odsold;":"\u29BC","ofcir;":"\u29BF","Ofr;":"\uD835\uDD12","ofr;":"\uD835\uDD2C","ogon;":"\u02DB","ogt;":"\u29C1","ohbar;":"\u29B5","ohm;":"\u03A9","oint;":"\u222E","olarr;":"\u21BA","olcir;":"\u29BE","olcross;":"\u29BB","olt;":"\u29C0","Omacr;":"\u014C","omacr;":"\u014D","omid;":"\u29B6","ominus;":"\u2296","Oopf;":"\uD835\uDD46","oopf;":"\uD835\uDD60","opar;":"\u29B7","OpenCurlyDoubleQuote;":"\u201C","OpenCurlyQuote;":"\u2018","operp;":"\u29B9","orarr;":"\u21BB","Or;":"\u2A54","ord;":"\u2A5D","order;":"\u2134","orderof;":"\u2134","origof;":"\u22B6","oror;":"\u2A56","orslope;":"\u2A57","orv;":"\u2A5B","oS;":"\u24C8","Oscr;":"\uD835\uDCAA","oscr;":"\u2134","osol;":"\u2298","otimesas;":"\u2A36","Otimes;":"\u2A37","ovbar;":"\u233D","OverBar;":"\u203E","OverBrace;":"\u23DE","OverBracket;":"\u23B4","OverParenthesis;":"\u23DC","parallel;":"\u2225","par;":"\u2225","parsim;":"\u2AF3","parsl;":"\u2AFD","PartialD;":"\u2202","Pcy;":"\u041F","pcy;":"\u043F","percnt;":"\u0025","period;":"\u002E","pertenk;":"\u2031","Pfr;":"\uD835\uDD13","pfr;":"\uD835\uDD2D","phiv;":"\u03D5","phmmat;":"\u2133","phone;":"\u260E","pitchfork;":"\u22D4","planck;":"\u210F","planckh;":"\u210E","plankv;":"\u210F","plusacir;":"\u2A23","plusb;":"\u229E","pluscir;":"\u2A22","plus;":"\u002B","plusdo;":"\u2214","plusdu;":"\u2A25","pluse;":"\u2A72","PlusMinus;":"\u00B1","plussim;":"\u2A26","plustwo;":"\u2A27","pm;":"\u00B1","Poincareplane;":"\u210C","pointint;":"\u2A15","popf;":"\uD835\uDD61","Popf;":"\u2119","prap;":"\u2AB7","Pr;":"\u2ABB","pr;":"\u227A","prcue;":"\u227C","precapprox;":"\u2AB7","prec;":"\u227A","preccurlyeq;":"\u227C","Precedes;":"\u227A","PrecedesEqual;":"\u2AAF","PrecedesSlantEqual;":"\u227C","PrecedesTilde;":"\u227E","preceq;":"\u2AAF","precnapprox;":"\u2AB9","precneqq;":"\u2AB5","precnsim;":"\u22E8","pre;":"\u2AAF","prE;":"\u2AB3","precsim;":"\u227E","primes;":"\u2119","prnap;":"\u2AB9","prnE;":"\u2AB5","prnsim;":"\u22E8","Product;":"\u220F","profalar;":"\u232E","profline;":"\u2312","profsurf;":"\u2313","Proportional;":"\u221D","Proportion;":"\u2237","propto;":"\u221D","prsim;":"\u227E","prurel;":"\u22B0","Pscr;":"\uD835\uDCAB","pscr;":"\uD835\uDCC5","puncsp;":"\u2008","Qfr;":"\uD835\uDD14","qfr;":"\uD835\uDD2E","qint;":"\u2A0C","qopf;":"\uD835\uDD62","Qopf;":"\u211A","qprime;":"\u2057","Qscr;":"\uD835\uDCAC","qscr;":"\uD835\uDCC6","quaternions;":"\u210D","quatint;":"\u2A16","quest;":"\u003F","questeq;":"\u225F","QUOT;":"\u0022","QUOT":"\u0022","rAarr;":"\u21DB","race;":"\u223D\u0331","Racute;":"\u0154","racute;":"\u0155","raemptyv;":"\u29B3","Rang;":"\u27EB","rangd;":"\u2992","range;":"\u29A5","rangle;":"\u27E9","rarrap;":"\u2975","rarrb;":"\u21E5","rarrbfs;":"\u2920","rarrc;":"\u2933","Rarr;":"\u21A0","rarrfs;":"\u291E","rarrhk;":"\u21AA","rarrlp;":"\u21AC","rarrpl;":"\u2945","rarrsim;":"\u2974","Rarrtl;":"\u2916","rarrtl;":"\u21A3","rarrw;":"\u219D","ratail;":"\u291A","rAtail;":"\u291C","ratio;":"\u2236","rationals;":"\u211A","rbarr;":"\u290D","rBarr;":"\u290F","RBarr;":"\u2910","rbbrk;":"\u2773","rbrace;":"\u007D","rbrack;":"\u005D","rbrke;":"\u298C","rbrksld;":"\u298E","rbrkslu;":"\u2990","Rcaron;":"\u0158","rcaron;":"\u0159","Rcedil;":"\u0156","rcedil;":"\u0157","rcub;":"\u007D","Rcy;":"\u0420","rcy;":"\u0440","rdca;":"\u2937","rdldhar;":"\u2969","rdquor;":"\u201D","rdsh;":"\u21B3","realine;":"\u211B","realpart;":"\u211C","reals;":"\u211D","Re;":"\u211C","rect;":"\u25AD","REG;":"\u00AE","REG":"\u00AE","ReverseElement;":"\u220B","ReverseEquilibrium;":"\u21CB","ReverseUpEquilibrium;":"\u296F","rfisht;":"\u297D","rfr;":"\uD835\uDD2F","Rfr;":"\u211C","rHar;":"\u2964","rhard;":"\u21C1","rharu;":"\u21C0","rharul;":"\u296C","rhov;":"\u03F1","RightAngleBracket;":"\u27E9","RightArrowBar;":"\u21E5","rightarrow;":"\u2192","RightArrow;":"\u2192","Rightarrow;":"\u21D2","RightArrowLeftArrow;":"\u21C4","rightarrowtail;":"\u21A3","RightCeiling;":"\u2309","RightDoubleBracket;":"\u27E7","RightDownTeeVector;":"\u295D","RightDownVectorBar;":"\u2955","RightDownVector;":"\u21C2","RightFloor;":"\u230B","rightharpoondown;":"\u21C1","rightharpoonup;":"\u21C0","rightleftarrows;":"\u21C4","rightleftharpoons;":"\u21CC","rightrightarrows;":"\u21C9","rightsquigarrow;":"\u219D","RightTeeArrow;":"\u21A6","RightTee;":"\u22A2","RightTeeVector;":"\u295B","rightthreetimes;":"\u22CC","RightTriangleBar;":"\u29D0","RightTriangle;":"\u22B3","RightTriangleEqual;":"\u22B5","RightUpDownVector;":"\u294F","RightUpTeeVector;":"\u295C","RightUpVectorBar;":"\u2954","RightUpVector;":"\u21BE","RightVectorBar;":"\u2953","RightVector;":"\u21C0","ring;":"\u02DA","risingdotseq;":"\u2253","rlarr;":"\u21C4","rlhar;":"\u21CC","rmoustache;":"\u23B1","rmoust;":"\u23B1","rnmid;":"\u2AEE","roang;":"\u27ED","roarr;":"\u21FE","robrk;":"\u27E7","ropar;":"\u2986","ropf;":"\uD835\uDD63","Ropf;":"\u211D","roplus;":"\u2A2E","rotimes;":"\u2A35","RoundImplies;":"\u2970","rpar;":"\u0029","rpargt;":"\u2994","rppolint;":"\u2A12","rrarr;":"\u21C9","Rrightarrow;":"\u21DB","rscr;":"\uD835\uDCC7","Rscr;":"\u211B","rsh;":"\u21B1","Rsh;":"\u21B1","rsqb;":"\u005D","rsquor;":"\u2019","rthree;":"\u22CC","rtimes;":"\u22CA","rtri;":"\u25B9","rtrie;":"\u22B5","rtrif;":"\u25B8","rtriltri;":"\u29CE","RuleDelayed;":"\u29F4","ruluhar;":"\u2968","rx;":"\u211E","Sacute;":"\u015A","sacute;":"\u015B","scap;":"\u2AB8","Sc;":"\u2ABC","sc;":"\u227B","sccue;":"\u227D","sce;":"\u2AB0","scE;":"\u2AB4","Scedil;":"\u015E","scedil;":"\u015F","Scirc;":"\u015C","scirc;":"\u015D","scnap;":"\u2ABA","scnE;":"\u2AB6","scnsim;":"\u22E9","scpolint;":"\u2A13","scsim;":"\u227F","Scy;":"\u0421","scy;":"\u0441","sdotb;":"\u22A1","sdote;":"\u2A66","searhk;":"\u2925","searr;":"\u2198","seArr;":"\u21D8","searrow;":"\u2198","semi;":"\u003B","seswar;":"\u2929","setminus;":"\u2216","setmn;":"\u2216","sext;":"\u2736","Sfr;":"\uD835\uDD16","sfr;":"\uD835\uDD30","sfrown;":"\u2322","sharp;":"\u266F","SHCHcy;":"\u0429","shchcy;":"\u0449","SHcy;":"\u0428","shcy;":"\u0448","ShortDownArrow;":"\u2193","ShortLeftArrow;":"\u2190","shortmid;":"\u2223","shortparallel;":"\u2225","ShortRightArrow;":"\u2192","ShortUpArrow;":"\u2191","sigmav;":"\u03C2","simdot;":"\u2A6A","sime;":"\u2243","simeq;":"\u2243","simg;":"\u2A9E","simgE;":"\u2AA0","siml;":"\u2A9D","simlE;":"\u2A9F","simne;":"\u2246","simplus;":"\u2A24","simrarr;":"\u2972","slarr;":"\u2190","SmallCircle;":"\u2218","smallsetminus;":"\u2216","smashp;":"\u2A33","smeparsl;":"\u29E4","smid;":"\u2223","smile;":"\u2323","smt;":"\u2AAA","smte;":"\u2AAC","smtes;":"\u2AAC\uFE00","SOFTcy;":"\u042C","softcy;":"\u044C","solbar;":"\u233F","solb;":"\u29C4","sol;":"\u002F","Sopf;":"\uD835\uDD4A","sopf;":"\uD835\uDD64","spadesuit;":"\u2660","spar;":"\u2225","sqcap;":"\u2293","sqcaps;":"\u2293\uFE00","sqcup;":"\u2294","sqcups;":"\u2294\uFE00","Sqrt;":"\u221A","sqsub;":"\u228F","sqsube;":"\u2291","sqsubset;":"\u228F","sqsubseteq;":"\u2291","sqsup;":"\u2290","sqsupe;":"\u2292","sqsupset;":"\u2290","sqsupseteq;":"\u2292","square;":"\u25A1","Square;":"\u25A1","SquareIntersection;":"\u2293","SquareSubset;":"\u228F","SquareSubsetEqual;":"\u2291","SquareSuperset;":"\u2290","SquareSupersetEqual;":"\u2292","SquareUnion;":"\u2294","squarf;":"\u25AA","squ;":"\u25A1","squf;":"\u25AA","srarr;":"\u2192","Sscr;":"\uD835\uDCAE","sscr;":"\uD835\uDCC8","ssetmn;":"\u2216","ssmile;":"\u2323","sstarf;":"\u22C6","Star;":"\u22C6","star;":"\u2606","starf;":"\u2605","straightepsilon;":"\u03F5","straightphi;":"\u03D5","strns;":"\u00AF","Sub;":"\u22D0","subdot;":"\u2ABD","subE;":"\u2AC5","subedot;":"\u2AC3","submult;":"\u2AC1","subnE;":"\u2ACB","subne;":"\u228A","subplus;":"\u2ABF","subrarr;":"\u2979","subset;":"\u2282","Subset;":"\u22D0","subseteq;":"\u2286","subseteqq;":"\u2AC5","SubsetEqual;":"\u2286","subsetneq;":"\u228A","subsetneqq;":"\u2ACB","subsim;":"\u2AC7","subsub;":"\u2AD5","subsup;":"\u2AD3","succapprox;":"\u2AB8","succ;":"\u227B","succcurlyeq;":"\u227D","Succeeds;":"\u227B","SucceedsEqual;":"\u2AB0","SucceedsSlantEqual;":"\u227D","SucceedsTilde;":"\u227F","succeq;":"\u2AB0","succnapprox;":"\u2ABA","succneqq;":"\u2AB6","succnsim;":"\u22E9","succsim;":"\u227F","SuchThat;":"\u220B","Sum;":"\u2211","sung;":"\u266A","Sup;":"\u22D1","supdot;":"\u2ABE","supdsub;":"\u2AD8","supE;":"\u2AC6","supedot;":"\u2AC4","Superset;":"\u2283","SupersetEqual;":"\u2287","suphsol;":"\u27C9","suphsub;":"\u2AD7","suplarr;":"\u297B","supmult;":"\u2AC2","supnE;":"\u2ACC","supne;":"\u228B","supplus;":"\u2AC0","supset;":"\u2283","Supset;":"\u22D1","supseteq;":"\u2287","supseteqq;":"\u2AC6","supsetneq;":"\u228B","supsetneqq;":"\u2ACC","supsim;":"\u2AC8","supsub;":"\u2AD4","supsup;":"\u2AD6","swarhk;":"\u2926","swarr;":"\u2199","swArr;":"\u21D9","swarrow;":"\u2199","swnwar;":"\u292A","Tab;":"\u0009","target;":"\u2316","tbrk;":"\u23B4","Tcaron;":"\u0164","tcaron;":"\u0165","Tcedil;":"\u0162","tcedil;":"\u0163","Tcy;":"\u0422","tcy;":"\u0442","tdot;":"\u20DB","telrec;":"\u2315","Tfr;":"\uD835\uDD17","tfr;":"\uD835\uDD31","therefore;":"\u2234","Therefore;":"\u2234","thetav;":"\u03D1","thickapprox;":"\u2248","thicksim;":"\u223C","ThickSpace;":"\u205F\u200A","ThinSpace;":"\u2009","thkap;":"\u2248","thksim;":"\u223C","Tilde;":"\u223C","TildeEqual;":"\u2243","TildeFullEqual;":"\u2245","TildeTilde;":"\u2248","timesbar;":"\u2A31","timesb;":"\u22A0","timesd;":"\u2A30","tint;":"\u222D","toea;":"\u2928","topbot;":"\u2336","topcir;":"\u2AF1","top;":"\u22A4","Topf;":"\uD835\uDD4B","topf;":"\uD835\uDD65","topfork;":"\u2ADA","tosa;":"\u2929","tprime;":"\u2034","TRADE;":"\u2122","triangle;":"\u25B5","triangledown;":"\u25BF","triangleleft;":"\u25C3","trianglelefteq;":"\u22B4","triangleq;":"\u225C","triangleright;":"\u25B9","trianglerighteq;":"\u22B5","tridot;":"\u25EC","trie;":"\u225C","triminus;":"\u2A3A","TripleDot;":"\u20DB","triplus;":"\u2A39","trisb;":"\u29CD","tritime;":"\u2A3B","trpezium;":"\u23E2","Tscr;":"\uD835\uDCAF","tscr;":"\uD835\uDCC9","TScy;":"\u0426","tscy;":"\u0446","TSHcy;":"\u040B","tshcy;":"\u045B","Tstrok;":"\u0166","tstrok;":"\u0167","twixt;":"\u226C","twoheadleftarrow;":"\u219E","twoheadrightarrow;":"\u21A0","Uarr;":"\u219F","Uarrocir;":"\u2949","Ubrcy;":"\u040E","ubrcy;":"\u045E","Ubreve;":"\u016C","ubreve;":"\u016D","Ucy;":"\u0423","ucy;":"\u0443","udarr;":"\u21C5","Udblac;":"\u0170","udblac;":"\u0171","udhar;":"\u296E","ufisht;":"\u297E","Ufr;":"\uD835\uDD18","ufr;":"\uD835\uDD32","uHar;":"\u2963","uharl;":"\u21BF","uharr;":"\u21BE","uhblk;":"\u2580","ulcorn;":"\u231C","ulcorner;":"\u231C","ulcrop;":"\u230F","ultri;":"\u25F8","Umacr;":"\u016A","umacr;":"\u016B","UnderBar;":"\u005F","UnderBrace;":"\u23DF","UnderBracket;":"\u23B5","UnderParenthesis;":"\u23DD","Union;":"\u22C3","UnionPlus;":"\u228E","Uogon;":"\u0172","uogon;":"\u0173","Uopf;":"\uD835\uDD4C","uopf;":"\uD835\uDD66","UpArrowBar;":"\u2912","uparrow;":"\u2191","UpArrow;":"\u2191","Uparrow;":"\u21D1","UpArrowDownArrow;":"\u21C5","updownarrow;":"\u2195","UpDownArrow;":"\u2195","Updownarrow;":"\u21D5","UpEquilibrium;":"\u296E","upharpoonleft;":"\u21BF","upharpoonright;":"\u21BE","uplus;":"\u228E","UpperLeftArrow;":"\u2196","UpperRightArrow;":"\u2197","upsi;":"\u03C5","Upsi;":"\u03D2","UpTeeArrow;":"\u21A5","UpTee;":"\u22A5","upuparrows;":"\u21C8","urcorn;":"\u231D","urcorner;":"\u231D","urcrop;":"\u230E","Uring;":"\u016E","uring;":"\u016F","urtri;":"\u25F9","Uscr;":"\uD835\uDCB0","uscr;":"\uD835\uDCCA","utdot;":"\u22F0","Utilde;":"\u0168","utilde;":"\u0169","utri;":"\u25B5","utrif;":"\u25B4","uuarr;":"\u21C8","uwangle;":"\u29A7","vangrt;":"\u299C","varepsilon;":"\u03F5","varkappa;":"\u03F0","varnothing;":"\u2205","varphi;":"\u03D5","varpi;":"\u03D6","varpropto;":"\u221D","varr;":"\u2195","vArr;":"\u21D5","varrho;":"\u03F1","varsigma;":"\u03C2","varsubsetneq;":"\u228A\uFE00","varsubsetneqq;":"\u2ACB\uFE00","varsupsetneq;":"\u228B\uFE00","varsupsetneqq;":"\u2ACC\uFE00","vartheta;":"\u03D1","vartriangleleft;":"\u22B2","vartriangleright;":"\u22B3","vBar;":"\u2AE8","Vbar;":"\u2AEB","vBarv;":"\u2AE9","Vcy;":"\u0412","vcy;":"\u0432","vdash;":"\u22A2","vDash;":"\u22A8","Vdash;":"\u22A9","VDash;":"\u22AB","Vdashl;":"\u2AE6","veebar;":"\u22BB","vee;":"\u2228","Vee;":"\u22C1","veeeq;":"\u225A","vellip;":"\u22EE","verbar;":"\u007C","Verbar;":"\u2016","vert;":"\u007C","Vert;":"\u2016","VerticalBar;":"\u2223","VerticalLine;":"\u007C","VerticalSeparator;":"\u2758","VerticalTilde;":"\u2240","VeryThinSpace;":"\u200A","Vfr;":"\uD835\uDD19","vfr;":"\uD835\uDD33","vltri;":"\u22B2","vnsub;":"\u2282\u20D2","vnsup;":"\u2283\u20D2","Vopf;":"\uD835\uDD4D","vopf;":"\uD835\uDD67","vprop;":"\u221D","vrtri;":"\u22B3","Vscr;":"\uD835\uDCB1","vscr;":"\uD835\uDCCB","vsubnE;":"\u2ACB\uFE00","vsubne;":"\u228A\uFE00","vsupnE;":"\u2ACC\uFE00","vsupne;":"\u228B\uFE00","Vvdash;":"\u22AA","vzigzag;":"\u299A","Wcirc;":"\u0174","wcirc;":"\u0175","wedbar;":"\u2A5F","wedge;":"\u2227","Wedge;":"\u22C0","wedgeq;":"\u2259","Wfr;":"\uD835\uDD1A","wfr;":"\uD835\uDD34","Wopf;":"\uD835\uDD4E","wopf;":"\uD835\uDD68","wp;":"\u2118","wr;":"\u2240","wreath;":"\u2240","Wscr;":"\uD835\uDCB2","wscr;":"\uD835\uDCCC","xcap;":"\u22C2","xcirc;":"\u25EF","xcup;":"\u22C3","xdtri;":"\u25BD","Xfr;":"\uD835\uDD1B","xfr;":"\uD835\uDD35","xharr;":"\u27F7","xhArr;":"\u27FA","xlarr;":"\u27F5","xlArr;":"\u27F8","xmap;":"\u27FC","xnis;":"\u22FB","xodot;":"\u2A00","Xopf;":"\uD835\uDD4F","xopf;":"\uD835\uDD69","xoplus;":"\u2A01","xotime;":"\u2A02","xrarr;":"\u27F6","xrArr;":"\u27F9","Xscr;":"\uD835\uDCB3","xscr;":"\uD835\uDCCD","xsqcup;":"\u2A06","xuplus;":"\u2A04","xutri;":"\u25B3","xvee;":"\u22C1","xwedge;":"\u22C0","YAcy;":"\u042F","yacy;":"\u044F","Ycirc;":"\u0176","ycirc;":"\u0177","Ycy;":"\u042B","ycy;":"\u044B","Yfr;":"\uD835\uDD1C","yfr;":"\uD835\uDD36","YIcy;":"\u0407","yicy;":"\u0457","Yopf;":"\uD835\uDD50","yopf;":"\uD835\uDD6A","Yscr;":"\uD835\uDCB4","yscr;":"\uD835\uDCCE","YUcy;":"\u042E","yucy;":"\u044E","Zacute;":"\u0179","zacute;":"\u017A","Zcaron;":"\u017D","zcaron;":"\u017E","Zcy;":"\u0417","zcy;":"\u0437","Zdot;":"\u017B","zdot;":"\u017C","zeetrf;":"\u2128","ZeroWidthSpace;":"\u200B","zfr;":"\uD835\uDD37","Zfr;":"\u2128","ZHcy;":"\u0416","zhcy;":"\u0436","zigrarr;":"\u21DD","zopf;":"\uD835\uDD6B","Zopf;":"\u2124","Zscr;":"\uD835\uDCB5","zscr;":"\uD835\uDCCF"} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/xml.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/xml.json new file mode 100644 index 00000000..b6e781c1 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/entities/xml.json @@ -0,0 +1 @@ +{"amp;":"\u0026","apos;":"\u0027","gt;":"\u003e","lt;":"\u003c","quot;":"\u0022"} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/index.js new file mode 100644 index 00000000..b5365383 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/index.js @@ -0,0 +1,117 @@ +var modes = ["XML", "HTML4", "HTML5"]; + +module.exports = { + decode: function(data, level){ + if(!modes[level]) level = 0; + return module.exports["decode" + modes[level]](data); + }, + decodeStrict: function(data, level){ + if(!modes[level]) level = 0; + return module.exports["decode" + modes[level] + "Strict"](data); + }, + encode: function(data, level){ + if(!modes[level]) level = 0; + return module.exports["encode" + modes[level]](data); + } +}; + +modes.reduce(function(prev, name){ + var obj = require("./entities/" + name.toLowerCase() + ".json"); + + if(prev){ + Object.keys(prev).forEach(function(name){ + obj[name] = prev[name]; + }); + } + + module.exports["decode" + name + "Strict"] = getStrictReplacer(obj); + + if(name === "XML"){ + //there is no non-strict mode for XML + module.exports.decodeXML = module.exports.decodeXMLStrict; + } else { + module.exports["decode" + name] = getReplacer(obj); + } + + module.exports["encode" + name] = getReverse(obj); + + return obj; +}, null); + +function getReplacer(obj){ + var keys = Object.keys(obj).sort(); + var re = keys.join("|").replace(/(\w+)\|\1;/g, "$1;?"); + + // also match hex and char codes + re += "|#[xX][\\da-fA-F]+;?|#\\d+;?"; + + return genReplaceFunc( + new RegExp("&(?:" + re + ")", "g"), + function func(name){ + if(name.charAt(1) === "#"){ + if(name.charAt(2).toLowerCase() === "x"){ + return String.fromCharCode(parseInt(name.substr(3), 16)); + } + return String.fromCharCode(parseInt(name.substr(2), 10)); + } + return obj[name.substr(1)]; + } + ); +} + +function getStrictReplacer(obj){ + var keys = Object.keys(obj).sort().filter(RegExp.prototype.test, /;$/); + var re = keys.map(function(name){ + return name.slice(0, -1); //remove trailing semicolon + }).join("|"); + + // also match hex and char codes + re += "|#[xX][\\da-fA-F]+|#\\d+"; + + var expr = new RegExp("&(?:" + re + ");", "g"); + + return genReplaceFunc(expr, func); + + function func(name){ + if(name.charAt(1) === "#"){ + if(name.charAt(2).toLowerCase() === "x"){ + return String.fromCharCode(parseInt(name.substr(3), 16)); + } + return String.fromCharCode(parseInt(name.substr(2), 10)); + } + return obj[name.substr(1)]; + } +} + +var re_nonUTF8 = /[\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]/g; + +function nonUTF8Replacer(c){ + return "&#" + c.charCodeAt(0) + ";"; +} + +function getReverse(obj){ + var reverse = Object.keys(obj).filter(function(name){ + //prefer identifiers with a semicolon + return name.substr(-1) === ";" || obj[name + ";"] !== obj[name]; + }).reduce(function(reverse, name){ + reverse[obj[name]] = name; + return reverse; + }, {}); + + var regex = new RegExp("\\" + Object.keys(reverse).sort().join("|\\"), "g"); + function func(name){ + return "&" + reverse[name]; + } + + return function(data){ + return data + .replace(regex, func) + .replace(re_nonUTF8, nonUTF8Replacer); + }; +} + +function genReplaceFunc(regex, func){ + return function(data){ + return data.replace(regex, func); + }; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/package.json new file mode 100644 index 00000000..de61b5a8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/package.json @@ -0,0 +1,42 @@ +{ + "name": "entities", + "version": "0.3.0", + "description": "Encode & decode XML/HTML entities with ease", + "author": { + "name": "Felix Boehm", + "email": "me@feedic.com" + }, + "keywords": [ + "html", + "xml", + "entity", + "encoding" + ], + "main": "./index.js", + "directories": { + "test": "test" + }, + "devDependencies": { + "mocha": "~1.9.0" + }, + "scripts": { + "test": "mocha" + }, + "repository": { + "type": "git", + "url": "git://github.com/fb55/node-entities.git" + }, + "license": "BSD-like", + "readme": "#entities\n\nEn- & decoder for XML/HTML entities.\n\n####Features:\n* Focussed on ___speed___\n* Supports three levels of entities: __XML__, __HTML4__ & __HTML5__\n * Supports _char code_ entities (eg. `U`)\n\n##How to…\n\n###…install `entities`\n\n npm i entities\n\n###…use `entities`\n\n```javascript\n//encoding\nrequire(\"entities\").encode( data[, level]);\n//decoding\nrequire(\"entities\").decode( data[, level]);\n```\n\nThe `level` attribute indicates what level of entities should be decoded (0 = XML, 1 = HTML4 and 2 = HTML5). The default is 0 (read: XML).\n\nThere are also methods to access the level directly. Just append the name of the level to the action and you're ready to go (e.g. `encodeHTML4(data)`, `decodeXML(data)`).\n", + "readmeFilename": "readme.md", + "bugs": { + "url": "https://github.com/fb55/node-entities/issues" + }, + "homepage": "https://github.com/fb55/node-entities", + "_id": "entities@0.3.0", + "dist": { + "shasum": "3e65fd50729380e0e60367e97b05e9b64182e6a8" + }, + "_from": "entities@0.x", + "_resolved": "https://registry.npmjs.org/entities/-/entities-0.3.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/readme.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/readme.md new file mode 100644 index 00000000..ebd87df3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/readme.md @@ -0,0 +1,27 @@ +#entities + +En- & decoder for XML/HTML entities. + +####Features: +* Focussed on ___speed___ +* Supports three levels of entities: __XML__, __HTML4__ & __HTML5__ + * Supports _char code_ entities (eg. `U`) + +##How to… + +###…install `entities` + + npm i entities + +###…use `entities` + +```javascript +//encoding +require("entities").encode( data[, level]); +//decoding +require("entities").decode( data[, level]); +``` + +The `level` attribute indicates what level of entities should be decoded (0 = XML, 1 = HTML4 and 2 = HTML5). The default is 0 (read: XML). + +There are also methods to access the level directly. Just append the name of the level to the action and you're ready to go (e.g. `encodeHTML4(data)`, `decodeXML(data)`). diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/test/mocha.opts b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/test/mocha.opts new file mode 100644 index 00000000..af53e242 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/test/mocha.opts @@ -0,0 +1,2 @@ +--check-leaks +--reporter spec diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/test/test.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/test/test.js new file mode 100644 index 00000000..fa6c00df --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/entities/test/test.js @@ -0,0 +1,68 @@ +var assert = require("assert"); +var entities = require('../'); + +describe("Encode->decode test", function() { + var testcases = [ + { + input: "asdf & ÿ ü '", + xml: "asdf & ÿ ü '", + html4: "asdf & ÿ ü '", + html5: "asdf & ÿ ü '" + }, { + input: "&", + xml: "&#38;", + html4: "&#38;", + html5: "&#38;" + }, + ]; + testcases.forEach(function(tc) { + var encodedXML = entities.encodeXML(tc.input); + it("should XML encode " + tc.input, function() { + assert.equal(encodedXML, tc.xml); + }); + it("should XML decode " + encodedXML, function() { + assert.equal(entities.decodeXML(encodedXML), tc.input); + }); + var encodedHTML4 = entities.encodeHTML4(tc.input); + it("should HTML4 encode " + tc.input, function() { + assert.equal(encodedHTML4, tc.html4); + }); + it("should HTML4 decode " + encodedHTML4, function() { + assert.equal(entities.decodeHTML4(encodedHTML4), tc.input); + }); + var encodedHTML5 = entities.encodeHTML5(tc.input); + it("should HTML5 encode " + tc.input, function() { + assert.equal(encodedHTML5, tc.html5); + }); + it("should HTML5 decode " + encodedHTML5, function() { + assert.equal(entities.decodeHTML5(encodedHTML5), tc.input); + }); + }); +}); + +describe("Decode test", function() { + var testcases = [ + { input: "&amp;", output: "&" }, + { input: "&#38;", output: "&" }, + { input: "&#x26;", output: "&" }, + { input: "&#X26;", output: "&" }, + { input: "&#38;", output: "&" }, + { input: "&#38;", output: "&" }, + { input: "&#38;", output: "&" }, + { input: ":", output: ":" }, + { input: ":", output: ":" }, + { input: ":", output: ":" }, + { input: ":", output: ":" } + ]; + testcases.forEach(function(tc) { + it("should XML decode " + tc.input, function() { + assert.equal(entities.decodeXML(tc.input), tc.output); + }); + it("should HTML4 decode " + tc.input, function() { + assert.equal(entities.decodeHTML4(tc.input), tc.output); + }); + it("should HTML5 decode " + tc.input, function() { + assert.equal(entities.decodeHTML5(tc.input), tc.output); + }); + }); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.gitattributes b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.gitattributes new file mode 100644 index 00000000..4bb50dc1 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text eol=lf \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.npmignore new file mode 100644 index 00000000..0db216bf --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.npmignore @@ -0,0 +1,2 @@ +npm-debug.log +node_modules diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.travis.yml new file mode 100644 index 00000000..d63ba095 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/LICENSE new file mode 100644 index 00000000..0a35e029 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/LICENSE @@ -0,0 +1,18 @@ +Copyright 2010, 2011, Chris Winberry . All rights reserved. +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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/README.md new file mode 100644 index 00000000..9ed236d4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/node_modules/htmlparser2/README.md @@ -0,0 +1,81 @@ +#htmlparser2 [![NPM version](https://badge.fury.io/js/htmlparser2.png)](https://npmjs.org/package/htmlparser2) [![Build Status](https://secure.travis-ci.org/fb55/htmlparser2.png)](http://travis-ci.org/fb55/htmlparser2) [![Dependency Status](https://david-dm.org/fb55/htmlparser2.png)](https://david-dm.org/fb55/htmlparser2) + +A forgiving HTML/XML/RSS parser written in JS for NodeJS. The parser can handle streams (chunked data) and supports custom handlers for writing custom DOMs/output. + +##Installing + npm install htmlparser2 + +A live demo of htmlparser2 is available at http://demos.forbeslindesay.co.uk/htmlparser2/ + +##Usage + +```javascript +var htmlparser = require("htmlparser2"); +var parser = new htmlparser.Parser({ + onopentag: function(name, attribs){ + if(name === "script" && attribs.type === "text/javascript"){ + console.log("JS! Hooray!"); + } + }, + ontext: function(text){ + console.log("-->", text); + }, + onclosetag: function(tagname){ + if(tagname === "script"){ + console.log("That's it?!"); + } + } +}); +parser.write("Xyz alert("XSS!")'); + }); + + it('(key, value) : should coerce values to a string', function() { + var $apple = $('.apple', fruits); + $apple.attr('data-test', 1); + expect($apple[0].attribs['data-test']).to.equal('1'); + expect($apple.attr('data-test')).to.equal('1'); + }); + }); + + describe('.data', function() { + + it('() : should get all data attributes', function() { + var data = $('.linth', chocolates).data(); + expect(data).to.eql({ + highlight: 'Lindor', + origin: 'swiss' + }); + }); + + it('() : no data attribute should return an empty object', function() { + var data = $('.cailler', chocolates).data(); + expect(data).to.be.empty(); + }); + + it('(invalid key) : invalid data attribute should return `undefined` ', function() { + var data = $('.frey', chocolates).data('lol'); + expect(data).to.be(undefined); + }); + + it('(valid key) : valid data attribute should get value', function() { + var highlight = $('.linth', chocolates).data('highlight'); + var origin = $('.linth', chocolates).data('origin'); + + expect(highlight).to.equal('Lindor'); + expect(origin).to.equal('swiss'); + }); + + it('(hyphen key) : data addribute with hyphen should be camelized ;-)', function() { + var data = $('.frey', chocolates).data(); + expect(data).to.eql({ + taste: 'sweet', + bestCollection: 'Mahony' + }); + }); + + it('(key, value) : should set data attribute', function() { + // Adding as object. + var a = $('.frey', chocolates).data({ + balls: 'giandor' + }); + // Adding as string. + var b = $('.linth', chocolates).data('snack', 'chocoletti'); + + expect(a.data('balls')).to.eql('giandor'); + expect(b.data('snack')).to.eql('chocoletti'); + }); + + it('(map) : object map should set multiple data attributes', function() { + var data = $('.linth', chocolates).data({ + id: 'Cailler', + flop: 'Pippilotti Rist', + top: 'Frigor', + url: 'http://www.cailler.ch/' + })['0'].data; + + expect(data.id).to.equal('Cailler'); + expect(data.flop).to.equal('Pippilotti Rist'); + expect(data.top).to.equal('Frigor'); + expect(data.url).to.equal('http://www.cailler.ch/'); + }); + + describe('(attr) : data-* attribute type coercion :', function() { + it('boolean', function() { + var $el = $('
    '); + expect($el.data('bool')).to.be(true); + }); + + it('number', function() { + var $el = $('
    '); + expect($el.data('number')).to.be(23); + }); + + it('number (scientific notation is not coerced)', function() { + var $el = $('
    '); + expect($el.data('sci')).to.be('1E10'); + }); + + it('null', function() { + var $el = $('
    '); + expect($el.data('null')).to.be(null); + }); + + it('object', function() { + var $el = $('
    '); + expect($el.data('obj')).to.eql({ a: 45 }); + }); + + it('array', function() { + var $el = $('
    '); + expect($el.data('array')).to.eql([1, 2, 3]); + }); + + }); + + }); + + + describe('.val', function() { + it('.val(): on select should get value', function() { + var val = $('select#one', inputs).val(); + expect(val).to.equal('option_selected'); + }); + it('.val(): on option should get value', function() { + var val = $('select#one option', inputs).eq(0).val(); + expect(val).to.equal('option_not_selected'); + }); + it('.val(): on text input should get value', function() { + var val = $('input[type="text"]', inputs).val(); + expect(val).to.equal('input_text'); + }); + it('.val(): on checked checkbox should get value', function() { + var val = $('input[name="checkbox_on"]', inputs).val(); + expect(val).to.equal('on'); + }); + it('.val(): on unchecked checkbox should get value', function() { + var val = $('input[name="checkbox_off"]', inputs).val(); + expect(val).to.equal('off'); + }); + it('.val(): on radio should get value', function() { + var val = $('input[type="radio"]', inputs).val(); + expect(val).to.equal('on'); + }); + it('.val(): on multiple select should get an array of values', function() { + var val = $('select#multi', inputs).val(); + expect(val).to.have.length(2); + }); + it('.val(value): on input text should set value', function() { + var element = $('input[type="text"]', inputs).val('test'); + expect(element.val()).to.equal('test'); + }); + it('.val(value): on select should set value', function() { + var element = $('select#one', inputs).val('option_not_selected'); + expect(element.val()).to.equal('option_not_selected'); + }); + it('.val(value): on option should set value', function() { + var element = $('select#one option', inputs).eq(0).val('option_changed'); + expect(element.val()).to.equal('option_changed'); + }); + it('.val(value): on radio should set value', function() { + var element = $('input[name="radio"]', inputs).val('off'); + expect(element.val()).to.equal('off'); + }); + it('.val(values): on multiple select should set multiple values', function() { + var element = $('select#multi', inputs).val(['1', '3', '4']); + expect(element.val()).to.have.length(3); + }); + }); + + describe('.removeAttr', function() { + + it('(key) : should remove a single attr', function() { + var $fruits = $(fruits); + expect($fruits.attr('id')).to.not.be(undefined); + $fruits.removeAttr('id'); + expect($fruits.attr('id')).to.be(undefined); + }); + + it('should return cheerio object', function() { + var obj = $('ul', fruits).removeAttr('id').cheerio; + expect(obj).to.be.ok(); + }); + + }); + + describe('.hasClass', function() { + + it('(valid class) : should return true', function() { + var $fruits = $(fruits); + var cls = $('.apple', $fruits).hasClass('apple'); + expect(cls).to.be.ok(); + }); + + it('(invalid class) : should return false', function() { + var cls = $('#fruits', fruits).hasClass('fruits'); + expect(cls).to.not.be.ok(); + }); + + it('should check multiple classes', function() { + var $fruits = $(fruits); + + // Add a class + $('.apple', $fruits).addClass('red'); + expect($('.apple', $fruits).hasClass('apple')).to.be.ok(); + expect($('.apple', $fruits).hasClass('red')).to.be.ok(); + + // Remove one and test again + $('.apple', $fruits).removeClass('apple'); + expect($('li', $fruits).eq(0).hasClass('apple')).to.not.be.ok(); + // expect($('li', $fruits).eq(0).hasClass('red')).to.be.ok(); + }); + }); + + describe('.addClass', function() { + + it('(first class) : should add the class to the element', function() { + var $fruits = $(fruits); + $fruits.addClass('fruits'); + var cls = $fruits.hasClass('fruits'); + expect(cls).to.be.ok(); + }); + + it('(single class) : should add the class to the element', function() { + var $fruits = $(fruits); + $('.apple', $fruits).addClass('fruit'); + var cls = $('.apple', $fruits).hasClass('fruit'); + expect(cls).to.be.ok(); + }); + + it('(class): adds classes to many selected items', function() { + var $fruits = $(fruits); + $('li', $fruits).addClass('fruit'); + expect($('.apple', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.orange', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.pear', $fruits).hasClass('fruit')).to.be.ok(); + }); + + it('(class class class) : should add multiple classes to the element', function() { + var $fruits = $(fruits); + $('.apple', $fruits).addClass('fruit red tasty'); + expect($('.apple', $fruits).hasClass('apple')).to.be.ok(); + expect($('.apple', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.apple', $fruits).hasClass('red')).to.be.ok(); + expect($('.apple', $fruits).hasClass('tasty')).to.be.ok(); + }); + + it('(fn) : should add classes returned from the function', function() { + var $fruits = $(fruits).children(); + var args = []; + var thisVals = []; + var toAdd = ['apple red', '', undefined]; + + $fruits.addClass(function(idx, currentClass) { + args.push(arguments); + thisVals.push(this); + return toAdd[idx]; + }); + + expect(args).to.eql([ + [0, 'apple'], + [1, 'orange'], + [2, 'pear'] + ]); + expect(thisVals).to.eql([ + $fruits[0], + $fruits[1], + $fruits[2] + ]); + expect($fruits.eq(0).hasClass('apple')).to.be.ok(); + expect($fruits.eq(0).hasClass('red')).to.be.ok(); + expect($fruits.eq(1).hasClass('orange')).to.be.ok(); + expect($fruits.eq(2).hasClass('pear')).to.be.ok(); + }); + + }); + + describe('.removeClass', function() { + + it('() : should remove all the classes', function() { + var $fruits = $(fruits); + $('.pear', $fruits).addClass('fruit'); + $('.pear', $fruits).removeClass(); + expect($('.pear', $fruits).attr('class')).to.be(undefined); + }); + + it('("") : should not modify class list', function() { + var $fruits = $(fruits); + $fruits.children().removeClass(''); + expect($('.apple', $fruits)).to.have.length(1); + }); + + it('(invalid class) : should not remove anything', function() { + var $fruits = $(fruits); + $('.pear', $fruits).removeClass('fruit'); + expect($('.pear', $fruits).hasClass('pear')).to.be.ok(); + }); + + it('(no class attribute) : should not throw an exception', function() { + var $vegetables = $(vegetables); + var thrown = null; + expect(function() { + $('li', $vegetables).removeClass('vegetable'); + }) + .to.not.throwException(); + }); + + it('(single class) : should remove a single class from the element', function() { + var $fruits = $(fruits); + $('.pear', $fruits).addClass('fruit'); + expect($('.pear', $fruits).hasClass('fruit')).to.be.ok(); + $('.pear', $fruits).removeClass('fruit'); + expect($('.pear', $fruits).hasClass('fruit')).to.not.be.ok(); + expect($('.pear', $fruits).hasClass('pear')).to.be.ok(); + }); + + it('(single class) : should remove a single class from multiple classes on the element', function() { + var $fruits = $(fruits); + $('.pear', $fruits).addClass('fruit green tasty'); + expect($('.pear', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.pear', $fruits).hasClass('green')).to.be.ok(); + expect($('.pear', $fruits).hasClass('tasty')).to.be.ok(); + + $('.pear', $fruits).removeClass('green'); + expect($('.pear', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.pear', $fruits).hasClass('green')).to.not.be.ok(); + expect($('.pear', $fruits).hasClass('tasty')).to.be.ok(); + }); + + it('(class class class) : should remove multiple classes from the element', function() { + var $fruits = $(fruits); + + $('.apple', $fruits).addClass('fruit red tasty'); + expect($('.apple', $fruits).hasClass('apple')).to.be.ok(); + expect($('.apple', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.apple', $fruits).hasClass('red')).to.be.ok(); + expect($('.apple', $fruits).hasClass('tasty')).to.be.ok(); + + $('.apple', $fruits).removeClass('apple red tasty'); + expect($('.fruit', $fruits).hasClass('apple')).to.not.be.ok(); + expect($('.fruit', $fruits).hasClass('red')).to.not.be.ok(); + expect($('.fruit', $fruits).hasClass('tasty')).to.not.be.ok(); + expect($('.fruit', $fruits).hasClass('fruit')).to.be.ok(); + }); + + it('(class) : should remove all occurrences of a class name', function() { + var $div = $('
    '); + expect($div.removeClass('x').hasClass('x')).to.be(false); + }); + + it('(fn) : should remove classes returned from the function', function() { + var $fruits = $(fruits).children(); + var args = []; + var thisVals = []; + var toAdd = ['apple red', '', undefined]; + + $fruits.removeClass(function(idx, currentClass) { + args.push(arguments); + thisVals.push(this); + return toAdd[idx]; + }); + + expect(args).to.eql([ + [0, 'apple'], + [1, 'orange'], + [2, 'pear'] + ]); + expect(thisVals).to.eql([ + $fruits[0], + $fruits[1], + $fruits[2] + ]); + expect($fruits.eq(0).hasClass('apple')).to.not.be.ok(); + expect($fruits.eq(0).hasClass('red')).to.not.be.ok(); + expect($fruits.eq(1).hasClass('orange')).to.be.ok(); + expect($fruits.eq(2).hasClass('pear')).to.be.ok(); + }); + + }); + + describe('.toggleClass', function() { + + it('(class class) : should toggle multiple classes from the element', function() { + var $fruits = $(fruits); + + $('.apple', $fruits).addClass('fruit'); + expect($('.apple', $fruits).hasClass('apple')).to.be.ok(); + expect($('.apple', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.apple', $fruits).hasClass('red')).to.not.be.ok(); + + $('.apple', $fruits).toggleClass('apple red'); + expect($('.fruit', $fruits).hasClass('apple')).to.not.be.ok(); + expect($('.fruit', $fruits).hasClass('red')).to.be.ok(); + expect($('.fruit', $fruits).hasClass('fruit')).to.be.ok(); + }); + + it('(class class, true) : should add multiple classes to the element', function() { + var $fruits = $(fruits); + + $('.apple', $fruits).addClass('fruit'); + expect($('.apple', $fruits).hasClass('apple')).to.be.ok(); + expect($('.apple', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.apple', $fruits).hasClass('red')).to.not.be.ok(); + + $('.apple', $fruits).toggleClass('apple red', true); + expect($('.fruit', $fruits).hasClass('apple')).to.be.ok(); + expect($('.fruit', $fruits).hasClass('red')).to.be.ok(); + expect($('.fruit', $fruits).hasClass('fruit')).to.be.ok(); + }); + + it('(class class, false) : should remove multiple classes from the element', function() { + var $fruits = $(fruits); + + $('.apple', $fruits).addClass('fruit'); + expect($('.apple', $fruits).hasClass('apple')).to.be.ok(); + expect($('.apple', $fruits).hasClass('fruit')).to.be.ok(); + expect($('.apple', $fruits).hasClass('red')).to.not.be.ok(); + + $('.apple', $fruits).toggleClass('apple red', false); + expect($('.fruit', $fruits).hasClass('apple')).to.not.be.ok(); + expect($('.fruit', $fruits).hasClass('red')).to.not.be.ok(); + expect($('.fruit', $fruits).hasClass('fruit')).to.be.ok(); + }); + + it('(fn) : should toggle classes returned from the function', function() { + var $food = $(food); + + $('.apple', $food).addClass('fruit'); + $('.carrot', $food).addClass('vegetable'); + expect($('.apple', $food).hasClass('fruit')).to.be.ok(); + expect($('.apple', $food).hasClass('vegetable')).to.not.be.ok(); + expect($('.orange', $food).hasClass('fruit')).to.not.be.ok(); + expect($('.orange', $food).hasClass('vegetable')).to.not.be.ok(); + expect($('.carrot', $food).hasClass('fruit')).to.not.be.ok(); + expect($('.carrot', $food).hasClass('vegetable')).to.be.ok(); + expect($('.sweetcorn', $food).hasClass('fruit')).to.not.be.ok(); + expect($('.sweetcorn', $food).hasClass('vegetable')).to.not.be.ok(); + + $('li', $food).toggleClass(function(index, className, switchVal) { + return $(this).parent().is('#fruits') ? 'fruit' : 'vegetable'; + }); + expect($('.apple', $food).hasClass('fruit')).to.not.be.ok(); + expect($('.apple', $food).hasClass('vegetable')).to.not.be.ok(); + expect($('.orange', $food).hasClass('fruit')).to.be.ok(); + expect($('.orange', $food).hasClass('vegetable')).to.not.be.ok(); + expect($('.carrot', $food).hasClass('fruit')).to.not.be.ok(); + expect($('.carrot', $food).hasClass('vegetable')).to.not.be.ok(); + expect($('.sweetcorn', $food).hasClass('fruit')).to.not.be.ok(); + expect($('.sweetcorn', $food).hasClass('vegetable')).to.be.ok(); + }); + + }); + + describe('.is', function () { + it('() : should return false', function() { + expect($('li.apple', fruits).is()).to.be(false); + }); + + it('(true selector) : should return true', function() { + expect($('#vegetables', vegetables).is('ul')).to.be(true); + }); + + it('(false selector) : should return false', function() { + expect($('#vegetables', vegetables).is('div')).to.be(false); + }); + + it('(true selection) : should return true', function() { + var $vegetables = $('li', vegetables); + expect($vegetables.is($vegetables.eq(1))).to.be(true); + }); + + it('(false selection) : should return false', function() { + var $vegetableList = $(vegetables); + var $vegetables = $vegetableList.find('li'); + expect($vegetables.is($vegetableList)).to.be(false); + }); + + it('(true element) : should return true', function() { + var $vegetables = $('li', vegetables); + expect($vegetables.is($vegetables[0])).to.be(true); + }); + + it('(false element) : should return false', function() { + var $vegetableList = $(vegetables); + var $vegetables = $vegetableList.find('li'); + expect($vegetables.is($vegetableList[0])).to.be(false); + }); + + it('(true predicate) : should return true', function() { + var result = $('li', fruits).is(function() { + return this.hasClass('pear'); + }); + expect(result).to.be(true); + }); + + it('(false predicate) : should return false', function () { + var result = $('li', fruits).last().is(function() { + return this.name === 'ul'; + }); + expect(result).to.be(false); + }); + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.css.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.css.js new file mode 100644 index 00000000..12f4415e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.css.js @@ -0,0 +1,88 @@ +var expect = require('expect.js'); +var $ = require('..'); + +describe('$(...)', function() { + + describe('.css', function() { + it('(prop): should return a css property value', function() { + var el = $('
  • '); + expect(el.css('hai')).to.equal('there'); + }); + + it('([prop1, prop2]): should return the specified property values as an object', function() { + var el = $('
  • '); + expect(el.css(['margin', 'color'])).to.eql({ margin: '1px', color: 'blue' }); + }); + + it('(prop, val): should set a css property', function() { + var el = $('
  • '); + el.css('color', 'red'); + expect(el.attr('style')).to.equal('margin: 0; color: red;'); + expect(el.eq(1).attr('style')).to.equal('color: red;'); + }); + + it('(prop, ""): should unset a css property', function() { + var el = $('
  • '); + el.css('padding', ''); + expect(el.attr('style')).to.equal('margin: 0;'); + }); + + it('(prop): should not mangle embedded urls', function() { + var el = $('
  • '); + expect(el.css('background-image')).to.equal('url(http://example.com/img.png)'); + }); + + it('(prop): should ignore blank properties', function() { + var el = $('
  • '); + expect(el.css()).to.eql({color:'#aaa'}); + }); + + it('(prop): should ignore blank values', function() { + var el = $('
  • '); + expect(el.css()).to.eql({position:'absolute'}); + }); + + describe('(prop, function):', function() { + beforeEach(function() { + this.$el = $('
    '); + }); + + it('should iterate over the selection', function() { + var count = 0; + var $el = this.$el; + this.$el.css('margin', function(idx, elem) { + expect(idx).to.equal(count); + expect(elem).to.equal($el[count]); + expect(this).to.equal($el[count]); + count++; + }); + expect(count).to.equal(3); + }); + + it('should set each attribute independently', function() { + var values = ['4px', '', undefined]; + this.$el.css('margin', function(idx) { + return values[idx]; + }); + expect(this.$el.eq(0).attr('style')).to.equal('margin: 4px;'); + expect(this.$el.eq(1).attr('style')).to.equal(''); + expect(this.$el.eq(2).attr('style')).to.equal('margin: 0;'); + }); + }); + + it('(obj): should set each key and val', function() { + var el = $('
  • '); + el.css({ foo: 0 }); + expect(el.eq(0).attr('style')).to.equal('padding: 0; foo: 0;'); + expect(el.eq(1).attr('style')).to.equal('foo: 0;'); + }); + + describe('parser', function(){ + it('should allow any whitespace between declarations', function() { + var el = $('
  • '); + expect(el.css(['one', 'two'])).to.eql({ one: 0, two: 1 }); + }); + }); + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.manipulation.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.manipulation.js new file mode 100644 index 00000000..2b618387 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.manipulation.js @@ -0,0 +1,716 @@ +var expect = require('expect.js'), + $ = require('../'), + fruits = require('./fixtures').fruits; + +describe('$(...)', function() { + + describe('.append', function() { + + it('() : should do nothing', function() { + expect($('#fruits', fruits).append()[0].name).to.equal('ul'); + }); + + it('(html) : should add element as last child', function() { + var $fruits = $(fruits); + $fruits.append('
  • Plum
  • '); + expect($fruits.children(3).hasClass('plum')).to.be.ok(); + }); + + it('($(...)) : should add element as last child', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + $fruits.append($plum); + expect($fruits.children(3).hasClass('plum')).to.be.ok(); + }); + + it('(Node) : should add element as last child', function() { + var $fruits = $(fruits); + var plum = $('
  • Plum
  • ')[0]; + $fruits.append(plum); + expect($fruits.children(3).hasClass('plum')).to.be.ok(); + }); + + it('($(...), html) : should add multiple elements as last children', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + var grape = '
  • Grape
  • '; + $fruits.append($plum, grape); + expect($fruits.children(3).hasClass('plum')).to.be.ok(); + expect($fruits.children(4).hasClass('grape')).to.be.ok(); + }); + + it('(Array) : should append all elements in the array', function() { + var $fruits = $(fruits); + var more = $('
  • Plum
  • Grape
  • ') + .toArray(); + $fruits.append(more); + expect($fruits.children(3).hasClass('plum')).to.be.ok(); + expect($fruits.children(4).hasClass('grape')).to.be.ok(); + }); + + it('(fn) : should invoke the callback with the correct argument and context', function() { + var $fruits = $(fruits).children(); + var args = []; + var thisValues = []; + + $fruits.append(function() { + args.push(arguments); + thisValues.push(this); + }); + + expect(args).to.eql([ + [0, 'Apple'], + [1, 'Orange'], + [2, 'Pear'] + ]); + expect(thisValues).to.eql([ + $fruits[0], + $fruits[1], + $fruits[2] + ]); + }); + + it('(fn) : should add returned string as last child', function() { + var $fruits = $(fruits).children(); + var $apple, $orange, $pear; + + $fruits.append(function() { + return '
    '; + }); + + $apple = $fruits.eq(0); + $orange = $fruits.eq(1); + $pear = $fruits.eq(2); + + expect($apple.find('.first')[0]).to.equal($apple.contents()[1]); + expect($orange.find('.first')[0]).to.equal($orange.contents()[1]); + expect($pear.find('.first')[0]).to.equal($pear.contents()[1]); + }); + + it('(fn) : should add returned Cheerio object as last child', function() { + var $fruits = $(fruits).children(); + var $apple, $orange, $pear; + + $fruits.append(function() { + return $('
    '); + }); + + $apple = $fruits.eq(0); + $orange = $fruits.eq(1); + $pear = $fruits.eq(2); + + expect($apple.find('.second')[0]).to.equal($apple.contents()[1]); + expect($orange.find('.second')[0]).to.equal($orange.contents()[1]); + expect($pear.find('.second')[0]).to.equal($pear.contents()[1]); + }); + + it('(fn) : should add returned Node as last child', function() { + var $fruits = $(fruits).children(); + var $apple, $orange, $pear; + + $fruits.append(function() { + return $('
    ')[0]; + }); + + $apple = $fruits.eq(0); + $orange = $fruits.eq(1); + $pear = $fruits.eq(2); + + expect($apple.find('.third')[0]).to.equal($apple.contents()[1]); + expect($orange.find('.third')[0]).to.equal($orange.contents()[1]); + expect($pear.find('.third')[0]).to.equal($pear.contents()[1]); + }); + + it('should maintain correct object state (Issue: #10)', function() { + var $obj = $('
    ') + .append('
    ') + .children() + .children() + .parent(); + expect($obj).to.be.ok(); + }); + + }); + + describe('.prepend', function() { + + it('() : should do nothing', function() { + expect($('#fruits', fruits).prepend()[0].name).to.equal('ul'); + }); + + it('(html) : should add element as first child', function() { + var $fruits = $(fruits); + $fruits.prepend('
  • Plum
  • '); + expect($fruits.children(0).hasClass('plum')).to.be.ok(); + }); + + it('($(...)) : should add element as first child', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + $fruits.prepend($plum); + expect($fruits.children(0).hasClass('plum')).to.be.ok(); + }); + + it('(Node) : should add node as first child', function() { + var $fruits = $(fruits); + var plum = $('
  • Plum
  • ')[0]; + $fruits.prepend(plum); + expect($fruits.children(0).hasClass('plum')).to.be.ok(); + }); + + it('(Array) : should add all elements in the array as inital children', function() { + var $fruits = $(fruits); + var more = $('
  • Plum
  • Grape
  • ') + .toArray(); + $fruits.prepend(more); + expect($fruits.children(0).hasClass('plum')).to.be.ok(); + expect($fruits.children(1).hasClass('grape')).to.be.ok(); + }); + + it('(html, $(...), html) : should add multiple elements as first children', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + var grape = '
  • Grape
  • '; + $fruits.prepend($plum, grape); + expect($fruits.children(0).hasClass('plum')).to.be.ok(); + expect($fruits.children(1).hasClass('grape')).to.be.ok(); + }); + + it('(fn) : should invoke the callback with the correct argument and context', function() { + var $fruits = $(fruits).children(); + var args = []; + var thisValues = []; + + $fruits.prepend(function() { + args.push(arguments); + thisValues.push(this); + }); + + expect(args).to.eql([ + [0, 'Apple'], + [1, 'Orange'], + [2, 'Pear'] + ]); + expect(thisValues).to.eql([ + $fruits[0], + $fruits[1], + $fruits[2] + ]); + }); + + it('(fn) : should add returned string as first child', function() { + var $fruits = $(fruits).children(); + var $apple, $orange, $pear; + + $fruits.prepend(function() { + return '
    '; + }); + + $apple = $fruits.eq(0); + $orange = $fruits.eq(1); + $pear = $fruits.eq(2); + + expect($apple.find('.first')[0]).to.equal($apple.contents()[0]); + expect($orange.find('.first')[0]).to.equal($orange.contents()[0]); + expect($pear.find('.first')[0]).to.equal($pear.contents()[0]); + }); + + it('(fn) : should add returned Cheerio object as first child', function() { + var $fruits = $(fruits).children(); + var $apple, $orange, $pear; + + $fruits.prepend(function() { + return $('
    '); + }); + + $apple = $fruits.eq(0); + $orange = $fruits.eq(1); + $pear = $fruits.eq(2); + + expect($apple.find('.second')[0]).to.equal($apple.contents()[0]); + expect($orange.find('.second')[0]).to.equal($orange.contents()[0]); + expect($pear.find('.second')[0]).to.equal($pear.contents()[0]); + }); + + it('(fn) : should add returned Node as first child', function() { + var $fruits = $(fruits).children(); + var $apple, $orange, $pear; + + $fruits.prepend(function() { + return $('
    ')[0]; + }); + + $apple = $fruits.eq(0); + $orange = $fruits.eq(1); + $pear = $fruits.eq(2); + + expect($apple.find('.third')[0]).to.equal($apple.contents()[0]); + expect($orange.find('.third')[0]).to.equal($orange.contents()[0]); + expect($pear.find('.third')[0]).to.equal($pear.contents()[0]); + }); + + }); + + describe('.after', function() { + + it('() : should do nothing', function() { + expect($('#fruits', fruits).after()[0].name).to.equal('ul'); + }); + + it('(html) : should add element as next sibling', function() { + var $fruits = $(fruits); + var grape = '
  • Grape
  • '; + $('.apple', $fruits).after(grape); + expect($('.apple', $fruits).next().hasClass('grape')).to.be.ok(); + }); + + it('(Array) : should add all elements in the array as next sibling', function() { + var $fruits = $(fruits); + var more = $('
  • Plum
  • Grape
  • ') + .toArray(); + $('.apple', $fruits).after(more); + expect($fruits.children(1).hasClass('plum')).to.be.ok(); + expect($fruits.children(2).hasClass('grape')).to.be.ok(); + }); + + it('($(...)) : should add element as next sibling', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + $('.apple', $fruits).after($plum); + expect($('.apple', $fruits).next().hasClass('plum')).to.be.ok(); + }); + + it('(Node) : should add element as next sibling', function() { + var $fruits = $(fruits); + var plum = $('
  • Plum
  • ')[0]; + $('.apple', $fruits).after(plum); + expect($('.apple', $fruits).next().hasClass('plum')).to.be.ok(); + }); + + it('($(...), html) : should add multiple elements as next siblings', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + var grape = '
  • Grape
  • '; + $('.apple', $fruits).after($plum, grape); + expect($('.apple', $fruits).next().hasClass('plum')).to.be.ok(); + expect($('.plum', $fruits).next().hasClass('grape')).to.be.ok(); + }); + + it('(fn) : should invoke the callback with the correct argument and context', function() { + var $fruits = $(fruits).children(); + var args = []; + var thisValues = []; + + $fruits.after(function() { + args.push(arguments); + thisValues.push(this); + }); + + expect(args).to.eql([[0], [1], [2]]); + expect(thisValues).to.eql([ + $fruits[0], + $fruits[1], + $fruits[2] + ]); + }); + + it('(fn) : should add returned string as next sibling', function() { + var $list = $(fruits); + var $fruits = $list.children(); + + $fruits.after(function() { + return '
  • '; + }); + + expect($list.find('.first')[0]).to.equal($list.contents()[1]); + expect($list.find('.first')[1]).to.equal($list.contents()[3]); + expect($list.find('.first')[2]).to.equal($list.contents()[5]); + }); + + it('(fn) : should add returned Cheerio object as next sibling', function() { + var $list = $(fruits); + var $fruits = $list.children(); + + $fruits.after(function() { + return $('
  • '); + }); + + expect($list.find('.second')[0]).to.equal($list.contents()[1]); + expect($list.find('.second')[1]).to.equal($list.contents()[3]); + expect($list.find('.second')[2]).to.equal($list.contents()[5]); + }); + + it('(fn) : should add returned element as next sibling', function() { + var $list = $(fruits); + var $fruits = $list.children(); + + $fruits.after(function() { + return $('
  • ')[0]; + }); + + expect($list.find('.third')[0]).to.equal($list.contents()[1]); + expect($list.find('.third')[1]).to.equal($list.contents()[3]); + expect($list.find('.third')[2]).to.equal($list.contents()[5]); + }); + + }); + + describe('.before', function() { + + it('() : should do nothing', function() { + expect($('#fruits', fruits).before()[0].name).to.equal('ul'); + }); + + it('(html) : should add element as previous sibling', function() { + var $fruits = $(fruits); + var grape = '
  • Grape
  • '; + $('.apple', $fruits).before(grape); + expect($('.apple', $fruits).prev().hasClass('grape')).to.be.ok(); + }); + + it('($(...)) : should add element as previous sibling', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + $('.apple', $fruits).before($plum); + expect($('.apple', $fruits).prev().hasClass('plum')).to.be.ok(); + }); + + it('(Node) : should add element as previous sibling', function() { + var $fruits = $(fruits); + var plum = $('
  • Plum
  • '); + $('.apple', $fruits).before(plum); + expect($('.apple', $fruits).prev().hasClass('plum')).to.be.ok(); + }); + + it('(Array) : should add all elements in the array as previous sibling', function() { + var $fruits = $(fruits); + var more = $('
  • Plum
  • Grape
  • ') + .toArray(); + $('.apple', $fruits).before(more); + expect($fruits.children(0).hasClass('plum')).to.be.ok(); + expect($fruits.children(1).hasClass('grape')).to.be.ok(); + }); + + it('($(...), html) : should add multiple elements as previous siblings', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + var grape = '
  • Grape
  • '; + $('.apple', $fruits).before($plum, grape); + expect($('.apple', $fruits).prev().hasClass('grape')).to.be.ok(); + expect($('.grape', $fruits).prev().hasClass('plum')).to.be.ok(); + }); + + it('(fn) : should invoke the callback with the correct argument and context', function() { + var $fruits = $(fruits).children(); + var args = []; + var thisValues = []; + + $fruits.before(function() { + args.push(arguments); + thisValues.push(this); + }); + + expect(args).to.eql([[0], [1], [2]]); + expect(thisValues).to.eql([ + $fruits[0], + $fruits[1], + $fruits[2] + ]); + }); + + it('(fn) : should add returned string as previous sibling', function() { + var $list = $(fruits); + var $fruits = $list.children(); + + $fruits.before(function() { + return '
  • '; + }); + + expect($list.find('.first')[0]).to.equal($list.contents()[0]); + expect($list.find('.first')[1]).to.equal($list.contents()[2]); + expect($list.find('.first')[2]).to.equal($list.contents()[4]); + }); + + it('(fn) : should add returned Cheerio object as previous sibling', function() { + var $list = $(fruits); + var $fruits = $list.children(); + + $fruits.before(function() { + return $('
  • '); + }); + + expect($list.find('.second')[0]).to.equal($list.contents()[0]); + expect($list.find('.second')[1]).to.equal($list.contents()[2]); + expect($list.find('.second')[2]).to.equal($list.contents()[4]); + }); + + it('(fn) : should add returned Node as previous sibling', function() { + var $list = $(fruits); + var $fruits = $list.children(); + + $fruits.before(function() { + return $('
  • ')[0]; + }); + + expect($list.find('.third')[0]).to.equal($list.contents()[0]); + expect($list.find('.third')[1]).to.equal($list.contents()[2]); + expect($list.find('.third')[2]).to.equal($list.contents()[4]); + }); + + }); + + describe('.remove', function() { + + it('() : should remove selected elements', function() { + var $fruits = $(fruits); + $('.apple', $fruits).remove(); + expect($fruits.find('.apple')).to.have.length(0); + }); + + it('(selector) : should remove matching selected elements', function() { + var $fruits = $(fruits); + $('li', $fruits).remove('.apple'); + expect($fruits.find('.apple')).to.have.length(0); + }); + + }); + + describe('.replaceWith', function() { + + it('(elem) : should replace one
  • tag with another', function() { + var $fruits = $(fruits); + var $plum = $('
  • Plum
  • '); + $('.pear', $fruits).replaceWith($plum); + expect($('.orange', $fruits).next().hasClass('plum')).to.be.ok(); + expect($('.orange', $fruits).next().html()).to.equal('Plum'); + }); + + it('(Array) : should replace one
  • tag with the elements in the array', function() { + var $fruits = $(fruits); + var more = $('
  • Plum
  • Grape
  • ') + .toArray(); + $('.pear', $fruits).replaceWith(more); + + expect($fruits.children(2).hasClass('plum')).to.be.ok(); + expect($fruits.children(3).hasClass('grape')).to.be.ok(); + expect($fruits.children()).to.have.length(4); + }); + + it('(Node) : should replace the selected element with given node', function() { + var $src = $('

    hi there

    '); + var $new = $('
      '); + var $replaced = $src.find('span').replaceWith($new[0]); + expect($new[0].parent).to.equal($src[0]); + expect($replaced[0].parent).to.equal(null); + expect($.html($src)).to.equal('

      hi

        '); + }); + + it('(existing element) : should remove element from its previous location', function() { + var $fruits = $(fruits); + $('.pear', $fruits).replaceWith($('.apple', $fruits)); + expect($fruits.children()).to.have.length(2); + expect($fruits.children()[0]).to.equal($('.orange', $fruits)[0]); + expect($fruits.children()[1]).to.equal($('.apple', $fruits)[0]); + }); + + it('(elem) : should replace the single selected element with given element', function() { + var $src = $('

        hi there

        '); + var $new = $('
        here
        '); + var $replaced = $src.find('span').replaceWith($new); + expect($new[0].parent).to.equal($src[0]); + expect($replaced[0].parent).to.equal(null); + expect($.html($src)).to.equal('

        hi
        here

        '); + }); + + it('(str) : should accept strings', function() { + var $src = $('

        hi there

        '); + var newStr = '
        here
        '; + var $replaced = $src.find('span').replaceWith(newStr); + expect($replaced[0].parent).to.equal(null); + expect($.html($src)).to.equal('

        hi
        here

        '); + }); + + it('(fn) : should invoke the callback with the correct argument and context', function() { + var $fruits = $(fruits); + var origChildren = $fruits.children().toArray(); + var args = []; + var thisValues = []; + + $fruits.children().replaceWith(function() { + args.push(arguments); + thisValues.push(this); + return '
      • '; + }); + + expect(args).to.eql([[0], [1], [2]]); + expect(thisValues).to.eql([ + origChildren[0], + origChildren[1], + origChildren[2] + ]); + }); + + it('(fn) : should replace the selected element with the returned string', function() { + var $fruits = $(fruits); + + $fruits.children().replaceWith(function() { + return '
      • '; + }); + + expect($fruits.find('.first')).to.have.length(3); + }); + + it('(fn) : should replace the selected element with the returned Cheerio object', function() { + var $fruits = $(fruits); + + $fruits.children().replaceWith(function() { + return $('
      • '); + }); + + expect($fruits.find('.second')).to.have.length(3); + }); + + it('(fn) : should replace the selected element with the returned node', function() { + var $fruits = $(fruits); + + $fruits.children().replaceWith(function() { + return $('
      • ')[0]; + }); + + expect($fruits.find('.third')).to.have.length(3); + }); + + }); + + describe('.empty', function() { + + it('() : should remove all children from selected elements', function() { + var $fruits = $(fruits); + $('#fruits', $fruits).empty(); + expect($('#fruits', $fruits).children()).to.have.length(0); + }); + + }); + + describe('.html', function() { + + it('() : should get the innerHTML for an element', function() { + var $fruits = $(fruits); + expect($fruits.html()).to.equal([ + '
      • Apple
      • ', + '
      • Orange
      • ', + '
      • Pear
      • ' + ].join('')); + }); + + it('() : should get innerHTML even if its just text', function() { + var item = '
      • Pear
      • '; + expect($('.pear', item).html()).to.equal('Pear'); + }); + + it('() : should return empty string if nothing inside', function() { + var item = '
      • '; + expect($('li', item).html()).to.equal(''); + }); + + it('(html) : should set the html for its children', function() { + var $fruits = $(fruits); + $fruits.html('
      • Durian
      • '); + var html = $fruits.html(); + expect(html).to.equal('
      • Durian
      • '); + }); + + it('(elem) : should set the html for its children with element', function() { + var $fruits = $(fruits); + $fruits.html($('
      • Durian
      • ')); + var html = $fruits.html(); + expect(html).to.equal('
      • Durian
      • '); + }); + + }); + + describe('.toString', function() { + it('() : should get the outerHTML for an element', function() { + var $fruits = $(fruits); + expect($fruits.toString()).to.equal(fruits); + }); + + it('() : should return an html string for a set of elements', function() { + var $fruits = $(fruits); + expect($fruits.find('li').toString()).to.equal('
      • Apple
      • Orange
      • Pear
      • '); + }); + + it('() : should be called implicitly', function() { + var string = [$(''), $(''), $('')].join(''); + expect(string).to.equal(''); + }); + }); + + describe('.text', function() { + + it('() : gets the text for a single element', function() { + expect($('.apple', fruits).text()).to.equal('Apple'); + }); + + it('() : combines all text from children text nodes', function() { + expect($('#fruits', fruits).text()).to.equal('AppleOrangePear'); + }); + + it('(text) : sets the text for the child node', function() { + var $fruits = $(fruits); + $('.apple', $fruits).text('Granny Smith Apple'); + expect($('.apple', $fruits)[0].children[0].data).to.equal('Granny Smith Apple'); + }); + + it('should allow functions as arguments', function() { + var $fruits = $(fruits); + $('.apple', $fruits).text(function(idx, content) { + expect(idx).to.equal(0); + expect(content).to.equal('Apple'); + return 'whatever mate'; + }); + expect($('.apple', $fruits)[0].children[0].data).to.equal('whatever mate'); + }); + + it('should decode special chars', function() { + var text = $('

        M&M

        ').text(); + expect(text).to.equal('M&M'); + }); + + it('should work with special chars added as strings', function() { + var text = $('

        M&M

        ').text(); + expect(text).to.equal('M&M'); + }); + + it('( undefined ) : should act as an accessor', function() { + var $div = $('
        test
        '); + expect($div.text(undefined)).to.be.a('string'); + expect($div.text()).to.be('test'); + }); + + it('( "" ) : should convert to string', function() { + var $div = $('
        test
        '); + expect($div.text('').text()).to.equal(''); + }); + + it('( null ) : should convert to string', function() { + expect($('
        ').text(null).text()).to.equal('null'); + }); + + it('( 0 ) : should convert to string', function() { + expect($('
        ').text(0).text()).to.equal('0'); + }); + + it('(str) should encode then decode unsafe characters', function() { + var $apple = $('.apple', fruits); + + $apple.text('blah blah'); + expect($apple[0].children[0].data).to.equal('blah <script>alert("XSS!")</script> blah'); + expect($apple.text()).to.equal('blah blah'); + + $apple.text('blah blah'); + expect($apple.html()).to.not.contain(''); + }); + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.traversing.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.traversing.js new file mode 100644 index 00000000..a67614d3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.traversing.js @@ -0,0 +1,740 @@ +var expect = require('expect.js'), + $ = require('../'), + food = require('./fixtures').food, + fruits = require('./fixtures').fruits, + drinks = require('./fixtures').drinks, + text = require('./fixtures').text; + +describe('$(...)', function() { + + describe('.find', function() { + + it('() : should find nothing', function() { + expect($('ul', fruits).find()).to.have.length(0); + }); + + it('(single) : should find one descendant', function() { + expect($('#fruits', fruits).find('.apple')[0].attribs['class']).to.equal('apple'); + }); + + it('(many) : should find all matching descendant', function() { + expect($('#fruits', fruits).find('li')).to.have.length(3); + }); + + it('(many) : should merge all selected elems with matching descendants', function() { + expect($('#fruits, #food', food).find('.apple')).to.have.length(1); + }); + + it('(invalid single) : should return empty if cant find', function() { + expect($('ul', fruits).find('blah')).to.have.length(0); + }); + + it('(invalid single) : should query descendants only', function() { + expect($('#fruits', fruits).find('ul')).to.have.length(0); + }); + + it('should return empty if search already empty result', function() { + expect($('#fruits').find('li')).to.have.length(0); + }); + + it('should throw a SyntaxError if given an invalid selector', function() { + expect(function() { + $('#fruits').find(':bah'); + }).to.throwException(function(err) { + expect(err).to.be.a(SyntaxError); + }); + }); + + }); + + describe('.children', function() { + + it('() : should get all children', function() { + expect($('ul', fruits).children()).to.have.length(3); + }); + + it('() : should return children of all matched elements', function() { + expect($('ul ul', food).children()).to.have.length(5); + }); + + it('(selector) : should return children matching selector', function() { + var cls = $('ul', fruits).children('.orange')[0].attribs['class']; + expect(cls).to.equal('orange'); + }); + + it('(invalid selector) : should return empty', function() { + expect($('ul', fruits).children('.lulz')).to.have.length(0); + }); + + it('should only match immediate children, not ancestors', function() { + expect($(food).children('li')).to.have.length(0); + }); + + }); + + describe('.contents', function() { + + it('() : should get all contents', function() { + expect($('p', text).contents()).to.have.length(5); + }); + + it('() : should include text nodes', function() { + expect($('p', text).contents().first()[0].type).to.equal('text'); + }); + + it('() : should include comment nodes', function() { + expect($('p', text).contents().last()[0].type).to.equal('comment'); + }); + + }); + + describe('.next', function() { + + it('() : should return next element', function() { + var cls = $('.orange', fruits).next()[0].attribs['class']; + expect(cls).to.equal('pear'); + }); + + it('(no next) : should return empty for last child', function() { + expect($('.pear', fruits).next()).to.have.length(0); + }); + + it('(next on empty object) : should return empty', function() { + expect($('.banana', fruits).next()).to.have.length(0); + }); + + it('() : should operate over all elements in the selection', function() { + expect($('.apple, .orange', food).next()).to.have.length(2); + }); + + }); + + describe('.nextAll', function() { + + it('() : should return all following siblings', function() { + var elems = $('.apple', fruits).nextAll(); + expect(elems).to.have.length(2); + expect(elems[0].attribs['class']).to.equal('orange'); + expect(elems[1].attribs['class']).to.equal('pear'); + }); + + it('(no next) : should return empty for last child', function() { + expect($('.pear', fruits).nextAll()).to.have.length(0); + }); + + it('(nextAll on empty object) : should return empty', function() { + expect($('.banana', fruits).nextAll()).to.have.length(0); + }); + + it('() : should operate over all elements in the selection', function() { + expect($('.apple, .carrot', food).nextAll()).to.have.length(3); + }); + + it('() : should not contain duplicate elements', function() { + var elems = $('.apple, .orange', food); + expect(elems.nextAll()).to.have.length(2); + }); + + }); + + describe('.nextUntil', function() { + + it('() : should return all following siblings if no selector specified', function() { + var elems = $('.apple', food).nextUntil(); + expect(elems).to.have.length(2); + expect(elems[0].attribs['class']).to.equal('orange'); + expect(elems[1].attribs['class']).to.equal('pear'); + }); + + it('() : should filter out non-element nodes', function() { + var elems = $('
        text
        '); + var div = elems.children().eq(0); + expect(div.nextUntil()).to.have.length(1); + }); + + it('() : should operate over all elements in the selection', function() { + var elems = $('.apple, .carrot', food); + expect(elems.nextUntil()).to.have.length(3); + }); + + it('() : should not contain duplicate elements', function() { + var elems = $('.apple, .orange', food); + expect(elems.nextUntil()).to.have.length(2); + }); + + it('(selector) : should return all following siblings until selector', function() { + var elems = $('.apple', food).nextUntil('.pear'); + expect(elems).to.have.length(1); + expect(elems[0].attribs['class']).to.equal('orange'); + }); + + it('(selector not sibling) : should return all following siblings', function() { + var elems = $('.apple', fruits).nextUntil('#vegetables'); + expect(elems).to.have.length(2); + }); + + it('(selector, filterString) : should return all following siblings until selector, filtered by filter', function() { + var elems = $('.beer', drinks).nextUntil('.water', '.milk'); + expect(elems).to.have.length(1); + expect(elems[0].attribs['class']).to.equal('milk'); + }); + + it('() : should return an empty object for last child', function() { + expect($('.pear', fruits).nextUntil()).to.have.length(0); + }); + + it('() : should return an empty object when called on an empty object', function() { + expect($('.banana', fruits).nextUntil()).to.have.length(0); + }); + + it('(node) : should return all following siblings until the node', function() { + var $fruits = $(fruits).children(); + var elems = $fruits.eq(0).nextUntil($fruits[2]); + expect(elems).to.have.length(1); + }); + + it('(cheerio object) : should return all following siblings until any member of the cheerio object', function() { + var $drinks = $(drinks).children(); + var $until = $([$drinks[4], $drinks[3]]); + var elems = $drinks.eq(0).nextUntil($until); + expect(elems).to.have.length(2); + }); + + }); + + describe('.prev', function() { + + it('() : should return previous element', function() { + var cls = $('.orange', fruits).prev()[0].attribs['class']; + expect(cls).to.equal('apple'); + }); + + it('(no prev) : should return empty for first child', function() { + expect($('.apple', fruits).prev()).to.have.length(0); + }); + + it('(prev on empty object) : should return empty', function() { + expect($('.banana', fruits).prev()).to.have.length(0); + }); + + it('() : should operate over all elements in the selection', function() { + expect($('.orange, .pear', food).prev()).to.have.length(2); + }); + + }); + + describe('.prevAll', function() { + + it('() : should return all preceding siblings', function() { + var elems = $('.pear', fruits).prevAll(); + expect(elems).to.have.length(2); + expect(elems[0].attribs['class']).to.equal('orange'); + expect(elems[1].attribs['class']).to.equal('apple'); + }); + + it('(no prev) : should return empty for first child', function() { + expect($('.apple', fruits).prevAll()).to.have.length(0); + }); + + it('(prevAll on empty object) : should return empty', function() { + expect($('.banana', fruits).prevAll()).to.have.length(0); + }); + + it('() : should operate over all elements in the selection', function() { + expect($('.orange, .sweetcorn', food).prevAll()).to.have.length(2); + }); + + it('() : should not contain duplicate elements', function() { + var elems = $('.orange, .pear', food); + expect(elems.prevAll()).to.have.length(2); + }); + + }); + + describe('.prevUntil', function() { + + it('() : should return all preceding siblings if no selector specified', function() { + var elems = $('.pear', fruits).prevUntil(); + expect(elems).to.have.length(2); + expect(elems[0].attribs['class']).to.equal('orange'); + expect(elems[1].attribs['class']).to.equal('apple'); + }); + + it('() : should filter out non-element nodes', function() { + var elems = $('
        text
        '); + var div = elems.children().last(); + expect(div.prevUntil()).to.have.length(1); + }); + + it('() : should operate over all elements in the selection', function() { + var elems = $('.pear, .sweetcorn', food); + expect(elems.prevUntil()).to.have.length(3); + }); + + it('() : should not contain duplicate elements', function() { + var elems = $('.orange, .pear', food); + expect(elems.prevUntil()).to.have.length(2); + }); + + it('(selector) : should return all preceding siblings until selector', function() { + var elems = $('.pear', fruits).prevUntil('.apple'); + expect(elems).to.have.length(1); + expect(elems[0].attribs['class']).to.equal('orange'); + }); + + it('(selector not sibling) : should return all preceding siblings', function() { + var elems = $('.sweetcorn', food).prevUntil('#fruits'); + expect(elems).to.have.length(1); + expect(elems[0].attribs['class']).to.equal('carrot'); + }); + + it('(selector, filterString) : should return all preceding siblings until selector, filtered by filter', function() { + var elems = $('.cider', drinks).prevUntil('.juice', '.water'); + expect(elems).to.have.length(1); + expect(elems[0].attribs['class']).to.equal('water'); + }); + + it('() : should return an empty object for first child', function() { + expect($('.apple', fruits).prevUntil()).to.have.length(0); + }); + + it('() : should return an empty object when called on an empty object', function() { + expect($('.banana', fruits).prevUntil()).to.have.length(0); + }); + + it('(node) : should return all previous siblings until the node', function() { + var $fruits = $(fruits).children(); + var elems = $fruits.eq(2).prevUntil($fruits[0]); + expect(elems).to.have.length(1); + }); + + it('(cheerio object) : should return all previous siblings until any member of the cheerio object', function() { + var $drinks = $(drinks).children(); + var $until = $([$drinks[0], $drinks[1]]); + var elems = $drinks.eq(4).prevUntil($until); + expect(elems).to.have.length(2); + }); + + }); + + describe('.siblings', function() { + + it('() : should get all the siblings', function() { + expect($('.orange', fruits).siblings()).to.have.length(2); + expect($('#fruits', fruits).siblings()).to.have.length(0); + expect($('.apple, .carrot', food).siblings()).to.have.length(3); + }); + + it('(selector) : should get all siblings that match the selector', function() { + expect($('.orange', fruits).siblings('.apple')).to.have.length(1); + expect($('.orange', fruits).siblings('.peach')).to.have.length(0); + }); + + it('(selector) : should throw a SyntaxError if given an invalid selector', function() { + expect(function() { + $('.orange', fruits).siblings(':bah'); + }).to.throwException(function(err) { + expect(err).to.be.a(SyntaxError); + }); + }); + + }); + + describe('.parents', function() { + it('() : should get all of the parents in logical order', function(){ + var result = $('.orange', food).parents(); + expect(result).to.have.length(2); + expect(result[0].attribs.id).to.be('fruits'); + expect(result[1].attribs.id).to.be('food'); + result = $('#fruits', food).parents(); + expect(result).to.have.length(1); + expect(result[0].attribs.id).to.be('food'); + }); + it('(selector) : should get all of the parents that match the selector in logical order', function() { + var result = $('.orange', food).parents('#fruits'); + expect(result).to.have.length(1); + expect(result[0].attribs.id).to.be('fruits'); + result = $('.orange', food).parents('ul'); + expect(result).to.have.length(2); + expect(result[0].attribs.id).to.be('fruits'); + expect(result[1].attribs.id).to.be('food'); + }); + it('() : should not break if the selector does not have any results', function() { + var result = $('.saladbar', food).parents(); + expect(result).to.have.length(0); + }); + it('() : should return an empty set for top-level elements', function() { + var result = $('#food', food).parents(); + expect(result).to.have.length(0); + }); + it('() : should return the parents of every element in the *reveresed* collection, omitting duplicates', function() { + var $food = $(food); + var $parents = $food.find('li').parents(); + + expect($parents).to.have.length(3); + expect($parents[0]).to.be($food.find('#vegetables')[0]); + expect($parents[1]).to.be($food[0]); + expect($parents[2]).to.be($food.find('#fruits')[0]); + }); + }); + + describe('.parent', function() { + + it('() : should return the parent of each matched element', function() { + var result = $('.orange', fruits).parent(); + expect(result).to.have.length(1); + expect(result[0].attribs.id).to.be('fruits'); + result = $('li', food).parent(); + expect(result).to.have.length(2); + expect(result[0].attribs.id).to.be('fruits'); + expect(result[1].attribs.id).to.be('vegetables'); + }); + + it('() : should return an empty object for top-level elements', function() { + var result = $('ul', fruits).parent(); + expect(result).to.have.length(0); + }); + + it('() : should not contain duplicate elements', function() { + var result = $('li', fruits).parent(); + expect(result).to.have.length(1); + }); + + it('(selector) : should filter the matched parent elements by the selector', function() { + var result = $('.orange', fruits).parent(); + expect(result).to.have.length(1); + expect(result[0].attribs.id).to.be('fruits'); + result = $('li', food).parent('#fruits'); + expect(result).to.have.length(1); + expect(result[0].attribs.id).to.be('fruits'); + }); + + }); + + describe('.closest', function() { + + it('() : should return an empty array', function() { + var result = $('.orange', fruits).closest(); + expect(result).to.have.length(0); + expect(result).to.be.a($); + }); + + it('(selector) : should find the closest element that matches the selector, searching through its ancestors and itself', function() { + expect($('.orange', fruits).closest('.apple')).to.have.length(0); + var result = $('.orange', food).closest('#food'); + expect(result[0].attribs.id).to.be('food'); + result = $('.orange', food).closest('ul'); + expect(result[0].attribs.id).to.be('fruits'); + result = $('.orange', food).closest('li'); + expect(result[0].attribs['class']).to.be('orange'); + }); + + it('(selector) : should find the closest element of each item, removing duplicates', function() { + var result = $('li', food).closest('ul'); + expect(result).to.have.length(2); + }); + + it('() : should not break if the selector does not have any results', function() { + var result = $('.saladbar', food).closest('ul'); + expect(result).to.have.length(0); + }); + + }); + + describe('.each', function() { + + it('( (i, elem) -> ) : should loop selected returning fn with (i, elem)', function() { + var items = [], + classes = ['apple', 'orange', 'pear']; + $('li', fruits).each(function(idx, elem) { + items[idx] = elem; + expect(this[0].attribs['class']).to.equal(classes[idx]); + }); + expect(items[0].attribs['class']).to.equal('apple'); + expect(items[1].attribs['class']).to.equal('orange'); + expect(items[2].attribs['class']).to.equal('pear'); + }); + + it('( (i, elem) -> ) : should break iteration when the iterator function returns false', function() { + var iterationCount = 0; + $('li', fruits).each(function(idx, elem) { + iterationCount++; + return idx < 1; + }); + + expect(iterationCount).to.equal(2); + }); + + }); + + describe('.map', function() { + it('(fn) : should be invoked with the correct arguments and context', function() { + var $fruits = $('li', fruits); + var args = []; + var thisVals = []; + + $fruits.map(function() { + args.push(arguments); + thisVals.push(this); + }); + + expect(args).to.eql([ + [0, $fruits[0]], + [1, $fruits[1]], + [2, $fruits[2]] + ]); + expect(thisVals).to.eql([ + $fruits[0], + $fruits[1], + $fruits[2] + ]); + }); + + it('(fn) : should return an Cheerio object wrapping the returned items', function() { + var $fruits = $('li', fruits); + var $mapped = $fruits.map(function(i, el) { + return $fruits[2 - i]; + }); + + expect($mapped).to.have.length(3); + expect($mapped[0]).to.be($fruits[2]); + expect($mapped[1]).to.be($fruits[1]); + expect($mapped[2]).to.be($fruits[0]); + }); + + it('(fn) : should ignore `null` and `undefined` returned by iterator', function() { + var $fruits = $('li', fruits); + var retVals = [null, undefined, $fruits[1]]; + + var $mapped = $fruits.map(function(i, el) { + return retVals[i]; + }); + + expect($mapped).to.have.length(1); + expect($mapped[0]).to.be($fruits[1]); + }); + + it('(fn) : should preform a shallow merge on arrays returned by iterator', function() { + var $fruits = $('li', fruits); + + var $mapped = $fruits.map(function(i, el) { + return [1, [3, 4]]; + }); + + expect($mapped.toArray()).to.eql([ + 1, [3, 4], + 1, [3, 4], + 1, [3, 4] + ]); + }); + + it('(fn) : should tolerate `null` and `undefined` when flattening arrays returned by iterator', function() { + var $fruits = $('li', fruits); + + var $mapped = $fruits.map(function(i, el) { + return [null, undefined]; + }); + + expect($mapped.toArray()).to.eql([ + null, undefined, + null, undefined, + null, undefined, + ]); + }); + }); + + describe('.filter', function() { + it('(selector) : should reduce the set of matched elements to those that match the selector', function() { + var pear = $('li', fruits).filter('.pear').text(); + expect(pear).to.be('Pear'); + }); + + it('(selector) : should not consider nested elements', function() { + var lis = $(fruits).filter('li'); + expect(lis).to.have.length(0); + }); + + it('(selection) : should reduce the set of matched elements to those that are contained in the provided selection', function() { + var $fruits = $('li', fruits); + var $pear = $fruits.filter('.pear, .apple'); + expect($fruits.filter($pear)).to.have.length(2); + }); + + it('(element) : should reduce the set of matched elements to those that specified directly', function() { + var $fruits = $('li', fruits); + var pear = $fruits.filter('.pear')[0]; + expect($fruits.filter(pear)).to.have.length(1); + }); + + it('(fn) : should reduce the set of matched elements to those that pass the function\'s test', function() { + var orange = $('li', fruits).filter(function(i, el) { + expect(this[0]).to.be(el); + expect(el.name).to.be('li'); + expect(i).to.be.a('number'); + return this.attr('class') === 'orange'; + }).text(); + + expect(orange).to.be('Orange'); + }); + }); + + describe('.first', function() { + + it('() : should return the first item', function() { + var $src = $('foobarbaz'); + var $elem = $src.first(); + expect($elem.length).to.equal(1); + expect($elem[0].children[0].data).to.equal('foo'); + }); + + it('() : should return an empty object for an empty object', function() { + var $src = $(); + var $first = $src.first(); + expect($first.length).to.equal(0); + expect($first[0]).to.be(undefined); + }); + + }); + + describe('.last', function() { + + it('() : should return the last element', function() { + var $src = $('foobarbaz'); + var $elem = $src.last(); + expect($elem.length).to.equal(1); + expect($elem[0].children[0].data).to.equal('baz'); + }); + + it('() : should return an empty object for an empty object', function() { + var $src = $(); + var $last = $src.last(); + expect($last.length).to.equal(0); + expect($last[0]).to.be(undefined); + }); + + }); + + describe('.first & .last', function() { + + it('() : should return equivalent collections if only one element', function() { + var $src = $('bar'); + var $first = $src.first(); + var $last = $src.last(); + expect($first.length).to.equal(1); + expect($first[0].children[0].data).to.equal('bar'); + expect($last.length).to.equal(1); + expect($last[0].children[0].data).to.equal('bar'); + expect($first[0]).to.equal($last[0]); + }); + + }); + + describe('.eq', function() { + + function getText(el) { + if(!el.length) return ''; + return el[0].children[0].data; + } + + it('(i) : should return the element at the specified index', function() { + expect(getText($('li', fruits).eq(0))).to.equal('Apple'); + expect(getText($('li', fruits).eq(1))).to.equal('Orange'); + expect(getText($('li', fruits).eq(2))).to.equal('Pear'); + expect(getText($('li', fruits).eq(3))).to.equal(''); + expect(getText($('li', fruits).eq(-1))).to.equal('Pear'); + }); + + }); + + describe('.slice', function() { + + function getText(el) { + if(!el.length) return ''; + return el[0].children[0].data; + } + + it('(start) : should return all elements after the given index', function() { + var sliced = $('li', fruits).slice(1); + expect(sliced).to.have.length(2); + expect(getText(sliced.eq(0))).to.equal('Orange'); + expect(getText(sliced.eq(1))).to.equal('Pear'); + }); + + it('(start, end) : should return all elements matching the given range', function() { + var sliced = $('li', fruits).slice(1, 2); + expect(sliced).to.have.length(1); + expect(getText(sliced.eq(0))).to.equal('Orange'); + }); + + it('(-start) : should return element matching the offset from the end', function() { + var sliced = $('li', fruits).slice(-1); + expect(sliced).to.have.length(1); + expect(getText(sliced.eq(0))).to.equal('Pear'); + }); + + }); + + describe('.end() :', function() { + var $fruits = $(fruits).children(); + + it('returns an empty object at the end of the chain', function() { + expect($fruits.end().end()).to.be.ok(); + expect($fruits.end().end()).to.have.length(0); + }); + it('find', function() { + expect($fruits.find('.apple').end()).to.be($fruits); + }); + it('filter', function() { + expect($fruits.filter('.apple').end()).to.be($fruits); + }); + it('map', function() { + expect($fruits.map(function() { return this; }).end()).to.be($fruits); + }); + it('contents', function() { + expect($fruits.contents().end()).to.be($fruits); + }); + it('eq', function() { + expect($fruits.eq(1).end()).to.be($fruits); + }); + it('first', function() { + expect($fruits.first().end()).to.be($fruits); + }); + it('last', function() { + expect($fruits.last().end()).to.be($fruits); + }); + it('slice', function() { + expect($fruits.slice(1).end()).to.be($fruits); + }); + it('children', function() { + expect($fruits.children().end()).to.be($fruits); + }); + it('parent', function() { + expect($fruits.parent().end()).to.be($fruits); + }); + it('parents', function() { + expect($fruits.parents().end()).to.be($fruits); + }); + it('closest', function() { + expect($fruits.closest('ul').end()).to.be($fruits); + }); + it('siblings', function() { + expect($fruits.siblings().end()).to.be($fruits); + }); + it('next', function() { + expect($fruits.next().end()).to.be($fruits); + }); + it('nextAll', function() { + expect($fruits.nextAll().end()).to.be($fruits); + }); + it('prev', function() { + expect($fruits.prev().end()).to.be($fruits); + }); + it('prevAll', function() { + expect($fruits.prevAll().end()).to.be($fruits); + }); + it('clone', function() { + expect($fruits.clone().end()).to.be($fruits); + }); + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.utils.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.utils.js new file mode 100644 index 00000000..348aae38 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/api.utils.js @@ -0,0 +1,162 @@ +var expect = require('expect.js'), + fixtures = require('./fixtures'), + $ = require('../'); + + +describe('$', function() { + + describe('.html', function() { + + it('() : should return innerHTML; $.html(obj) should return outerHTML', function() { + var $div = $('div', '
        foobar
        '); + var span = $div.children()[1]; + expect($(span).html()).to.equal('bar'); + expect($.html(span)).to.equal('bar'); + }); + + it('() : should accept an object, an array, or a cheerio object', function() { + var $span = $('foo'); + expect($.html($span[0])).to.equal('foo'); + expect($.html($span)).to.equal('foo'); + }); + + it('() : should be able to set to an empty string', function() { + var $elem = $('foo').html(''); + expect($.html($elem)).to.equal(''); + }); + + it('() : of empty cheerio object should return null', function() { + expect($().html()).to.be(null); + }); + + it('(selector) : should return the outerHTML of the selected element', function() { + var _$ = $.load(fixtures.fruits); + expect(_$.html('.pear')).to.equal('
      • Pear
      • '); + }); + }); + + + + describe('.load', function() { + + it('(html) : should retain original root after creating a new node', function() { + var $html = $.load('
          '); + expect($html('body')).to.have.length(1); + $html('', { xmlMode : true }); + // console.log($html('script')[0].type); + // expect($html('script')[0].type).to.be('tag'); + // }); + + }); + + + describe('.clone', function() { + + it('() : should return a copy', function() { + var $src = $('
          foobarbaz
          ').children(); + var $elem = $src.clone(); + expect($elem.length).to.equal(3); + expect($elem.parent()).to.have.length(0); + expect($elem.text()).to.equal($src.text()); + $src.text('rofl'); + expect($elem.text()).to.not.equal($src.text()); + }); + + }); + + describe('.parseHTML', function() { + + it('() : returns null', function() { + expect($.parseHTML()).to.equal(null); + }); + + it('(null) : returns null', function() { + expect($.parseHTML(null)).to.equal(null); + }); + + it('("") : returns null', function() { + expect($.parseHTML('')).to.equal(null); + }); + + it('(largeHtmlString) : parses large HTML strings', function() { + var html = new Array(10).join('
          '); + var nodes = $.parseHTML(html); + + expect(nodes.length).to.be.greaterThan(4); + expect(nodes).to.be.an('array'); + }); + + it('("'; + expect($.parseHTML(html)).to.have.length(0); + }); + + it('("'; + expect($.parseHTML(html, true)[0].name).to.match(/script/i); + }); + + it('("scriptAndNonScript) : preserves non-script nodes', function() { + var html = '
          '; + expect($.parseHTML(html)[0].name).to.match(/div/i); + }); + + it('(scriptAndNonScript, true) : Preserves script position', function() { + var html = '
          '; + expect($.parseHTML(html, true)[0].name).to.match(/script/i); + }); + + it('(text) : returns a text node', function() { + expect($.parseHTML('text')[0].type).to.be('text'); + }); + + it('(\\ttext) : preserves leading whitespace', function() { + expect($.parseHTML('\t
          ')[0].data).to.equal('\t'); + }); + + it('( text) : Leading spaces are treated as text nodes', function() { + expect($.parseHTML('
          ')[0].type).to.be('text'); + }); + + it('(html) : should preserve content', function() { + var html = '
          test div
          '; + expect($($.parseHTML(html)[0]).html()).to.equal('test div'); + }); + + it('(malformedHtml) : should not break', function() { + expect($.parseHTML('')).to.have.length(1); + }); + + it('(garbageInput) : should not cause an error', function() { + expect($.parseHTML('<#if>

          This is a test.

          <#/if>') || true).to.be.ok(); + }); + + }); + + describe('.root', function() { + + it('() : should return a cheerio-wrapped root object', function() { + var $html = $.load('
          foobar
          '); + $html.root().append('
          '); + expect($html.html()).to.equal('
          foobar
          '); + }); + + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/cheerio.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/cheerio.js new file mode 100644 index 00000000..17869585 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/cheerio.js @@ -0,0 +1,223 @@ +var expect = require('expect.js'), + _ = require('underscore'), + $ = require('../'), + fixtures = require('./fixtures'), + fruits = fixtures.fruits, + food = fixtures.food; + +// HTML +var script = '', + multiclass = '

          Save

          '; + +describe('cheerio', function() { + + it('should get the version', function() { + expect(/\d+\.\d+\.\d+/.test($.version)).to.be.ok(); + }); + + it('$(null) should return be empty', function() { + expect($(null)).to.be.empty(); + }); + + it('$(undefined) should be empty', function() { + expect($(undefined)).to.be.empty(); + }); + + it('$(null) should be empty', function() { + expect($('')).to.be.empty(); + }); + + it('$(selector) with no context or root should be empty', function() { + expect($('.h2')).to.be.empty(); + expect($('#fruits')).to.be.empty(); + }); + + it('$(node) : should override previously-loaded nodes', function() { + var C = $.load('
          '); + var spanNode = C('span')[0]; + var $span = C(spanNode); + expect($span[0]).to.equal(spanNode); + }); + + it('should be able to create html without a root or context', function() { + var $h2 = $('

          '); + expect($h2).to.not.be.empty(); + expect($h2).to.have.length(1); + expect($h2[0].name).to.equal('h2'); + }); + + it('should be able to create complicated html', function() { + var $script = $(script); + expect($script).to.not.be.empty(); + expect($script).to.have.length(1); + expect($script[0].attribs.src).to.equal('script.js'); + expect($script[0].attribs.type).to.equal('text/javascript'); + expect($script[0].children).to.be.empty(); + }); + + var testAppleSelect = function($apple) { + expect($apple).to.have.length(1); + $apple = $apple[0]; + expect($apple.parent.name).to.equal('ul'); + expect($apple.prev).to.be(null); + expect($apple.next.attribs['class']).to.equal('orange'); + expect($apple.children).to.have.length(1); + expect($apple.children[0].data).to.equal('Apple'); + }; + + it('should be able to select .apple with only a context', function() { + var $apple = $('.apple', fruits); + testAppleSelect($apple); + }); + + it('should be able to select .apple with only a root', function() { + var $apple = $('.apple', null, fruits); + testAppleSelect($apple); + }); + + it('should be able to select an id', function() { + var $fruits = $('#fruits', null, fruits); + expect($fruits).to.have.length(1); + expect($fruits[0].attribs.id).to.equal('fruits'); + }); + + it('should be able to select a tag', function() { + var $ul = $('ul', fruits); + expect($ul).to.have.length(1); + expect($ul[0].name).to.equal('ul'); + }); + + it('should be able to filter down using the context', function() { + var q = $.load(fruits), + apple = q('.apple', 'ul'), + lis = q('li', 'ul'); + + expect(apple).to.have.length(1); + expect(lis).to.have.length(3); + }); + + it('should select only elements inside given context (Issue #193)', function() { + var q = $.load(food), + fruits = q('#fruits'), + fruitElements = q('li', fruits); + + expect(fruitElements).to.have.length(3); + }); + + it('should be able to select multiple tags', function() { + var $fruits = $('li', null, fruits); + expect($fruits).to.have.length(3); + var classes = ['apple', 'orange', 'pear']; + $fruits.each(function(idx, $fruit) { + expect($fruit.attribs['class']).to.equal(classes[idx]); + }); + }); + + it('should be able to do: $("#fruits .apple")', function() { + var $apple = $('#fruits .apple', fruits); + testAppleSelect($apple); + }); + + it('should be able to do: $("li.apple")', function() { + var $apple = $('li.apple', fruits); + testAppleSelect($apple); + }); + + it('should be able to select by attributes', function() { + var $apple = $('li[class=apple]', fruits); + testAppleSelect($apple); + }); + + it('should be able to select multiple classes: $(".btn.primary")', function() { + var $a = $('.btn.primary', multiclass); + expect($a).to.have.length(1); + expect($a[0].children[0].data).to.equal('Save'); + }); + + it('should not create a top-level node', function() { + var $elem = $('* div', '
          '); + expect($elem).to.have.length(0); + }); + + it('should be able to select multiple elements: $(".apple, #fruits")', function() { + var $elems = $('.apple, #fruits', fruits); + expect($elems).to.have.length(2); + + var $apple = _($elems).filter(function(elem) { + return elem.attribs['class'] === 'apple'; + }); + var $fruits = _($elems).filter(function(elem) { + return elem.attribs.id === 'fruits'; + }); + testAppleSelect($apple); + expect($fruits[0].attribs.id).to.equal('fruits'); + }); + + it('should select first element $(:first)'); + // var $elem = $(':first', fruits); + // var $h2 = $('

          fruits

          '); + // console.log($elem.before('hi')); + // console.log($elem.before($h2)); + + it('should be able to select immediate children: $("#fruits > .pear")', function() { + var $food = $(food); + $('.pear', $food).append('
        • Another Pear!
        • '); + expect($('#fruits .pear', $food)).to.have.length(2); + var $elem = $('#fruits > .pear', $food); + expect($elem).to.have.length(1); + expect($elem.attr('class')).to.equal('pear'); + }); + + it('should be able to select immediate children: $(".apple + .pear")', function() { + var $elem = $('.apple + li', fruits); + expect($elem).to.have.length(1); + $elem = $('.apple + .pear', fruits); + expect($elem).to.have.length(0); + $elem = $('.apple + .orange', fruits); + expect($elem).to.have.length(1); + expect($elem.attr('class')).to.equal('orange'); + }); + + it('should be able to select immediate children: $(".apple ~ .pear")', function() { + var $elem = $('.apple ~ li', fruits); + expect($elem).to.have.length(2); + $elem = $('.apple ~ .pear', fruits); + expect($elem.attr('class')).to.equal('pear'); + }); + + it('should handle wildcards on attributes: $("li[class*=r]")', function() { + var $elem = $('li[class*=r]', fruits); + expect($elem).to.have.length(2); + expect($elem.eq(0).attr('class')).to.equal('orange'); + expect($elem.eq(1).attr('class')).to.equal('pear'); + }); + + it('should handle beginning of attr selectors: $("li[class^=o]")', function() { + var $elem = $('li[class^=o]', fruits); + expect($elem).to.have.length(1); + expect($elem.eq(0).attr('class')).to.equal('orange'); + }); + + it('should handle beginning of attr selectors: $("li[class$=e]")', function() { + var $elem = $('li[class$=e]', fruits); + expect($elem).to.have.length(2); + expect($elem.eq(0).attr('class')).to.equal('apple'); + expect($elem.eq(1).attr('class')).to.equal('orange'); + }); + + it('should gracefully degrade on complex, unmatched queries', function() { + var $elem = $('Eastern States Cup #8-fin 
          Downhill '); + expect($elem).to.have.length(0); // [] + }); + + it('(extended Array) should not interfere with prototype methods (issue #119)', function() { + var extended = []; + var custom = extended.find = extended.children = extended.each = function() {}; + var $empty = $(extended); + + expect($empty.find).to.be($.prototype.find); + expect($empty.children).to.be($.prototype.children); + expect($empty.each).to.be($.prototype.each); + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/fixtures.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/fixtures.js new file mode 100644 index 00000000..0762f127 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/fixtures.js @@ -0,0 +1,53 @@ +/* jshint indent: false */ +exports.fruits = [ + '
            ', + '
          • Apple
          • ', + '
          • Orange
          • ', + '
          • Pear
          • ', + '
          ' +].join(''); + +exports.vegetables = [ + '
            ', + '
          • Carrot
          • ', + '
          • Sweetcorn
          • ', + '
          ' +].join(''); + +exports.chocolates = [ + '
            ', + '
          • Linth
          • ', + '
          • Frey
          • ', + '
          • Cailler
          • ', + '
          ' +].join(''); + +exports.drinks = [ + '
            ', + '
          • Beer
          • ', + '
          • Juice
          • ', + '
          • Milk
          • ', + '
          • Water
          • ', + '
          • Cider
          • ', + '
          ' +].join(''); + +exports.food = [ + '
            ', + exports.fruits, + exports.vegetables, + '
          ' +].join(''); + +exports.inputs = [ + '', + '', + '', + '', + '' +].join(''); + +exports.text = [ + '

          Apples, oranges and pears.

          ', + '

          Carrots and

          ' +].join(''); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/mocha.opts b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/mocha.opts new file mode 100644 index 00000000..9431de4c --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/mocha.opts @@ -0,0 +1,2 @@ +--reporter list +--growl \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/parse.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/parse.js new file mode 100644 index 00000000..ab6eacc7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/parse.js @@ -0,0 +1,217 @@ +var expect = require('expect.js'), + parse = require('../lib/parse'); + + +// Tags +var basic = ''; +var siblings = '

          '; + +// Single Tags +var single = '
          '; +var singleWrong = '
          '; + +// Children +var children = '
          '; +var li = '
        • Durian
        • '; + +// Attributes +var attributes = 'man waving'; +var noValueAttribute = ''; + +// Comments +var comment = ''; +var conditional = ''; + +// Text +var text = 'lorem ipsum'; + +// Script +var script = ''; +var scriptEmpty = ''; + +// Style +var style = ''; +var styleEmpty = ''; + +// Directives +var directive = ''; + + +describe('parse', function() { + + describe('.eval', function() { + + it('should parse basic empty tags: ' + basic, function() { + var tag = parse.evaluate(basic)[0]; + expect(tag.type).to.equal('tag'); + expect(tag.name).to.equal('html'); + expect(tag.children).to.be.empty(); + }); + + it('should handle sibling tags: ' + siblings, function() { + var dom = parse.evaluate(siblings), + h2 = dom[0], + p = dom[1]; + + expect(dom).to.have.length(2); + expect(h2.name).to.equal('h2'); + expect(p.name).to.equal('p'); + }); + + it('should handle single tags: ' + single, function() { + var tag = parse.evaluate(single)[0]; + expect(tag.type).to.equal('tag'); + expect(tag.name).to.equal('br'); + expect(tag.children).to.be.empty(); + }); + + it('should handle malformatted single tags: ' + singleWrong, function() { + var tag = parse.evaluate(singleWrong)[0]; + expect(tag.type).to.equal('tag'); + expect(tag.name).to.equal('br'); + expect(tag.children).to.be.empty(); + }); + + it('should handle tags with children: ' + children, function() { + var tag = parse.evaluate(children)[0]; + expect(tag.type).to.equal('tag'); + expect(tag.name).to.equal('html'); + expect(tag.children).to.be.ok(); + expect(tag.children).to.have.length(1); + }); + + it('should handle tags with children: ' + li, function() { + var tag = parse.evaluate(li)[0]; + expect(tag.children).to.have.length(1); + expect(tag.children[0].data).to.equal('Durian'); + }); + + it('should handle tags with attributes: ' + attributes, function() { + var attrs = parse.evaluate(attributes)[0].attribs; + expect(attrs).to.be.ok(); + expect(attrs.src).to.equal('hello.png'); + expect(attrs.alt).to.equal('man waving'); + }); + + it('should handle value-less attributes: ' + noValueAttribute, function() { + var attrs = parse.evaluate(noValueAttribute)[0].attribs; + expect(attrs).to.be.ok(); + expect(attrs.disabled).to.equal(''); + }); + + it('should handle comments: ' + comment, function() { + var elem = parse.evaluate(comment)[0]; + expect(elem.type).to.equal('comment'); + expect(elem.data).to.equal(' sexy '); + }); + + it('should handle conditional comments: ' + conditional, function() { + var elem = parse.evaluate(conditional)[0]; + expect(elem.type).to.equal('comment'); + expect(elem.data).to.equal(conditional.replace('', '')); + }); + + it('should handle text: ' + text, function() { + var text_ = parse.evaluate(text)[0]; + expect(text_.type).to.equal('text'); + expect(text_.data).to.equal('lorem ipsum'); + }); + + it('should handle script tags: ' + script, function() { + var script_ = parse.evaluate(script)[0]; + expect(script_.type).to.equal('script'); + expect(script_.name).to.equal('script'); + expect(script_.attribs.type).to.equal('text/javascript'); + expect(script_.children).to.have.length(1); + expect(script_.children[0].type).to.equal('text'); + expect(script_.children[0].data).to.equal('alert("hi world!");'); + }); + + it('should handle style tags: ' + style, function() { + var style_ = parse.evaluate(style)[0]; + expect(style_.type).to.equal('style'); + expect(style_.name).to.equal('style'); + expect(style_.attribs.type).to.equal('text/css'); + expect(style_.children).to.have.length(1); + expect(style_.children[0].type).to.equal('text'); + expect(style_.children[0].data).to.equal(' h2 { color:blue; } '); + }); + + it('should handle directives: ' + directive, function() { + var elem = parse.evaluate(directive)[0]; + expect(elem.type).to.equal('directive'); + expect(elem.data).to.equal('!doctype html'); + expect(elem.name).to.equal('!doctype'); + }); + + }); + + describe('.parse', function() { + + // root test utility + function rootTest(root) { + expect(root.name).to.equal('root'); + + // Should exist but be null + expect(root.next).to.be(null); + expect(root.prev).to.be(null); + expect(root.parent).to.be(null); + + var child = root.children[0]; + expect(child.parent).to.be(null); + } + + it('should add root to: ' + basic, function() { + var root = parse(basic); + rootTest(root); + expect(root.children).to.have.length(1); + expect(root.children[0].name).to.equal('html'); + }); + + it('should add root to: ' + siblings, function() { + var root = parse(siblings); + rootTest(root); + expect(root.children).to.have.length(2); + expect(root.children[0].name).to.equal('h2'); + expect(root.children[1].name).to.equal('p'); + expect(root.children[1].parent).to.equal(null); + }); + + it('should add root to: ' + comment, function() { + var root = parse(comment); + rootTest(root); + expect(root.children).to.have.length(1); + expect(root.children[0].type).to.equal('comment'); + }); + + it('should add root to: ' + text, function() { + var root = parse(text); + rootTest(root); + expect(root.children).to.have.length(1); + expect(root.children[0].type).to.equal('text'); + }); + + it('should add root to: ' + scriptEmpty, function() { + var root = parse(scriptEmpty); + rootTest(root); + expect(root.children).to.have.length(1); + expect(root.children[0].type).to.equal('script'); + }); + + it('should add root to: ' + styleEmpty, function() { + var root = parse(styleEmpty); + rootTest(root); + expect(root.children).to.have.length(1); + expect(root.children[0].type).to.equal('style'); + }); + + it('should add root to: ' + directive, function() { + var root = parse(directive); + rootTest(root); + expect(root.children).to.have.length(1); + expect(root.children[0].type).to.equal('directive'); + }); + + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/render.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/render.js new file mode 100644 index 00000000..02425096 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/render.js @@ -0,0 +1,62 @@ +var expect = require('expect.js'), + parse = require('../lib/parse'), + render = require('../lib/render'); + +var html = function(str, options) { + options = options || {}; + var dom = parse(str, options); + return render(dom); +}; + +describe('render', function() { + + describe('(html)', function() { + + it('should render
          tags correctly', function() { + var str = '
          '; + expect(html(str)).to.equal('
          '); + }); + + it('should handle double quotes within single quoted attributes properly', function() { + var str = '
          '; + expect(html(str)).to.equal('
          '); + }); + + it('should retain encoded HTML content within attributes', function() { + var str = '
          '; + expect(html(str)).to.equal('
          '); + }); + + it('should shorten the "checked" attribute when it contains the value "checked"', function() { + var str = ''; + expect(html(str)).to.equal(''); + }); + + it('should not shorten the "name" attribute when it contains the value "name"', function() { + var str = ''; + expect(html(str)).to.equal(''); + }); + + it('should render comments correctly', function() { + var str = ''; + expect(html(str)).to.equal(''); + }); + + it('should render whitespace by default', function() { + var str = 'hi
          blah'; + expect(html(str)).to.equal(str); + }); + + it('should normalize whitespace if specified', function() { + var str = 'hi blah '; + expect(html(str, { normalizeWhitespace: true })).to.equal('hi blah '); + }); + + it('should preserve multiple hyphens in data attributes', function() { + var str = '
          '; + expect(html(str)).to.equal('
          '); + }); + + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/utilities.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/utilities.js new file mode 100644 index 00000000..84171665 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/utilities.js @@ -0,0 +1,33 @@ +var expect = require('expect.js'), + $ = require('../'), + food = require('./fixtures').food; + +describe('utility methods', function() { + + describe('.contains', function() { + + it('(container, contained) : should correctly detect the provided element', function() { + var $food = $(food); + var $fruits = $food.find('#fruits'); + var $apple = $fruits.find('.apple'); + + expect($.contains($food[0], $fruits[0])).to.equal(true); + expect($.contains($food[0], $apple[0])).to.equal(true); + }); + + it('(container, other) : should not detect elements that are not contained', function() { + var $food = $(food); + var $fruits = $food.find('#fruits'); + var $vegetables = $food.find('#vegetables'); + var $apple = $fruits.find('.apple'); + + expect($.contains($vegetables[0], $apple[0])).to.equal(false); + expect($.contains($fruits[0], $vegetables[0])).to.equal(false); + expect($.contains($vegetables[0], $fruits[0])).to.equal(false); + expect($.contains($fruits[0], $fruits[0])).to.equal(false); + expect($.contains($vegetables[0], $vegetables[0])).to.equal(false); + }); + + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/xml.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/xml.js new file mode 100644 index 00000000..d3a0bea6 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/cheerio/test/xml.js @@ -0,0 +1,27 @@ +var expect = require('expect.js'), + _ = require('underscore'), + cheerio = require('../lib/cheerio'); + +var xml = function(str, options) { + options = _.extend({ xmlMode: true }, options); + var dom = cheerio.load(str, options); + return dom.xml(); +}; + +describe('render', function() { + + describe('(xml)', function() { + + it('should render tags correctly', function() { + var str = ''; + expect(xml(str)).to.equal(''); + }); + + it('should render tags (RSS) correctly', function() { + var str = 'http://www.github.com/'; + expect(xml(str)).to.equal('http://www.github.com/'); + }); + + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/.npmignore new file mode 100644 index 00000000..78cdbf85 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/.npmignore @@ -0,0 +1,15 @@ +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +npm-debug.log +node_modules diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/README.md new file mode 100644 index 00000000..ed53ccf8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/README.md @@ -0,0 +1,56 @@ +# hyperdirect + +Follow redirects for hyperquest GET requests. Process all other requests exactly as normal. + +## Installation + + $ npm install hyperdirect + +## Usage + +```js +//basic usage +var request = require('hyperquest').request; + +request('https://github.com/ForbesLindesay/hyperdirect/archive/master.tar.gz') + .pipe(require('fs').createWriteStream(__dirname + '/hyperdirect.tar.gz')); + +//moderate usage +var request = require('hyperquest')(2/* Max Redirects to follow, defaults to 10 */); + +request('https://github.com/ForbesLindesay/hyperdirect/archive/master.tar.gz') + .pipe(require('fs').createWriteStream(__dirname + '/hyperdirect.tar.gz')); + +//advanced usage +var hyperdirect = require('hyperdirect')(5, require('hyperquest')); +``` + +## API + +### hyperdirect(maxRedirects, subquest) + +Returns a new function with the same API as [hyperquest](https://github.com/hyperquest/hyperquest) but which follows redirects for GET requests. Both `maxRedirects` and `subquest` are optional and can be in either order. + +If provided, `subquest` should be a function which matches the API of [hyperquest](https://github.com/hyperquest/hyperquest) or an object of the form `{request: hyperquest}` where `hyperquest` is a function matching the API of [hyperquest](https://github.com/hyperquest/hyperquest). + +`maxRedirects` will default to `10`. Once the request has been redirected more times than that it will give up and throw an error. The error has a `res` and `statusCode` property set to the apropriate properties from the last request made. + +The returned stream will emit `redirect` events with the response of any request that results in another redirect. This means you could trace the path something a request took by doing: + +```js +require('hyperdirect')(100)(url) + .on('redirect', function (res) { + console.log('REDIRECT ' + res.statusCode + ': ' + res.headers.location); + }) + .on('response', function (res) { + console.log('FINAL URL: ' + res.url); + }); +``` + +### hyperdirect.request(uri, opts, cb) + +Follows exactly the same API as [hyperquest](https://github.com/hyperquest/hyperquest) but automatically follows up to 10 redirects for GET requests. It's the same as what you get by calling `hyperdirect()`. + +## License + +MIT \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/index.js new file mode 100644 index 00000000..d2da4bc4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/index.js @@ -0,0 +1,68 @@ +var through = require('through'); +var hyperquest = require('hyperquest'); + +module.exports = direct; +module.exports.request = direct(hyperquest); + +function direct(subquest, maxRedirects) { + if (typeof subquest === 'number') { + var tmp = subquest; + subquest = maxRedirects; + maxRedirects = tmp; + } + if (subquest === undefined) subquest = hyperquest; + if (maxRedirects === undefined) maxRedirects = 10; + if (typeof subquest.request === 'function') subquest = subquest.request; + if (subquest.isCap) throw new Error('The subquest argument "' + subquest + '" was invalid. You must use a valid hyperquest module that is not a cap.'); + function request(uri, opts, cb) { + if (typeof uri === 'object') { + cb = opts; + opts = uri; + uri = undefined; + } + if (typeof opts === 'function') { + cb = opts; + opts = undefined; + } + if (!opts) opts = {}; + if (uri !== undefined) opts.uri = uri; + + var method = (opts.method || 'GET').toUpperCase(); + if (method != 'GET') return subquest(opts, cb); + + var rs = through(); + var remainingRedirects = maxRedirects; + function doRequest() { + if (remainingRedirects < 0) { + rs.emit('error', new Error('The response was redirected ' + (maxRedirects + 1) + ' times and the `maxRedirects` option was set to ' + maxRedirects)) + } + subquest(opts, function (err, res) { + if (err) return rs.emit('error', err); + res.url = opts.uri; + if (isRedirect(res.statusCode)) { + remainingRedirects--; + rs.emit('redirect', res); + opts.uri = res.headers.location; + return doRequest(); + } + rs.emit('response', res); + this.pipe(rs); + }); + } + doRequest(); + + if (cb) { + rs.on('error', cb); + rs.on('response', function (res) { + cb.call(rs, null, res); + }); + } + return rs; + } + request.request = request; + return request; +} + +function isRedirect(statusCode) { + return statusCode === 301 || statusCode === 302 || statusCode === 307 || statusCode === 308; +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/.travis.yml new file mode 100644 index 00000000..dad2273c --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.8 + - "0.10" diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/LICENSE new file mode 100644 index 00000000..ee27ba4b --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/example/req.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/example/req.js new file mode 100644 index 00000000..2d73de7e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/example/req.js @@ -0,0 +1,2 @@ +var hyperquest = require('../'); +hyperquest('http://localhost:8000').pipe(process.stdout); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/index.js new file mode 100644 index 00000000..73d66748 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/index.js @@ -0,0 +1,139 @@ +var url = require('url'); +var http = require('http'); +var https = require('https'); +var through = require('through'); +var duplexer = require('duplexer'); + +module.exports = hyperquest; + +function bind (obj, fn) { + var args = Array.prototype.slice.call(arguments, 2); + return function () { + var argv = args.concat(Array.prototype.slice.call(arguments)); + return fn.apply(obj, argv); + } +} + +function hyperquest (uri, opts, cb, extra) { + if (typeof uri === 'object') { + cb = opts; + opts = uri; + uri = undefined; + } + if (typeof opts === 'function') { + cb = opts; + opts = undefined; + } + if (!opts) opts = {}; + if (uri !== undefined) opts.uri = uri; + if (extra) opts.method = extra.method; + + var req = new Req(opts); + var ws = req.duplex && through(); + if (ws) ws.pause(); + var rs = through(); + + var dup = req.duplex ? duplexer(ws, rs) : rs; + if (!req.duplex) { + rs.writable = false; + } + dup.request = req; + dup.setHeader = bind(req, req.setHeader); + dup.setLocation = bind(req, req.setLocation); + + var closed = false; + dup.on('close', function () { closed = true }); + + process.nextTick(function () { + if (closed) return; + dup.on('close', function () { r.destroy() }); + + var r = req._send(); + r.on('error', bind(dup, dup.emit, 'error')); + + r.on('response', function (res) { + dup.response = res; + dup.emit('response', res); + if (req.duplex) res.pipe(rs) + else { + res.on('data', function (buf) { rs.queue(buf) }); + res.on('end', function () { rs.queue(null) }); + } + }); + + if (req.duplex) { + ws.pipe(r); + ws.resume(); + } + else r.end(); + }); + + if (cb) { + dup.on('error', cb); + dup.on('response', bind(dup, cb, null)); + } + return dup; +} + +hyperquest.get = hyperquest; + +hyperquest.post = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'POST' }); +}; + +hyperquest.put = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'PUT' }); +}; + +hyperquest['delete'] = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'DELETE' }); +}; + +function Req (opts) { + this.headers = opts.headers || {}; + + var method = (opts.method || 'GET').toUpperCase(); + this.method = method; + this.duplex = !(method === 'GET' || method === 'DELETE' + || method === 'HEAD'); + this.auth = opts.auth; + + if (opts.uri) this.setLocation(opts.uri); +} + +Req.prototype._send = function () { + this._sent = true; + + var headers = this.headers || {}; + var u = url.parse(this.uri); + var au = u.auth || this.auth; + if (au) { + headers.authorization = 'Basic ' + Buffer(au).toString('base64'); + } + + var protocol = u.protocol || ''; + var iface = protocol === 'https:' ? https : http; + var req = iface.request({ + scheme: protocol.replace(/:$/, ''), + method: this.method, + host: u.hostname, + port: Number(u.port), + path: u.path, + agent: false, + headers: headers + }); + + if (req.setTimeout) req.setTimeout(Math.pow(2, 32) * 1000); + return req; +}; + +Req.prototype.setHeader = function (key, value) { + if (this._sent) throw new Error('request already sent'); + this.headers[key] = value; + return this; +}; + +Req.prototype.setLocation = function (uri) { + this.uri = uri; + return this; +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/package.json new file mode 100644 index 00000000..621c7a57 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/package.json @@ -0,0 +1,46 @@ +{ + "name": "hyperquest", + "version": "0.1.8", + "description": "make streaming http requests", + "main": "index.js", + "dependencies": { + "through": "~2.2.0", + "duplexer": "~0.1.0" + }, + "devDependencies": { + "tap": "~0.4.0" + }, + "scripts": { + "test": "tap test/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/substack/hyperquest.git" + }, + "homepage": "https://github.com/substack/hyperquest", + "keywords": [ + "stream", + "http", + "transport", + "request", + "get", + "post", + "put", + "delete", + "duplex", + "pooling" + ], + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "license": "MIT", + "readme": "# hyperquest\n\ntreat http requests as a streaming transport\n\n[![build status](https://secure.travis-ci.org/substack/hyperquest.png)](http://travis-ci.org/substack/hyperquest)\n\nThe hyperquest api is a subset of [request](https://github.com/mikeal/request).\n\nThis module works in the browser with [browserify](http://browserify.org).\n\n# rant\n\n![animated gif rant](http://substack.net/images/substack.gif)\n\nThis module disables a lot of infuriating things about core http that WILL cause\nbugs in your application if you think of http as just another kind of stream:\n\n* http requests have a default idle timeout of 2 minutes. This is terrible if\nyou just want to pipe together a bunch of persistent backend processes over\nhttp.\n\n* There is a default connection pool of 5 requests. If you have 5 or more extant\nhttp requests, any additional requests will HANG for NO GOOD REASON.\n\nhyperquest turns these annoyances off so you can just pretend that core http is\njust a fancier version of tcp and not the horrible monstrosity that it actually\nis.\n\nI have it on good authority that these annoyances will be fixed in node 0.12.\n\n# example\n\n# simple streaming GET\n\n``` js\nvar hyperquest = require('hyperquest');\nhyperquest('http://localhost:8000').pipe(process.stdout);\n```\n\n```\n$ node example/req.js\nbeep boop\n```\n\n# pooling is evil\n\nNow to drive the point home about pooling being evil and almost always never\nwhat you want ever.\n\n[request](https://github.com/mikeal/request)\nhas its own forever agent thing that works pretty much the same as node core\nhttp.request: the wrong, horrible, broken way.\n\nFor instance, the following request code takes 12+ seconds to finish:\n\n``` js\nvar http = require('http');\nvar request = require('request');\n\nvar server = http.createServer(function (req, res) {\n res.write(req.url.slice(1) + '\\n');\n setTimeout(res.end.bind(res), 3000);\n});\n\nserver.listen(5000, function () {\n var pending = 20;\n for (var i = 0; i < 20; i++) {\n var r = request('http://localhost:5000/' + i);\n r.pipe(process.stdout, { end: false });\n r.on('end', function () {\n if (--pending === 0) server.close();\n });\n }\n});\n\nprocess.stdout.setMaxListeners(0); // turn off annoying warnings\n```\n\n```\nsubstack : example $ time node many_request.js \n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n\nreal 0m12.423s\nuser 0m0.424s\nsys 0m0.048s\n```\n\nSurprising? YES. This is pretty much never what you want, particularly if you\nhave a lot of streaming http API endpoints. Your code will just *HANG* once the\nconnection pool fills up and it won't start working again until some connections\ndie for whatever reason. I have encountered this so many times in production\ninstances and it is SO hard to track down reliably.\n\nCompare to using hyperquest, which is exactly the same code but it takes 3\nseconds instead of 12 to finish because it's not completely self-crippled like\nrequest and core http.request.\n\n``` js\nvar http = require('http');\nvar hyperquest = require('hyperquest');\n\nvar server = http.createServer(function (req, res) {\n res.write(req.url.slice(1) + '\\n');\n setTimeout(res.end.bind(res), 3000);\n});\n\nserver.listen(5000, function () {\n var pending = 20;\n for (var i = 0; i < 20; i++) {\n var r = hyperquest('http://localhost:5000/' + i);\n r.pipe(process.stdout, { end: false });\n r.on('end', function () {\n if (--pending === 0) server.close();\n });\n }\n});\n\nprocess.stdout.setMaxListeners(0); // turn off annoying warnings\n```\n```\n$ time node many_hyperquest.js \n0\n1\n2\n3\n4\n5\n6\n8\n9\n7\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n\nreal 0m3.284s\nuser 0m0.288s\nsys 0m0.060s\n```\n\nSo the other thing is, the justification I've heard supporting this horrible\nlimit-of-5 pooling behavior is \"performance\". The first example which has been\ntuned for \"performance\" takes 12 seconds. The second example that removes these\n\"performance\" enhancements takes 3. Some performance improvement INDEED!\n\n# methods\n\n``` js\nvar hyperquest = require('hyperquest');\n```\n\n## var req = hyperquest(uri, opts={}, cb)\n\nCreate an outgoing http request to `uri` or `opts.uri`.\nYou need not pass any arguments here since there are setter methods documented\nbelow.\n\nReturn a readable or duplex stream depending on the `opts.method`.\n\nDefault option values:\n\n* opts.method - `\"GET\"`\n* opts.headers - `{}`\n* opts.auth - undefined, but is set automatically when the `uri` has an auth\nstring in it such as `\"http://user:passwd@host\"`. `opts.auth` is of the form\n`\"user:pass\"`, just like `http.request()`.\n\nThe request does not go through until the `nextTick` so you can set values\noutside of the `opts` so long as they are called on the same tick.\n\nOptionally you can pass a `cb(err, res)` to set up listeners for `'error'` and\n`'response'` events in one place.\n\nNote that the optional `cb` is NOT like\n[request](https://github.com/mikeal/request)\nin that hyperquest will not buffer content for you or decode to json or any such\nmagical thing.\n\n## req.setHeader(key, value);\n\nSet an outgoing header `key` to `value`.\n\n## req.setLocation(uri);\n\nSet the location if you didn't specify it in the `hyperquest()` call.\n\n## var req = hyperquest.get(uri, opts, cb)\n\nReturn a readable stream from `hyperquest(..., { method: 'GET' })`.\n\n## var req = hyperquest.put(uri, opts, cb)\n\nReturn a duplex stream from `hyperquest(..., { method: 'PUT' })`.\n\n## var req = hyperquest.post(uri, opts, cb)\n\nReturn a duplex stream from `hyperquest(..., { method: 'POST' })`.\n\n## var req = hyperquest.delete(uri, opts, cb)\n\nReturn a readable stream from `hyperquest(..., { method: 'DELETE' })`.\n\n# events\n\n## req.on('response', function (res) {})\n\nThe `'response'` event is forwarded from the underlying `http.request()`.\n\n## req.on('error', function (res) {})\n\nThe `'error'` event is forwarded from the underlying `http.request()`.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install hyperquest\n```\n\n# license\n\nMIT\n", + "readmeFilename": "readme.markdown", + "bugs": { + "url": "https://github.com/substack/hyperquest/issues" + }, + "_id": "hyperquest@0.1.8", + "_from": "hyperquest@~0.1.5" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/readme.markdown b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/readme.markdown new file mode 100644 index 00000000..af7bdf01 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/readme.markdown @@ -0,0 +1,249 @@ +# hyperquest + +treat http requests as a streaming transport + +[![build status](https://secure.travis-ci.org/substack/hyperquest.png)](http://travis-ci.org/substack/hyperquest) + +The hyperquest api is a subset of [request](https://github.com/mikeal/request). + +This module works in the browser with [browserify](http://browserify.org). + +# rant + +![animated gif rant](http://substack.net/images/substack.gif) + +This module disables a lot of infuriating things about core http that WILL cause +bugs in your application if you think of http as just another kind of stream: + +* http requests have a default idle timeout of 2 minutes. This is terrible if +you just want to pipe together a bunch of persistent backend processes over +http. + +* There is a default connection pool of 5 requests. If you have 5 or more extant +http requests, any additional requests will HANG for NO GOOD REASON. + +hyperquest turns these annoyances off so you can just pretend that core http is +just a fancier version of tcp and not the horrible monstrosity that it actually +is. + +I have it on good authority that these annoyances will be fixed in node 0.12. + +# example + +# simple streaming GET + +``` js +var hyperquest = require('hyperquest'); +hyperquest('http://localhost:8000').pipe(process.stdout); +``` + +``` +$ node example/req.js +beep boop +``` + +# pooling is evil + +Now to drive the point home about pooling being evil and almost always never +what you want ever. + +[request](https://github.com/mikeal/request) +has its own forever agent thing that works pretty much the same as node core +http.request: the wrong, horrible, broken way. + +For instance, the following request code takes 12+ seconds to finish: + +``` js +var http = require('http'); +var request = require('request'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = request('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings +``` + +``` +substack : example $ time node many_request.js +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 + +real 0m12.423s +user 0m0.424s +sys 0m0.048s +``` + +Surprising? YES. This is pretty much never what you want, particularly if you +have a lot of streaming http API endpoints. Your code will just *HANG* once the +connection pool fills up and it won't start working again until some connections +die for whatever reason. I have encountered this so many times in production +instances and it is SO hard to track down reliably. + +Compare to using hyperquest, which is exactly the same code but it takes 3 +seconds instead of 12 to finish because it's not completely self-crippled like +request and core http.request. + +``` js +var http = require('http'); +var hyperquest = require('hyperquest'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = hyperquest('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings +``` +``` +$ time node many_hyperquest.js +0 +1 +2 +3 +4 +5 +6 +8 +9 +7 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 + +real 0m3.284s +user 0m0.288s +sys 0m0.060s +``` + +So the other thing is, the justification I've heard supporting this horrible +limit-of-5 pooling behavior is "performance". The first example which has been +tuned for "performance" takes 12 seconds. The second example that removes these +"performance" enhancements takes 3. Some performance improvement INDEED! + +# methods + +``` js +var hyperquest = require('hyperquest'); +``` + +## var req = hyperquest(uri, opts={}, cb) + +Create an outgoing http request to `uri` or `opts.uri`. +You need not pass any arguments here since there are setter methods documented +below. + +Return a readable or duplex stream depending on the `opts.method`. + +Default option values: + +* opts.method - `"GET"` +* opts.headers - `{}` +* opts.auth - undefined, but is set automatically when the `uri` has an auth +string in it such as `"http://user:passwd@host"`. `opts.auth` is of the form +`"user:pass"`, just like `http.request()`. + +The request does not go through until the `nextTick` so you can set values +outside of the `opts` so long as they are called on the same tick. + +Optionally you can pass a `cb(err, res)` to set up listeners for `'error'` and +`'response'` events in one place. + +Note that the optional `cb` is NOT like +[request](https://github.com/mikeal/request) +in that hyperquest will not buffer content for you or decode to json or any such +magical thing. + +## req.setHeader(key, value); + +Set an outgoing header `key` to `value`. + +## req.setLocation(uri); + +Set the location if you didn't specify it in the `hyperquest()` call. + +## var req = hyperquest.get(uri, opts, cb) + +Return a readable stream from `hyperquest(..., { method: 'GET' })`. + +## var req = hyperquest.put(uri, opts, cb) + +Return a duplex stream from `hyperquest(..., { method: 'PUT' })`. + +## var req = hyperquest.post(uri, opts, cb) + +Return a duplex stream from `hyperquest(..., { method: 'POST' })`. + +## var req = hyperquest.delete(uri, opts, cb) + +Return a readable stream from `hyperquest(..., { method: 'DELETE' })`. + +# events + +## req.on('response', function (res) {}) + +The `'response'` event is forwarded from the underlying `http.request()`. + +## req.on('error', function (res) {}) + +The `'error'` event is forwarded from the underlying `http.request()`. + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install hyperquest +``` + +# license + +MIT diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth.js new file mode 100644 index 00000000..6e711480 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'moo' && s[1] === 'hax') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic auth', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://moo:hax@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://beep:boop@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth_encoded.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth_encoded.js new file mode 100644 index 00000000..bac51264 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth_encoded.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'm##' && s[1] === 'h@x') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic auth with escaped params', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://m%23%23:h%40x@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://beep:boop@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth_opt.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth_opt.js new file mode 100644 index 00000000..f85f979e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/auth_opt.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'moo' && s[1] === 'hax') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic opts.auth', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://localhost:' + port, { auth: 'moo:hax' }); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://localhost:' + port, { auth: 'beep:boop' }); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/get.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/get.js new file mode 100644 index 00000000..db6720d7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/get.js @@ -0,0 +1,33 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.setHeader('content-type', 'text/robot-speak'); + res.end('beep boop'); +}); + +test('get', function (t) { + t.plan(2); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + r.pipe(through(write, end)); + + r.on('response', function (res) { + t.equal(res.headers['content-type'], 'text/robot-speak'); + }); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/many.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/many.js new file mode 100644 index 00000000..40b18b36 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/many.js @@ -0,0 +1,34 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.write('beep boop'); +}); + +test('more than 5 pending connections', function (t) { + t.plan(20); + var pending = []; + server.listen(0, function () { + var port = server.address().port; + for (var i = 0; i < 20; i++) { + pending.push(check(t, port)); + } + }); + t.on('end', function () { + pending.forEach(function (p) { p.destroy() }); + server.close(); + }); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.pipe(through(function (buf) { data += buf })); + + setTimeout(function () { + t.equal(data, 'beep boop'); + }, 100); + return r; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/opts.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/opts.js new file mode 100644 index 00000000..a8b4604f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/opts.js @@ -0,0 +1,34 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.setHeader('content-type', 'text/robot-speak'); + res.end('beep boop'); +}); + +test('1st-arg options', function (t) { + t.plan(2); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest( + { uri: 'http://localhost:' + port }, + function (err, res) { + t.equal(res.headers['content-type'], 'text/robot-speak'); + } + ); + r.pipe(through(write, end)); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/post.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/post.js new file mode 100644 index 00000000..fefc0643 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/post.js @@ -0,0 +1,38 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + req.pipe(through(function (buf) { + this.queue(String(buf).toUpperCase()); + })).pipe(res); +}); + +test('post', function (t) { + t.plan(1); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest.post('http://localhost:' + port); + r.pipe(through(write, end)); + + setTimeout(function () { + r.write('beep '); + }, 50); + + setTimeout(function () { + r.end('boop.'); + }, 100); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'BEEP BOOP.'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/set_header.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/set_header.js new file mode 100644 index 00000000..6a5c59e8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/hyperquest/test/set_header.js @@ -0,0 +1,30 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +test('setHeader on a request', function (t) { + t.plan(2); + + var server = http.createServer(function (req, res) { + t.equal(req.headers.robot, 'party'); + res.end('beep boop'); + }); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + r.setHeader('robot', 'party'); + r.pipe(through(write, end)); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/.travis.yml new file mode 100644 index 00000000..c693a939 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.6 + - 0.8 + - "0.10" diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/LICENSE.APACHE2 b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/LICENSE.APACHE2 new file mode 100644 index 00000000..6366c047 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/LICENSE.APACHE2 @@ -0,0 +1,15 @@ +Apache License, Version 2.0 + +Copyright (c) 2011 Dominic Tarr + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/LICENSE.MIT b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/LICENSE.MIT new file mode 100644 index 00000000..6eafbd73 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/LICENSE.MIT @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/index.js new file mode 100644 index 00000000..7b935bf9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/index.js @@ -0,0 +1,108 @@ +var Stream = require('stream') + +// through +// +// a stream that does nothing but re-emit the input. +// useful for aggregating a series of changing but not ending streams into one stream) + +exports = module.exports = through +through.through = through + +//create a readable writable stream. + +function through (write, end, opts) { + write = write || function (data) { this.queue(data) } + end = end || function () { this.queue(null) } + + var ended = false, destroyed = false, buffer = [], _ended = false + var stream = new Stream() + stream.readable = stream.writable = true + stream.paused = false + +// stream.autoPause = !(opts && opts.autoPause === false) + stream.autoDestroy = !(opts && opts.autoDestroy === false) + + stream.write = function (data) { + write.call(this, data) + return !stream.paused + } + + function drain() { + while(buffer.length && !stream.paused) { + var data = buffer.shift() + if(null === data) + return stream.emit('end') + else + stream.emit('data', data) + } + } + + stream.queue = stream.push = function (data) { +// console.error(ended) + if(_ended) return stream + if(data == null) _ended = true + buffer.push(data) + drain() + return stream + } + + //this will be registered as the first 'end' listener + //must call destroy next tick, to make sure we're after any + //stream piped from here. + //this is only a problem if end is not emitted synchronously. + //a nicer way to do this is to make sure this is the last listener for 'end' + + stream.on('end', function () { + stream.readable = false + if(!stream.writable && stream.autoDestroy) + process.nextTick(function () { + stream.destroy() + }) + }) + + function _end () { + stream.writable = false + end.call(stream) + if(!stream.readable && stream.autoDestroy) + stream.destroy() + } + + stream.end = function (data) { + if(ended) return + ended = true + if(arguments.length) stream.write(data) + _end() // will emit or queue + return stream + } + + stream.destroy = function () { + if(destroyed) return + destroyed = true + ended = true + buffer.length = 0 + stream.writable = stream.readable = false + stream.emit('close') + return stream + } + + stream.pause = function () { + if(stream.paused) return + stream.paused = true + return stream + } + + stream.resume = function () { + if(stream.paused) { + stream.paused = false + stream.emit('resume') + } + drain() + //may have become paused again, + //as drain emits 'data'. + if(!stream.paused) + stream.emit('drain') + return stream + } + return stream +} + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/package.json new file mode 100644 index 00000000..65301c5a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/package.json @@ -0,0 +1,46 @@ +{ + "name": "through", + "version": "2.3.4", + "description": "simplified stream contsruction", + "main": "index.js", + "scripts": { + "test": "set -e; for t in test/*.js; do node $t; done" + }, + "devDependencies": { + "stream-spec": "~0.3.5", + "tape": "~0.2.2" + }, + "keywords": [ + "stream", + "streams", + "user-streams", + "pipe" + ], + "author": { + "name": "Dominic Tarr", + "email": "dominic.tarr@gmail.com", + "url": "dominictarr.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/dominictarr/through.git" + }, + "homepage": "http://github.com/dominictarr/through", + "testling": { + "browsers": [ + "ie/8..latest", + "ff/15..latest", + "chrome/20..latest", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "readme": "#through\n\n[![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through)\n\nEasy way to create a `Stream` that is both `readable` and `writable`. \n\n* Pass in optional `write` and `end` methods.\n* `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`.\n* Use `this.pause()` and `this.resume()` to manage flow.\n* Check `this.paused` to see current flow state. (`write` always returns `!this.paused`).\n\nThis function is the basis for most of the synchronous streams in \n[event-stream](http://github.com/dominictarr/event-stream).\n\n``` js\nvar through = require('through')\n\nthrough(function write(data) {\n this.queue(data) //data *must* not be null\n },\n function end () { //optional\n this.queue(null)\n })\n```\n\nOr, can also be used _without_ buffering on pause, use `this.emit('data', data)`,\nand this.emit('end')\n\n``` js\nvar through = require('through')\n\nthrough(function write(data) {\n this.emit('data', data)\n //this.pause() \n },\n function end () { //optional\n this.emit('end')\n })\n```\n\n## Extended Options\n\nYou will probably not need these 99% of the time.\n\n### autoDestroy=false\n\nBy default, `through` emits close when the writable\nand readable side of the stream has ended.\nIf that is not desired, set `autoDestroy=false`.\n\n``` js\nvar through = require('through')\n\n//like this\nvar ts = through(write, end, {autoDestroy: false})\n//or like this\nvar ts = through(write, end)\nts.autoDestroy = false\n```\n\n## License\n\nMIT / Apache2\n", + "readmeFilename": "readme.markdown", + "bugs": { + "url": "https://github.com/dominictarr/through/issues" + }, + "_id": "through@2.3.4", + "_from": "through@~2.3.4" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/readme.markdown b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/readme.markdown new file mode 100644 index 00000000..b20bc9a8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/readme.markdown @@ -0,0 +1,63 @@ +#through + +[![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through) + +Easy way to create a `Stream` that is both `readable` and `writable`. + +* Pass in optional `write` and `end` methods. +* `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`. +* Use `this.pause()` and `this.resume()` to manage flow. +* Check `this.paused` to see current flow state. (`write` always returns `!this.paused`). + +This function is the basis for most of the synchronous streams in +[event-stream](http://github.com/dominictarr/event-stream). + +``` js +var through = require('through') + +through(function write(data) { + this.queue(data) //data *must* not be null + }, + function end () { //optional + this.queue(null) + }) +``` + +Or, can also be used _without_ buffering on pause, use `this.emit('data', data)`, +and this.emit('end') + +``` js +var through = require('through') + +through(function write(data) { + this.emit('data', data) + //this.pause() + }, + function end () { //optional + this.emit('end') + }) +``` + +## Extended Options + +You will probably not need these 99% of the time. + +### autoDestroy=false + +By default, `through` emits close when the writable +and readable side of the stream has ended. +If that is not desired, set `autoDestroy=false`. + +``` js +var through = require('through') + +//like this +var ts = through(write, end, {autoDestroy: false}) +//or like this +var ts = through(write, end) +ts.autoDestroy = false +``` + +## License + +MIT / Apache2 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/auto-destroy.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/auto-destroy.js new file mode 100644 index 00000000..9a8fd000 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/auto-destroy.js @@ -0,0 +1,30 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('end before close', function (assert) { + var ts = through() + ts.autoDestroy = false + var ended = false, closed = false + + ts.on('end', function () { + assert.ok(!closed) + ended = true + }) + ts.on('close', function () { + assert.ok(ended) + closed = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.ok(ended) + assert.notOk(closed) + ts.destroy() + assert.ok(closed) + assert.end() +}) + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/buffering.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/buffering.js new file mode 100644 index 00000000..b0084bfc --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/buffering.js @@ -0,0 +1,71 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('buffering', function(assert) { + var ts = through(function (data) { + this.queue(data) + }, function () { + this.queue(null) + }) + + var ended = false, actual = [] + + ts.on('data', actual.push.bind(actual)) + ts.on('end', function () { + ended = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + assert.deepEqual(actual, [1, 2, 3]) + ts.pause() + ts.write(4) + ts.write(5) + ts.write(6) + assert.deepEqual(actual, [1, 2, 3]) + ts.resume() + assert.deepEqual(actual, [1, 2, 3, 4, 5, 6]) + ts.pause() + ts.end() + assert.ok(!ended) + ts.resume() + assert.ok(ended) + assert.end() +}) + +test('buffering has data in queue, when ends', function (assert) { + + /* + * If stream ends while paused with data in the queue, + * stream should still emit end after all data is written + * on resume. + */ + + var ts = through(function (data) { + this.queue(data) + }, function () { + this.queue(null) + }) + + var ended = false, actual = [] + + ts.on('data', actual.push.bind(actual)) + ts.on('end', function () { + ended = true + }) + + ts.pause() + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.deepEqual(actual, [], 'no data written yet, still paused') + assert.ok(!ended, 'end not emitted yet, still paused') + ts.resume() + assert.deepEqual(actual, [1, 2, 3], 'resumed, all data should be delivered') + assert.ok(ended, 'end should be emitted once all data was delivered') + assert.end(); +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/end.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/end.js new file mode 100644 index 00000000..fa113f58 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/end.js @@ -0,0 +1,45 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('end before close', function (assert) { + var ts = through() + var ended = false, closed = false + + ts.on('end', function () { + assert.ok(!closed) + ended = true + }) + ts.on('close', function () { + assert.ok(ended) + closed = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.ok(ended) + assert.ok(closed) + assert.end() +}) + +test('end only once', function (t) { + + var ts = through() + var ended = false, closed = false + + ts.on('end', function () { + t.equal(ended, false) + ended = true + }) + + ts.queue(null) + ts.queue(null) + ts.queue(null) + + ts.resume() + + t.end() +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/index.js new file mode 100644 index 00000000..33e33f96 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/node_modules/through/test/index.js @@ -0,0 +1,114 @@ + +var test = require('tape') +var spec = require('stream-spec') +var through = require('../') + +/* + I'm using these two functions, and not streams and pipe + so there is less to break. if this test fails it must be + the implementation of _through_ +*/ + +function write(array, stream) { + array = array.slice() + function next() { + while(array.length) + if(stream.write(array.shift()) === false) + return stream.once('drain', next) + + stream.end() + } + + next() +} + +function read(stream, callback) { + var actual = [] + stream.on('data', function (data) { + actual.push(data) + }) + stream.once('end', function () { + callback(null, actual) + }) + stream.once('error', function (err) { + callback(err) + }) +} + +test('simple defaults', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l * Math.random()) + + var t = through() + spec(t) + .through() + .pausable() + .validateOnExit() + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected) + assert.end() + }) + + write(expected, t) +}); + +test('simple functions', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l * Math.random()) + + var t = through(function (data) { + this.emit('data', data*2) + }) + spec(t) + .through() + .pausable() + .validateOnExit() + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected.map(function (data) { + return data*2 + })) + assert.end() + }) + + write(expected, t) +}) + +test('pauses', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l) //Math.random()) + + var t = through() + spec(t) + .through() + .pausable() + .validateOnExit() + + t.on('data', function () { + if(Math.random() > 0.1) return + t.pause() + process.nextTick(function () { + t.resume() + }) + }) + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected) + assert.end() + }) + + write(expected, t) +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/package.json new file mode 100644 index 00000000..9632020a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperdirect/package.json @@ -0,0 +1,33 @@ +{ + "name": "hyperdirect", + "version": "0.0.0", + "description": "Follow redirects for hyperquest GET requests", + "main": "index.js", + "scripts": { + "test": "mocha -R spec" + }, + "repository": { + "type": "git", + "url": "https://github.com/ForbesLindesay/hyperdirect.git" + }, + "author": { + "name": "ForbesLindesay" + }, + "license": "MIT", + "dependencies": { + "through": "~2.3.4", + "hyperquest": "~0.1.5" + }, + "readme": "# hyperdirect\r\n\r\nFollow redirects for hyperquest GET requests. Process all other requests exactly as normal.\r\n\r\n## Installation\r\n\r\n $ npm install hyperdirect\r\n\r\n## Usage\r\n\r\n```js\r\n//basic usage\r\nvar request = require('hyperquest').request;\r\n\r\nrequest('https://github.com/ForbesLindesay/hyperdirect/archive/master.tar.gz')\r\n .pipe(require('fs').createWriteStream(__dirname + '/hyperdirect.tar.gz'));\r\n\r\n//moderate usage\r\nvar request = require('hyperquest')(2/* Max Redirects to follow, defaults to 10 */);\r\n\r\nrequest('https://github.com/ForbesLindesay/hyperdirect/archive/master.tar.gz')\r\n .pipe(require('fs').createWriteStream(__dirname + '/hyperdirect.tar.gz'));\r\n\r\n//advanced usage\r\nvar hyperdirect = require('hyperdirect')(5, require('hyperquest'));\r\n```\r\n\r\n## API\r\n\r\n### hyperdirect(maxRedirects, subquest)\r\n\r\nReturns a new function with the same API as [hyperquest](https://github.com/hyperquest/hyperquest) but which follows redirects for GET requests. Both `maxRedirects` and `subquest` are optional and can be in either order.\r\n\r\nIf provided, `subquest` should be a function which matches the API of [hyperquest](https://github.com/hyperquest/hyperquest) or an object of the form `{request: hyperquest}` where `hyperquest` is a function matching the API of [hyperquest](https://github.com/hyperquest/hyperquest).\r\n\r\n`maxRedirects` will default to `10`. Once the request has been redirected more times than that it will give up and throw an error. The error has a `res` and `statusCode` property set to the apropriate properties from the last request made.\r\n\r\nThe returned stream will emit `redirect` events with the response of any request that results in another redirect. This means you could trace the path something a request took by doing:\r\n\r\n```js\r\nrequire('hyperdirect')(100)(url)\r\n .on('redirect', function (res) {\r\n console.log('REDIRECT ' + res.statusCode + ': ' + res.headers.location);\r\n })\r\n .on('response', function (res) {\r\n console.log('FINAL URL: ' + res.url);\r\n });\r\n```\r\n\r\n### hyperdirect.request(uri, opts, cb)\r\n\r\nFollows exactly the same API as [hyperquest](https://github.com/hyperquest/hyperquest) but automatically follows up to 10 redirects for GET requests. It's the same as what you get by calling `hyperdirect()`.\r\n\r\n## License\r\n\r\nMIT", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/ForbesLindesay/hyperdirect/issues" + }, + "homepage": "https://github.com/ForbesLindesay/hyperdirect", + "_id": "hyperdirect@0.0.0", + "dist": { + "shasum": "4024d59ba71442d340c1cf649ce7e42209840c3d" + }, + "_from": "hyperdirect@", + "_resolved": "https://registry.npmjs.org/hyperdirect/-/hyperdirect-0.0.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/.travis.yml new file mode 100644 index 00000000..dad2273c --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.8 + - "0.10" diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/LICENSE new file mode 100644 index 00000000..ee27ba4b --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/many_hyperquest.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/many_hyperquest.js new file mode 100644 index 00000000..590e3bd5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/many_hyperquest.js @@ -0,0 +1,20 @@ +var http = require('http'); +var hyperquest = require('../'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = hyperquest('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/many_request.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/many_request.js new file mode 100644 index 00000000..abbc28ea --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/many_request.js @@ -0,0 +1,20 @@ +var http = require('http'); +var request = require('request'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = request('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/req.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/req.js new file mode 100644 index 00000000..2d73de7e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/example/req.js @@ -0,0 +1,2 @@ +var hyperquest = require('../'); +hyperquest('http://localhost:8000').pipe(process.stdout); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/index.js new file mode 100644 index 00000000..b487c87f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/index.js @@ -0,0 +1,151 @@ +var url = require('url'); +var http = require('http'); +var https = require('https'); +var through = require('through'); +var duplexer = require('duplexer'); + +module.exports = hyperquest; + +function bind (obj, fn) { + var args = Array.prototype.slice.call(arguments, 2); + return function () { + var argv = args.concat(Array.prototype.slice.call(arguments)); + return fn.apply(obj, argv); + } +} + +function hyperquest (uri, opts, cb, extra) { + if (typeof uri === 'object') { + cb = opts; + opts = uri; + uri = undefined; + } + if (typeof opts === 'function') { + cb = opts; + opts = undefined; + } + if (!opts) opts = {}; + if (uri !== undefined) opts.uri = uri; + if (extra) opts.method = extra.method; + + var req = new Req(opts); + var ws = req.duplex && through(); + if (ws) ws.pause(); + var rs = through(); + + var dup = req.duplex ? duplexer(ws, rs) : rs; + if (!req.duplex) { + rs.writable = false; + } + dup.request = req; + dup.setHeader = bind(req, req.setHeader); + dup.setLocation = bind(req, req.setLocation); + + var closed = false; + dup.on('close', function () { closed = true }); + + process.nextTick(function () { + if (closed) return; + dup.on('close', function () { r.destroy() }); + + var r = req._send(); + r.on('error', bind(dup, dup.emit, 'error')); + + r.on('response', function (res) { + dup.response = res; + dup.emit('response', res); + if (req.duplex) res.pipe(rs) + else { + res.on('data', function (buf) { rs.queue(buf) }); + res.on('end', function () { rs.queue(null) }); + } + }); + + if (req.duplex) { + ws.pipe(r); + ws.resume(); + } + else r.end(); + }); + + if (cb) { + dup.on('error', cb); + dup.on('response', bind(dup, cb, null)); + } + return dup; +} + +hyperquest.get = hyperquest; + +hyperquest.post = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'POST' }); +}; + +hyperquest.put = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'PUT' }); +}; + +hyperquest['delete'] = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'DELETE' }); +}; + +function Req (opts) { + this.headers = opts.headers || {}; + + var method = (opts.method || 'GET').toUpperCase(); + this.method = method; + this.duplex = !(method === 'GET' || method === 'DELETE' + || method === 'HEAD'); + this.auth = opts.auth; + + this.options = opts; + + if (opts.uri) this.setLocation(opts.uri); +} + +Req.prototype._send = function () { + this._sent = true; + + var headers = this.headers || {}; + var u = url.parse(this.uri); + var au = u.auth || this.auth; + if (au) { + headers.authorization = 'Basic ' + Buffer(au).toString('base64'); + } + + var protocol = u.protocol || ''; + var iface = protocol === 'https:' ? https : http; + var opts = { + scheme: protocol.replace(/:$/, ''), + method: this.method, + host: u.hostname, + port: Number(u.port) || (protocol === 'https:' ? 443 : 80), + path: u.path, + agent: false, + headers: headers + }; + if (protocol === 'https:') { + opts.pfx = this.options.pfx; + opts.key = this.options.key; + opts.cert = this.options.cert; + opts.ca = this.options.ca; + opts.ciphers = this.options.ciphers; + opts.rejectUnauthorized = this.options.rejectUnauthorized; + opts.secureProtocol = this.options.secureProtocol; + } + var req = iface.request(opts); + + if (req.setTimeout) req.setTimeout(Math.pow(2, 32) * 1000); + return req; +}; + +Req.prototype.setHeader = function (key, value) { + if (this._sent) throw new Error('request already sent'); + this.headers[key] = value; + return this; +}; + +Req.prototype.setLocation = function (uri) { + this.uri = uri; + return this; +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/.npmignore new file mode 100644 index 00000000..062c11e8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/.npmignore @@ -0,0 +1,3 @@ +node_modules +*.log +*.err \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/.travis.yml new file mode 100644 index 00000000..ed05f88d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.11" + - "0.10" + - "0.8" + - "0.6" diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/LICENCE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/LICENCE new file mode 100644 index 00000000..a23e08a8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/LICENCE @@ -0,0 +1,19 @@ +Copyright (c) 2012 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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/README.md new file mode 100644 index 00000000..61ff71aa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/README.md @@ -0,0 +1,47 @@ +# duplexer + +[![build status][1]][2] [![dependency status][3]][4] + +[![browser support][5]][6] + +Creates a duplex stream + +Taken from [event-stream][7] + +## duplex (writeStream, readStream) + +Takes a writable stream and a readable stream and makes them appear as a readable writable stream. + +It is assumed that the two streams are connected to each other in some way. + +## Example + +```js +var grep = cp.exec('grep Stream') + +duplex(grep.stdin, grep.stdout) +``` + +## Installation + +`npm install duplexer` + +## Tests + +`npm test` + +## Contributors + + - Dominictarr + - Raynos + - samccone + +## MIT Licenced + + [1]: https://secure.travis-ci.org/Raynos/duplexer.png + [2]: https://travis-ci.org/Raynos/duplexer + [3]: https://david-dm.org/Raynos/duplexer.png + [4]: https://david-dm.org/Raynos/duplexer + [5]: https://ci.testling.com/Raynos/duplexer.png + [6]: https://ci.testling.com/Raynos/duplexer + [7]: https://github.com/dominictarr/event-stream#duplex-writestream-readstream diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/index.js new file mode 100644 index 00000000..a188a210 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/index.js @@ -0,0 +1,87 @@ +var Stream = require("stream") +var writeMethods = ["write", "end", "destroy"] +var readMethods = ["resume", "pause"] +var readEvents = ["data", "close"] +var slice = Array.prototype.slice + +module.exports = duplex + +function forEach (arr, fn) { + if (arr.forEach) { + return arr.forEach(fn) + } + + for (var i = 0; i < arr.length; i++) { + fn(arr[i], i) + } +} + +function duplex(writer, reader) { + var stream = new Stream() + var ended = false + + forEach(writeMethods, proxyWriter) + + forEach(readMethods, proxyReader) + + forEach(readEvents, proxyStream) + + reader.on("end", handleEnd) + + writer.on("drain", function() { + stream.emit("drain") + }) + + writer.on("error", reemit) + reader.on("error", reemit) + + stream.writable = writer.writable + stream.readable = reader.readable + + return stream + + function proxyWriter(methodName) { + stream[methodName] = method + + function method() { + return writer[methodName].apply(writer, arguments) + } + } + + function proxyReader(methodName) { + stream[methodName] = method + + function method() { + stream.emit(methodName) + var func = reader[methodName] + if (func) { + return func.apply(reader, arguments) + } + reader.emit(methodName) + } + } + + function proxyStream(methodName) { + reader.on(methodName, reemit) + + function reemit() { + var args = slice.call(arguments) + args.unshift(methodName) + stream.emit.apply(stream, args) + } + } + + function handleEnd() { + if (ended) { + return + } + ended = true + var args = slice.call(arguments) + args.unshift("end") + stream.emit.apply(stream, args) + } + + function reemit(err) { + stream.emit("error", err) + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/package.json new file mode 100644 index 00000000..f6f719c2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/package.json @@ -0,0 +1,57 @@ +{ + "name": "duplexer", + "version": "0.1.1", + "description": "Creates a duplex stream", + "keywords": [], + "author": { + "name": "Raynos", + "email": "raynos2@gmail.com" + }, + "repository": { + "type": "git", + "url": "git://github.com/Raynos/duplexer.git" + }, + "main": "index", + "homepage": "https://github.com/Raynos/duplexer", + "contributors": [ + { + "name": "Jake Verbaten" + } + ], + "bugs": { + "url": "https://github.com/Raynos/duplexer/issues", + "email": "raynos2@gmail.com" + }, + "devDependencies": { + "tape": "0.3.3", + "through": "~0.1.4" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://github.com/Raynos/duplexer/raw/master/LICENSE" + } + ], + "scripts": { + "test": "node test" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "ie/8..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest" + ] + }, + "readme": "# duplexer\n\n[![build status][1]][2] [![dependency status][3]][4]\n\n[![browser support][5]][6]\n\nCreates a duplex stream\n\nTaken from [event-stream][7]\n\n## duplex (writeStream, readStream)\n\nTakes a writable stream and a readable stream and makes them appear as a readable writable stream.\n\nIt is assumed that the two streams are connected to each other in some way.\n\n## Example\n\n```js\nvar grep = cp.exec('grep Stream')\n\nduplex(grep.stdin, grep.stdout)\n```\n\n## Installation\n\n`npm install duplexer`\n\n## Tests\n\n`npm test`\n\n## Contributors\n\n - Dominictarr\n - Raynos\n - samccone\n\n## MIT Licenced\n\n [1]: https://secure.travis-ci.org/Raynos/duplexer.png\n [2]: https://travis-ci.org/Raynos/duplexer\n [3]: https://david-dm.org/Raynos/duplexer.png\n [4]: https://david-dm.org/Raynos/duplexer\n [5]: https://ci.testling.com/Raynos/duplexer.png\n [6]: https://ci.testling.com/Raynos/duplexer\n [7]: https://github.com/dominictarr/event-stream#duplex-writestream-readstream\n", + "readmeFilename": "README.md", + "_id": "duplexer@0.1.1", + "_from": "duplexer@~0.1.0" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/test/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/test/index.js new file mode 100644 index 00000000..4988e0d9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/duplexer/test/index.js @@ -0,0 +1,31 @@ +var through = require("through") +var test = require("tape") + +var duplex = require("../index") + +var readable = through() +var writable = through(write) +var written = 0 +var data = 0 + +var stream = duplex(writable, readable) + +function write() { + written++ +} + +stream.on("data", ondata) + +function ondata() { + data++ +} + +test("emit and write", function(t) { + t.plan(2) + + stream.write() + readable.emit("data") + + t.equal(written, 1, "should have written once") + t.equal(data, 1, "should have recived once") +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/.travis.yml new file mode 100644 index 00000000..895dbd36 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.6 + - 0.8 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/LICENSE.APACHE2 b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/LICENSE.APACHE2 new file mode 100644 index 00000000..6366c047 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/LICENSE.APACHE2 @@ -0,0 +1,15 @@ +Apache License, Version 2.0 + +Copyright (c) 2011 Dominic Tarr + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/LICENSE.MIT b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/LICENSE.MIT new file mode 100644 index 00000000..6eafbd73 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/LICENSE.MIT @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/index.js new file mode 100644 index 00000000..d9165607 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/index.js @@ -0,0 +1,103 @@ +var Stream = require('stream') + +// through +// +// a stream that does nothing but re-emit the input. +// useful for aggregating a series of changing but not ending streams into one stream) + + + +exports = module.exports = through +through.through = through + +//create a readable writable stream. + +function through (write, end) { + write = write || function (data) { this.queue(data) } + end = end || function () { this.queue(null) } + + var ended = false, destroyed = false, buffer = [] + var stream = new Stream() + stream.readable = stream.writable = true + stream.paused = false + + stream.write = function (data) { + write.call(this, data) + return !stream.paused + } + + function drain() { + while(buffer.length && !stream.paused) { + var data = buffer.shift() + if(null === data) + return stream.emit('end') + else + stream.emit('data', data) + } + } + + stream.queue = stream.push = function (data) { + buffer.push(data) + drain() + return stream + } + + //this will be registered as the first 'end' listener + //must call destroy next tick, to make sure we're after any + //stream piped from here. + //this is only a problem if end is not emitted synchronously. + //a nicer way to do this is to make sure this is the last listener for 'end' + + stream.on('end', function () { + stream.readable = false + if(!stream.writable) + process.nextTick(function () { + stream.destroy() + }) + }) + + function _end () { + stream.writable = false + end.call(stream) + if(!stream.readable) + stream.destroy() + } + + stream.end = function (data) { + if(ended) return + ended = true + if(arguments.length) stream.write(data) + _end() // will emit or queue + return stream + } + + stream.destroy = function () { + if(destroyed) return + destroyed = true + ended = true + buffer.length = 0 + stream.writable = stream.readable = false + stream.emit('close') + return stream + } + + stream.pause = function () { + if(stream.paused) return + stream.paused = true + stream.emit('pause') + return stream + } + stream.resume = function () { + if(stream.paused) { + stream.paused = false + } + drain() + //may have become paused again, + //as drain emits 'data'. + if(!stream.paused) + stream.emit('drain') + return stream + } + return stream +} + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/package.json new file mode 100644 index 00000000..350964b3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/package.json @@ -0,0 +1,46 @@ +{ + "name": "through", + "version": "2.2.7", + "description": "simplified stream contruction", + "main": "index.js", + "scripts": { + "test": "set -e; for t in test/*.js; do node $t; done" + }, + "devDependencies": { + "stream-spec": "~0.3.5", + "tape": "~0.2.2" + }, + "keywords": [ + "stream", + "streams", + "user-streams", + "pipe" + ], + "author": { + "name": "Dominic Tarr", + "email": "dominic.tarr@gmail.com", + "url": "dominictarr.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/dominictarr/through.git" + }, + "homepage": "http://github.com/dominictarr/through", + "testling": { + "browsers": [ + "ie/8..latest", + "ff/15..latest", + "chrome/20..latest", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "readme": "#through\n\n[![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through)\n\nEasy way to create a `Stream` that is both `readable` and `writable`. \n\n* Pass in optional `write` and `end` methods.\n* `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`.\n* Use `this.pause()` and `this.resume()` to manage flow.\n* Check `this.paused` to see current flow state. (write always returns `!this.paused`).\n\nThis function is the basis for most of the synchronous streams in \n[event-stream](http://github.com/dominictarr/event-stream).\n\n``` js\nvar through = require('through')\n\nthrough(function write(data) {\n this.queue(data) //data *must* not be null\n },\n function end () { //optional\n this.queue(null)\n })\n```\n\nOr, can also be used _without_ buffering on pause, use `this.emit('data', data)`,\nand this.emit('end')\n\n``` js\nvar through = require('through')\n\nthrough(function write(data) {\n this.emit('data', data)\n //this.pause() \n },\n function end () { //optional\n this.emit('end')\n })\n```\n\n## License\n\nMIT / Apache2\n", + "readmeFilename": "readme.markdown", + "bugs": { + "url": "https://github.com/dominictarr/through/issues" + }, + "_id": "through@2.2.7", + "_from": "through@~2.2.0" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/readme.markdown b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/readme.markdown new file mode 100644 index 00000000..870fdd1d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/readme.markdown @@ -0,0 +1,43 @@ +#through + +[![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through) + +Easy way to create a `Stream` that is both `readable` and `writable`. + +* Pass in optional `write` and `end` methods. +* `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`. +* Use `this.pause()` and `this.resume()` to manage flow. +* Check `this.paused` to see current flow state. (write always returns `!this.paused`). + +This function is the basis for most of the synchronous streams in +[event-stream](http://github.com/dominictarr/event-stream). + +``` js +var through = require('through') + +through(function write(data) { + this.queue(data) //data *must* not be null + }, + function end () { //optional + this.queue(null) + }) +``` + +Or, can also be used _without_ buffering on pause, use `this.emit('data', data)`, +and this.emit('end') + +``` js +var through = require('through') + +through(function write(data) { + this.emit('data', data) + //this.pause() + }, + function end () { //optional + this.emit('end') + }) +``` + +## License + +MIT / Apache2 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/buffering.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/buffering.js new file mode 100644 index 00000000..b0084bfc --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/buffering.js @@ -0,0 +1,71 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('buffering', function(assert) { + var ts = through(function (data) { + this.queue(data) + }, function () { + this.queue(null) + }) + + var ended = false, actual = [] + + ts.on('data', actual.push.bind(actual)) + ts.on('end', function () { + ended = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + assert.deepEqual(actual, [1, 2, 3]) + ts.pause() + ts.write(4) + ts.write(5) + ts.write(6) + assert.deepEqual(actual, [1, 2, 3]) + ts.resume() + assert.deepEqual(actual, [1, 2, 3, 4, 5, 6]) + ts.pause() + ts.end() + assert.ok(!ended) + ts.resume() + assert.ok(ended) + assert.end() +}) + +test('buffering has data in queue, when ends', function (assert) { + + /* + * If stream ends while paused with data in the queue, + * stream should still emit end after all data is written + * on resume. + */ + + var ts = through(function (data) { + this.queue(data) + }, function () { + this.queue(null) + }) + + var ended = false, actual = [] + + ts.on('data', actual.push.bind(actual)) + ts.on('end', function () { + ended = true + }) + + ts.pause() + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.deepEqual(actual, [], 'no data written yet, still paused') + assert.ok(!ended, 'end not emitted yet, still paused') + ts.resume() + assert.deepEqual(actual, [1, 2, 3], 'resumed, all data should be delivered') + assert.ok(ended, 'end should be emitted once all data was delivered') + assert.end(); +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/end.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/end.js new file mode 100644 index 00000000..73216676 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/end.js @@ -0,0 +1,26 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('end before close', function (assert) { + var ts = through() + var ended = false, closed = false + + ts.on('end', function () { + assert.ok(!closed) + ended = true + }) + ts.on('close', function () { + assert.ok(ended) + closed = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.ok(ended) + assert.ok(closed) + assert.end() +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/index.js new file mode 100644 index 00000000..33e33f96 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/node_modules/through/test/index.js @@ -0,0 +1,114 @@ + +var test = require('tape') +var spec = require('stream-spec') +var through = require('../') + +/* + I'm using these two functions, and not streams and pipe + so there is less to break. if this test fails it must be + the implementation of _through_ +*/ + +function write(array, stream) { + array = array.slice() + function next() { + while(array.length) + if(stream.write(array.shift()) === false) + return stream.once('drain', next) + + stream.end() + } + + next() +} + +function read(stream, callback) { + var actual = [] + stream.on('data', function (data) { + actual.push(data) + }) + stream.once('end', function () { + callback(null, actual) + }) + stream.once('error', function (err) { + callback(err) + }) +} + +test('simple defaults', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l * Math.random()) + + var t = through() + spec(t) + .through() + .pausable() + .validateOnExit() + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected) + assert.end() + }) + + write(expected, t) +}); + +test('simple functions', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l * Math.random()) + + var t = through(function (data) { + this.emit('data', data*2) + }) + spec(t) + .through() + .pausable() + .validateOnExit() + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected.map(function (data) { + return data*2 + })) + assert.end() + }) + + write(expected, t) +}) + +test('pauses', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l) //Math.random()) + + var t = through() + spec(t) + .through() + .pausable() + .validateOnExit() + + t.on('data', function () { + if(Math.random() > 0.1) return + t.pause() + process.nextTick(function () { + t.resume() + }) + }) + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected) + assert.end() + }) + + write(expected, t) +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/package.json new file mode 100644 index 00000000..56f70772 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/package.json @@ -0,0 +1,50 @@ +{ + "name": "hyperquest", + "version": "0.2.0", + "description": "make streaming http requests", + "main": "index.js", + "dependencies": { + "through": "~2.2.0", + "duplexer": "~0.1.0" + }, + "devDependencies": { + "tap": "~0.4.0" + }, + "scripts": { + "test": "tap test/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/substack/hyperquest.git" + }, + "homepage": "https://github.com/substack/hyperquest", + "keywords": [ + "stream", + "http", + "transport", + "request", + "get", + "post", + "put", + "delete", + "duplex", + "pooling" + ], + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "license": "MIT", + "readme": "# hyperquest\n\ntreat http requests as a streaming transport\n\n[![build status](https://secure.travis-ci.org/substack/hyperquest.png)](http://travis-ci.org/substack/hyperquest)\n\nThe hyperquest api is a subset of [request](https://github.com/mikeal/request).\n\nThis module works in the browser with [browserify](http://browserify.org).\n\n# rant\n\n![animated gif rant](http://substack.net/images/substack.gif)\n\nThis module disables a lot of infuriating things about core http that WILL cause\nbugs in your application if you think of http as just another kind of stream:\n\n* http requests have a default idle timeout of 2 minutes. This is terrible if\nyou just want to pipe together a bunch of persistent backend processes over\nhttp.\n\n* There is a default connection pool of 5 requests. If you have 5 or more extant\nhttp requests, any additional requests will HANG for NO GOOD REASON.\n\nhyperquest turns these annoyances off so you can just pretend that core http is\njust a fancier version of tcp and not the horrible monstrosity that it actually\nis.\n\nI have it on good authority that these annoyances will be fixed in node 0.12.\n\n# example\n\n# simple streaming GET\n\n``` js\nvar hyperquest = require('hyperquest');\nhyperquest('http://localhost:8000').pipe(process.stdout);\n```\n\n```\n$ node example/req.js\nbeep boop\n```\n\n# pooling is evil\n\nNow to drive the point home about pooling being evil and almost always never\nwhat you want ever.\n\n[request](https://github.com/mikeal/request)\nhas its own forever agent thing that works pretty much the same as node core\nhttp.request: the wrong, horrible, broken way.\n\nFor instance, the following request code takes 12+ seconds to finish:\n\n``` js\nvar http = require('http');\nvar request = require('request');\n\nvar server = http.createServer(function (req, res) {\n res.write(req.url.slice(1) + '\\n');\n setTimeout(res.end.bind(res), 3000);\n});\n\nserver.listen(5000, function () {\n var pending = 20;\n for (var i = 0; i < 20; i++) {\n var r = request('http://localhost:5000/' + i);\n r.pipe(process.stdout, { end: false });\n r.on('end', function () {\n if (--pending === 0) server.close();\n });\n }\n});\n\nprocess.stdout.setMaxListeners(0); // turn off annoying warnings\n```\n\n```\nsubstack : example $ time node many_request.js \n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n\nreal 0m12.423s\nuser 0m0.424s\nsys 0m0.048s\n```\n\nSurprising? YES. This is pretty much never what you want, particularly if you\nhave a lot of streaming http API endpoints. Your code will just *HANG* once the\nconnection pool fills up and it won't start working again until some connections\ndie for whatever reason. I have encountered this so many times in production\ninstances and it is SO hard to track down reliably.\n\nCompare to using hyperquest, which is exactly the same code but it takes 3\nseconds instead of 12 to finish because it's not completely self-crippled like\nrequest and core http.request.\n\n``` js\nvar http = require('http');\nvar hyperquest = require('hyperquest');\n\nvar server = http.createServer(function (req, res) {\n res.write(req.url.slice(1) + '\\n');\n setTimeout(res.end.bind(res), 3000);\n});\n\nserver.listen(5000, function () {\n var pending = 20;\n for (var i = 0; i < 20; i++) {\n var r = hyperquest('http://localhost:5000/' + i);\n r.pipe(process.stdout, { end: false });\n r.on('end', function () {\n if (--pending === 0) server.close();\n });\n }\n});\n\nprocess.stdout.setMaxListeners(0); // turn off annoying warnings\n```\n```\n$ time node many_hyperquest.js \n0\n1\n2\n3\n4\n5\n6\n8\n9\n7\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n\nreal 0m3.284s\nuser 0m0.288s\nsys 0m0.060s\n```\n\nSo the other thing is, the justification I've heard supporting this horrible\nlimit-of-5 pooling behavior is \"performance\". The first example which has been\ntuned for \"performance\" takes 12 seconds. The second example that removes these\n\"performance\" enhancements takes 3. Some performance improvement INDEED!\n\n# methods\n\n``` js\nvar hyperquest = require('hyperquest');\n```\n\n## var req = hyperquest(uri, opts={}, cb)\n\nCreate an outgoing http request to `uri` or `opts.uri`.\nYou need not pass any arguments here since there are setter methods documented\nbelow.\n\nReturn a readable or duplex stream depending on the `opts.method`.\n\nDefault option values:\n\n* opts.method - `\"GET\"`\n* opts.headers - `{}`\n* opts.auth - undefined, but is set automatically when the `uri` has an auth\nstring in it such as `\"http://user:passwd@host\"`. `opts.auth` is of the form\n`\"user:pass\"`, just like `http.request()`.\n\nIn https mode, you can specify options to the underlying `tls.connect()` call:\n\n* opts.pfx\n* opts.key\n* opts.cert\n* opts.ca\n* opts.ciphers\n* opts.rejectUnauthorized\n* opts.secureProtocol\n\nThe request does not go through until the `nextTick` so you can set values\noutside of the `opts` so long as they are called on the same tick.\n\nOptionally you can pass a `cb(err, res)` to set up listeners for `'error'` and\n`'response'` events in one place.\n\nNote that the optional `cb` is NOT like\n[request](https://github.com/mikeal/request)\nin that hyperquest will not buffer content for you or decode to json or any such\nmagical thing.\n\n## req.setHeader(key, value);\n\nSet an outgoing header `key` to `value`.\n\n## req.setLocation(uri);\n\nSet the location if you didn't specify it in the `hyperquest()` call.\n\n## var req = hyperquest.get(uri, opts, cb)\n\nReturn a readable stream from `hyperquest(..., { method: 'GET' })`.\n\n## var req = hyperquest.put(uri, opts, cb)\n\nReturn a duplex stream from `hyperquest(..., { method: 'PUT' })`.\n\n## var req = hyperquest.post(uri, opts, cb)\n\nReturn a duplex stream from `hyperquest(..., { method: 'POST' })`.\n\n## var req = hyperquest.delete(uri, opts, cb)\n\nReturn a readable stream from `hyperquest(..., { method: 'DELETE' })`.\n\n# events\n\n## req.on('response', function (res) {})\n\nThe `'response'` event is forwarded from the underlying `http.request()`.\n\n## req.on('error', function (res) {})\n\nThe `'error'` event is forwarded from the underlying `http.request()`.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install hyperquest\n```\n\n# license\n\nMIT\n", + "readmeFilename": "readme.markdown", + "bugs": { + "url": "https://github.com/substack/hyperquest/issues" + }, + "_id": "hyperquest@0.2.0", + "dist": { + "shasum": "4d3e59af6604e8ccab73f76896d5844495fa85aa" + }, + "_from": "hyperquest@", + "_resolved": "https://registry.npmjs.org/hyperquest/-/hyperquest-0.2.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/readme.markdown b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/readme.markdown new file mode 100644 index 00000000..abb99ba3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/readme.markdown @@ -0,0 +1,259 @@ +# hyperquest + +treat http requests as a streaming transport + +[![build status](https://secure.travis-ci.org/substack/hyperquest.png)](http://travis-ci.org/substack/hyperquest) + +The hyperquest api is a subset of [request](https://github.com/mikeal/request). + +This module works in the browser with [browserify](http://browserify.org). + +# rant + +![animated gif rant](http://substack.net/images/substack.gif) + +This module disables a lot of infuriating things about core http that WILL cause +bugs in your application if you think of http as just another kind of stream: + +* http requests have a default idle timeout of 2 minutes. This is terrible if +you just want to pipe together a bunch of persistent backend processes over +http. + +* There is a default connection pool of 5 requests. If you have 5 or more extant +http requests, any additional requests will HANG for NO GOOD REASON. + +hyperquest turns these annoyances off so you can just pretend that core http is +just a fancier version of tcp and not the horrible monstrosity that it actually +is. + +I have it on good authority that these annoyances will be fixed in node 0.12. + +# example + +# simple streaming GET + +``` js +var hyperquest = require('hyperquest'); +hyperquest('http://localhost:8000').pipe(process.stdout); +``` + +``` +$ node example/req.js +beep boop +``` + +# pooling is evil + +Now to drive the point home about pooling being evil and almost always never +what you want ever. + +[request](https://github.com/mikeal/request) +has its own forever agent thing that works pretty much the same as node core +http.request: the wrong, horrible, broken way. + +For instance, the following request code takes 12+ seconds to finish: + +``` js +var http = require('http'); +var request = require('request'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = request('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings +``` + +``` +substack : example $ time node many_request.js +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 + +real 0m12.423s +user 0m0.424s +sys 0m0.048s +``` + +Surprising? YES. This is pretty much never what you want, particularly if you +have a lot of streaming http API endpoints. Your code will just *HANG* once the +connection pool fills up and it won't start working again until some connections +die for whatever reason. I have encountered this so many times in production +instances and it is SO hard to track down reliably. + +Compare to using hyperquest, which is exactly the same code but it takes 3 +seconds instead of 12 to finish because it's not completely self-crippled like +request and core http.request. + +``` js +var http = require('http'); +var hyperquest = require('hyperquest'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = hyperquest('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings +``` +``` +$ time node many_hyperquest.js +0 +1 +2 +3 +4 +5 +6 +8 +9 +7 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 + +real 0m3.284s +user 0m0.288s +sys 0m0.060s +``` + +So the other thing is, the justification I've heard supporting this horrible +limit-of-5 pooling behavior is "performance". The first example which has been +tuned for "performance" takes 12 seconds. The second example that removes these +"performance" enhancements takes 3. Some performance improvement INDEED! + +# methods + +``` js +var hyperquest = require('hyperquest'); +``` + +## var req = hyperquest(uri, opts={}, cb) + +Create an outgoing http request to `uri` or `opts.uri`. +You need not pass any arguments here since there are setter methods documented +below. + +Return a readable or duplex stream depending on the `opts.method`. + +Default option values: + +* opts.method - `"GET"` +* opts.headers - `{}` +* opts.auth - undefined, but is set automatically when the `uri` has an auth +string in it such as `"http://user:passwd@host"`. `opts.auth` is of the form +`"user:pass"`, just like `http.request()`. + +In https mode, you can specify options to the underlying `tls.connect()` call: + +* opts.pfx +* opts.key +* opts.cert +* opts.ca +* opts.ciphers +* opts.rejectUnauthorized +* opts.secureProtocol + +The request does not go through until the `nextTick` so you can set values +outside of the `opts` so long as they are called on the same tick. + +Optionally you can pass a `cb(err, res)` to set up listeners for `'error'` and +`'response'` events in one place. + +Note that the optional `cb` is NOT like +[request](https://github.com/mikeal/request) +in that hyperquest will not buffer content for you or decode to json or any such +magical thing. + +## req.setHeader(key, value); + +Set an outgoing header `key` to `value`. + +## req.setLocation(uri); + +Set the location if you didn't specify it in the `hyperquest()` call. + +## var req = hyperquest.get(uri, opts, cb) + +Return a readable stream from `hyperquest(..., { method: 'GET' })`. + +## var req = hyperquest.put(uri, opts, cb) + +Return a duplex stream from `hyperquest(..., { method: 'PUT' })`. + +## var req = hyperquest.post(uri, opts, cb) + +Return a duplex stream from `hyperquest(..., { method: 'POST' })`. + +## var req = hyperquest.delete(uri, opts, cb) + +Return a readable stream from `hyperquest(..., { method: 'DELETE' })`. + +# events + +## req.on('response', function (res) {}) + +The `'response'` event is forwarded from the underlying `http.request()`. + +## req.on('error', function (res) {}) + +The `'error'` event is forwarded from the underlying `http.request()`. + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install hyperquest +``` + +# license + +MIT diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth.js new file mode 100644 index 00000000..6e711480 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'moo' && s[1] === 'hax') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic auth', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://moo:hax@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://beep:boop@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth_encoded.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth_encoded.js new file mode 100644 index 00000000..bac51264 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth_encoded.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'm##' && s[1] === 'h@x') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic auth with escaped params', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://m%23%23:h%40x@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://beep:boop@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth_opt.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth_opt.js new file mode 100644 index 00000000..f85f979e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/auth_opt.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'moo' && s[1] === 'hax') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic opts.auth', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://localhost:' + port, { auth: 'moo:hax' }); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://localhost:' + port, { auth: 'beep:boop' }); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/get.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/get.js new file mode 100644 index 00000000..db6720d7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/get.js @@ -0,0 +1,33 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.setHeader('content-type', 'text/robot-speak'); + res.end('beep boop'); +}); + +test('get', function (t) { + t.plan(2); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + r.pipe(through(write, end)); + + r.on('response', function (res) { + t.equal(res.headers['content-type'], 'text/robot-speak'); + }); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/many.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/many.js new file mode 100644 index 00000000..40b18b36 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/many.js @@ -0,0 +1,34 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.write('beep boop'); +}); + +test('more than 5 pending connections', function (t) { + t.plan(20); + var pending = []; + server.listen(0, function () { + var port = server.address().port; + for (var i = 0; i < 20; i++) { + pending.push(check(t, port)); + } + }); + t.on('end', function () { + pending.forEach(function (p) { p.destroy() }); + server.close(); + }); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.pipe(through(function (buf) { data += buf })); + + setTimeout(function () { + t.equal(data, 'beep boop'); + }, 100); + return r; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/opts.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/opts.js new file mode 100644 index 00000000..a8b4604f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/opts.js @@ -0,0 +1,34 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.setHeader('content-type', 'text/robot-speak'); + res.end('beep boop'); +}); + +test('1st-arg options', function (t) { + t.plan(2); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest( + { uri: 'http://localhost:' + port }, + function (err, res) { + t.equal(res.headers['content-type'], 'text/robot-speak'); + } + ); + r.pipe(through(write, end)); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/post.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/post.js new file mode 100644 index 00000000..fefc0643 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/post.js @@ -0,0 +1,38 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + req.pipe(through(function (buf) { + this.queue(String(buf).toUpperCase()); + })).pipe(res); +}); + +test('post', function (t) { + t.plan(1); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest.post('http://localhost:' + port); + r.pipe(through(write, end)); + + setTimeout(function () { + r.write('beep '); + }, 50); + + setTimeout(function () { + r.end('boop.'); + }, 100); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'BEEP BOOP.'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/post_immediate.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/post_immediate.js new file mode 100644 index 00000000..ed8606fa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/post_immediate.js @@ -0,0 +1,30 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + req.pipe(through(function (buf) { + this.queue(String(buf).toUpperCase()); + })).pipe(res); +}); + +test('post', function (t) { + t.plan(1); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest.post('http://localhost:' + port); + r.end('beep boop.'); + + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { + t.equal(data, 'BEEP BOOP.'); + }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/set_header.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/set_header.js new file mode 100644 index 00000000..6a5c59e8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperquest/test/set_header.js @@ -0,0 +1,30 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +test('setHeader on a request', function (t) { + t.plan(2); + + var server = http.createServer(function (req, res) { + t.equal(req.headers.robot, 'party'); + res.end('beep boop'); + }); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + r.setHeader('robot', 'party'); + r.pipe(through(write, end)); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/.npmignore new file mode 100644 index 00000000..0b1d3fa0 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/.npmignore @@ -0,0 +1,14 @@ +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +npm-debug.log diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/README.md new file mode 100644 index 00000000..c40b1c4f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/README.md @@ -0,0 +1,3 @@ +# hyperzip + +Make hyperquest requests that have full support for gzip and deflate encoding (server side only) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/index.js new file mode 100644 index 00000000..160fbd8f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/index.js @@ -0,0 +1,62 @@ +var through = require('through'); +var duplexer = require('duplexer'); +var zlib = require('zlib'); +var hyperquest = require('hyperquest'); + +module.exports = zip; +module.exports.request = zip(hyperquest); + +function zip(subquest) { + if (subquest === undefined) subquest = hyperquest; + if (typeof subquest.request === 'function') subquest = subquest.request; + if (subquest.isCap) throw new Error('The subquest argument "' + subquest + '" was invalid. You must use a valid hyperquest module that is not a cap.'); + function request(uri, opts, cb) { + if (typeof uri === 'object') { + cb = opts; + opts = uri; + uri = undefined; + } + if (typeof opts === 'function') { + cb = opts; + opts = undefined; + } + if (!opts) opts = {}; + if (uri !== undefined) opts.uri = uri; + + opts.headers = opts.headers || {}; + opts.headers['Accept-Encoding'] = opts.headers['Accept-Encoding'] ? opts.headers['Accept-Encoding'] + ',gzip,deflate' : 'gzip,deflate'; + + var method = (opts.method || 'GET').toUpperCase(); + var duplex = (method != 'GET' && method != 'DELETE'); + + var rs = through(); + var ws = hyperquest(opts, function (err, res) { + if (err) dup.emit('error', err); + switch (res.headers['content-encoding']) { + case 'gzip': + res.headers['content-encoding'] = null; + this.pipe(zlib.createGunzip()).pipe(rs); + break; + case 'deflate': + res.headers['content-encoding'] = null; + this.pipe(zlib.createInflate()).pipe(rs); + break; + default: + this.pipe(rs); + break; + } + dup.emit('response', res); + }) + var dup = duplex ? duplexer(ws, rs) : rs; + + if (cb) { + dup.on('error', cb); + dup.on('response', function (res) { + cb.call(dup, null, res); + }); + } + return dup; + } + request.request = request; + return request; +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/.npmignore new file mode 100644 index 00000000..062c11e8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/.npmignore @@ -0,0 +1,3 @@ +node_modules +*.log +*.err \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/.travis.yml new file mode 100644 index 00000000..ed05f88d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.11" + - "0.10" + - "0.8" + - "0.6" diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/LICENCE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/LICENCE new file mode 100644 index 00000000..a23e08a8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/LICENCE @@ -0,0 +1,19 @@ +Copyright (c) 2012 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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/README.md new file mode 100644 index 00000000..61ff71aa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/README.md @@ -0,0 +1,47 @@ +# duplexer + +[![build status][1]][2] [![dependency status][3]][4] + +[![browser support][5]][6] + +Creates a duplex stream + +Taken from [event-stream][7] + +## duplex (writeStream, readStream) + +Takes a writable stream and a readable stream and makes them appear as a readable writable stream. + +It is assumed that the two streams are connected to each other in some way. + +## Example + +```js +var grep = cp.exec('grep Stream') + +duplex(grep.stdin, grep.stdout) +``` + +## Installation + +`npm install duplexer` + +## Tests + +`npm test` + +## Contributors + + - Dominictarr + - Raynos + - samccone + +## MIT Licenced + + [1]: https://secure.travis-ci.org/Raynos/duplexer.png + [2]: https://travis-ci.org/Raynos/duplexer + [3]: https://david-dm.org/Raynos/duplexer.png + [4]: https://david-dm.org/Raynos/duplexer + [5]: https://ci.testling.com/Raynos/duplexer.png + [6]: https://ci.testling.com/Raynos/duplexer + [7]: https://github.com/dominictarr/event-stream#duplex-writestream-readstream diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/index.js new file mode 100644 index 00000000..a188a210 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/index.js @@ -0,0 +1,87 @@ +var Stream = require("stream") +var writeMethods = ["write", "end", "destroy"] +var readMethods = ["resume", "pause"] +var readEvents = ["data", "close"] +var slice = Array.prototype.slice + +module.exports = duplex + +function forEach (arr, fn) { + if (arr.forEach) { + return arr.forEach(fn) + } + + for (var i = 0; i < arr.length; i++) { + fn(arr[i], i) + } +} + +function duplex(writer, reader) { + var stream = new Stream() + var ended = false + + forEach(writeMethods, proxyWriter) + + forEach(readMethods, proxyReader) + + forEach(readEvents, proxyStream) + + reader.on("end", handleEnd) + + writer.on("drain", function() { + stream.emit("drain") + }) + + writer.on("error", reemit) + reader.on("error", reemit) + + stream.writable = writer.writable + stream.readable = reader.readable + + return stream + + function proxyWriter(methodName) { + stream[methodName] = method + + function method() { + return writer[methodName].apply(writer, arguments) + } + } + + function proxyReader(methodName) { + stream[methodName] = method + + function method() { + stream.emit(methodName) + var func = reader[methodName] + if (func) { + return func.apply(reader, arguments) + } + reader.emit(methodName) + } + } + + function proxyStream(methodName) { + reader.on(methodName, reemit) + + function reemit() { + var args = slice.call(arguments) + args.unshift(methodName) + stream.emit.apply(stream, args) + } + } + + function handleEnd() { + if (ended) { + return + } + ended = true + var args = slice.call(arguments) + args.unshift("end") + stream.emit.apply(stream, args) + } + + function reemit(err) { + stream.emit("error", err) + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/package.json new file mode 100644 index 00000000..86ab2145 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/package.json @@ -0,0 +1,57 @@ +{ + "name": "duplexer", + "version": "0.1.1", + "description": "Creates a duplex stream", + "keywords": [], + "author": { + "name": "Raynos", + "email": "raynos2@gmail.com" + }, + "repository": { + "type": "git", + "url": "git://github.com/Raynos/duplexer.git" + }, + "main": "index", + "homepage": "https://github.com/Raynos/duplexer", + "contributors": [ + { + "name": "Jake Verbaten" + } + ], + "bugs": { + "url": "https://github.com/Raynos/duplexer/issues", + "email": "raynos2@gmail.com" + }, + "devDependencies": { + "tape": "0.3.3", + "through": "~0.1.4" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://github.com/Raynos/duplexer/raw/master/LICENSE" + } + ], + "scripts": { + "test": "node test" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "ie/8..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest" + ] + }, + "readme": "# duplexer\n\n[![build status][1]][2] [![dependency status][3]][4]\n\n[![browser support][5]][6]\n\nCreates a duplex stream\n\nTaken from [event-stream][7]\n\n## duplex (writeStream, readStream)\n\nTakes a writable stream and a readable stream and makes them appear as a readable writable stream.\n\nIt is assumed that the two streams are connected to each other in some way.\n\n## Example\n\n```js\nvar grep = cp.exec('grep Stream')\n\nduplex(grep.stdin, grep.stdout)\n```\n\n## Installation\n\n`npm install duplexer`\n\n## Tests\n\n`npm test`\n\n## Contributors\n\n - Dominictarr\n - Raynos\n - samccone\n\n## MIT Licenced\n\n [1]: https://secure.travis-ci.org/Raynos/duplexer.png\n [2]: https://travis-ci.org/Raynos/duplexer\n [3]: https://david-dm.org/Raynos/duplexer.png\n [4]: https://david-dm.org/Raynos/duplexer\n [5]: https://ci.testling.com/Raynos/duplexer.png\n [6]: https://ci.testling.com/Raynos/duplexer\n [7]: https://github.com/dominictarr/event-stream#duplex-writestream-readstream\n", + "readmeFilename": "README.md", + "_id": "duplexer@0.1.1", + "_from": "duplexer@~0.1.1" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/test/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/test/index.js new file mode 100644 index 00000000..4988e0d9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/duplexer/test/index.js @@ -0,0 +1,31 @@ +var through = require("through") +var test = require("tape") + +var duplex = require("../index") + +var readable = through() +var writable = through(write) +var written = 0 +var data = 0 + +var stream = duplex(writable, readable) + +function write() { + written++ +} + +stream.on("data", ondata) + +function ondata() { + data++ +} + +test("emit and write", function(t) { + t.plan(2) + + stream.write() + readable.emit("data") + + t.equal(written, 1, "should have written once") + t.equal(data, 1, "should have recived once") +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/.travis.yml new file mode 100644 index 00000000..dad2273c --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.8 + - "0.10" diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/LICENSE new file mode 100644 index 00000000..ee27ba4b --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/example/many_request.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/example/many_request.js new file mode 100644 index 00000000..abbc28ea --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/example/many_request.js @@ -0,0 +1,20 @@ +var http = require('http'); +var request = require('request'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = request('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/example/req.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/example/req.js new file mode 100644 index 00000000..2d73de7e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/example/req.js @@ -0,0 +1,2 @@ +var hyperquest = require('../'); +hyperquest('http://localhost:8000').pipe(process.stdout); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/index.js new file mode 100644 index 00000000..73d66748 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/index.js @@ -0,0 +1,139 @@ +var url = require('url'); +var http = require('http'); +var https = require('https'); +var through = require('through'); +var duplexer = require('duplexer'); + +module.exports = hyperquest; + +function bind (obj, fn) { + var args = Array.prototype.slice.call(arguments, 2); + return function () { + var argv = args.concat(Array.prototype.slice.call(arguments)); + return fn.apply(obj, argv); + } +} + +function hyperquest (uri, opts, cb, extra) { + if (typeof uri === 'object') { + cb = opts; + opts = uri; + uri = undefined; + } + if (typeof opts === 'function') { + cb = opts; + opts = undefined; + } + if (!opts) opts = {}; + if (uri !== undefined) opts.uri = uri; + if (extra) opts.method = extra.method; + + var req = new Req(opts); + var ws = req.duplex && through(); + if (ws) ws.pause(); + var rs = through(); + + var dup = req.duplex ? duplexer(ws, rs) : rs; + if (!req.duplex) { + rs.writable = false; + } + dup.request = req; + dup.setHeader = bind(req, req.setHeader); + dup.setLocation = bind(req, req.setLocation); + + var closed = false; + dup.on('close', function () { closed = true }); + + process.nextTick(function () { + if (closed) return; + dup.on('close', function () { r.destroy() }); + + var r = req._send(); + r.on('error', bind(dup, dup.emit, 'error')); + + r.on('response', function (res) { + dup.response = res; + dup.emit('response', res); + if (req.duplex) res.pipe(rs) + else { + res.on('data', function (buf) { rs.queue(buf) }); + res.on('end', function () { rs.queue(null) }); + } + }); + + if (req.duplex) { + ws.pipe(r); + ws.resume(); + } + else r.end(); + }); + + if (cb) { + dup.on('error', cb); + dup.on('response', bind(dup, cb, null)); + } + return dup; +} + +hyperquest.get = hyperquest; + +hyperquest.post = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'POST' }); +}; + +hyperquest.put = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'PUT' }); +}; + +hyperquest['delete'] = function (uri, opts, cb) { + return hyperquest(uri, opts, cb, { method: 'DELETE' }); +}; + +function Req (opts) { + this.headers = opts.headers || {}; + + var method = (opts.method || 'GET').toUpperCase(); + this.method = method; + this.duplex = !(method === 'GET' || method === 'DELETE' + || method === 'HEAD'); + this.auth = opts.auth; + + if (opts.uri) this.setLocation(opts.uri); +} + +Req.prototype._send = function () { + this._sent = true; + + var headers = this.headers || {}; + var u = url.parse(this.uri); + var au = u.auth || this.auth; + if (au) { + headers.authorization = 'Basic ' + Buffer(au).toString('base64'); + } + + var protocol = u.protocol || ''; + var iface = protocol === 'https:' ? https : http; + var req = iface.request({ + scheme: protocol.replace(/:$/, ''), + method: this.method, + host: u.hostname, + port: Number(u.port), + path: u.path, + agent: false, + headers: headers + }); + + if (req.setTimeout) req.setTimeout(Math.pow(2, 32) * 1000); + return req; +}; + +Req.prototype.setHeader = function (key, value) { + if (this._sent) throw new Error('request already sent'); + this.headers[key] = value; + return this; +}; + +Req.prototype.setLocation = function (uri) { + this.uri = uri; + return this; +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/package.json new file mode 100644 index 00000000..621c7a57 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/package.json @@ -0,0 +1,46 @@ +{ + "name": "hyperquest", + "version": "0.1.8", + "description": "make streaming http requests", + "main": "index.js", + "dependencies": { + "through": "~2.2.0", + "duplexer": "~0.1.0" + }, + "devDependencies": { + "tap": "~0.4.0" + }, + "scripts": { + "test": "tap test/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/substack/hyperquest.git" + }, + "homepage": "https://github.com/substack/hyperquest", + "keywords": [ + "stream", + "http", + "transport", + "request", + "get", + "post", + "put", + "delete", + "duplex", + "pooling" + ], + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "license": "MIT", + "readme": "# hyperquest\n\ntreat http requests as a streaming transport\n\n[![build status](https://secure.travis-ci.org/substack/hyperquest.png)](http://travis-ci.org/substack/hyperquest)\n\nThe hyperquest api is a subset of [request](https://github.com/mikeal/request).\n\nThis module works in the browser with [browserify](http://browserify.org).\n\n# rant\n\n![animated gif rant](http://substack.net/images/substack.gif)\n\nThis module disables a lot of infuriating things about core http that WILL cause\nbugs in your application if you think of http as just another kind of stream:\n\n* http requests have a default idle timeout of 2 minutes. This is terrible if\nyou just want to pipe together a bunch of persistent backend processes over\nhttp.\n\n* There is a default connection pool of 5 requests. If you have 5 or more extant\nhttp requests, any additional requests will HANG for NO GOOD REASON.\n\nhyperquest turns these annoyances off so you can just pretend that core http is\njust a fancier version of tcp and not the horrible monstrosity that it actually\nis.\n\nI have it on good authority that these annoyances will be fixed in node 0.12.\n\n# example\n\n# simple streaming GET\n\n``` js\nvar hyperquest = require('hyperquest');\nhyperquest('http://localhost:8000').pipe(process.stdout);\n```\n\n```\n$ node example/req.js\nbeep boop\n```\n\n# pooling is evil\n\nNow to drive the point home about pooling being evil and almost always never\nwhat you want ever.\n\n[request](https://github.com/mikeal/request)\nhas its own forever agent thing that works pretty much the same as node core\nhttp.request: the wrong, horrible, broken way.\n\nFor instance, the following request code takes 12+ seconds to finish:\n\n``` js\nvar http = require('http');\nvar request = require('request');\n\nvar server = http.createServer(function (req, res) {\n res.write(req.url.slice(1) + '\\n');\n setTimeout(res.end.bind(res), 3000);\n});\n\nserver.listen(5000, function () {\n var pending = 20;\n for (var i = 0; i < 20; i++) {\n var r = request('http://localhost:5000/' + i);\n r.pipe(process.stdout, { end: false });\n r.on('end', function () {\n if (--pending === 0) server.close();\n });\n }\n});\n\nprocess.stdout.setMaxListeners(0); // turn off annoying warnings\n```\n\n```\nsubstack : example $ time node many_request.js \n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n\nreal 0m12.423s\nuser 0m0.424s\nsys 0m0.048s\n```\n\nSurprising? YES. This is pretty much never what you want, particularly if you\nhave a lot of streaming http API endpoints. Your code will just *HANG* once the\nconnection pool fills up and it won't start working again until some connections\ndie for whatever reason. I have encountered this so many times in production\ninstances and it is SO hard to track down reliably.\n\nCompare to using hyperquest, which is exactly the same code but it takes 3\nseconds instead of 12 to finish because it's not completely self-crippled like\nrequest and core http.request.\n\n``` js\nvar http = require('http');\nvar hyperquest = require('hyperquest');\n\nvar server = http.createServer(function (req, res) {\n res.write(req.url.slice(1) + '\\n');\n setTimeout(res.end.bind(res), 3000);\n});\n\nserver.listen(5000, function () {\n var pending = 20;\n for (var i = 0; i < 20; i++) {\n var r = hyperquest('http://localhost:5000/' + i);\n r.pipe(process.stdout, { end: false });\n r.on('end', function () {\n if (--pending === 0) server.close();\n });\n }\n});\n\nprocess.stdout.setMaxListeners(0); // turn off annoying warnings\n```\n```\n$ time node many_hyperquest.js \n0\n1\n2\n3\n4\n5\n6\n8\n9\n7\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n\nreal 0m3.284s\nuser 0m0.288s\nsys 0m0.060s\n```\n\nSo the other thing is, the justification I've heard supporting this horrible\nlimit-of-5 pooling behavior is \"performance\". The first example which has been\ntuned for \"performance\" takes 12 seconds. The second example that removes these\n\"performance\" enhancements takes 3. Some performance improvement INDEED!\n\n# methods\n\n``` js\nvar hyperquest = require('hyperquest');\n```\n\n## var req = hyperquest(uri, opts={}, cb)\n\nCreate an outgoing http request to `uri` or `opts.uri`.\nYou need not pass any arguments here since there are setter methods documented\nbelow.\n\nReturn a readable or duplex stream depending on the `opts.method`.\n\nDefault option values:\n\n* opts.method - `\"GET\"`\n* opts.headers - `{}`\n* opts.auth - undefined, but is set automatically when the `uri` has an auth\nstring in it such as `\"http://user:passwd@host\"`. `opts.auth` is of the form\n`\"user:pass\"`, just like `http.request()`.\n\nThe request does not go through until the `nextTick` so you can set values\noutside of the `opts` so long as they are called on the same tick.\n\nOptionally you can pass a `cb(err, res)` to set up listeners for `'error'` and\n`'response'` events in one place.\n\nNote that the optional `cb` is NOT like\n[request](https://github.com/mikeal/request)\nin that hyperquest will not buffer content for you or decode to json or any such\nmagical thing.\n\n## req.setHeader(key, value);\n\nSet an outgoing header `key` to `value`.\n\n## req.setLocation(uri);\n\nSet the location if you didn't specify it in the `hyperquest()` call.\n\n## var req = hyperquest.get(uri, opts, cb)\n\nReturn a readable stream from `hyperquest(..., { method: 'GET' })`.\n\n## var req = hyperquest.put(uri, opts, cb)\n\nReturn a duplex stream from `hyperquest(..., { method: 'PUT' })`.\n\n## var req = hyperquest.post(uri, opts, cb)\n\nReturn a duplex stream from `hyperquest(..., { method: 'POST' })`.\n\n## var req = hyperquest.delete(uri, opts, cb)\n\nReturn a readable stream from `hyperquest(..., { method: 'DELETE' })`.\n\n# events\n\n## req.on('response', function (res) {})\n\nThe `'response'` event is forwarded from the underlying `http.request()`.\n\n## req.on('error', function (res) {})\n\nThe `'error'` event is forwarded from the underlying `http.request()`.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install hyperquest\n```\n\n# license\n\nMIT\n", + "readmeFilename": "readme.markdown", + "bugs": { + "url": "https://github.com/substack/hyperquest/issues" + }, + "_id": "hyperquest@0.1.8", + "_from": "hyperquest@~0.1.5" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/readme.markdown b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/readme.markdown new file mode 100644 index 00000000..af7bdf01 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/readme.markdown @@ -0,0 +1,249 @@ +# hyperquest + +treat http requests as a streaming transport + +[![build status](https://secure.travis-ci.org/substack/hyperquest.png)](http://travis-ci.org/substack/hyperquest) + +The hyperquest api is a subset of [request](https://github.com/mikeal/request). + +This module works in the browser with [browserify](http://browserify.org). + +# rant + +![animated gif rant](http://substack.net/images/substack.gif) + +This module disables a lot of infuriating things about core http that WILL cause +bugs in your application if you think of http as just another kind of stream: + +* http requests have a default idle timeout of 2 minutes. This is terrible if +you just want to pipe together a bunch of persistent backend processes over +http. + +* There is a default connection pool of 5 requests. If you have 5 or more extant +http requests, any additional requests will HANG for NO GOOD REASON. + +hyperquest turns these annoyances off so you can just pretend that core http is +just a fancier version of tcp and not the horrible monstrosity that it actually +is. + +I have it on good authority that these annoyances will be fixed in node 0.12. + +# example + +# simple streaming GET + +``` js +var hyperquest = require('hyperquest'); +hyperquest('http://localhost:8000').pipe(process.stdout); +``` + +``` +$ node example/req.js +beep boop +``` + +# pooling is evil + +Now to drive the point home about pooling being evil and almost always never +what you want ever. + +[request](https://github.com/mikeal/request) +has its own forever agent thing that works pretty much the same as node core +http.request: the wrong, horrible, broken way. + +For instance, the following request code takes 12+ seconds to finish: + +``` js +var http = require('http'); +var request = require('request'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = request('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings +``` + +``` +substack : example $ time node many_request.js +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 + +real 0m12.423s +user 0m0.424s +sys 0m0.048s +``` + +Surprising? YES. This is pretty much never what you want, particularly if you +have a lot of streaming http API endpoints. Your code will just *HANG* once the +connection pool fills up and it won't start working again until some connections +die for whatever reason. I have encountered this so many times in production +instances and it is SO hard to track down reliably. + +Compare to using hyperquest, which is exactly the same code but it takes 3 +seconds instead of 12 to finish because it's not completely self-crippled like +request and core http.request. + +``` js +var http = require('http'); +var hyperquest = require('hyperquest'); + +var server = http.createServer(function (req, res) { + res.write(req.url.slice(1) + '\n'); + setTimeout(res.end.bind(res), 3000); +}); + +server.listen(5000, function () { + var pending = 20; + for (var i = 0; i < 20; i++) { + var r = hyperquest('http://localhost:5000/' + i); + r.pipe(process.stdout, { end: false }); + r.on('end', function () { + if (--pending === 0) server.close(); + }); + } +}); + +process.stdout.setMaxListeners(0); // turn off annoying warnings +``` +``` +$ time node many_hyperquest.js +0 +1 +2 +3 +4 +5 +6 +8 +9 +7 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 + +real 0m3.284s +user 0m0.288s +sys 0m0.060s +``` + +So the other thing is, the justification I've heard supporting this horrible +limit-of-5 pooling behavior is "performance". The first example which has been +tuned for "performance" takes 12 seconds. The second example that removes these +"performance" enhancements takes 3. Some performance improvement INDEED! + +# methods + +``` js +var hyperquest = require('hyperquest'); +``` + +## var req = hyperquest(uri, opts={}, cb) + +Create an outgoing http request to `uri` or `opts.uri`. +You need not pass any arguments here since there are setter methods documented +below. + +Return a readable or duplex stream depending on the `opts.method`. + +Default option values: + +* opts.method - `"GET"` +* opts.headers - `{}` +* opts.auth - undefined, but is set automatically when the `uri` has an auth +string in it such as `"http://user:passwd@host"`. `opts.auth` is of the form +`"user:pass"`, just like `http.request()`. + +The request does not go through until the `nextTick` so you can set values +outside of the `opts` so long as they are called on the same tick. + +Optionally you can pass a `cb(err, res)` to set up listeners for `'error'` and +`'response'` events in one place. + +Note that the optional `cb` is NOT like +[request](https://github.com/mikeal/request) +in that hyperquest will not buffer content for you or decode to json or any such +magical thing. + +## req.setHeader(key, value); + +Set an outgoing header `key` to `value`. + +## req.setLocation(uri); + +Set the location if you didn't specify it in the `hyperquest()` call. + +## var req = hyperquest.get(uri, opts, cb) + +Return a readable stream from `hyperquest(..., { method: 'GET' })`. + +## var req = hyperquest.put(uri, opts, cb) + +Return a duplex stream from `hyperquest(..., { method: 'PUT' })`. + +## var req = hyperquest.post(uri, opts, cb) + +Return a duplex stream from `hyperquest(..., { method: 'POST' })`. + +## var req = hyperquest.delete(uri, opts, cb) + +Return a readable stream from `hyperquest(..., { method: 'DELETE' })`. + +# events + +## req.on('response', function (res) {}) + +The `'response'` event is forwarded from the underlying `http.request()`. + +## req.on('error', function (res) {}) + +The `'error'` event is forwarded from the underlying `http.request()`. + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install hyperquest +``` + +# license + +MIT diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth.js new file mode 100644 index 00000000..6e711480 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'moo' && s[1] === 'hax') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic auth', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://moo:hax@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://beep:boop@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth_encoded.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth_encoded.js new file mode 100644 index 00000000..bac51264 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth_encoded.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'm##' && s[1] === 'h@x') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic auth with escaped params', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://m%23%23:h%40x@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://beep:boop@localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth_opt.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth_opt.js new file mode 100644 index 00000000..f85f979e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/auth_opt.js @@ -0,0 +1,51 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + var au = req.headers.authorization; + if (!au) return res.end('ACCESS DENIED'); + + var buf = Buffer(au.replace(/^Basic\s+/, ''), 'base64'); + var s = buf.toString().split(':'); + + if (s[0] === 'moo' && s[1] === 'hax') { + res.end('WELCOME TO ZOMBO COM'); + } + else { + res.end('ACCESS DENIED!!!'); + } +}); + +test('basic opts.auth', function (t) { + t.plan(3); + server.listen(0, function () { + var port = server.address().port; + checkUnauth(t, port); + checkValid(t, port); + checkInvalid(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function checkUnauth (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED') }); +} + +function checkValid (t, port) { + var r = hyperquest('http://localhost:' + port, { auth: 'moo:hax' }); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') }); +} + +function checkInvalid (t, port) { + var r = hyperquest('http://localhost:' + port, { auth: 'beep:boop' }); + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/get.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/get.js new file mode 100644 index 00000000..db6720d7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/get.js @@ -0,0 +1,33 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.setHeader('content-type', 'text/robot-speak'); + res.end('beep boop'); +}); + +test('get', function (t) { + t.plan(2); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + r.pipe(through(write, end)); + + r.on('response', function (res) { + t.equal(res.headers['content-type'], 'text/robot-speak'); + }); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/many.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/many.js new file mode 100644 index 00000000..40b18b36 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/many.js @@ -0,0 +1,34 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.write('beep boop'); +}); + +test('more than 5 pending connections', function (t) { + t.plan(20); + var pending = []; + server.listen(0, function () { + var port = server.address().port; + for (var i = 0; i < 20; i++) { + pending.push(check(t, port)); + } + }); + t.on('end', function () { + pending.forEach(function (p) { p.destroy() }); + server.close(); + }); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + var data = ''; + r.pipe(through(function (buf) { data += buf })); + + setTimeout(function () { + t.equal(data, 'beep boop'); + }, 100); + return r; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/opts.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/opts.js new file mode 100644 index 00000000..a8b4604f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/opts.js @@ -0,0 +1,34 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + res.setHeader('content-type', 'text/robot-speak'); + res.end('beep boop'); +}); + +test('1st-arg options', function (t) { + t.plan(2); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest( + { uri: 'http://localhost:' + port }, + function (err, res) { + t.equal(res.headers['content-type'], 'text/robot-speak'); + } + ); + r.pipe(through(write, end)); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/post.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/post.js new file mode 100644 index 00000000..fefc0643 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/post.js @@ -0,0 +1,38 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + req.pipe(through(function (buf) { + this.queue(String(buf).toUpperCase()); + })).pipe(res); +}); + +test('post', function (t) { + t.plan(1); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest.post('http://localhost:' + port); + r.pipe(through(write, end)); + + setTimeout(function () { + r.write('beep '); + }, 50); + + setTimeout(function () { + r.end('boop.'); + }, 100); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'BEEP BOOP.'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/post_immediate.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/post_immediate.js new file mode 100644 index 00000000..ed8606fa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/post_immediate.js @@ -0,0 +1,30 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +var server = http.createServer(function (req, res) { + req.pipe(through(function (buf) { + this.queue(String(buf).toUpperCase()); + })).pipe(res); +}); + +test('post', function (t) { + t.plan(1); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest.post('http://localhost:' + port); + r.end('beep boop.'); + + var data = ''; + r.on('data', function (buf) { data += buf }); + r.on('end', function () { + t.equal(data, 'BEEP BOOP.'); + }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/set_header.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/set_header.js new file mode 100644 index 00000000..6a5c59e8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/hyperquest/test/set_header.js @@ -0,0 +1,30 @@ +var test = require('tap').test; +var http = require('http'); +var hyperquest = require('../'); +var through = require('through'); + +test('setHeader on a request', function (t) { + t.plan(2); + + var server = http.createServer(function (req, res) { + t.equal(req.headers.robot, 'party'); + res.end('beep boop'); + }); + server.listen(0, function () { + var port = server.address().port; + check(t, port); + }); + t.on('end', server.close.bind(server)); +}); + +function check (t, port) { + var r = hyperquest('http://localhost:' + port); + r.setHeader('robot', 'party'); + r.pipe(through(write, end)); + + var data = ''; + function write (buf) { data += buf } + function end () { + t.equal(data, 'beep boop'); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/.travis.yml new file mode 100644 index 00000000..c693a939 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.6 + - 0.8 + - "0.10" diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/LICENSE.APACHE2 b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/LICENSE.APACHE2 new file mode 100644 index 00000000..6366c047 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/LICENSE.APACHE2 @@ -0,0 +1,15 @@ +Apache License, Version 2.0 + +Copyright (c) 2011 Dominic Tarr + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/LICENSE.MIT b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/LICENSE.MIT new file mode 100644 index 00000000..6eafbd73 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/LICENSE.MIT @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/index.js new file mode 100644 index 00000000..7b935bf9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/index.js @@ -0,0 +1,108 @@ +var Stream = require('stream') + +// through +// +// a stream that does nothing but re-emit the input. +// useful for aggregating a series of changing but not ending streams into one stream) + +exports = module.exports = through +through.through = through + +//create a readable writable stream. + +function through (write, end, opts) { + write = write || function (data) { this.queue(data) } + end = end || function () { this.queue(null) } + + var ended = false, destroyed = false, buffer = [], _ended = false + var stream = new Stream() + stream.readable = stream.writable = true + stream.paused = false + +// stream.autoPause = !(opts && opts.autoPause === false) + stream.autoDestroy = !(opts && opts.autoDestroy === false) + + stream.write = function (data) { + write.call(this, data) + return !stream.paused + } + + function drain() { + while(buffer.length && !stream.paused) { + var data = buffer.shift() + if(null === data) + return stream.emit('end') + else + stream.emit('data', data) + } + } + + stream.queue = stream.push = function (data) { +// console.error(ended) + if(_ended) return stream + if(data == null) _ended = true + buffer.push(data) + drain() + return stream + } + + //this will be registered as the first 'end' listener + //must call destroy next tick, to make sure we're after any + //stream piped from here. + //this is only a problem if end is not emitted synchronously. + //a nicer way to do this is to make sure this is the last listener for 'end' + + stream.on('end', function () { + stream.readable = false + if(!stream.writable && stream.autoDestroy) + process.nextTick(function () { + stream.destroy() + }) + }) + + function _end () { + stream.writable = false + end.call(stream) + if(!stream.readable && stream.autoDestroy) + stream.destroy() + } + + stream.end = function (data) { + if(ended) return + ended = true + if(arguments.length) stream.write(data) + _end() // will emit or queue + return stream + } + + stream.destroy = function () { + if(destroyed) return + destroyed = true + ended = true + buffer.length = 0 + stream.writable = stream.readable = false + stream.emit('close') + return stream + } + + stream.pause = function () { + if(stream.paused) return + stream.paused = true + return stream + } + + stream.resume = function () { + if(stream.paused) { + stream.paused = false + stream.emit('resume') + } + drain() + //may have become paused again, + //as drain emits 'data'. + if(!stream.paused) + stream.emit('drain') + return stream + } + return stream +} + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/package.json new file mode 100644 index 00000000..65301c5a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/package.json @@ -0,0 +1,46 @@ +{ + "name": "through", + "version": "2.3.4", + "description": "simplified stream contsruction", + "main": "index.js", + "scripts": { + "test": "set -e; for t in test/*.js; do node $t; done" + }, + "devDependencies": { + "stream-spec": "~0.3.5", + "tape": "~0.2.2" + }, + "keywords": [ + "stream", + "streams", + "user-streams", + "pipe" + ], + "author": { + "name": "Dominic Tarr", + "email": "dominic.tarr@gmail.com", + "url": "dominictarr.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/dominictarr/through.git" + }, + "homepage": "http://github.com/dominictarr/through", + "testling": { + "browsers": [ + "ie/8..latest", + "ff/15..latest", + "chrome/20..latest", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "readme": "#through\n\n[![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through)\n\nEasy way to create a `Stream` that is both `readable` and `writable`. \n\n* Pass in optional `write` and `end` methods.\n* `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`.\n* Use `this.pause()` and `this.resume()` to manage flow.\n* Check `this.paused` to see current flow state. (`write` always returns `!this.paused`).\n\nThis function is the basis for most of the synchronous streams in \n[event-stream](http://github.com/dominictarr/event-stream).\n\n``` js\nvar through = require('through')\n\nthrough(function write(data) {\n this.queue(data) //data *must* not be null\n },\n function end () { //optional\n this.queue(null)\n })\n```\n\nOr, can also be used _without_ buffering on pause, use `this.emit('data', data)`,\nand this.emit('end')\n\n``` js\nvar through = require('through')\n\nthrough(function write(data) {\n this.emit('data', data)\n //this.pause() \n },\n function end () { //optional\n this.emit('end')\n })\n```\n\n## Extended Options\n\nYou will probably not need these 99% of the time.\n\n### autoDestroy=false\n\nBy default, `through` emits close when the writable\nand readable side of the stream has ended.\nIf that is not desired, set `autoDestroy=false`.\n\n``` js\nvar through = require('through')\n\n//like this\nvar ts = through(write, end, {autoDestroy: false})\n//or like this\nvar ts = through(write, end)\nts.autoDestroy = false\n```\n\n## License\n\nMIT / Apache2\n", + "readmeFilename": "readme.markdown", + "bugs": { + "url": "https://github.com/dominictarr/through/issues" + }, + "_id": "through@2.3.4", + "_from": "through@~2.3.4" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/readme.markdown b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/readme.markdown new file mode 100644 index 00000000..b20bc9a8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/readme.markdown @@ -0,0 +1,63 @@ +#through + +[![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through) + +Easy way to create a `Stream` that is both `readable` and `writable`. + +* Pass in optional `write` and `end` methods. +* `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`. +* Use `this.pause()` and `this.resume()` to manage flow. +* Check `this.paused` to see current flow state. (`write` always returns `!this.paused`). + +This function is the basis for most of the synchronous streams in +[event-stream](http://github.com/dominictarr/event-stream). + +``` js +var through = require('through') + +through(function write(data) { + this.queue(data) //data *must* not be null + }, + function end () { //optional + this.queue(null) + }) +``` + +Or, can also be used _without_ buffering on pause, use `this.emit('data', data)`, +and this.emit('end') + +``` js +var through = require('through') + +through(function write(data) { + this.emit('data', data) + //this.pause() + }, + function end () { //optional + this.emit('end') + }) +``` + +## Extended Options + +You will probably not need these 99% of the time. + +### autoDestroy=false + +By default, `through` emits close when the writable +and readable side of the stream has ended. +If that is not desired, set `autoDestroy=false`. + +``` js +var through = require('through') + +//like this +var ts = through(write, end, {autoDestroy: false}) +//or like this +var ts = through(write, end) +ts.autoDestroy = false +``` + +## License + +MIT / Apache2 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/auto-destroy.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/auto-destroy.js new file mode 100644 index 00000000..9a8fd000 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/auto-destroy.js @@ -0,0 +1,30 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('end before close', function (assert) { + var ts = through() + ts.autoDestroy = false + var ended = false, closed = false + + ts.on('end', function () { + assert.ok(!closed) + ended = true + }) + ts.on('close', function () { + assert.ok(ended) + closed = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.ok(ended) + assert.notOk(closed) + ts.destroy() + assert.ok(closed) + assert.end() +}) + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/buffering.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/buffering.js new file mode 100644 index 00000000..b0084bfc --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/buffering.js @@ -0,0 +1,71 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('buffering', function(assert) { + var ts = through(function (data) { + this.queue(data) + }, function () { + this.queue(null) + }) + + var ended = false, actual = [] + + ts.on('data', actual.push.bind(actual)) + ts.on('end', function () { + ended = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + assert.deepEqual(actual, [1, 2, 3]) + ts.pause() + ts.write(4) + ts.write(5) + ts.write(6) + assert.deepEqual(actual, [1, 2, 3]) + ts.resume() + assert.deepEqual(actual, [1, 2, 3, 4, 5, 6]) + ts.pause() + ts.end() + assert.ok(!ended) + ts.resume() + assert.ok(ended) + assert.end() +}) + +test('buffering has data in queue, when ends', function (assert) { + + /* + * If stream ends while paused with data in the queue, + * stream should still emit end after all data is written + * on resume. + */ + + var ts = through(function (data) { + this.queue(data) + }, function () { + this.queue(null) + }) + + var ended = false, actual = [] + + ts.on('data', actual.push.bind(actual)) + ts.on('end', function () { + ended = true + }) + + ts.pause() + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.deepEqual(actual, [], 'no data written yet, still paused') + assert.ok(!ended, 'end not emitted yet, still paused') + ts.resume() + assert.deepEqual(actual, [1, 2, 3], 'resumed, all data should be delivered') + assert.ok(ended, 'end should be emitted once all data was delivered') + assert.end(); +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/end.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/end.js new file mode 100644 index 00000000..fa113f58 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/end.js @@ -0,0 +1,45 @@ +var test = require('tape') +var through = require('../') + +// must emit end before close. + +test('end before close', function (assert) { + var ts = through() + var ended = false, closed = false + + ts.on('end', function () { + assert.ok(!closed) + ended = true + }) + ts.on('close', function () { + assert.ok(ended) + closed = true + }) + + ts.write(1) + ts.write(2) + ts.write(3) + ts.end() + assert.ok(ended) + assert.ok(closed) + assert.end() +}) + +test('end only once', function (t) { + + var ts = through() + var ended = false, closed = false + + ts.on('end', function () { + t.equal(ended, false) + ended = true + }) + + ts.queue(null) + ts.queue(null) + ts.queue(null) + + ts.resume() + + t.end() +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/index.js new file mode 100644 index 00000000..33e33f96 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/node_modules/through/test/index.js @@ -0,0 +1,114 @@ + +var test = require('tape') +var spec = require('stream-spec') +var through = require('../') + +/* + I'm using these two functions, and not streams and pipe + so there is less to break. if this test fails it must be + the implementation of _through_ +*/ + +function write(array, stream) { + array = array.slice() + function next() { + while(array.length) + if(stream.write(array.shift()) === false) + return stream.once('drain', next) + + stream.end() + } + + next() +} + +function read(stream, callback) { + var actual = [] + stream.on('data', function (data) { + actual.push(data) + }) + stream.once('end', function () { + callback(null, actual) + }) + stream.once('error', function (err) { + callback(err) + }) +} + +test('simple defaults', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l * Math.random()) + + var t = through() + spec(t) + .through() + .pausable() + .validateOnExit() + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected) + assert.end() + }) + + write(expected, t) +}); + +test('simple functions', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l * Math.random()) + + var t = through(function (data) { + this.emit('data', data*2) + }) + spec(t) + .through() + .pausable() + .validateOnExit() + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected.map(function (data) { + return data*2 + })) + assert.end() + }) + + write(expected, t) +}) + +test('pauses', function(assert) { + + var l = 1000 + , expected = [] + + while(l--) expected.push(l) //Math.random()) + + var t = through() + spec(t) + .through() + .pausable() + .validateOnExit() + + t.on('data', function () { + if(Math.random() > 0.1) return + t.pause() + process.nextTick(function () { + t.resume() + }) + }) + + read(t, function (err, actual) { + assert.ifError(err) + assert.deepEqual(actual, expected) + assert.end() + }) + + write(expected, t) +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/package.json new file mode 100644 index 00000000..53b8dbb2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/node_modules/hyperzip/package.json @@ -0,0 +1,34 @@ +{ + "name": "hyperzip", + "version": "0.0.0", + "description": "Make hyperquest requests that have full support for gzip and deflate encoding (server side only)", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/hyperquest/hyperzip.git" + }, + "author": { + "name": "ForbesLindesay" + }, + "license": "MIT", + "dependencies": { + "duplexer": "~0.1.1", + "through": "~2.3.4", + "hyperquest": "~0.1.5" + }, + "readme": "# hyperzip\r\n\r\nMake hyperquest requests that have full support for gzip and deflate encoding (server side only)\r\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/hyperquest/hyperzip/issues" + }, + "homepage": "https://github.com/hyperquest/hyperzip", + "_id": "hyperzip@0.0.0", + "dist": { + "shasum": "29d2fb5699271d82f59a51b432fe9f341014bfda" + }, + "_from": "hyperzip@", + "_resolved": "https://registry.npmjs.org/hyperzip/-/hyperzip-0.0.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/package.json new file mode 100644 index 00000000..f7ee6a46 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/package.json @@ -0,0 +1,12 @@ +{ + "name": "string_decoder-build", + "version": "0.0.0", + "description": "", + "main": "build.js", + "dependencies": { + "bl": "~0.6.0", + "hyperzip": "0.0.0", + "hyperdirect": "0.0.0", + "cheerio": "~0.13.1" + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/test-replacements.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/test-replacements.js new file mode 100644 index 00000000..5bbf6028 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/build/test-replacements.js @@ -0,0 +1,24 @@ +module.exports.all = [ + [ + /require\(['"]string_decoder['"]\)/g + , 'require(\'../../\')' + ] + +] + +module.exports['common.js'] = [ + [ + /^ setImmediate,$/m + , ' typeof setImmediate == \'undefined\' ? null : setImmediate,' + ] + + , [ + /^ clearImmediate,$/m + , ' typeof clearImmediate == \'undefined\' ? null : clearImmediate,' + ] + + , [ + /^ global];$/m + , ' global].filter(Boolean);' + ] +] diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/index.js new file mode 100644 index 00000000..2e44a03e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/index.js @@ -0,0 +1,200 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var Buffer = require('buffer').Buffer; + +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + this.charBuffer = new Buffer(6); + this.charReceived = 0; + this.charLength = 0; +}; + + +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + var offset = 0; + + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var i = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, offset, i); + this.charReceived += (i - offset); + offset = i; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (i == buffer.length) return charStr; + + // otherwise cut off the characters end from the beginning of this buffer + buffer = buffer.slice(i, buffer.length); + break; + } + + var lenIncomplete = this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end); + this.charReceived = lenIncomplete; + end -= lenIncomplete; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + + return i; +}; + +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + var incomplete = this.charReceived = buffer.length % 2; + this.charLength = incomplete ? 2 : 0; + return incomplete; +} + +function base64DetectIncompleteChar(buffer) { + var incomplete = this.charReceived = buffer.length % 3; + this.charLength = incomplete ? 3 : 0; + return incomplete; +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/package.json new file mode 100644 index 00000000..bf4f67f6 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/package.json @@ -0,0 +1,33 @@ +{ + "name": "string_decoder", + "version": "0.10.25", + "description": "The string_decoder module from Node core", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "tap": "~0.4.8" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/rvagg/string_decoder.git" + }, + "homepage": "https://github.com/rvagg/string_decoder", + "keywords": [ + "string", + "decoder", + "browser", + "browserify" + ], + "license": "MIT", + "readme": "**string_decoder.js** (`require('string_decoder')`) from Node.js core\n\nCopyright Joyent, Inc. and other Node contributors. See LICENCE file for details.\n\nVersion numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10. **Prefer the stable version over the unstable.**\n\nThe *build/* directory contains a build script that will scrape the source from the [joyent/node](https://github.com/joyent/node) repo given a specific Node version.", + "readmeFilename": "README.md", + "_id": "string_decoder@0.10.25", + "dist": { + "shasum": "c21a1fdf7dea11b4459227df93db7591731ef620" + }, + "_from": "string_decoder@~0.10.x", + "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.25.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/common.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/common.js new file mode 100644 index 00000000..ed5ff08d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/common.js @@ -0,0 +1,200 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var path = require('path'); +var assert = require('assert'); + +exports.testDir = path.dirname(__filename); +exports.fixturesDir = path.join(exports.testDir, 'fixtures'); +exports.libDir = path.join(exports.testDir, '../lib'); +exports.tmpDir = path.join(exports.testDir, 'tmp'); +exports.PORT = +process.env.NODE_COMMON_PORT || 12346; + +if (process.platform === 'win32') { + exports.PIPE = '\\\\.\\pipe\\libuv-test'; +} else { + exports.PIPE = exports.tmpDir + '/test.sock'; +} + +var util = require('util'); +for (var i in util) exports[i] = util[i]; +//for (var i in exports) global[i] = exports[i]; + +function protoCtrChain(o) { + var result = []; + for (; o; o = o.__proto__) { result.push(o.constructor); } + return result.join(); +} + +exports.indirectInstanceOf = function(obj, cls) { + if (obj instanceof cls) { return true; } + var clsChain = protoCtrChain(cls.prototype); + var objChain = protoCtrChain(obj); + return objChain.slice(-clsChain.length) === clsChain; +}; + + +exports.ddCommand = function(filename, kilobytes) { + if (process.platform === 'win32') { + var p = path.resolve(exports.fixturesDir, 'create-file.js'); + return '"' + process.argv[0] + '" "' + p + '" "' + + filename + '" ' + (kilobytes * 1024); + } else { + return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes; + } +}; + + +exports.spawnCat = function(options) { + var spawn = require('child_process').spawn; + + if (process.platform === 'win32') { + return spawn('more', [], options); + } else { + return spawn('cat', [], options); + } +}; + + +exports.spawnPwd = function(options) { + var spawn = require('child_process').spawn; + + if (process.platform === 'win32') { + return spawn('cmd.exe', ['/c', 'cd'], options); + } else { + return spawn('pwd', [], options); + } +}; + + +// Turn this off if the test should not check for global leaks. +exports.globalCheck = true; + +process.on('exit', function() { + if (!exports.globalCheck) return; + var knownGlobals = [setTimeout, + setInterval, + typeof setImmediate == 'undefined' ? null : setImmediate, + clearTimeout, + clearInterval, + typeof clearImmediate == 'undefined' ? null : clearImmediate, + console, + Buffer, + process, + global].filter(Boolean); + + if (global.gc) { + knownGlobals.push(gc); + } + + if (global.DTRACE_HTTP_SERVER_RESPONSE) { + knownGlobals.push(DTRACE_HTTP_SERVER_RESPONSE); + knownGlobals.push(DTRACE_HTTP_SERVER_REQUEST); + knownGlobals.push(DTRACE_HTTP_CLIENT_RESPONSE); + knownGlobals.push(DTRACE_HTTP_CLIENT_REQUEST); + knownGlobals.push(DTRACE_NET_STREAM_END); + knownGlobals.push(DTRACE_NET_SERVER_CONNECTION); + knownGlobals.push(DTRACE_NET_SOCKET_READ); + knownGlobals.push(DTRACE_NET_SOCKET_WRITE); + } + if (global.COUNTER_NET_SERVER_CONNECTION) { + knownGlobals.push(COUNTER_NET_SERVER_CONNECTION); + knownGlobals.push(COUNTER_NET_SERVER_CONNECTION_CLOSE); + knownGlobals.push(COUNTER_HTTP_SERVER_REQUEST); + knownGlobals.push(COUNTER_HTTP_SERVER_RESPONSE); + knownGlobals.push(COUNTER_HTTP_CLIENT_REQUEST); + knownGlobals.push(COUNTER_HTTP_CLIENT_RESPONSE); + } + + if (global.ArrayBuffer) { + knownGlobals.push(ArrayBuffer); + knownGlobals.push(Int8Array); + knownGlobals.push(Uint8Array); + knownGlobals.push(Uint8ClampedArray); + knownGlobals.push(Int16Array); + knownGlobals.push(Uint16Array); + knownGlobals.push(Int32Array); + knownGlobals.push(Uint32Array); + knownGlobals.push(Float32Array); + knownGlobals.push(Float64Array); + knownGlobals.push(DataView); + } + + for (var x in global) { + var found = false; + + for (var y in knownGlobals) { + if (global[x] === knownGlobals[y]) { + found = true; + break; + } + } + + if (!found) { + console.error('Unknown global: %s', x); + assert.ok(false, 'Unknown global found'); + } + } +}); + + +var mustCallChecks = []; + + +function runCallChecks(exitCode) { + if (exitCode !== 0) return; + + var failed = mustCallChecks.filter(function(context) { + return context.actual !== context.expected; + }); + + failed.forEach(function(context) { + console.log('Mismatched %s function calls. Expected %d, actual %d.', + context.name, + context.expected, + context.actual); + console.log(context.stack.split('\n').slice(2).join('\n')); + }); + + if (failed.length) process.exit(1); +} + + +exports.mustCall = function(fn, expected) { + if (typeof expected !== 'number') expected = 1; + + var context = { + expected: expected, + actual: 0, + stack: (new Error).stack, + name: fn.name || '' + }; + + // add the exit listener only once to avoid listener leak warnings + if (mustCallChecks.length === 0) process.on('exit', runCallChecks); + + mustCallChecks.push(context); + + return function() { + context.actual++; + return fn.apply(this, arguments); + }; +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/simple/test-string-decoder-end.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/simple/test-string-decoder-end.js new file mode 100644 index 00000000..869a4116 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/simple/test-string-decoder-end.js @@ -0,0 +1,75 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// verify that the string decoder works getting 1 byte at a time, +// the whole buffer at once, and that both match the .toString(enc) +// result of the entire buffer. + +var assert = require('assert'); +var SD = require('../../').StringDecoder; +var encodings = ['base64', 'hex', 'utf8', 'utf16le', 'ucs2']; + +var bufs = [ '☃💩', 'asdf' ].map(function(b) { + return new Buffer(b); +}); + +// also test just arbitrary bytes from 0-15. +for (var i = 1; i <= 16; i++) { + var bytes = new Array(i).join('.').split('.').map(function(_, j) { + return j + 0x78; + }); + bufs.push(new Buffer(bytes)); +} + +encodings.forEach(testEncoding); + +console.log('ok'); + +function testEncoding(encoding) { + bufs.forEach(function(buf) { + testBuf(encoding, buf); + }); +} + +function testBuf(encoding, buf) { + console.error('# %s', encoding, buf); + + // write one byte at a time. + var s = new SD(encoding); + var res1 = ''; + for (var i = 0; i < buf.length; i++) { + res1 += s.write(buf.slice(i, i + 1)); + } + res1 += s.end(); + + // write the whole buffer at once. + var res2 = ''; + var s = new SD(encoding); + res2 += s.write(buf); + res2 += s.end(); + + // .toString() on the buffer + var res3 = buf.toString(encoding); + + console.log('expect=%j', res3); + assert.equal(res1, res3, 'one byte at a time should match toString'); + assert.equal(res2, res3, 'all bytes at once should match toString'); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/simple/test-string-decoder.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/simple/test-string-decoder.js new file mode 100644 index 00000000..7f69f7ea --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/node_modules/string_decoder/test/simple/test-string-decoder.js @@ -0,0 +1,163 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var common = require('../common'); +var assert = require('assert'); +var StringDecoder = require('../../').StringDecoder; +var decoder = new StringDecoder('utf8'); + + + +var buffer = new Buffer('$'); +assert.deepEqual('$', decoder.write(buffer)); + +buffer = new Buffer('¢'); +assert.deepEqual('', decoder.write(buffer.slice(0, 1))); +assert.deepEqual('¢', decoder.write(buffer.slice(1, 2))); + +buffer = new Buffer('€'); +assert.deepEqual('', decoder.write(buffer.slice(0, 1))); +assert.deepEqual('', decoder.write(buffer.slice(1, 2))); +assert.deepEqual('€', decoder.write(buffer.slice(2, 3))); + +buffer = new Buffer([0xF0, 0xA4, 0xAD, 0xA2]); +var s = ''; +s += decoder.write(buffer.slice(0, 1)); +s += decoder.write(buffer.slice(1, 2)); +s += decoder.write(buffer.slice(2, 3)); +s += decoder.write(buffer.slice(3, 4)); +assert.ok(s.length > 0); + +// CESU-8 +buffer = new Buffer('EDA0BDEDB18D', 'hex'); // THUMBS UP SIGN (in CESU-8) +var s = ''; +s += decoder.write(buffer.slice(0, 1)); +s += decoder.write(buffer.slice(1, 2)); +s += decoder.write(buffer.slice(2, 3)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(3, 4)); +s += decoder.write(buffer.slice(4, 5)); +s += decoder.write(buffer.slice(5, 6)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 2)); +s += decoder.write(buffer.slice(2, 4)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(4, 6)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 3)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(3, 6)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 4)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(4, 5)); +s += decoder.write(buffer.slice(5, 6)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 5)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(5, 6)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 6)); +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + + +// UCS-2 +decoder = new StringDecoder('ucs2'); +buffer = new Buffer('ab', 'ucs2'); +assert.equal(decoder.write(buffer), 'ab'); // 2 complete chars +buffer = new Buffer('abc', 'ucs2'); +assert.equal(decoder.write(buffer.slice(0, 3)), 'a'); // 'a' and first of 'b' +assert.equal(decoder.write(buffer.slice(3, 6)), 'bc'); // second of 'b' and 'c' + + +// UTF-16LE +buffer = new Buffer('3DD84DDC', 'hex'); // THUMBS UP SIGN (in CESU-8) +var s = ''; +s += decoder.write(buffer.slice(0, 1)); +s += decoder.write(buffer.slice(1, 2)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(2, 3)); +s += decoder.write(buffer.slice(3, 4)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 2)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(2, 4)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 3)); // complete lead surrogate +assert.equal(s, ''); +s += decoder.write(buffer.slice(3, 4)); // complete trail surrogate +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + +var s = ''; +s += decoder.write(buffer.slice(0, 4)); +assert.equal(s, '\uD83D\uDC4D'); // THUMBS UP SIGN (in UTF-16) + + +// A mixed ascii and non-ascii string +// Test stolen from deps/v8/test/cctest/test-strings.cc +// U+02E4 -> CB A4 +// U+0064 -> 64 +// U+12E4 -> E1 8B A4 +// U+0030 -> 30 +// U+3045 -> E3 81 85 +var expected = '\u02e4\u0064\u12e4\u0030\u3045'; +var buffer = new Buffer([0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, + 0x30, 0xE3, 0x81, 0x85]); +var charLengths = [0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5]; + +// Split the buffer into 3 segments +// |----|------|-------| +// 0 i j buffer.length +// Scan through every possible 3 segment combination +// and make sure that the string is always parsed. +common.print('scanning '); +for (var j = 2; j < buffer.length; j++) { + for (var i = 1; i < j; i++) { + var decoder = new StringDecoder('utf8'); + + var sum = decoder.write(buffer.slice(0, i)); + + // just check that we've received the right amount + // after the first write + assert.equal(charLengths[i], sum.length); + + sum += decoder.write(buffer.slice(i, j)); + sum += decoder.write(buffer.slice(j, buffer.length)); + assert.equal(expected, sum); + common.print('.'); + } +} +console.log(' crayon!'); + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/package.json new file mode 100644 index 00000000..3bf407fd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/package.json @@ -0,0 +1,43 @@ +{ + "name": "readable-stream", + "version": "1.1.10", + "description": "An exploration of a new kind of readable streams for Node.js", + "main": "readable.js", + "dependencies": { + "core-util-is": "~1.0.0", + "string_decoder": "~0.10.x", + "debuglog": "0.0.2" + }, + "devDependencies": { + "tap": "~0.2.6" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/readable-stream" + }, + "keywords": [ + "readable", + "stream", + "pipe" + ], + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "MIT", + "optionalDependencies": { + "debuglog": "0.0.2" + }, + "readme": "# readable-stream\n\nA new class of streams for Node.js\n\nThis module provides the new Stream base classes introduced in Node\nv0.10, for use in Node v0.8. You can use it to have programs that\nhave to work with node v0.8, while being forward-compatible for v0.10\nand beyond. When you drop support for v0.8, you can remove this\nmodule, and only use the native streams.\n\nThis is almost exactly the same codebase as appears in Node v0.10.\nHowever:\n\n1. The exported object is actually the Readable class. Decorating the\n native `stream` module would be global pollution.\n2. In v0.10, you can safely use `base64` as an argument to\n `setEncoding` in Readable streams. However, in v0.8, the\n StringDecoder class has no `end()` method, which is problematic for\n Base64. So, don't use that, because it'll break and be weird.\n\nOther than that, the API is the same as `require('stream')` in v0.10,\nso the API docs are reproduced below.\n\n----------\n\n Stability: 2 - Unstable\n\nA stream is an abstract interface implemented by various objects in\nNode. For example a request to an HTTP server is a stream, as is\nstdout. Streams are readable, writable, or both. All streams are\ninstances of [EventEmitter][]\n\nYou can load the Stream base classes by doing `require('stream')`.\nThere are base classes provided for Readable streams, Writable\nstreams, Duplex streams, and Transform streams.\n\n## Compatibility\n\nIn earlier versions of Node, the Readable stream interface was\nsimpler, but also less powerful and less useful.\n\n* Rather than waiting for you to call the `read()` method, `'data'`\n events would start emitting immediately. If you needed to do some\n I/O to decide how to handle data, then you had to store the chunks\n in some kind of buffer so that they would not be lost.\n* The `pause()` method was advisory, rather than guaranteed. This\n meant that you still had to be prepared to receive `'data'` events\n even when the stream was in a paused state.\n\nIn Node v0.10, the Readable class described below was added. For\nbackwards compatibility with older Node programs, Readable streams\nswitch into \"old mode\" when a `'data'` event handler is added, or when\nthe `pause()` or `resume()` methods are called. The effect is that,\neven if you are not using the new `read()` method and `'readable'`\nevent, you no longer have to worry about losing `'data'` chunks.\n\nMost programs will continue to function normally. However, this\nintroduces an edge case in the following conditions:\n\n* No `'data'` event handler is added.\n* The `pause()` and `resume()` methods are never called.\n\nFor example, consider the following code:\n\n```javascript\n// WARNING! BROKEN!\nnet.createServer(function(socket) {\n\n // we add an 'end' method, but never consume the data\n socket.on('end', function() {\n // It will never get here.\n socket.end('I got your message (but didnt read it)\\n');\n });\n\n}).listen(1337);\n```\n\nIn versions of node prior to v0.10, the incoming message data would be\nsimply discarded. However, in Node v0.10 and beyond, the socket will\nremain paused forever.\n\nThe workaround in this situation is to call the `resume()` method to\ntrigger \"old mode\" behavior:\n\n```javascript\n// Workaround\nnet.createServer(function(socket) {\n\n socket.on('end', function() {\n socket.end('I got your message (but didnt read it)\\n');\n });\n\n // start the flow of data, discarding it.\n socket.resume();\n\n}).listen(1337);\n```\n\nIn addition to new Readable streams switching into old-mode, pre-v0.10\nstyle streams can be wrapped in a Readable class using the `wrap()`\nmethod.\n\n## Class: stream.Readable\n\n\n\nA `Readable Stream` has the following methods, members, and events.\n\nNote that `stream.Readable` is an abstract class designed to be\nextended with an underlying implementation of the `_read(size)`\nmethod. (See below.)\n\n### new stream.Readable([options])\n\n* `options` {Object}\n * `highWaterMark` {Number} The maximum number of bytes to store in\n the internal buffer before ceasing to read from the underlying\n resource. Default=16kb\n * `encoding` {String} If specified, then buffers will be decoded to\n strings using the specified encoding. Default=null\n * `objectMode` {Boolean} Whether this stream should behave\n as a stream of objects. Meaning that stream.read(n) returns\n a single value instead of a Buffer of size n\n\nIn classes that extend the Readable class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n### readable.\\_read(size)\n\n* `size` {Number} Number of bytes to read asynchronously\n\nNote: **This function should NOT be called directly.** It should be\nimplemented by child classes, and called by the internal Readable\nclass methods only.\n\nAll Readable stream implementations must provide a `_read` method\nto fetch data from the underlying resource.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\nWhen data is available, put it into the read queue by calling\n`readable.push(chunk)`. If `push` returns false, then you should stop\nreading. When `_read` is called again, you should start pushing more\ndata.\n\nThe `size` argument is advisory. Implementations where a \"read\" is a\nsingle call that returns data can use this to know how much data to\nfetch. Implementations where that is not relevant, such as TCP or\nTLS, may ignore this argument, and simply provide data whenever it\nbecomes available. There is no need, for example to \"wait\" until\n`size` bytes are available before calling `stream.push(chunk)`.\n\n### readable.push(chunk)\n\n* `chunk` {Buffer | null | String} Chunk of data to push into the read queue\n* return {Boolean} Whether or not more pushes should be performed\n\nNote: **This function should be called by Readable implementors, NOT\nby consumers of Readable subclasses.** The `_read()` function will not\nbe called again until at least one `push(chunk)` call is made. If no\ndata is available, then you MAY call `push('')` (an empty string) to\nallow a future `_read` call, without adding any data to the queue.\n\nThe `Readable` class works by putting data into a read queue to be\npulled out later by calling the `read()` method when the `'readable'`\nevent fires.\n\nThe `push()` method will explicitly insert some data into the read\nqueue. If it is called with `null` then it will signal the end of the\ndata.\n\nIn some cases, you may be wrapping a lower-level source which has some\nsort of pause/resume mechanism, and a data callback. In those cases,\nyou could wrap the low-level source object by doing something like\nthis:\n\n```javascript\n// source is an object with readStop() and readStart() methods,\n// and an `ondata` member that gets called when it has data, and\n// an `onend` member that gets called when the data is over.\n\nvar stream = new Readable();\n\nsource.ondata = function(chunk) {\n // if push() returns false, then we need to stop reading from source\n if (!stream.push(chunk))\n source.readStop();\n};\n\nsource.onend = function() {\n stream.push(null);\n};\n\n// _read will be called when the stream wants to pull more data in\n// the advisory size argument is ignored in this case.\nstream._read = function(n) {\n source.readStart();\n};\n```\n\n### readable.unshift(chunk)\n\n* `chunk` {Buffer | null | String} Chunk of data to unshift onto the read queue\n* return {Boolean} Whether or not more pushes should be performed\n\nThis is the corollary of `readable.push(chunk)`. Rather than putting\nthe data at the *end* of the read queue, it puts it at the *front* of\nthe read queue.\n\nThis is useful in certain use-cases where a stream is being consumed\nby a parser, which needs to \"un-consume\" some data that it has\noptimistically pulled out of the source.\n\n```javascript\n// A parser for a simple data protocol.\n// The \"header\" is a JSON object, followed by 2 \\n characters, and\n// then a message body.\n//\n// Note: This can be done more simply as a Transform stream. See below.\n\nfunction SimpleProtocol(source, options) {\n if (!(this instanceof SimpleProtocol))\n return new SimpleProtocol(options);\n\n Readable.call(this, options);\n this._inBody = false;\n this._sawFirstCr = false;\n\n // source is a readable stream, such as a socket or file\n this._source = source;\n\n var self = this;\n source.on('end', function() {\n self.push(null);\n });\n\n // give it a kick whenever the source is readable\n // read(0) will not consume any bytes\n source.on('readable', function() {\n self.read(0);\n });\n\n this._rawHeader = [];\n this.header = null;\n}\n\nSimpleProtocol.prototype = Object.create(\n Readable.prototype, { constructor: { value: SimpleProtocol }});\n\nSimpleProtocol.prototype._read = function(n) {\n if (!this._inBody) {\n var chunk = this._source.read();\n\n // if the source doesn't have data, we don't have data yet.\n if (chunk === null)\n return this.push('');\n\n // check if the chunk has a \\n\\n\n var split = -1;\n for (var i = 0; i < chunk.length; i++) {\n if (chunk[i] === 10) { // '\\n'\n if (this._sawFirstCr) {\n split = i;\n break;\n } else {\n this._sawFirstCr = true;\n }\n } else {\n this._sawFirstCr = false;\n }\n }\n\n if (split === -1) {\n // still waiting for the \\n\\n\n // stash the chunk, and try again.\n this._rawHeader.push(chunk);\n this.push('');\n } else {\n this._inBody = true;\n var h = chunk.slice(0, split);\n this._rawHeader.push(h);\n var header = Buffer.concat(this._rawHeader).toString();\n try {\n this.header = JSON.parse(header);\n } catch (er) {\n this.emit('error', new Error('invalid simple protocol data'));\n return;\n }\n // now, because we got some extra data, unshift the rest\n // back into the read queue so that our consumer will see it.\n var b = chunk.slice(split);\n this.unshift(b);\n\n // and let them know that we are done parsing the header.\n this.emit('header', this.header);\n }\n } else {\n // from there on, just provide the data to our consumer.\n // careful not to push(null), since that would indicate EOF.\n var chunk = this._source.read();\n if (chunk) this.push(chunk);\n }\n};\n\n// Usage:\nvar parser = new SimpleProtocol(source);\n// Now parser is a readable stream that will emit 'header'\n// with the parsed header data.\n```\n\n### readable.wrap(stream)\n\n* `stream` {Stream} An \"old style\" readable stream\n\nIf you are using an older Node library that emits `'data'` events and\nhas a `pause()` method that is advisory only, then you can use the\n`wrap()` method to create a Readable stream that uses the old stream\nas its data source.\n\nFor example:\n\n```javascript\nvar OldReader = require('./old-api-module.js').OldReader;\nvar oreader = new OldReader;\nvar Readable = require('stream').Readable;\nvar myReader = new Readable().wrap(oreader);\n\nmyReader.on('readable', function() {\n myReader.read(); // etc.\n});\n```\n\n### Event: 'readable'\n\nWhen there is data ready to be consumed, this event will fire.\n\nWhen this event emits, call the `read()` method to consume the data.\n\n### Event: 'end'\n\nEmitted when the stream has received an EOF (FIN in TCP terminology).\nIndicates that no more `'data'` events will happen. If the stream is\nalso writable, it may be possible to continue writing.\n\n### Event: 'data'\n\nThe `'data'` event emits either a `Buffer` (by default) or a string if\n`setEncoding()` was used.\n\nNote that adding a `'data'` event listener will switch the Readable\nstream into \"old mode\", where data is emitted as soon as it is\navailable, rather than waiting for you to call `read()` to consume it.\n\n### Event: 'error'\n\nEmitted if there was an error receiving data.\n\n### Event: 'close'\n\nEmitted when the underlying resource (for example, the backing file\ndescriptor) has been closed. Not all streams will emit this.\n\n### readable.setEncoding(encoding)\n\nMakes the `'data'` event emit a string instead of a `Buffer`. `encoding`\ncan be `'utf8'`, `'utf16le'` (`'ucs2'`), `'ascii'`, or `'hex'`.\n\nThe encoding can also be set by specifying an `encoding` field to the\nconstructor.\n\n### readable.read([size])\n\n* `size` {Number | null} Optional number of bytes to read.\n* Return: {Buffer | String | null}\n\nNote: **This function SHOULD be called by Readable stream users.**\n\nCall this method to consume data once the `'readable'` event is\nemitted.\n\nThe `size` argument will set a minimum number of bytes that you are\ninterested in. If not set, then the entire content of the internal\nbuffer is returned.\n\nIf there is no data to consume, or if there are fewer bytes in the\ninternal buffer than the `size` argument, then `null` is returned, and\na future `'readable'` event will be emitted when more is available.\n\nCalling `stream.read(0)` will always return `null`, and will trigger a\nrefresh of the internal buffer, but otherwise be a no-op.\n\n### readable.pipe(destination, [options])\n\n* `destination` {Writable Stream}\n* `options` {Object} Optional\n * `end` {Boolean} Default=true\n\nConnects this readable stream to `destination` WriteStream. Incoming\ndata on this stream gets written to `destination`. Properly manages\nback-pressure so that a slow destination will not be overwhelmed by a\nfast readable stream.\n\nThis function returns the `destination` stream.\n\nFor example, emulating the Unix `cat` command:\n\n process.stdin.pipe(process.stdout);\n\nBy default `end()` is called on the destination when the source stream\nemits `end`, so that `destination` is no longer writable. Pass `{ end:\nfalse }` as `options` to keep the destination stream open.\n\nThis keeps `writer` open so that \"Goodbye\" can be written at the\nend.\n\n reader.pipe(writer, { end: false });\n reader.on(\"end\", function() {\n writer.end(\"Goodbye\\n\");\n });\n\nNote that `process.stderr` and `process.stdout` are never closed until\nthe process exits, regardless of the specified options.\n\n### readable.unpipe([destination])\n\n* `destination` {Writable Stream} Optional\n\nUndo a previously established `pipe()`. If no destination is\nprovided, then all previously established pipes are removed.\n\n### readable.pause()\n\nSwitches the readable stream into \"old mode\", where data is emitted\nusing a `'data'` event rather than being buffered for consumption via\nthe `read()` method.\n\nCeases the flow of data. No `'data'` events are emitted while the\nstream is in a paused state.\n\n### readable.resume()\n\nSwitches the readable stream into \"old mode\", where data is emitted\nusing a `'data'` event rather than being buffered for consumption via\nthe `read()` method.\n\nResumes the incoming `'data'` events after a `pause()`.\n\n\n## Class: stream.Writable\n\n\n\nA `Writable` Stream has the following methods, members, and events.\n\nNote that `stream.Writable` is an abstract class designed to be\nextended with an underlying implementation of the\n`_write(chunk, encoding, cb)` method. (See below.)\n\n### new stream.Writable([options])\n\n* `options` {Object}\n * `highWaterMark` {Number} Buffer level when `write()` starts\n returning false. Default=16kb\n * `decodeStrings` {Boolean} Whether or not to decode strings into\n Buffers before passing them to `_write()`. Default=true\n\nIn classes that extend the Writable class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n### writable.\\_write(chunk, encoding, callback)\n\n* `chunk` {Buffer | String} The chunk to be written. Will always\n be a buffer unless the `decodeStrings` option was set to `false`.\n* `encoding` {String} If the chunk is a string, then this is the\n encoding type. Ignore chunk is a buffer. Note that chunk will\n **always** be a buffer unless the `decodeStrings` option is\n explicitly set to `false`.\n* `callback` {Function} Call this function (optionally with an error\n argument) when you are done processing the supplied chunk.\n\nAll Writable stream implementations must provide a `_write` method to\nsend data to the underlying resource.\n\nNote: **This function MUST NOT be called directly.** It should be\nimplemented by child classes, and called by the internal Writable\nclass methods only.\n\nCall the callback using the standard `callback(error)` pattern to\nsignal that the write completed successfully or with an error.\n\nIf the `decodeStrings` flag is set in the constructor options, then\n`chunk` may be a string rather than a Buffer, and `encoding` will\nindicate the sort of string that it is. This is to support\nimplementations that have an optimized handling for certain string\ndata encodings. If you do not explicitly set the `decodeStrings`\noption to `false`, then you can safely ignore the `encoding` argument,\nand assume that `chunk` will always be a Buffer.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\n\n### writable.write(chunk, [encoding], [callback])\n\n* `chunk` {Buffer | String} Data to be written\n* `encoding` {String} Optional. If `chunk` is a string, then encoding\n defaults to `'utf8'`\n* `callback` {Function} Optional. Called when this chunk is\n successfully written.\n* Returns {Boolean}\n\nWrites `chunk` to the stream. Returns `true` if the data has been\nflushed to the underlying resource. Returns `false` to indicate that\nthe buffer is full, and the data will be sent out in the future. The\n`'drain'` event will indicate when the buffer is empty again.\n\nThe specifics of when `write()` will return false, is determined by\nthe `highWaterMark` option provided to the constructor.\n\n### writable.end([chunk], [encoding], [callback])\n\n* `chunk` {Buffer | String} Optional final data to be written\n* `encoding` {String} Optional. If `chunk` is a string, then encoding\n defaults to `'utf8'`\n* `callback` {Function} Optional. Called when the final chunk is\n successfully written.\n\nCall this method to signal the end of the data being written to the\nstream.\n\n### Event: 'drain'\n\nEmitted when the stream's write queue empties and it's safe to write\nwithout buffering again. Listen for it when `stream.write()` returns\n`false`.\n\n### Event: 'close'\n\nEmitted when the underlying resource (for example, the backing file\ndescriptor) has been closed. Not all streams will emit this.\n\n### Event: 'finish'\n\nWhen `end()` is called and there are no more chunks to write, this\nevent is emitted.\n\n### Event: 'pipe'\n\n* `source` {Readable Stream}\n\nEmitted when the stream is passed to a readable stream's pipe method.\n\n### Event 'unpipe'\n\n* `source` {Readable Stream}\n\nEmitted when a previously established `pipe()` is removed using the\nsource Readable stream's `unpipe()` method.\n\n## Class: stream.Duplex\n\n\n\nA \"duplex\" stream is one that is both Readable and Writable, such as a\nTCP socket connection.\n\nNote that `stream.Duplex` is an abstract class designed to be\nextended with an underlying implementation of the `_read(size)`\nand `_write(chunk, encoding, callback)` methods as you would with a Readable or\nWritable stream class.\n\nSince JavaScript doesn't have multiple prototypal inheritance, this\nclass prototypally inherits from Readable, and then parasitically from\nWritable. It is thus up to the user to implement both the lowlevel\n`_read(n)` method as well as the lowlevel `_write(chunk, encoding, cb)` method\non extension duplex classes.\n\n### new stream.Duplex(options)\n\n* `options` {Object} Passed to both Writable and Readable\n constructors. Also has the following fields:\n * `allowHalfOpen` {Boolean} Default=true. If set to `false`, then\n the stream will automatically end the readable side when the\n writable side ends and vice versa.\n\nIn classes that extend the Duplex class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n## Class: stream.Transform\n\nA \"transform\" stream is a duplex stream where the output is causally\nconnected in some way to the input, such as a zlib stream or a crypto\nstream.\n\nThere is no requirement that the output be the same size as the input,\nthe same number of chunks, or arrive at the same time. For example, a\nHash stream will only ever have a single chunk of output which is\nprovided when the input is ended. A zlib stream will either produce\nmuch smaller or much larger than its input.\n\nRather than implement the `_read()` and `_write()` methods, Transform\nclasses must implement the `_transform()` method, and may optionally\nalso implement the `_flush()` method. (See below.)\n\n### new stream.Transform([options])\n\n* `options` {Object} Passed to both Writable and Readable\n constructors.\n\nIn classes that extend the Transform class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n### transform.\\_transform(chunk, encoding, callback)\n\n* `chunk` {Buffer | String} The chunk to be transformed. Will always\n be a buffer unless the `decodeStrings` option was set to `false`.\n* `encoding` {String} If the chunk is a string, then this is the\n encoding type. (Ignore if `decodeStrings` chunk is a buffer.)\n* `callback` {Function} Call this function (optionally with an error\n argument) when you are done processing the supplied chunk.\n\nNote: **This function MUST NOT be called directly.** It should be\nimplemented by child classes, and called by the internal Transform\nclass methods only.\n\nAll Transform stream implementations must provide a `_transform`\nmethod to accept input and produce output.\n\n`_transform` should do whatever has to be done in this specific\nTransform class, to handle the bytes being written, and pass them off\nto the readable portion of the interface. Do asynchronous I/O,\nprocess things, and so on.\n\nCall `transform.push(outputChunk)` 0 or more times to generate output\nfrom this input chunk, depending on how much data you want to output\nas a result of this chunk.\n\nCall the callback function only when the current chunk is completely\nconsumed. Note that there may or may not be output as a result of any\nparticular input chunk.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\n### transform.\\_flush(callback)\n\n* `callback` {Function} Call this function (optionally with an error\n argument) when you are done flushing any remaining data.\n\nNote: **This function MUST NOT be called directly.** It MAY be implemented\nby child classes, and if so, will be called by the internal Transform\nclass methods only.\n\nIn some cases, your transform operation may need to emit a bit more\ndata at the end of the stream. For example, a `Zlib` compression\nstream will store up some internal state so that it can optimally\ncompress the output. At the end, however, it needs to do the best it\ncan with what is left, so that the data will be complete.\n\nIn those cases, you can implement a `_flush` method, which will be\ncalled at the very end, after all the written data is consumed, but\nbefore emitting `end` to signal the end of the readable side. Just\nlike with `_transform`, call `transform.push(chunk)` zero or more\ntimes, as appropriate, and call `callback` when the flush operation is\ncomplete.\n\nThis method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you **are** expected to override this method in\nyour own extension classes.\n\n### Example: `SimpleProtocol` parser\n\nThe example above of a simple protocol parser can be implemented much\nmore simply by using the higher level `Transform` stream class.\n\nIn this example, rather than providing the input as an argument, it\nwould be piped into the parser, which is a more idiomatic Node stream\napproach.\n\n```javascript\nfunction SimpleProtocol(options) {\n if (!(this instanceof SimpleProtocol))\n return new SimpleProtocol(options);\n\n Transform.call(this, options);\n this._inBody = false;\n this._sawFirstCr = false;\n this._rawHeader = [];\n this.header = null;\n}\n\nSimpleProtocol.prototype = Object.create(\n Transform.prototype, { constructor: { value: SimpleProtocol }});\n\nSimpleProtocol.prototype._transform = function(chunk, encoding, done) {\n if (!this._inBody) {\n // check if the chunk has a \\n\\n\n var split = -1;\n for (var i = 0; i < chunk.length; i++) {\n if (chunk[i] === 10) { // '\\n'\n if (this._sawFirstCr) {\n split = i;\n break;\n } else {\n this._sawFirstCr = true;\n }\n } else {\n this._sawFirstCr = false;\n }\n }\n\n if (split === -1) {\n // still waiting for the \\n\\n\n // stash the chunk, and try again.\n this._rawHeader.push(chunk);\n } else {\n this._inBody = true;\n var h = chunk.slice(0, split);\n this._rawHeader.push(h);\n var header = Buffer.concat(this._rawHeader).toString();\n try {\n this.header = JSON.parse(header);\n } catch (er) {\n this.emit('error', new Error('invalid simple protocol data'));\n return;\n }\n // and let them know that we are done parsing the header.\n this.emit('header', this.header);\n\n // now, because we got some extra data, emit this first.\n this.push(b);\n }\n } else {\n // from there on, just provide the data to our consumer as-is.\n this.push(b);\n }\n done();\n};\n\nvar parser = new SimpleProtocol();\nsource.pipe(parser)\n\n// Now parser is a readable stream that will emit 'header'\n// with the parsed header data.\n```\n\n\n## Class: stream.PassThrough\n\nThis is a trivial implementation of a `Transform` stream that simply\npasses the input bytes across to the output. Its purpose is mainly\nfor examples and testing, but there are occasionally use cases where\nit can come in handy.\n\n\n[EventEmitter]: events.html#events_class_events_eventemitter\n", + "readmeFilename": "README.md", + "_id": "readable-stream@1.1.10", + "dist": { + "shasum": "a8f59a6db2bc499a3c78c241df717c2e6b035415" + }, + "_from": "readable-stream@~1.1.9", + "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.10.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/passthrough.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/passthrough.js new file mode 100644 index 00000000..27e8d8a5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/passthrough.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_passthrough.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/readable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/readable.js new file mode 100644 index 00000000..09b8bf50 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/readable.js @@ -0,0 +1,7 @@ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = require('stream'); +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/transform.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/transform.js new file mode 100644 index 00000000..5d482f07 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/transform.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_transform.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/writable.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/writable.js new file mode 100644 index 00000000..e1e9efdf --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/readable-stream/writable.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_writable.js") diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/.npmignore new file mode 100644 index 00000000..07e6e472 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/.npmignore @@ -0,0 +1 @@ +/node_modules diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/README.md new file mode 100644 index 00000000..8d6a1928 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/README.md @@ -0,0 +1,14 @@ +# stream-counter + +Keep track of how many bytes have been written to a stream. + +## Usage + +```js +var StreamCounter = require('stream-counter'); +var counter = new StreamCounter(); +counter.on('progress', function() { + console.log("progress", counter.bytes); +}); +fs.createReadStream('foo.txt').pipe(counter); +``` diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/index.js new file mode 100644 index 00000000..c490c2db --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/index.js @@ -0,0 +1,16 @@ +module.exports = ByteCounter; + +var Writable = require('readable-stream').Writable; +var util = require('util'); + +util.inherits(ByteCounter, Writable); +function ByteCounter(options) { + Writable.call(this, options); + this.bytes = 0; +} + +ByteCounter.prototype._write = function(chunk, encoding, cb) { + this.bytes += chunk.length; + this.emit('progress'); + cb(); +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/package.json new file mode 100644 index 00000000..7c1df3f4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/package.json @@ -0,0 +1,28 @@ +{ + "name": "stream-counter", + "version": "0.2.0", + "description": "keeps track of how many bytes have been written to a stream", + "main": "index.js", + "scripts": { + "test": "node test/test.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/superjoe30/node-stream-counter.git" + }, + "author": { + "name": "Andrew Kelley", + "email": "superjoe30@gmail.com" + }, + "license": "BSD", + "engines": { + "node": ">=0.8.0" + }, + "dependencies": { + "readable-stream": "~1.1.8" + }, + "readme": "# stream-counter\n\nKeep track of how many bytes have been written to a stream.\n\n## Usage\n\n```js\nvar StreamCounter = require('stream-counter');\nvar counter = new StreamCounter();\ncounter.on('progress', function() {\n console.log(\"progress\", counter.bytes);\n});\nfs.createReadStream('foo.txt').pipe(counter);\n```\n", + "readmeFilename": "README.md", + "_id": "stream-counter@0.2.0", + "_from": "stream-counter@~0.2.0" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/test/test.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/test/test.js new file mode 100644 index 00000000..0da95660 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/test/test.js @@ -0,0 +1,20 @@ +var ByteCounter = require('../'); +var fs = require('fs'); +var path = require('path'); +var assert = require('assert'); + +var counter = new ByteCounter(); +var remainingTests = 2; +counter.once('progress', function() { + assert.strictEqual(counter.bytes, 5); + remainingTests -= 1; +}); +var is = fs.createReadStream(path.join(__dirname, 'test.txt')); +is.pipe(counter); +is.on('end', function() { + remainingTests -= 1; + assert.strictEqual(counter.bytes, 5); +}); +process.on('exit', function() { + assert.strictEqual(remainingTests, 0); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/test/test.txt b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/test/test.txt new file mode 100644 index 00000000..81c545ef --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/stream-counter/test/test.txt @@ -0,0 +1 @@ +1234 diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/package.json new file mode 100644 index 00000000..4eaf52bd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/package.json @@ -0,0 +1,43 @@ +{ + "name": "multiparty", + "version": "2.2.0", + "description": "multipart/form-data parser which supports streaming", + "repository": { + "type": "git", + "url": "git@github.com:superjoe30/node-multiparty.git" + }, + "keywords": [ + "file", + "upload", + "formidable", + "stream", + "s3" + ], + "devDependencies": { + "findit": "0.1.1", + "hashish": "0.0.4", + "mocha": "~1.8.2", + "request": "~2.16.6", + "mkdirp": "~0.3.5", + "superagent": "~0.14.1" + }, + "scripts": { + "test": "ulimit -n 500 && mocha --timeout 4000 --reporter spec --recursive test/test.js" + }, + "engines": { + "node": ">=0.8.0" + }, + "license": "MIT", + "dependencies": { + "readable-stream": "~1.1.9", + "stream-counter": "~0.2.0" + }, + "readme": "[![Build Status](https://travis-ci.org/superjoe30/node-multiparty.png?branch=master)](https://travis-ci.org/superjoe30/node-multiparty)\n# multiparty\n\nParse http requests with content-type `multipart/form-data`, also known as file uploads.\n\nSee also [busboy](https://github.com/mscdex/busboy) - a\n[faster](https://github.com/mscdex/dicer/wiki/Benchmarks) alternative\nwhich may be worth looking into.\n\n### Why the fork?\n\n * This module uses the Node.js v0.10 streams properly, *even in Node.js v0.8*\n * It will not create a temp file for you unless you want it to.\n * Counts bytes and does math to help you figure out the `Content-Length` of\n each part.\n * You can easily stream uploads to s3 with\n [knox](https://github.com/LearnBoost/knox), for [example](examples/s3.js).\n * Less bugs. This code is simpler, has all deprecated functionality removed,\n has cleaner tests, and does not try to do anything beyond multipart stream\n parsing.\n\n## Installation\n\n```\nnpm install multiparty\n```\n\n## Usage\n\n * See [examples](examples).\n\nParse an incoming `multipart/form-data` request.\n\n```js\nvar multiparty = require('multiparty')\n , http = require('http')\n , util = require('util')\n\nhttp.createServer(function(req, res) {\n if (req.url === '/upload' && req.method === 'POST') {\n // parse a file upload\n var form = new multiparty.Form();\n\n form.parse(req, function(err, fields, files) {\n res.writeHead(200, {'content-type': 'text/plain'});\n res.write('received upload:\\n\\n');\n res.end(util.inspect({fields: fields, files: files}));\n });\n\n return;\n }\n\n // show a file upload form\n res.writeHead(200, {'content-type': 'text/html'});\n res.end(\n '
          '+\n '
          '+\n '
          '+\n ''+\n '
          '\n );\n}).listen(8080);\n```\n\n## API\n\n### multiparty.Form\n```js\nvar form = new multiparty.Form(options)\n```\nCreates a new form. Options:\n\n * `encoding` - sets encoding for the incoming form fields. Defaults to `utf8`.\n * `maxFieldSize` - Limits the amount of memory a field (not a file) can\n allocate in bytes. If this value is exceeded, an `error` event is emitted.\n The default size is 2MB.\n * `maxFields` - Limits the number of fields that will be parsed before\n emitting an `error` event. A file counts as a field in this case.\n Defaults to 1000.\n * `autoFields` - Enables `field` events. This is automatically set to `true`\n if you add a `field` listener.\n * `autoFiles` - Enables `file` events. This is automatically set to `true`\n if you add a `file` listener.\n * `uploadDir` - Only relevant when `autoFiles` is `true`. The directory for\n placing file uploads in. You can move them later using `fs.rename()`.\n Defaults to `os.tmpDir()`.\n * `hash` - Only relevant when `autoFiles` is `true`. If you want checksums\n calculated for incoming files, set this to either `sha1` or `md5`.\n Defaults to off.\n\n#### form.parse(request, [cb])\n\nParses an incoming node.js `request` containing form data. If `cb` is\nprovided, `autoFields` and `autoFiles` are set to `true` and all fields and\nfiles are collected and passed to the callback:\n\n```js\nform.parse(req, function(err, fieldsObject, filesObject, fieldsList, filesList) {\n // ...\n});\n```\n\nIt is often convenient to access a field or file by name. In this situation,\nuse `fieldsObject` or `filesObject`. However sometimes, as in the case of a\n`` the multipart stream will contain\nmultiple files of the same input name, and you are interested in all of them.\nIn this case, use `filesList`.\n\nAnother example is when you do not care what the field name of a file is; you\nare merely interested in a single upload. In this case, set `maxFields` to 1\n(assuming no other fields expected besides the file) and use `filesList[0]`.\n\n#### form.bytesReceived\n\nThe amount of bytes received for this form so far.\n\n#### form.bytesExpected\n\nThe expected number of bytes in this form.\n\n### Events\n\n#### 'error' (err)\n\nYou definitely want to handle this event. If not your server *will* crash when\nusers submit bogus multipart requests!\n\n#### 'part' (part)\n\nEmitted when a part is encountered in the request. `part` is a\n`ReadableStream`. It also has the following properties:\n\n * `headers` - the headers for this part. For example, you may be interested\n in `content-type`.\n * `name` - the field name for this part\n * `filename` - only if the part is an incoming file\n * `byteOffset` - the byte offset of this part in the request body\n * `byteCount` - assuming that this is the last part in the request,\n this is the size of this part in bytes. You could use this, for\n example, to set the `Content-Length` header if uploading to S3.\n If the part had a `Content-Length` header then that value is used\n here instead.\n\n#### 'aborted'\n\nEmitted when the request is aborted. This event will be followed shortly\nby an `error` event. In practice you do not need to handle this event.\n\n#### 'progress' (bytesReceived, bytesExpected)\n\n#### 'close'\n\nEmitted after all parts have been parsed and emitted. Not emitted if an `error`\nevent is emitted. This is typically when you would send your response.\n\n#### 'file' (name, file)\n\n**By default multiparty will not touch your hard drive.** But if you add this\nlistener, multiparty automatically sets `form.autoFiles` to `true` and will\nstream uploads to disk for you. \n\n * `name` - the field name for this file\n * `file` - an object with these properties:\n - `fieldName` - same as `name` - the field name for this file\n - `originalFilename` - the filename that the user reports for the file\n - `path` - the absolute path of the uploaded file on disk\n - `headers` - the HTTP headers that were sent along with this file\n - `size` - size of the file in bytes\n\nIf you set the `form.hash` option, then `file` will also contain a `hash`\nproperty which is the checksum of the file.\n\n#### 'field' (name, value)\n\n * `name` - field name\n * `value` - string field value\n\n", + "readmeFilename": "README.md", + "_id": "multiparty@2.2.0", + "dist": { + "shasum": "a7f2341196203083ed0367e4432332bbeb00dfc4" + }, + "_from": "multiparty@2.2.0", + "_resolved": "https://registry.npmjs.org/multiparty/-/multiparty-2.2.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/bench-multipart-parser.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/bench-multipart-parser.js new file mode 100644 index 00000000..ee5dbad4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/bench-multipart-parser.js @@ -0,0 +1,76 @@ +var assert = require('assert') + , Form = require('../').Form + , boundary = '-----------------------------168072824752491622650073' + , mb = 100 + , buffer = createMultipartBuffer(boundary, mb * 1024 * 1024) + +var callbacks = { + partBegin: -1, + partEnd: -1, + headerField: -1, + headerValue: -1, + partData: -1, + end: -1, +}; + +var form = new Form({ boundary: boundary }); + +hijack('onParseHeaderField', function() { + callbacks.headerField++; +}); + +hijack('onParseHeaderValue', function() { + callbacks.headerValue++; +}); + +hijack('onParsePartBegin', function() { + callbacks.partBegin++; +}); + +hijack('onParsePartData', function() { + callbacks.partData++; +}); + +hijack('onParsePartEnd', function() { + callbacks.partEnd++; +}); + +form.on('finish', function() { + callbacks.end++; +}); + +var start = new Date(); +form.write(buffer, function(err) { + var duration = new Date() - start; + assert.ifError(err); + var mbPerSec = (mb / (duration / 1000)).toFixed(2); + console.log(mbPerSec+' mb/sec'); +}); + +process.on('exit', function() { + for (var k in callbacks) { + assert.equal(0, callbacks[k], k+' count off by '+callbacks[k]); + } +}); + +function createMultipartBuffer(boundary, size) { + var head = + '--'+boundary+'\r\n' + + 'content-disposition: form-data; name="field1"\r\n' + + '\r\n' + , tail = '\r\n--'+boundary+'--\r\n' + , buffer = new Buffer(size); + + buffer.write(head, 'ascii', 0); + buffer.write(tail, 'ascii', buffer.length - tail.length); + return buffer; +} + +function hijack(name, fn) { + var oldFn = form[name]; + form[name] = function() { + fn(); + return oldFn.apply(this, arguments); + }; +} + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/beta-sticker-1.png b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/beta-sticker-1.png new file mode 100644 index 00000000..20b1a7f1 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/beta-sticker-1.png differ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/binaryfile.tar.gz b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/binaryfile.tar.gz new file mode 100644 index 00000000..4a85af7a Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/binaryfile.tar.gz differ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/blank.gif b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/blank.gif new file mode 100644 index 00000000..75b945d2 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/blank.gif differ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/funkyfilename.txt b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/funkyfilename.txt new file mode 100644 index 00000000..e7a4785e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/funkyfilename.txt @@ -0,0 +1 @@ +I am a text file with a funky name! diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/menu_separator.png b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/menu_separator.png new file mode 100644 index 00000000..1c16a71e Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/menu_separator.png differ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/pf1y5.png b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/pf1y5.png new file mode 100644 index 00000000..44d60175 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/pf1y5.png differ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/plain.txt b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/plain.txt new file mode 100644 index 00000000..9b6903e2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/file/plain.txt @@ -0,0 +1 @@ +I am a plain text file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/beta-sticker-1.png.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/beta-sticker-1.png.http new file mode 100644 index 00000000..833b83ca --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/beta-sticker-1.png.http @@ -0,0 +1,12 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Length: 2483 + +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Disposition: form-data; name="sticker"; filename="beta-sticker-1.png" +Content-Type: image/png +Content-Transfer-Encoding: base64 + +iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABh5JREFUeNrMmHtIHEcYwGfv5SNwaovxEanEiJKqlYCCTRo1f0SvDeof1legEcE/YttQaNOiaQjYFFtpKaJILZU8SCRUWqlJGpoWepGLTXqUEnzFxCrnK9DEelbvvPOe/WacuY7r7HmGFjrwsbNzt7u//V7zfYvQ/2xI/9K1/NyvMP9PgCTuGmmL6/0ckD9UOGmbIExUsqMkAPHJjv5QwKRtgKioqDlh5+w/7IFeCuLlxCeA2zQ0IcCwh2qoaLH09fUdTElJ2e/1elU+n0/y+9fvPz4+fvfYsWN3YOoBcXPiocLghD4mBYHhQTCErqWlZU9FRcXJqKiowyqVSk/uSEH4o8fjWVlYWDB2d3e3d3R0WGB5jYqLg/NyGgsKxMNgkDB4451NTU3vxcXF1SlBKB0tFsuVxsbGjlu3bj2GJQeIk8K5RVBqBTMxrYRfuHAh9/jx4+ejo6MPS9I6f6hHPOC6rOLi4vyVlZXf7t27Z5c5/iZfkgMxxyUwFy9ezC0tLe3V6XRJ/MOCAYjWwsLCni0oKCh98uSJaWhoyMZFn0/uT2qBqYi/1NbWxjc0NJwPFUYExc/B53R5eXk5ZrN5YH5+3slFn5+D2uBDzG90IJETExOtzGdC9RelNf78wYMH3xQWFn4Ep0sgyyCr1NmJP6kEIa5tbW3dEx8fXxeKRoJpT76OR3p6enllZWUKTCOwNalFAglWDkTCvLq6+uR2YYKZSw4GQVKNfZQCafjkqhKYTBsTE3NY/uYi2Q4MP5KTkw9QGB3VEMv6G/YioqFLly5lazQavfytxobnUW+PWTGisIyNPEL3QYLB4PPIyMi4EydO7JUBbTIZ0RDYOFPkE8t/OdHczCK6Y/qdzP8BfUTW8Tj/uQndvT1F5vOzVvTLz1PwX4cQbt++fekURsNpSNLIw16v1z/HLsRRgecsSnovm8nxs5bvUe+NN1Bz47fkfBaAXj2aA2BWEsM/3hhFX1/5Fe3NTEAfvn8NXTO+tSH68IiNjU2Qw/AmCzg2XCQp+YyhJAu9c+pl9GJ+KmhiEt38bhjpoyJQRtYudA60k3dwD6o4mouKjmSiolcy0ArRqnXz3rT+knwFEShhNKLNlmmFP7Kf8XxuehHpj0QQmLdPGch/ioYyCSAe57pMaHnJgcprctDdwUkRjKi8CUTWhipvbm7uvlJo3zFNoHJDOznPeGEXqn+9EBUf+AQZXvqU+BEG/KCpHz2flYh+ALO9++ZX5L/Mj3gfevjw4ZRoP+PzD/b4HadPn844c+aMkb0F1DqIz9byzBvquXytvr6+7vr16+Ow9CfN2njjdfFAWpo9o2FnNmm12kQMw24gcvSnhbHb7Y+huHsNlhapLNHSxK3idlq287qhhrkKlSByOBzIZrPhGyCn04ncbjfRGAMV5ZlQxvDw8E+yYi1Q3qpleYjUQlNTU5aysrJqgNBhIAwGVSDCkFj48BVFULA1eCl7XV3dx1CKYK3YqKnY7u9Ti2royclJ76FDh1YhxefgsoFpCIOtra0RuGBQwYbRaLzc1dVlpjA2ZiqmKbWsDAmEYU9Pz8Tg4OCNoqKixNTU1BQostDq6iqBcrlcRBiYfEff1KBR+OnpabPBYOikWlnhtOOWm0zUffpnZ2ednZ2dJtCYMTs7+xkA2x0eHk6gsMYwFPYr/EC1Wo2LMEWzWa1WC1QRZ8FUVgpj42ohD3umWqHjRFxf5RkZGVkCNQ9CcTWQn5+flpSUtBOiMKAt7Fek/FSAmpmZMVdVVZ0dGxv7g4PhteMVlbBIofv0sh4Lbmhtb2+/Cbv1eFpaWmJCQsJODMO0hGGgUghAAay9v7//i5KSki9lmmG+4+Jg/MHaIH6f0dCkqaNFFc5VkViam5v319TUNEDdvRubEGsNYHGqsAwMDFxta2u7DdpdpA+3c+LgWiHfVkCiFnpDw0iLqwgqO6BVKoPo00K6WIDsOzE6OrpE395FzeLgxMn5jVe0dYTa26s5jfFg4VR0nAuwNtrFda1rgmToD6VzVWq3eTPyYAxOwwH5gvT2PiWY7X4fUgJTywp1fivyyL6E+Lb6XvQ0X9AkBeeXZED+p/k+9LcAAwAXm3hBLzoZPAAAAABJRU5ErkJggg== +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/binaryfile.tar.gz.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/binaryfile.tar.gz.http new file mode 100644 index 00000000..4f4fadb0 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/binaryfile.tar.gz.http @@ -0,0 +1,12 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Length: 676 + +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Disposition: form-data; name="file"; filename="binaryfile.tar.gz" +Content-Type: application/x-gzip +Content-Transfer-Encoding: base64 + +H4sIAGiNIU8AA+3R0W6CMBQGYK59iobLZantRDG73osUOGqnFNJWM2N897UghG1ZdmWWLf93U/jP4bRAq8q92hJ/dY1J7kQEqyyLq8yXYrp2ltkqkTKXYiEykYc++ZTLVcLEvQ40dXReWcYSV1pdnL/v+6n+R11mjKVG1ZQ+s3TT2FpXqjhQ+hjzE1mnGxNLkgu+7tOKWjIVmVKTC6XL9ZaeXj4VQhwKWzL+cI4zwgQuuhkh3mhTad/Hkssh3im3027X54JnQ360R/M19OT8kC7SEN7Ooi2VvrEfznHQRWzl83gxttZKmzGehzPRW/+W8X+3fvL8sFet9sS6m3EIma02071MU3Uf9KHrmV1/+y8DAAAAAAAAAAAAAAAAAAAAAMB/9A6txIuJACgAAA== +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/blank.gif.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/blank.gif.http new file mode 100644 index 00000000..7426f5b6 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/blank.gif.http @@ -0,0 +1,12 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Length: 323 + +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Disposition: form-data; name="file"; filename="blank.gif" +Content-Type: image/gif +Content-Transfer-Encoding: base64 + +R0lGODlhAQABAJH/AP///wAAAMDAwAAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw== +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/menu_seperator.png.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/menu_seperator.png.http new file mode 100644 index 00000000..d08fd37e --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/menu_seperator.png.http @@ -0,0 +1,12 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Length: 1509 + +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Disposition: form-data; name="image"; filename="menu_separator.png" +Content-Type: image/png +Content-Transfer-Encoding: base64 + +iVBORw0KGgoAAAANSUhEUgAAAAIAAAAYCAIAAABfmbuOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDcxODNBNzJERDcyMTFFMUFBOEVFNDQzOTA0MDJDMjQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDcxODNBNzNERDcyMTFFMUFBOEVFNDQzOTA0MDJDMjQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowNzE4M0E3MERENzIxMUUxQUE4RUU0NDM5MDQwMkMyNCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowNzE4M0E3MURENzIxMUUxQUE4RUU0NDM5MDQwMkMyNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pmvhbb8AAAAXSURBVHjaYnHk9PON8WJiAIPBSwEEGAAPrgG+VozFWgAAAABJRU5ErkJggg== +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/pf1y5.png.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/pf1y5.png.http new file mode 100644 index 00000000..20c2c2df Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/pf1y5.png.http differ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/plain.txt.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/plain.txt.http new file mode 100644 index 00000000..5e85ad6b --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/encoding/plain.txt.http @@ -0,0 +1,13 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 221 + +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="file"; filename="plain.txt" +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +I am a plain text file + +------TLV0SrKD4z1TRxRhAPUvZ-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/no-filename/filename-name.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/no-filename/filename-name.http new file mode 100644 index 00000000..43672a32 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/no-filename/filename-name.http @@ -0,0 +1,13 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Length: 1000 + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; filename="plain.txt"; name="upload" +Content-Type: text/plain + +I am a plain text file + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/no-filename/generic.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/no-filename/generic.http new file mode 100644 index 00000000..e0dee27c --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/no-filename/generic.http @@ -0,0 +1,13 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Length: 1000 + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; name="upload"; filename="" +Content-Type: text/plain + +I am a plain text file + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/preamble/crlf.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/preamble/crlf.http new file mode 100644 index 00000000..1d5f7095 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/preamble/crlf.http @@ -0,0 +1,13 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 184 + + +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="upload"; filename="plain.txt" +Content-Type: text/plain + +I am a plain text file + +------TLV0SrKD4z1TRxRhAPUvZ-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/preamble/preamble.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/preamble/preamble.http new file mode 100644 index 00000000..d14d4330 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/preamble/preamble.http @@ -0,0 +1,13 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 226 + +This is a preamble which should be ignored +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="upload"; filename="plain.txt" +Content-Type: text/plain + +I am a plain text file + +------TLV0SrKD4z1TRxRhAPUvZ-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/info.md b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/info.md new file mode 100644 index 00000000..3c9dbe3d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/info.md @@ -0,0 +1,3 @@ +* Opera does not allow submitting this file, it shows a warning to the + user that the file could not be found instead. Tested in 9.8, 11.51 on OSX. + Reported to Opera on 08.09.2011 (tracking email DSK-346009@bugs.opera.com). diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-chrome-13.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-chrome-13.http new file mode 100644 index 00000000..4ef39172 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-chrome-13.http @@ -0,0 +1,26 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Connection: keep-alive +Referer: http://localhost:8080/ +Content-Length: 383 +Cache-Control: max-age=0 +Origin: http://localhost:8080 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Encoding: gzip,deflate,sdch +Accept-Language: en-US,en;q=0.8 +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 +Cookie: jqCookieJar_tablesorter=%7B%22showListTable%22%3A%5B%5B5%2C1%5D%2C%5B1%2C0%5D%5D%7D + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + +I am a text file with a funky name! + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http new file mode 100644 index 00000000..bf49f85f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http @@ -0,0 +1,24 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22 +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Language: en-us,en;q=0.5 +Accept-Encoding: gzip,deflate +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 +Keep-Alive: 115 +Connection: keep-alive +Referer: http://localhost:8080/ +Content-Type: multipart/form-data; boundary=---------------------------9849436581144108930470211272 +Content-Length: 438 + +-----------------------------9849436581144108930470211272 +Content-Disposition: form-data; name="title" + +Weird filename +-----------------------------9849436581144108930470211272 +Content-Disposition: form-data; name="upload"; filename=": \ ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + +I am a text file with a funky name! + +-----------------------------9849436581144108930470211272-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-safari-5.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-safari-5.http new file mode 100644 index 00000000..ff158a43 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/osx-safari-5.http @@ -0,0 +1,23 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Origin: http://localhost:8080 +Content-Length: 383 +User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQJZ1gvhvdgfisJPJ +Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 +Referer: http://localhost:8080/ +Accept-Language: en-us +Accept-Encoding: gzip, deflate +Connection: keep-alive + +------WebKitFormBoundaryQJZ1gvhvdgfisJPJ +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundaryQJZ1gvhvdgfisJPJ +Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + +I am a text file with a funky name! + +------WebKitFormBoundaryQJZ1gvhvdgfisJPJ-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-chrome-12.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-chrome-12.http new file mode 100644 index 00000000..f0fc533a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-chrome-12.http @@ -0,0 +1,24 @@ +POST /upload HTTP/1.1 +Host: 192.168.56.1:8080 +Connection: keep-alive +Referer: http://192.168.56.1:8080/ +Content-Length: 344 +Cache-Control: max-age=0 +Origin: http://192.168.56.1:8080 +User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryEvqBNplR3ByrwQPa +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Encoding: gzip,deflate,sdch +Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4 +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 + +------WebKitFormBoundaryEvqBNplR3ByrwQPa +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundaryEvqBNplR3ByrwQPa +Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + + +------WebKitFormBoundaryEvqBNplR3ByrwQPa-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-ie-7.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-ie-7.http new file mode 100644 index 00000000..2e2c61c7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-ie-7.http @@ -0,0 +1,22 @@ +POST /upload HTTP/1.1 +Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */* +Referer: http://192.168.56.1:8080/ +Accept-Language: de +User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) +Content-Type: multipart/form-data; boundary=---------------------------7db1fe232017c +Accept-Encoding: gzip, deflate +Host: 192.168.56.1:8080 +Content-Length: 368 +Connection: Keep-Alive +Cache-Control: no-cache + +-----------------------------7db1fe232017c +Content-Disposition: form-data; name="title" + +Weird filename +-----------------------------7db1fe232017c +Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: application/octet-stream + + +-----------------------------7db1fe232017c-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-ie-8.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-ie-8.http new file mode 100644 index 00000000..e2b94fae --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-ie-8.http @@ -0,0 +1,22 @@ +POST /upload HTTP/1.1 +Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */* +Referer: http://192.168.56.1:8080/ +Accept-Language: de +User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) +Content-Type: multipart/form-data; boundary=---------------------------7db3a8372017c +Accept-Encoding: gzip, deflate +Host: 192.168.56.1:8080 +Content-Length: 368 +Connection: Keep-Alive +Cache-Control: no-cache + +-----------------------------7db3a8372017c +Content-Disposition: form-data; name="title" + +Weird filename +-----------------------------7db3a8372017c +Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: application/octet-stream + + +-----------------------------7db3a8372017c-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-safari-5.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-safari-5.http new file mode 100644 index 00000000..6379ac01 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/special-chars-in-filename/xp-safari-5.http @@ -0,0 +1,22 @@ +POST /upload HTTP/1.1 +Host: 192.168.56.1:8080 +Referer: http://192.168.56.1:8080/ +Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 +Accept-Language: en-US +Origin: http://192.168.56.1:8080 +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4 +Accept-Encoding: gzip, deflate +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarykmaWSUbu697WN9TM +Content-Length: 344 +Connection: keep-alive + +------WebKitFormBoundarykmaWSUbu697WN9TM +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundarykmaWSUbu697WN9TM +Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + + +------WebKitFormBoundarykmaWSUbu697WN9TM-- diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/workarounds/missing-hyphens1.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/workarounds/missing-hyphens1.http new file mode 100644 index 00000000..28268903 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/workarounds/missing-hyphens1.http @@ -0,0 +1,12 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 178 + +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="upload"; filename="plain.txt" +Content-Type: text/plain + +I am a plain text file + +------TLV0SrKD4z1TRxRhAPUvZ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/workarounds/missing-hyphens2.http b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/workarounds/missing-hyphens2.http new file mode 100644 index 00000000..8e181947 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/http/workarounds/missing-hyphens2.http @@ -0,0 +1,12 @@ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 180 + +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="upload"; filename="plain.txt" +Content-Type: text/plain + +I am a plain text file + +------TLV0SrKD4z1TRxRhAPUvZ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/encoding.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/encoding.js new file mode 100644 index 00000000..1ade9656 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/encoding.js @@ -0,0 +1,69 @@ +module.exports['menu_seperator.png.http'] = [ + { + type: 'file', + name: 'image', + filename: 'menu_separator.png', + fixture: 'menu_separator.png', + sha1: 'c845ca3ea794be298f2a1b79769b71939eaf4e54', + size: 931, + } +]; + +module.exports['beta-sticker-1.png.http'] = [ + { + type: 'file', + name: 'sticker', + filename: 'beta-sticker-1.png', + fixture: 'beta-sticker-1.png', + sha1: '6abbcffd12b4ada5a6a084fe9e4584f846331bc4', + size: 1660, + } +]; + +module.exports['blank.gif.http'] = [ + { + type: 'file', + name: 'file', + filename: 'blank.gif', + fixture: 'blank.gif', + sha1: 'a1fdee122b95748d81cee426d717c05b5174fe96', + size: 49, + } +]; + +module.exports['binaryfile.tar.gz.http'] = [ + { + type: 'file', + name: 'file', + filename: 'binaryfile.tar.gz', + fixture: 'binaryfile.tar.gz', + sha1: 'cfabe13b348e5e69287d677860880c52a69d2155', + size: 301, + } +]; + +module.exports['plain.txt.http'] = [ + { + type: 'file', + name: 'file', + filename: 'plain.txt', + fixture: 'plain.txt', + sha1: 'b31d07bac24ac32734de88b3687dddb10e976872', + size: 23, + } +]; + +module.exports['pf1y5.png.http'] = [ + { + type: 'field', + name: 'path', + }, + { + type: 'file', + name: 'upload', + filename: 'pf1y5.png', + fixture: 'pf1y5.png', + sha1: '805cc640c5b182e86f2b5c8ebf34ecf063cd34fd', + size: 768323, + } +]; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/no-filename.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/no-filename.js new file mode 100644 index 00000000..f03b4f01 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/no-filename.js @@ -0,0 +1,9 @@ +module.exports['generic.http'] = [ + {type: 'file', name: 'upload', filename: '', fixture: 'plain.txt', + sha1: 'b31d07bac24ac32734de88b3687dddb10e976872'}, +]; + +module.exports['filename-name.http'] = [ + {type: 'file', name: 'upload', filename: 'plain.txt', fixture: 'plain.txt', + sha1: 'b31d07bac24ac32734de88b3687dddb10e976872'}, +]; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/preamble.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/preamble.js new file mode 100644 index 00000000..d2e4cfdb --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/preamble.js @@ -0,0 +1,9 @@ +module.exports['crlf.http'] = [ + {type: 'file', name: 'upload', filename: 'plain.txt', fixture: 'plain.txt', + sha1: 'b31d07bac24ac32734de88b3687dddb10e976872'}, +]; + +module.exports['preamble.http'] = [ + {type: 'file', name: 'upload', filename: 'plain.txt', fixture: 'plain.txt', + sha1: 'b31d07bac24ac32734de88b3687dddb10e976872'}, +]; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/special-chars-in-filename.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/special-chars-in-filename.js new file mode 100644 index 00000000..aa0b79f3 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/special-chars-in-filename.js @@ -0,0 +1,30 @@ +var properFilename = 'funkyfilename.txt'; + +function expect(filename) { + return [ + { + type: 'field', + name: 'title', + value: 'Weird filename', + }, + { + type: 'file', + name: 'upload', + filename: filename, + fixture: properFilename, + }, + ]; +} + +var webkit = " ? % * | \" < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"; +var ffOrIe = " ? % * | \" < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"; + +module.exports = { + 'osx-chrome-13.http' : expect(webkit), + 'osx-firefox-3.6.http' : expect(ffOrIe), + 'osx-safari-5.http' : expect(webkit), + 'xp-chrome-12.http' : expect(webkit), + 'xp-ie-7.http' : expect(ffOrIe), + 'xp-ie-8.http' : expect(ffOrIe), + 'xp-safari-5.http' : expect(webkit), +}; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/workarounds.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/workarounds.js new file mode 100644 index 00000000..e59c5b26 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/js/workarounds.js @@ -0,0 +1,8 @@ +module.exports['missing-hyphens1.http'] = [ + {type: 'file', name: 'upload', filename: 'plain.txt', fixture: 'plain.txt', + sha1: 'b31d07bac24ac32734de88b3687dddb10e976872'}, +]; +module.exports['missing-hyphens2.http'] = [ + {type: 'file', name: 'upload', filename: 'plain.txt', fixture: 'plain.txt', + sha1: 'b31d07bac24ac32734de88b3687dddb10e976872'}, +]; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/multi_video.upload b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/multi_video.upload new file mode 100644 index 00000000..9c82ba36 Binary files /dev/null and b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/multi_video.upload differ diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/multipart.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/multipart.js new file mode 100644 index 00000000..a4761699 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/fixture/multipart.js @@ -0,0 +1,72 @@ +exports['rfc1867'] = + { boundary: 'AaB03x', + raw: + '--AaB03x\r\n'+ + 'content-disposition: form-data; name="field1"\r\n'+ + '\r\n'+ + 'Joe Blow\r\nalmost tricked you!\r\n'+ + '--AaB03x\r\n'+ + 'content-disposition: form-data; name="pics"; filename="file1.txt"\r\n'+ + 'Content-Type: text/plain\r\n'+ + '\r\n'+ + '... contents of file1.txt ...\r\r\n'+ + '--AaB03x--\r\n', + parts: + [ { headers: { + 'content-disposition': 'form-data; name="field1"', + }, + data: 'Joe Blow\r\nalmost tricked you!', + }, + { headers: { + 'content-disposition': 'form-data; name="pics"; filename="file1.txt"', + 'Content-Type': 'text/plain', + }, + data: '... contents of file1.txt ...\r', + } + ] + }; + +exports['noTrailing\r\n'] = + { boundary: 'AaB03x', + raw: + '--AaB03x\r\n'+ + 'content-disposition: form-data; name="field1"\r\n'+ + '\r\n'+ + 'Joe Blow\r\nalmost tricked you!\r\n'+ + '--AaB03x\r\n'+ + 'content-disposition: form-data; name="pics"; filename="file1.txt"\r\n'+ + 'Content-Type: text/plain\r\n'+ + '\r\n'+ + '... contents of file1.txt ...\r\r\n'+ + '--AaB03x--', + parts: + [ { headers: { + 'content-disposition': 'form-data; name="field1"', + }, + data: 'Joe Blow\r\nalmost tricked you!', + }, + { headers: { + 'content-disposition': 'form-data; name="pics"; filename="file1.txt"', + 'Content-Type': 'text/plain', + }, + data: '... contents of file1.txt ...\r', + } + ] + }; + +exports['emptyHeader'] = + { boundary: 'AaB03x', + raw: + '--AaB03x\r\n'+ + 'content-disposition: form-data; name="field1"\r\n'+ + ': foo\r\n'+ + '\r\n'+ + 'Joe Blow\r\nalmost tricked you!\r\n'+ + '--AaB03x\r\n'+ + 'content-disposition: form-data; name="pics"; filename="file1.txt"\r\n'+ + 'Content-Type: text/plain\r\n'+ + '\r\n'+ + '... contents of file1.txt ...\r\r\n'+ + '--AaB03x--\r\n', + expectError: true, + }; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/record.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/record.js new file mode 100644 index 00000000..9f1cef86 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/record.js @@ -0,0 +1,47 @@ +var http = require('http'); +var fs = require('fs'); +var connections = 0; + +var server = http.createServer(function(req, res) { + var socket = req.socket; + console.log('Request: %s %s -> %s', req.method, req.url, socket.filename); + + req.on('end', function() { + if (req.url !== '/') { + res.end(JSON.stringify({ + method: req.method, + url: req.url, + filename: socket.filename, + })); + return; + } + + res.writeHead(200, {'content-type': 'text/html'}); + res.end( + '
          '+ + '
          '+ + '
          '+ + ''+ + '
          ' + ); + }); +}); + +server.on('connection', function(socket) { + connections++; + + socket.id = connections; + socket.filename = 'connection-' + socket.id + '.http'; + socket.file = fs.createWriteStream(socket.filename); + socket.pipe(socket.file); + + console.log('--> %s', socket.filename); + socket.on('close', function() { + console.log('<-- %s', socket.filename); + }); +}); + +var port = process.env.PORT || 8080; +server.listen(port, function() { + console.log('Recording connections on port %s', port); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-connection-aborted.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-connection-aborted.js new file mode 100644 index 00000000..bd83e1d6 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-connection-aborted.js @@ -0,0 +1,27 @@ +var assert = require('assert'); +var http = require('http'); +var net = require('net'); +var multiparty = require('../../'); + +var server = http.createServer(function (req, res) { + var form = new multiparty.Form(); + var aborted_received = false; + form.on('aborted', function () { + aborted_received = true; + }); + form.on('error', function () { + assert(aborted_received, 'Error event should follow aborted'); + server.close(); + }); + form.on('end', function () { + throw new Error('Unexpected "end" event'); + }); + form.parse(req); +}).listen(0, 'localhost', function () { + var client = net.connect(server.address().port); + client.write( + "POST / HTTP/1.1\r\n" + + "Content-Length: 70\r\n" + + "Content-Type: multipart/form-data; boundary=foo\r\n\r\n"); + client.end(); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-content-transfer-encoding.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-content-transfer-encoding.js new file mode 100644 index 00000000..35e5a1f8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-content-transfer-encoding.js @@ -0,0 +1,52 @@ +var assert = require('assert') + , multiparty = require('../../') + , http = require('http') + , path = require('path') + , TMP_PATH = path.join(__dirname, '..', 'tmp') + +var server = http.createServer(function(req, res) { + var form = new multiparty.Form(); + form.uploadDir = TMP_PATH; + form.on('close', function () { + throw new Error('Unexpected "close" event'); + }); + form.on('end', function () { + throw new Error('Unexpected "end" event'); + }); + form.on('error', function (e) { + res.writeHead(500); + res.end(e.message); + }); + form.parse(req); +}); + +server.listen(0, function() { + var body = + '--foo\r\n' + + 'Content-Disposition: form-data; name="file1"; filename="file1"\r\n' + + 'Content-Type: application/octet-stream\r\n' + + '\r\nThis is the first file\r\n' + + '--foo\r\n' + + 'Content-Type: application/octet-stream\r\n' + + 'Content-Disposition: form-data; name="file2"; filename="file2"\r\n' + + 'Content-Transfer-Encoding: unknown\r\n' + + '\r\nThis is the second file\r\n' + + '--foo--\r\n'; + + var req = http.request({ + method: 'POST', + port: server.address().port, + headers: { + 'Content-Length': body.length, + 'Content-Type': 'multipart/form-data; boundary=foo' + } + }); + req.on('response', function (res) { + assert.equal(res.statusCode, 500); + res.on('data', function () {}); + res.on('end', function () { + server.close(); + }); + }); + req.end(body); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-invalid.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-invalid.js new file mode 100644 index 00000000..ede541da --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-invalid.js @@ -0,0 +1,35 @@ +var superagent = require('superagent') + , multiparty = require('../../') + , http = require('http') + +var server = http.createServer(function(req, resp) { + var form = new multiparty.Form(); + + var errCount = 0; + form.on('error', function(err) { + errCount += 1; + resp.end(); + }); + form.on('file', function(name, file) { + }); + form.on('field', function(name, file) { + }); + + form.parse(req); +}); +server.listen(function() { + var url = 'http://localhost:' + server.address().port + '/' + var req = superagent.post(url) + req.set('Content-Type', 'multipart/form-data; boundary=foo') + req.write('--foo\r\n') + req.write('Content-filename="foo.txt"\r\n') + req.write('\r\n') + req.write('some text here') + req.write('Content-Disposition: form-data; name="text"; filename="bar.txt"\r\n') + req.write('\r\n') + req.write('some more text stuff') + req.write('\r\n--foo--') + req.end(function(err, resp) { + server.close(); + }); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-15.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-15.js new file mode 100644 index 00000000..43982fa7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-15.js @@ -0,0 +1,88 @@ +var http = require('http') + , multiparty = require('../../') + , assert = require('assert') + , superagent = require('superagent') + , path = require('path') + +var server = http.createServer(function(req, res) { + assert.strictEqual(req.url, '/upload'); + assert.strictEqual(req.method, 'POST'); + + var form = new multiparty.Form({autoFields:true,autoFiles:true}); + + form.on('error', function(err) { + console.log(err); + }); + + form.on('close', function() { + }); + + var fileCount = 0; + form.on('file', function(name, file) { + fileCount += 1; + }); + + form.parse(req, function(err, fields, files) { + var objFileCount = 0; + for (var file in files) { + objFileCount += 1; + } + // multiparty does NOT try to do intelligent things based on + // the part name. + assert.strictEqual(fileCount, 2); + assert.strictEqual(objFileCount, 1); + res.end(); + }); +}); +server.listen(function() { + var url = 'http://localhost:' + server.address().port + '/upload'; + var req = superagent.post(url); + req.attach('files[]', fixture('pf1y5.png'), 'SOG2.JPG'); + req.attach('files[]', fixture('binaryfile.tar.gz'), 'BenF364_LIB353.zip'); + + // Get the existing boundary. + var contentType = req.get('content-type'); + var split = contentType.split(' '); + + // Set the content-type. + req.set('content-type', split.join('')); + + req.end(function(err, resp) { + assert.ifError(err); + resp.on('end', function() { + server.close(); + }); + }); + + // No space. + createRequest(''); + + // Single space. + createRequest(' '); + + // Multiple spaces. + createRequest(' '); +}); + +function createRequest(separator) { + var url = 'http://localhost:' + server.address().port + '/upload'; + var req = superagent.post(url); + req.attach('files[]', fixture('pf1y5.png'), 'SOG2.JPG'); + req.attach('files[]', fixture('binaryfile.tar.gz'), 'BenF364_LIB353.zip'); + + // Get the existing boundary. + var contentType = req.get('content-type'); + var split = contentType.split(' '); + + // Set the content-type. + req.set('content-type', split.join(separator)); + + req.end(function(err, resp) { + assert.ifError(err); + // We don't close the server, to allow other requests to pass. + }); +} + +function fixture(name) { + return path.join(__dirname, '..', 'fixture', 'file', name) +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-19.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-19.js new file mode 100644 index 00000000..d7da0cfb --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-19.js @@ -0,0 +1,44 @@ +var assert = require('assert'); +var http = require('http'); +var net = require('net'); +var multiparty = require('../../'); + +var client; +var server = http.createServer(function (req, res) { + var form = new multiparty.Form({maxFields: 1}); + form.on('aborted', function () { + throw new Error("did not expect aborted"); + }); + var first = true; + form.on('error', function (err) { + assert.ok(first); + first = false; + client.end(); + assert.ok(/maxFields/.test(err.message)); + server.close(); + }); + form.on('end', function () { + throw new Error('Unexpected "end" event'); + }); + form.parse(req); +}); +server.listen(function() { + client = net.connect(server.address().port); + + client.write("POST /upload HTTP/1.1\r\n" + + "Content-Length: 728\r\n" + + "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "Content-Disposition: form-data; name=\"title\"\r\n" + + "\r\n" + + "foofoo" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "Content-Disposition: form-data; name=\"upload\"; filename=\"blah1.txt\"\r\n" + + "Content-Type: text/plain\r\n" + + "\r\n" + + "hi1\r\n" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n"); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-21.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-21.js new file mode 100644 index 00000000..155fba05 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-21.js @@ -0,0 +1,66 @@ +var assert = require('assert'); +var http = require('http'); +var net = require('net'); +var multiparty = require('../../'); + +var client; +var server = http.createServer(function(req, res) { + var form = new multiparty.Form(); + + form.parse(req, function(err, fieldsTable, filesTable, fieldsList, filesList) { + if (err) { + console.error(err.stack); + return; + } + assert.strictEqual(fieldsList.length, 1); + assert.strictEqual(fieldsList[0].name, "title"); + assert.strictEqual(fieldsList[0].value, "foofoo"); + assert.strictEqual(filesList.length, 4); + assert.strictEqual(filesList[0].fieldName, "upload"); + assert.strictEqual(filesList[1].fieldName, "upload"); + assert.strictEqual(filesList[2].fieldName, "upload"); + assert.strictEqual(filesList[3].fieldName, "upload"); + res.end(); + client.end(); + server.close(); + }); +}); +server.listen(function() { + client = net.connect(server.address().port); + + client.write("POST /upload HTTP/1.1\r\n" + + "Content-Length: 728\r\n" + + "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "Content-Disposition: form-data; name=\"title\"\r\n" + + "\r\n" + + "foofoo" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "Content-Disposition: form-data; name=\"upload\"; filename=\"blah1.txt\"\r\n" + + "Content-Type: text/plain\r\n" + + "\r\n" + + "hi1\r\n" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "Content-Disposition: form-data; name=\"upload\"; filename=\"blah2.txt\"\r\n" + + "Content-Type: text/plain\r\n" + + "\r\n" + + "hi2\r\n" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "Content-Disposition: form-data; name=\"upload\"; filename=\"blah3.txt\"\r\n" + + "Content-Type: text/plain\r\n" + + "\r\n" + + "hi3\r\n" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "Content-Disposition: form-data; name=\"upload\"; filename=\"blah4.txt\"\r\n" + + "Content-Type: text/plain\r\n" + + "\r\n" + + "hi4\r\n" + + "\r\n" + + "------WebKitFormBoundaryvfUZhxgsZDO7FXLF--\r\n" + ); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-4.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-4.js new file mode 100644 index 00000000..66b2a690 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-4.js @@ -0,0 +1,51 @@ +var http = require('http') + , multiparty = require('../../') + , assert = require('assert') + , superagent = require('superagent') + , path = require('path') + +var server = http.createServer(function(req, res) { + assert.strictEqual(req.url, '/upload'); + assert.strictEqual(req.method, 'POST'); + + var form = new multiparty.Form({autoFields:true,autoFiles:true}); + + form.on('error', function(err) { + console.log(err); + }); + + form.on('close', function() { + }); + + var fileCount = 0; + form.on('file', function(name, file) { + fileCount += 1; + }); + + form.parse(req, function(err, fields, files) { + var objFileCount = 0; + for (var file in files) { + objFileCount += 1; + } + // multiparty does NOT try to do intelligent things based on + // the part name. + assert.strictEqual(fileCount, 2); + assert.strictEqual(objFileCount, 1); + res.end(); + }); +}); +server.listen(function() { + var url = 'http://localhost:' + server.address().port + '/upload'; + var req = superagent.post(url); + req.attach('files[]', fixture('pf1y5.png'), 'SOG2.JPG'); + req.attach('files[]', fixture('binaryfile.tar.gz'), 'BenF364_LIB353.zip'); + req.end(function(err, resp) { + assert.ifError(err); + resp.on('end', function() { + server.close(); + }); + }); +}); +function fixture(name) { + return path.join(__dirname, '..', 'fixture', 'file', name) +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-46.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-46.js new file mode 100644 index 00000000..676b8709 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-46.js @@ -0,0 +1,49 @@ +var http = require('http'), + multiparty = require('../../'), + request = require('request'), + assert = require('assert'); + +var host = 'localhost'; + +var index = [ + '
          ', + ' ', + ' ', + '
          ' +].join("\n"); + +var server = http.createServer(function(req, res) { + + // Show a form for testing purposes. + if (req.method === 'GET') { + res.writeHead(200, {'content-type': 'text/html'}); + res.end(index); + return; + } + + // Parse form and write results to response. + var form = new multiparty.Form(); + form.parse(req, function(err, fields, files) { + res.writeHead(200, {'content-type': 'text/plain'}); + res.write(JSON.stringify({err: err, fields: fields, files: files})); + res.end(); + }); + +}).listen(0, host, function() { + + //console.log("Server up and running..."); + + var server = this, + url = 'http://' + host + ':' + server.address().port; + + var parts = [ + {'Content-Disposition': 'form-data; name="foo"', 'body': 'bar'} + ] + + var req = request({method: 'POST', url: url, multipart: parts}, function(e, res, body) { + var obj = JSON.parse(body); + assert.equal("bar", obj.fields.foo); + server.close(); + }); + +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-5.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-5.js new file mode 100644 index 00000000..80eadf20 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/standalone/test-issue-5.js @@ -0,0 +1,39 @@ +var assert = require('assert'); +var http = require('http'); +var net = require('net'); +var multiparty = require('../../'); + +var client; +var attachmentCount = 510; +var server = http.createServer(function(req, res) { + var form = new multiparty.Form({maxFields: 10000}); + + form.parse(req, function(err, fieldsTable, filesTable, fieldsList, filesList) { + assert.strictEqual(err.code, "EMFILE"); + res.end(); + client.end(); + server.close(); + }); +}); +server.listen(function() { + client = net.connect(server.address().port); + + var boundary = "------WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n"; + var oneAttachment = boundary + + "Content-Disposition: form-data; name=\"upload\"; filename=\"blah1.txt\"\r\n" + + "Content-Type: text/plain\r\n" + + "\r\n" + + "hi1\r\n" + + "\r\n"; + var payloadSize = oneAttachment.length * attachmentCount + boundary.length; + + client.write("POST /upload HTTP/1.1\r\n" + + "Content-Length: " + payloadSize + "\r\n" + + "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryvfUZhxgsZDO7FXLF\r\n" + + "\r\n"); + + for (var i = 0; i < attachmentCount; i += 1) { + client.write(oneAttachment); + } + client.write(boundary); +}); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/test.js b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/test.js new file mode 100644 index 00000000..199d5cdd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/multiparty/test/test.js @@ -0,0 +1,117 @@ +var spawn = require('child_process').spawn + , findit = require('findit') + , path = require('path') + , hashish = require('hashish') + , fs = require('fs') + , http = require('http') + , net = require('net') + , assert = require('assert') + , multiparty = require('../') + , mkdirp = require('mkdirp') + , STANDALONE_PATH = path.join(__dirname, 'standalone') + , server = http.createServer() + , PORT = 13532 + , FIXTURE_PATH = path.join(__dirname, 'fixture') + , TMP_PATH = path.join(__dirname, 'tmp') + +mkdirp.sync(TMP_PATH); + +describe("fixtures", function() { + before(function(done) { + server.listen(PORT, done); + }); + var fixtures = []; + findit + .sync(path.join(FIXTURE_PATH, 'js')) + .forEach(function(jsPath) { + if (!/\.js$/.test(jsPath)) return; + var group = path.basename(jsPath, '.js'); + hashish.forEach(require(jsPath), function(fixture, name) { + it(group + '/' + name, createTest({ + name : group + '/' + name, + fixture : fixture, + })); + }); + }); +}); + +describe("standalone", function() { + findit + .sync(STANDALONE_PATH) + .forEach(function(jsPath) { + if (!/\.js$/.test(jsPath)) return; + it(path.basename(jsPath, '.js'), function(done) { + var child = spawn(process.execPath, [jsPath], { stdio: 'inherit' }); + child.on('error', function(err) { + done(err); + }); + child.on('exit', function(code) { + if (code) return done(new Error("exited with code " + code)); + done(); + }); + }); + }); +}); + +function createTest(fixture) { + var name = fixture.name; + fixture = fixture.fixture; + return function(done) { + uploadFixture(name, function(err, parts) { + if (err) return done(err); + fixture.forEach(function(expectedPart, i) { + var parsedPart = parts[i]; + assert.equal(parsedPart.type, expectedPart.type); + assert.equal(parsedPart.name, expectedPart.name); + + if (parsedPart.type === 'file') { + var file = parsedPart.value; + assert.equal(file.originalFilename, expectedPart.filename); + if(expectedPart.sha1) assert.strictEqual(file.hash, expectedPart.sha1); + if(expectedPart.size) assert.strictEqual(file.size, expectedPart.size); + } + }); + done(); + }); + }; + +} + +function uploadFixture(name, cb) { + server.once('request', function(req, res) { + var parts = []; + var form = new multiparty.Form({ + autoFields: true, + autoFiles: true, + }); + form.uploadDir = TMP_PATH; + form.hash = "sha1"; + + form.on('error', callback); + form.on('file', function(name, value) { + parts.push({type: 'file', name: name, value: value}); + }); + form.on('field', function(name, value) { + parts.push({type: 'field', name: name, value: value}); + }); + form.on('close', function() { + res.end('OK'); + callback(null, parts); + }); + form.parse(req); + + function callback() { + var realCallback = cb; + cb = function() {}; + realCallback.apply(null, arguments); + } + }); + + var socket = net.createConnection(PORT); + var file = fs.createReadStream(FIXTURE_PATH + '/http/' + name); + + file.pipe(socket, {end: false}); + socket.on('data', function () { + socket.end(); + }); +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/LICENSE new file mode 100644 index 00000000..42ca2e7d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/LICENSE @@ -0,0 +1,27 @@ +Original "Negotiator" program Copyright Federico Romero +Port to JavaScript Copyright Isaac Z. Schlueter + +All rights reserved. + +MIT License + +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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/accept.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/accept.js new file mode 100644 index 00000000..2a180391 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/accept.js @@ -0,0 +1,47 @@ +(function() { + var Negotiator, availableMediaTypes, http, key, representations, server, val; + + Negotiator = require('../lib/negotiator').Negotiator; + + http = require('http'); + + representations = { + 'text/html': '

          Hello world!

          ', + 'text/plain': 'Hello World!', + 'application/json': JSON.stringify({ + hello: 'world!' + }) + }; + + availableMediaTypes = (function() { + var _results; + _results = []; + for (key in representations) { + val = representations[key]; + _results.push(key); + } + return _results; + })(); + + server = http.createServer(function(req, res) { + var mediaType, negotiator; + negotiator = new Negotiator(req); + console.log("Accept: " + req.headers['accept']); + console.log("Preferred: " + (negotiator.preferredMediaTypes())); + console.log("Possible: " + (negotiator.preferredMediaTypes(availableMediaTypes))); + mediaType = negotiator.preferredMediaType(availableMediaTypes); + console.log("Selected: " + mediaType); + if (mediaType) { + res.writeHead(200, { + 'Content-Type': mediaType + }); + return res.end(representations[mediaType]); + } else { + res.writeHead(406); + return res.end(); + } + }); + + server.listen(8080); + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/charset.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/charset.js new file mode 100644 index 00000000..6455effa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/charset.js @@ -0,0 +1,52 @@ +(function() { + var Buffer, Iconv, Negotiator, availableCharsets, http, iconv, key, message, messages, server, val; + + Negotiator = require('../lib/negotiator').Negotiator; + + http = require('http'); + + Buffer = require('buffer').Buffer; + + Iconv = require('iconv').Iconv; + + iconv = new Iconv('UTF-8', 'ISO-8859-1'); + + message = "ë"; + + messages = { + 'utf-8': message, + 'iso-8859-1': iconv.convert(new Buffer(message)) + }; + + availableCharsets = (function() { + var _results; + _results = []; + for (key in messages) { + val = messages[key]; + _results.push(key); + } + return _results; + })(); + + server = http.createServer(function(req, res) { + var charset, negotiator; + negotiator = new Negotiator(req); + console.log("Accept-Charset: " + req.headers['accept-charset']); + console.log("Preferred: " + (negotiator.preferredCharsets())); + console.log("Possible: " + (negotiator.preferredCharsets(availableCharsets))); + charset = negotiator.preferredCharset(availableCharsets); + console.log("Selected: " + charset); + if (charset) { + res.writeHead(200, { + 'Content-Type': "text/html; charset=" + charset + }); + return res.end(messages[charset]); + } else { + res.writeHead(406); + return res.end(); + } + }); + + server.listen(8080); + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/encoding.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/encoding.js new file mode 100644 index 00000000..a02d0f46 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/encoding.js @@ -0,0 +1,48 @@ +(function() { + var Negotiator, gbuf, http, messages; + + Negotiator = require('../lib/negotiator').Negotiator; + + http = require('http'); + + gbuf = require('gzip-buffer'); + + messages = { + identity: 'Hello World' + }; + + gbuf.gzip(messages.identity, function(zipped) { + var availableEncodings, key, server, val; + messages.gzip = zipped; + availableEncodings = (function() { + var _results; + _results = []; + for (key in messages) { + val = messages[key]; + _results.push(key); + } + return _results; + })(); + console.log(availableEncodings); + server = http.createServer(function(req, res) { + var encoding, negotiator; + negotiator = new Negotiator(req); + console.log("Accept-Encoding: " + req.headers['accept-encoding']); + console.log("Preferred: " + (negotiator.preferredEncodings())); + console.log("Possible: " + (negotiator.preferredEncodings(availableEncodings))); + encoding = negotiator.preferredEncoding(availableEncodings); + console.log("Selected: " + encoding); + if (encoding) { + res.writeHead(200, { + 'Content-Encoding': encoding + }); + return res.end(messages[encoding]); + } else { + res.writeHead(406); + return res.end(); + } + }); + return server.listen(8080); + }); + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/language.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/language.js new file mode 100644 index 00000000..f161743f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/examples/language.js @@ -0,0 +1,44 @@ +(function() { + var Negotiator, availableLanguages, http, key, messages, server, val; + + Negotiator = require('../lib/negotiator').Negotiator; + + http = require('http'); + + messages = { + es: "¡Hola Mundo!", + en: "Hello World!" + }; + + availableLanguages = (function() { + var _results; + _results = []; + for (key in messages) { + val = messages[key]; + _results.push(key); + } + return _results; + })(); + + server = http.createServer(function(req, res) { + var language, negotiator; + negotiator = new Negotiator(req); + console.log("Accept-Language: " + req.headers['accept-language']); + console.log("Preferred: " + (negotiator.preferredLanguages())); + console.log("Possible: " + (negotiator.preferredLanguages(availableLanguages))); + language = negotiator.preferredLanguage(availableLanguages); + console.log("Selected: " + language); + if (language) { + res.writeHead(200, { + 'Content-Language': language + }); + return res.end(messages[language]); + } else { + res.writeHead(406); + return res.end(); + } + }); + + server.listen(8080); + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/charset.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/charset.js new file mode 100644 index 00000000..33004572 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/charset.js @@ -0,0 +1,71 @@ +module.exports = preferredCharsets; +preferredCharsets.preferredCharsets = preferredCharsets; + +function parseAcceptCharset(accept) { + return accept.split(',').map(function(e) { + return parseCharset(e.trim()); + }).filter(function(e) { + return e && e.q > 0; + }); +} + +function parseCharset(s) { + var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/); + if (!match) return null; + + var charset = match[1]; + var q = 1; + if (match[2]) { + var params = match[2].split(';') + for (var i = 0; i < params.length; i ++) { + var p = params[i].trim().split('='); + if (p[0] === 'q') { + q = parseFloat(p[1]); + break; + } + } + } + + return { + charset: charset, + q: q + }; +} + +function getCharsetPriority(charset, accepted) { + return (accepted.filter(function(a) { + return specify(charset, a); + }).sort(function (a, b) { + // revsort + return a.q === b.q ? 0 : a.q > b.q ? -1 : 1; + })[0] || {q:0}).q; +} + +function specify(charset, spec) { + if (spec.charset === '*' || spec.charset === charset) { + return spec; + } +}; + +function preferredCharsets(accept, provided) { + accept = parseAcceptCharset(accept || ''); + if (provided) { + return provided.map(function(type) { + return [type, getCharsetPriority(type, accept)]; + }).filter(function(pair) { + return pair[1] > 0; + }).sort(function(a, b) { + // revsort + return a[1] === b[1] ? 0 : a[1] > b[1] ? -1 : 1; + }).map(function(pair) { + return pair[0]; + }); + } else { + return accept.sort(function (a, b) { + // revsort + return a.q < b.q ? 1 : -1; + }).map(function(type) { + return type.charset; + }); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/encoding.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/encoding.js new file mode 100644 index 00000000..b4fc889f --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/encoding.js @@ -0,0 +1,89 @@ +module.exports = preferredEncodings; +preferredEncodings.preferredEncodings = preferredEncodings; + +function parseAcceptEncoding(accept) { + var acceptableEncodings; + + if (accept) { + acceptableEncodings = accept.split(',').map(function(e) { + return parseEncoding(e.trim()); + }); + } else { + acceptableEncodings = []; + } + + if (!acceptableEncodings.some(function(e) { + return e && e.encoding === 'identity'; + })) { + acceptableEncodings.push({ + encoding: 'identity', + q: 0.1 + }); + } + + return acceptableEncodings.filter(function(e) { + return e && e.q > 0; + }); +} + +function parseEncoding(s) { + var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/); + + if (!match) return null; + + var encoding = match[1]; + var q = 1; + if (match[2]) { + var params = match[2].split(';'); + for (var i = 0; i < params.length; i ++) { + var p = params[i].trim().split('='); + if (p[0] === 'q') { + q = parseFloat(p[1]); + break; + } + } + } + + return { + encoding: encoding, + q: q + }; +} + +function getEncodingPriority(encoding, accepted) { + return (accepted.filter(function(a) { + return specify(encoding, a); + }).sort(function (a, b) { + // revsort + return a.q === b.q ? 0 : a.q > b.q ? -1 : 1; + })[0] || {q:0}).q; +} + +function specify(encoding, spec) { + if (spec.encoding === '*' || spec.encoding === encoding) { + return spec; + } +} + +function preferredEncodings(accept, provided) { + accept = parseAcceptEncoding(accept || ''); + if (provided) { + return provided.map(function(type) { + return [type, getEncodingPriority(type, accept)]; + }).filter(function(pair) { + return pair[1] > 0; + }).sort(function(a, b) { + // revsort + return a[1] === b[1] ? 0 : a[1] > b[1] ? -1 : 1; + }).map(function(pair) { + return pair[0]; + }); + } else { + return accept.sort(function (a, b) { + // revsort + return a.q < b.q ? 1 : -1; + }).map(function(type) { + return type.encoding; + }); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/language.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/language.js new file mode 100644 index 00000000..432b7026 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/language.js @@ -0,0 +1,92 @@ +module.exports = preferredLanguages; +preferredLanguages.preferredLanguages = preferredLanguages; + +function parseAcceptLanguage(accept) { + return accept.split(',').map(function(e) { + return parseLanguage(e.trim()); + }).filter(function(e) { + return e && e.q > 0; + }); +} + +function parseLanguage(s) { + var match = s.match(/^\s*(\S+?)(?:-(\S+?))?\s*(?:;(.*))?$/); + if (!match) return null; + + var prefix = match[1], + suffix = match[2], + full = prefix; + + if (suffix) full += "-" + suffix; + + var q = 1; + if (match[3]) { + var params = match[3].split(';') + for (var i = 0; i < params.length; i ++) { + var p = params[i].split('='); + if (p[0] === 'q') q = parseFloat(p[1]); + } + } + + return { + prefix: prefix, + suffix: suffix, + q: q, + full: full + }; +} + +function getLanguagePriority(language, accepted) { + var match = getClosestMatch(language, accepted); + return match ? match.q : 0; +} + +function getClosestMatch(language, accepted) { + var parsed = parseLanguage(language); + + var matches = accepted.filter(function(a) { + return a.full === parsed.full; + }); + if (matches.length) return matches[0]; + + matches = accepted.filter(function(a) { + return a.prefix === parsed.prefix && !a.suffix; + }); + if (matches.length) return matches[0]; + + matches = accepted.filter(function(a) { + return a.prefix === parsed.prefix; + }); + if (matches.length) return matches[0]; + + matches = accepted.filter(function(a) { + return a.prefix === '*'; + }); + return matches[0]; +} + +function preferredLanguages(accept, provided) { + accept = parseAcceptLanguage(accept || ''); + if (provided) { + + var ret = provided.map(function(type) { + return [type, getLanguagePriority(type, accept)]; + }).filter(function(pair) { + return pair[1] > 0; + }).sort(function(a, b) { + // revsort + return a[1] === b[1] ? 0 : a[1] > b[1] ? -1 : 1; + }).map(function(pair) { + return pair[0]; + }); + return ret; + + } else { + return accept.sort(function (a, b) { + // revsort + return a.q < b.q ? 1 : -1; + }).map(function(type) { + return type.full; + }); + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/mediaType.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/mediaType.js new file mode 100644 index 00000000..3dc017fd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/mediaType.js @@ -0,0 +1,101 @@ +module.exports = preferredMediaTypes; +preferredMediaTypes.preferredMediaTypes = preferredMediaTypes; + +function parseAccept(accept) { + return accept.split(',').map(function(e) { + return parseMediaType(e.trim()); + }).filter(function(e) { + return e && e.q > 0; + }); +}; + +function parseMediaType(s) { + var match = s.match(/\s*(\S+)\/([^;\s]+)\s*(?:;(.*))?/); + if (!match) return null; + + var type = match[1], + subtype = match[2], + full = "" + type + "/" + subtype, + params = {}, + q = 1; + + if (match[3]) { + params = match[3].split(';').map(function(s) { + return s.trim().split('='); + }).reduce(function (set, p) { + set[p[0]] = p[1]; + return set + }, params); + + if (params.q != null) { + q = parseFloat(params.q); + delete params.q; + } + } + + return { + type: type, + subtype: subtype, + params: params, + q: q, + full: full + }; +} + +function getMediaTypePriority(type, accepted) { + return (accepted.filter(function(a) { + return specify(type, a); + }).sort(function (a, b) { + // revsort + return a.q > b.q ? -1 : 1; + })[0] || {q:0}).q; +} + +function specifies(spec, type) { + return spec === '*' || spec === type; +} + +function specify(type, spec) { + var p = parseMediaType(type); + + if (spec.params) { + var keys = Object.keys(spec.params); + if (keys.some(function (k) { + return !specifies(spec.params[k], p.params[k]); + })) { + // some didn't specify. + return null; + } + } + + if (specifies(spec.type, p.type) && + specifies(spec.subtype, p.subtype)) { + return spec; + } +} + +function preferredMediaTypes(accept, provided) { + accept = parseAccept(accept || ''); + if (provided) { + return provided.map(function(type) { + return [type, getMediaTypePriority(type, accept)]; + }).filter(function(pair) { + return pair[1] > 0; + }).sort(function(a, b) { + // revsort + return a[1] === b[1] ? 0 : a[1] > b[1] ? -1 : 1; + }).map(function(pair) { + return pair[0]; + }); + + } else { + return accept.sort(function (a, b) { + // revsort + return a.q < b.q ? 1 : -1; + }).map(function(type) { + return type.full; + }); + } +} + + diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/negotiator.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/negotiator.js new file mode 100644 index 00000000..fe0e58a5 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/lib/negotiator.js @@ -0,0 +1,29 @@ +module.exports = Negotiator; +Negotiator.Negotiator = Negotiator; + +function Negotiator(request) { + if (!(this instanceof Negotiator)) return new Negotiator(request); + this.request = request; +} + +var set = { preferredCharset: [require('./charset.js'), 'accept-charset'], + preferredEncoding: [require('./encoding.js'), 'accept-encoding'], + preferredLanguage: [require('./language.js'), 'accept-language'], + preferredMediaType: [require('./mediaType.js'), 'accept'] }; + +Object.keys(set).forEach(function (k) { + var mh = set[k], + method = mh[0], + header = mh[1], + singular = k, + plural = k + 's'; + + Negotiator.prototype[plural] = function (available) { + return method(this.request.headers[header], available); + }; + + Negotiator.prototype[singular] = function(available) { + var set = this[plural](available); + if (set) return set[0]; + }; +}) diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/package.json new file mode 100644 index 00000000..0a10415b --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/package.json @@ -0,0 +1,50 @@ +{ + "name": "negotiator", + "description": "HTTP content negotiation", + "version": "0.3.0", + "author": { + "name": "Federico Romero", + "email": "federico.romero@outboxlabs.com" + }, + "contributors": [ + { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + } + ], + "repository": { + "type": "git", + "url": "git://github.com/federomero/negotiator.git" + }, + "keywords": [ + "http", + "content negotiation", + "accept", + "accept-language", + "accept-encoding", + "accept-charset" + ], + "engine": "node >= 0.6", + "license": "MIT", + "devDependencies": { + "nodeunit": "0.6.x" + }, + "scripts": { + "test": "nodeunit test" + }, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "main": "lib/negotiator.js", + "readme": "# Negotiator\n\nAn HTTP content negotiator for node.js written in javascript.\n\n# Accept Negotiation\n\n Negotiator = require('negotiator')\n\n availableMediaTypes = ['text/html', 'text/plain', 'application/json']\n\n // The negotiator constructor receives a request object\n negotiator = new Negotiator(request)\n\n // Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8'\n\n negotiator.preferredMediaTypes()\n // -> ['text/html', 'image/jpeg', 'application/*']\n\n negotiator.preferredMediaTypes(availableMediaTypes)\n // -> ['text/html', 'application/json']\n\n negotiator.preferredMediaType(availableMediaTypes)\n // -> 'text/html'\n\nYou can check a working example at `examples/accept.js`.\n\n## Methods\n\n`preferredMediaTypes(availableMediaTypes)`:\n\nReturns an array of preferred media types ordered by priority from a list of available media types.\n\n`preferredMediaType(availableMediaType)`:\n\nReturns the top preferred media type from a list of available media types.\n\n# Accept-Language Negotiation\n\n Negotiator = require('negotiator')\n\n negotiator = new Negotiator(request)\n\n availableLanguages = 'en', 'es', 'fr'\n\n // Let's say Accept-Language header is 'en;q=0.8, es, pt'\n\n negotiator.preferredLanguages()\n // -> ['es', 'pt', 'en']\n\n negotiator.preferredLanguages(availableLanguages)\n // -> ['es', 'en']\n\n language = negotiator.preferredLanguage(availableLanguages)\n // -> 'es'\n\nYou can check a working example at `examples/language.js`.\n\n## Methods\n\n`preferredLanguages(availableLanguages)`:\n\nReturns an array of preferred languages ordered by priority from a list of available languages.\n\n`preferredLanguage(availableLanguages)`:\n\nReturns the top preferred language from a list of available languages.\n\n# Accept-Charset Negotiation\n\n Negotiator = require('negotiator')\n\n availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5']\n\n negotiator = new Negotiator(request)\n\n // Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2'\n\n negotiator.preferredCharsets()\n // -> ['utf-8', 'iso-8859-1', 'utf-7']\n\n negotiator.preferredCharsets(availableCharsets)\n // -> ['utf-8', 'iso-8859-1']\n\n negotiator.preferredCharset(availableCharsets)\n // -> 'utf-8'\n\nYou can check a working example at `examples/charset.js`.\n\n## Methods\n\n`preferredCharsets(availableCharsets)`:\n\nReturns an array of preferred charsets ordered by priority from a list of available charsets.\n\n`preferredCharset(availableCharsets)`:\n\nReturns the top preferred charset from a list of available charsets.\n\n# Accept-Encoding Negotiation\n\n Negotiator = require('negotiator').Negotiator\n\n availableEncodings = ['identity', 'gzip']\n\n negotiator = new Negotiator(request)\n\n // Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5'\n\n negotiator.preferredEncodings()\n // -> ['gzip', 'identity', 'compress']\n\n negotiator.preferredEncodings(availableEncodings)\n // -> ['gzip', 'identity']\n\n negotiator.preferredEncoding(availableEncodings)\n // -> 'gzip'\n\nYou can check a working example at `examples/encoding.js`.\n\n## Methods\n\n`preferredEncodings(availableEncodings)`:\n\nReturns an array of preferred encodings ordered by priority from a list of available encodings.\n\n`preferredEncoding(availableEncodings)`:\n\nReturns the top preferred encoding from a list of available encodings.\n\n# License\n\nMIT\n", + "readmeFilename": "readme.md", + "_id": "negotiator@0.3.0", + "dependencies": {}, + "dist": { + "shasum": "9fc159fef4b4d854d4a9559fe80ee4bf919304ae" + }, + "_from": "negotiator@0.3.0", + "_resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.3.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/readme.md b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/readme.md new file mode 100644 index 00000000..0a077bbe --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/readme.md @@ -0,0 +1,132 @@ +# Negotiator + +An HTTP content negotiator for node.js written in javascript. + +# Accept Negotiation + + Negotiator = require('negotiator') + + availableMediaTypes = ['text/html', 'text/plain', 'application/json'] + + // The negotiator constructor receives a request object + negotiator = new Negotiator(request) + + // Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8' + + negotiator.preferredMediaTypes() + // -> ['text/html', 'image/jpeg', 'application/*'] + + negotiator.preferredMediaTypes(availableMediaTypes) + // -> ['text/html', 'application/json'] + + negotiator.preferredMediaType(availableMediaTypes) + // -> 'text/html' + +You can check a working example at `examples/accept.js`. + +## Methods + +`preferredMediaTypes(availableMediaTypes)`: + +Returns an array of preferred media types ordered by priority from a list of available media types. + +`preferredMediaType(availableMediaType)`: + +Returns the top preferred media type from a list of available media types. + +# Accept-Language Negotiation + + Negotiator = require('negotiator') + + negotiator = new Negotiator(request) + + availableLanguages = 'en', 'es', 'fr' + + // Let's say Accept-Language header is 'en;q=0.8, es, pt' + + negotiator.preferredLanguages() + // -> ['es', 'pt', 'en'] + + negotiator.preferredLanguages(availableLanguages) + // -> ['es', 'en'] + + language = negotiator.preferredLanguage(availableLanguages) + // -> 'es' + +You can check a working example at `examples/language.js`. + +## Methods + +`preferredLanguages(availableLanguages)`: + +Returns an array of preferred languages ordered by priority from a list of available languages. + +`preferredLanguage(availableLanguages)`: + +Returns the top preferred language from a list of available languages. + +# Accept-Charset Negotiation + + Negotiator = require('negotiator') + + availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5'] + + negotiator = new Negotiator(request) + + // Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2' + + negotiator.preferredCharsets() + // -> ['utf-8', 'iso-8859-1', 'utf-7'] + + negotiator.preferredCharsets(availableCharsets) + // -> ['utf-8', 'iso-8859-1'] + + negotiator.preferredCharset(availableCharsets) + // -> 'utf-8' + +You can check a working example at `examples/charset.js`. + +## Methods + +`preferredCharsets(availableCharsets)`: + +Returns an array of preferred charsets ordered by priority from a list of available charsets. + +`preferredCharset(availableCharsets)`: + +Returns the top preferred charset from a list of available charsets. + +# Accept-Encoding Negotiation + + Negotiator = require('negotiator').Negotiator + + availableEncodings = ['identity', 'gzip'] + + negotiator = new Negotiator(request) + + // Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5' + + negotiator.preferredEncodings() + // -> ['gzip', 'identity', 'compress'] + + negotiator.preferredEncodings(availableEncodings) + // -> ['gzip', 'identity'] + + negotiator.preferredEncoding(availableEncodings) + // -> 'gzip' + +You can check a working example at `examples/encoding.js`. + +## Methods + +`preferredEncodings(availableEncodings)`: + +Returns an array of preferred encodings ordered by priority from a list of available encodings. + +`preferredEncoding(availableEncodings)`: + +Returns the top preferred encoding from a list of available encodings. + +# License + +MIT diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/charset.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/charset.js new file mode 100644 index 00000000..79224a75 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/charset.js @@ -0,0 +1,62 @@ +(function() { + var configuration, preferredCharsets, testConfigurations, testCorrectCharset, _i, _len, + _this = this; + + preferredCharsets = require('../lib/charset').preferredCharsets; + + this["Should not return a charset when no charset is provided"] = function(test) { + test.deepEqual(preferredCharsets('*', []), []); + return test.done(); + }; + + this["Should not return a charset when no charset is acceptable"] = function(test) { + test.deepEqual(preferredCharsets('ISO-8859-1', ['utf-8']), []); + return test.done(); + }; + + this["Should not return a charset with q = 0"] = function(test) { + test.deepEqual(preferredCharsets('utf-8;q=0', ['utf-8']), []); + return test.done(); + }; + + testCorrectCharset = function(c) { + return _this["Should return " + c.selected + " for accept-charset header " + c.accept + " with provided charset " + c.provided] = function(test) { + test.deepEqual(preferredCharsets(c.accept, c.provided), c.selected); + return test.done(); + }; + }; + + testConfigurations = [ + { + accept: 'utf-8', + provided: ['utf-8'], + selected: ['utf-8'] + }, { + accept: '*', + provided: ['utf-8'], + selected: ['utf-8'] + }, { + accept: 'utf-8', + provided: ['utf-8', 'ISO-8859-1'], + selected: ['utf-8'] + }, { + accept: 'utf-8, ISO-8859-1', + provided: ['utf-8'], + selected: ['utf-8'] + }, { + accept: 'utf-8;q=0.8, ISO-8859-1', + provided: ['utf-8', 'ISO-8859-1'], + selected: ['ISO-8859-1', 'utf-8'] + }, { + accept: 'utf-8;q=0.8, ISO-8859-1', + provided: null, + selected: ['ISO-8859-1', 'utf-8'] + } + ]; + + for (_i = 0, _len = testConfigurations.length; _i < _len; _i++) { + configuration = testConfigurations[_i]; + testCorrectCharset(configuration); + } + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/encoding.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/encoding.js new file mode 100644 index 00000000..7859d5e4 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/encoding.js @@ -0,0 +1,70 @@ +(function() { + var configuration, preferredEncodings, testConfigurations, testCorrectEncoding, _i, _len, + _this = this; + + preferredEncodings = require('../lib/encoding').preferredEncodings; + + this["Should return identity encoding when no encoding is provided"] = function(test) { + test.deepEqual(preferredEncodings(null), ['identity']); + return test.done(); + }; + + this["Should include the identity encoding even if not explicity listed"] = function(test) { + test.ok(preferredEncodings('gzip').indexOf('identity') !== -1); + return test.done(); + }; + + this["Should not return identity encoding if q = 0"] = function(test) { + test.ok(preferredEncodings('identity;q=0').indexOf('identity') === -1); + return test.done(); + }; + + testCorrectEncoding = function(c) { + return _this["Should return " + c.selected + " for accept-encoding header " + c.accept + " with provided encoding " + c.provided] = function(test) { + test.deepEqual(preferredEncodings(c.accept, c.provided), c.selected); + return test.done(); + }; + }; + + testConfigurations = [ + { + accept: 'gzip', + provided: ['identity', 'gzip'], + selected: ['gzip', 'identity'] + }, { + accept: 'gzip, compress', + provided: ['compress'], + selected: ['compress'] + }, { + accept: 'deflate', + provided: ['gzip', 'identity'], + selected: ['identity'] + }, { + accept: '*', + provided: ['identity', 'gzip'], + selected: ['identity', 'gzip'] + }, { + accept: 'gzip, compress', + provided: ['compress', 'identity'], + selected: ['compress', 'identity'] + }, { + accept: 'gzip;q=0.8, identity;q=0.5, *;q=0.3', + provided: ['identity', 'gzip', 'compress'], + selected: ['gzip', 'identity', 'compress'] + }, { + accept: 'gzip;q=0.8, compress', + provided: ['gzip', 'compress'], + selected: ['compress', 'gzip'] + }, { + accept: 'gzip;q=0.8, compress', + provided: null, + selected: ['compress', 'gzip', 'identity'] + } + ]; + + for (_i = 0, _len = testConfigurations.length; _i < _len; _i++) { + configuration = testConfigurations[_i]; + testCorrectEncoding(configuration); + } + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/language.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/language.js new file mode 100644 index 00000000..d98f26de --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/language.js @@ -0,0 +1,70 @@ +(function() { + var configuration, preferredLanguages, testConfigurations, testCorrectType, _i, _len, + _this = this; + + preferredLanguages = require('../lib/language').preferredLanguages; + + this["Should not return a language when no is provided"] = function(test) { + test.deepEqual(preferredLanguages('*', []), []); + return test.done(); + }; + + this["Should not return a language when no language is acceptable"] = function(test) { + test.deepEqual(preferredLanguages('en', ['es']), []); + return test.done(); + }; + + this["Should not return a language with q = 0"] = function(test) { + test.deepEqual(preferredLanguages('en;q=0', ['en']), []); + return test.done(); + }; + + testCorrectType = function(c) { + return _this["Should return " + c.selected + " for accept-language header " + c.accept + " with provided language " + c.provided] = function(test) { + test.deepEqual(preferredLanguages(c.accept, c.provided), c.selected); + return test.done(); + }; + }; + + testConfigurations = [ + { + accept: 'en', + provided: ['en'], + selected: ['en'] + }, { + accept: '*', + provided: ['en'], + selected: ['en'] + }, { + accept: 'en-US, en;q=0.8', + provided: ['en-US', 'en-GB'], + selected: ['en-US', 'en-GB'] + }, { + accept: 'en-US, en-GB', + provided: ['en-US'], + selected: ['en-US'] + }, { + accept: 'en', + provided: ['en-US'], + selected: ['en-US'] + }, { + accept: 'en;q=0.8, es', + provided: ['en', 'es'], + selected: ['es', 'en'] + }, { + accept: 'en-US;q=0.8, es', + provided: ['en', 'es'], + selected: ['es', 'en'] + }, { + accept: 'en-US;q=0.8, es', + provided: null, + selected: ['es', 'en-US'] + } + ]; + + for (_i = 0, _len = testConfigurations.length; _i < _len; _i++) { + configuration = testConfigurations[_i]; + testCorrectType(configuration); + } + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/mediaType.js b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/mediaType.js new file mode 100644 index 00000000..08e49231 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/negotiator/test/mediaType.js @@ -0,0 +1,70 @@ +(function() { + var configuration, preferredMediaTypes, testConfigurations, testCorrectType, _i, _len, + _this = this; + + preferredMediaTypes = require('../lib/mediaType').preferredMediaTypes; + + this["Should not return a media type when no media type provided"] = function(test) { + test.deepEqual(preferredMediaTypes('*/*', []), []); + return test.done(); + }; + + this["Should not return a media type when no media type is acceptable"] = function(test) { + test.deepEqual(preferredMediaTypes('application/json', ['text/html']), []); + return test.done(); + }; + + this["Should not return a media type with q = 0"] = function(test) { + test.deepEqual(preferredMediaTypes('text/html;q=0', ['text/html']), []); + return test.done(); + }; + + testCorrectType = function(c) { + return _this["Should return " + c.selected + " for access header " + c.accept + " with provided types " + c.provided] = function(test) { + test.deepEqual(preferredMediaTypes(c.accept, c.provided), c.selected); + return test.done(); + }; + }; + + testConfigurations = [ + { + accept: 'text/html', + provided: ['text/html'], + selected: ['text/html'] + }, { + accept: '*/*', + provided: ['text/html'], + selected: ['text/html'] + }, { + accept: 'text/*', + provided: ['text/html'], + selected: ['text/html'] + }, { + accept: 'application/json, text/html', + provided: ['text/html'], + selected: ['text/html'] + }, { + accept: 'text/html;q=0.1', + provided: ['text/html'], + selected: ['text/html'] + }, { + accept: 'application/json, text/html', + provided: ['application/json', 'text/html'], + selected: ['application/json', 'text/html'] + }, { + accept: 'application/json;q=0.2, text/html', + provided: ['application/json', 'text/html'], + selected: ['text/html', 'application/json'] + }, { + accept: 'application/json;q=0.2, text/html', + provided: null, + selected: ['text/html', 'application/json'] + } + ]; + + for (_i = 0, _len = testConfigurations.length; _i < _len; _i++) { + configuration = testConfigurations[_i]; + testCorrectType(configuration); + } + +}).call(this); diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/pause/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/pause/.npmignore new file mode 100644 index 00000000..f1250e58 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/pause/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/pause/History.md b/realtime/node_modules/express/node_modules/connect/node_modules/pause/History.md new file mode 100644 index 00000000..c8aa68fa --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/pause/History.md @@ -0,0 +1,5 @@ + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/pause/Makefile b/realtime/node_modules/express/node_modules/connect/node_modules/pause/Makefile new file mode 100644 index 00000000..4e9c8d36 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/pause/Makefile @@ -0,0 +1,7 @@ + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec + +.PHONY: test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/pause/Readme.md b/realtime/node_modules/express/node_modules/connect/node_modules/pause/Readme.md new file mode 100644 index 00000000..1cdd68a2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/pause/Readme.md @@ -0,0 +1,29 @@ + +# pause + + Pause streams... + +## 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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/pause/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/pause/index.js new file mode 100644 index 00000000..1b7b3794 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/pause/index.js @@ -0,0 +1,29 @@ + +module.exports = function(obj){ + var onData + , onEnd + , events = []; + + // buffer data + obj.on('data', onData = function(data, encoding){ + events.push(['data', data, encoding]); + }); + + // buffer end + obj.on('end', onEnd = function(data, encoding){ + events.push(['end', data, encoding]); + }); + + return { + end: function(){ + obj.removeListener('data', onData); + obj.removeListener('end', onEnd); + }, + resume: function(){ + this.end(); + for (var i = 0, len = events.length; i < len; ++i) { + obj.emit.apply(obj, events[i]); + } + } + }; +}; \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/pause/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/pause/package.json new file mode 100644 index 00000000..edd7930d --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/pause/package.json @@ -0,0 +1,24 @@ +{ + "name": "pause", + "version": "0.0.1", + "description": "Pause streams...", + "keywords": [], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "main": "index", + "readme": "\n# pause\n\n Pause streams...\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", + "readmeFilename": "Readme.md", + "_id": "pause@0.0.1", + "dist": { + "shasum": "138b3b78c1cd2c50addc0557010d144b31cca445" + }, + "_from": "pause@0.0.1", + "_resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/qs/.gitmodules b/realtime/node_modules/express/node_modules/connect/node_modules/qs/.gitmodules new file mode 100644 index 00000000..49e31dac --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/qs/.gitmodules @@ -0,0 +1,6 @@ +[submodule "support/expresso"] + path = support/expresso + url = git://github.com/visionmedia/expresso.git +[submodule "support/should"] + path = support/should + url = git://github.com/visionmedia/should.js.git diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/qs/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/qs/.npmignore new file mode 100644 index 00000000..e85ce2af --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/qs/.npmignore @@ -0,0 +1,7 @@ +test +.travis.yml +benchmark.js +component.json +examples.js +History.md +Makefile diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/qs/Readme.md b/realtime/node_modules/express/node_modules/connect/node_modules/qs/Readme.md new file mode 100644 index 00000000..27e54a4a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/qs/Readme.md @@ -0,0 +1,58 @@ +# node-querystring + + query string parser for node and the browser supporting nesting, as it was removed from `0.3.x`, so this library provides the previous and commonly desired behaviour (and twice as fast). Used by [express](http://expressjs.com), [connect](http://senchalabs.github.com/connect) and others. + +## Installation + + $ npm install qs + +## Examples + +```js +var qs = require('qs'); + +qs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com'); +// => { user: { name: { first: 'Tobi' }, email: 'tobi@learnboost.com' } } + +qs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }}) +// => user[name]=Tobi&user[email]=tobi%40learnboost.com +``` + +## Testing + +Install dev dependencies: + + $ npm install -d + +and execute: + + $ make test + +browser: + + $ open test/browser/index.html + +## License + +(The MIT License) + +Copyright (c) 2010 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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/qs/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/qs/index.js new file mode 100644 index 00000000..b05938ac --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/qs/index.js @@ -0,0 +1,366 @@ +/** + * Object#toString() ref for stringify(). + */ + +var toString = Object.prototype.toString; + +/** + * Object#hasOwnProperty ref + */ + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Array#indexOf shim. + */ + +var indexOf = typeof Array.prototype.indexOf === 'function' + ? function(arr, el) { return arr.indexOf(el); } + : function(arr, el) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] === el) return i; + } + return -1; + }; + +/** + * Array.isArray shim. + */ + +var isArray = Array.isArray || function(arr) { + return toString.call(arr) == '[object Array]'; +}; + +/** + * Object.keys shim. + */ + +var objectKeys = Object.keys || function(obj) { + var ret = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + ret.push(key); + } + } + return ret; +}; + +/** + * Array#forEach shim. + */ + +var forEach = typeof Array.prototype.forEach === 'function' + ? function(arr, fn) { return arr.forEach(fn); } + : function(arr, fn) { + for (var i = 0; i < arr.length; i++) fn(arr[i]); + }; + +/** + * Array#reduce shim. + */ + +var reduce = function(arr, fn, initial) { + if (typeof arr.reduce === 'function') return arr.reduce(fn, initial); + var res = initial; + for (var i = 0; i < arr.length; i++) res = fn(res, arr[i]); + return res; +}; + +/** + * Cache non-integer test regexp. + */ + +var isint = /^[0-9]+$/; + +function promote(parent, key) { + if (parent[key].length == 0) return parent[key] = {} + var t = {}; + for (var i in parent[key]) { + if (hasOwnProperty.call(parent[key], i)) { + t[i] = parent[key][i]; + } + } + parent[key] = t; + return t; +} + +function parse(parts, parent, key, val) { + var part = parts.shift(); + + // illegal + if (Object.getOwnPropertyDescriptor(Object.prototype, key)) return; + + // end + if (!part) { + if (isArray(parent[key])) { + parent[key].push(val); + } else if ('object' == typeof parent[key]) { + parent[key] = val; + } else if ('undefined' == typeof parent[key]) { + parent[key] = val; + } else { + parent[key] = [parent[key], val]; + } + // array + } else { + var obj = parent[key] = parent[key] || []; + if (']' == part) { + if (isArray(obj)) { + if ('' != val) obj.push(val); + } else if ('object' == typeof obj) { + obj[objectKeys(obj).length] = val; + } else { + obj = parent[key] = [parent[key], val]; + } + // prop + } else if (~indexOf(part, ']')) { + part = part.substr(0, part.length - 1); + if (!isint.test(part) && isArray(obj)) obj = promote(parent, key); + parse(parts, obj, part, val); + // key + } else { + if (!isint.test(part) && isArray(obj)) obj = promote(parent, key); + parse(parts, obj, part, val); + } + } +} + +/** + * Merge parent key/val pair. + */ + +function merge(parent, key, val){ + if (~indexOf(key, ']')) { + var parts = key.split('[') + , len = parts.length + , last = len - 1; + parse(parts, parent, 'base', val); + // optimize + } else { + if (!isint.test(key) && isArray(parent.base)) { + var t = {}; + for (var k in parent.base) t[k] = parent.base[k]; + parent.base = t; + } + set(parent.base, key, val); + } + + return parent; +} + +/** + * Compact sparse arrays. + */ + +function compact(obj) { + if ('object' != typeof obj) return obj; + + if (isArray(obj)) { + var ret = []; + + for (var i in obj) { + if (hasOwnProperty.call(obj, i)) { + ret.push(obj[i]); + } + } + + return ret; + } + + for (var key in obj) { + obj[key] = compact(obj[key]); + } + + return obj; +} + +/** + * Parse the given obj. + */ + +function parseObject(obj){ + var ret = { base: {} }; + + forEach(objectKeys(obj), function(name){ + merge(ret, name, obj[name]); + }); + + return compact(ret.base); +} + +/** + * Parse the given str. + */ + +function parseString(str){ + var ret = reduce(String(str).split('&'), function(ret, pair){ + var eql = indexOf(pair, '=') + , brace = lastBraceInKey(pair) + , key = pair.substr(0, brace || eql) + , val = pair.substr(brace || eql, pair.length) + , val = val.substr(indexOf(val, '=') + 1, val.length); + + // ?foo + if ('' == key) key = pair, val = ''; + if ('' == key) return ret; + + return merge(ret, decode(key), decode(val)); + }, { base: {} }).base; + + return compact(ret); +} + +/** + * Parse the given query `str` or `obj`, returning an object. + * + * @param {String} str | {Object} obj + * @return {Object} + * @api public + */ + +exports.parse = function(str){ + if (null == str || '' == str) return {}; + return 'object' == typeof str + ? parseObject(str) + : parseString(str); +}; + +/** + * Turn the given `obj` into a query string + * + * @param {Object} obj + * @return {String} + * @api public + */ + +var stringify = exports.stringify = function(obj, prefix) { + if (isArray(obj)) { + return stringifyArray(obj, prefix); + } else if ('[object Object]' == toString.call(obj)) { + return stringifyObject(obj, prefix); + } else if ('string' == typeof obj) { + return stringifyString(obj, prefix); + } else { + return prefix + '=' + encodeURIComponent(String(obj)); + } +}; + +/** + * Stringify the given `str`. + * + * @param {String} str + * @param {String} prefix + * @return {String} + * @api private + */ + +function stringifyString(str, prefix) { + if (!prefix) throw new TypeError('stringify expects an object'); + return prefix + '=' + encodeURIComponent(str); +} + +/** + * Stringify the given `arr`. + * + * @param {Array} arr + * @param {String} prefix + * @return {String} + * @api private + */ + +function stringifyArray(arr, prefix) { + var ret = []; + if (!prefix) throw new TypeError('stringify expects an object'); + for (var i = 0; i < arr.length; i++) { + ret.push(stringify(arr[i], prefix + '[' + i + ']')); + } + return ret.join('&'); +} + +/** + * Stringify the given `obj`. + * + * @param {Object} obj + * @param {String} prefix + * @return {String} + * @api private + */ + +function stringifyObject(obj, prefix) { + var ret = [] + , keys = objectKeys(obj) + , key; + + for (var i = 0, len = keys.length; i < len; ++i) { + key = keys[i]; + if ('' == key) continue; + if (null == obj[key]) { + ret.push(encodeURIComponent(key) + '='); + } else { + ret.push(stringify(obj[key], prefix + ? prefix + '[' + encodeURIComponent(key) + ']' + : encodeURIComponent(key))); + } + } + + return ret.join('&'); +} + +/** + * Set `obj`'s `key` to `val` respecting + * the weird and wonderful syntax of a qs, + * where "foo=bar&foo=baz" becomes an array. + * + * @param {Object} obj + * @param {String} key + * @param {String} val + * @api private + */ + +function set(obj, key, val) { + var v = obj[key]; + if (Object.getOwnPropertyDescriptor(Object.prototype, key)) return; + if (undefined === v) { + obj[key] = val; + } else if (isArray(v)) { + v.push(val); + } else { + obj[key] = [v, val]; + } +} + +/** + * Locate last brace in `str` within the key. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function lastBraceInKey(str) { + var len = str.length + , brace + , c; + for (var i = 0; i < len; ++i) { + c = str[i]; + if (']' == c) brace = false; + if ('[' == c) brace = true; + if ('=' == c && !brace) return i; + } +} + +/** + * Decode `str`. + * + * @param {String} str + * @return {String} + * @api private + */ + +function decode(str) { + try { + return decodeURIComponent(str.replace(/\+/g, ' ')); + } catch (err) { + return str; + } +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/qs/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/qs/package.json new file mode 100644 index 00000000..ebe7de67 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/qs/package.json @@ -0,0 +1,38 @@ +{ + "name": "qs", + "description": "querystring parser", + "version": "0.6.6", + "keywords": [ + "query string", + "parser", + "component" + ], + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/node-querystring.git" + }, + "devDependencies": { + "mocha": "*", + "expect.js": "*" + }, + "scripts": { + "test": "make test" + }, + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + }, + "main": "index", + "engines": { + "node": "*" + }, + "readme": "# node-querystring\n\n query string parser for node and the browser supporting nesting, as it was removed from `0.3.x`, so this library provides the previous and commonly desired behaviour (and twice as fast). Used by [express](http://expressjs.com), [connect](http://senchalabs.github.com/connect) and others.\n\n## Installation\n\n $ npm install qs\n\n## Examples\n\n```js\nvar qs = require('qs');\n\nqs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com');\n// => { user: { name: { first: 'Tobi' }, email: 'tobi@learnboost.com' } }\n\nqs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }})\n// => user[name]=Tobi&user[email]=tobi%40learnboost.com\n```\n\n## Testing\n\nInstall dev dependencies:\n\n $ npm install -d\n\nand execute:\n\n $ make test\n\nbrowser:\n\n $ open test/browser/index.html\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2010 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", + "readmeFilename": "Readme.md", + "_id": "qs@0.6.6", + "dist": { + "shasum": "a106b5c23ca4dbbdbcbca55af9e13505bf65a6bc" + }, + "_from": "qs@0.6.6", + "_resolved": "https://registry.npmjs.org/qs/-/qs-0.6.6.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/.npmignore b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/.npmignore new file mode 100644 index 00000000..b59f7e3a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/.npmignore @@ -0,0 +1 @@ +test/ \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/.travis.yml b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/.travis.yml new file mode 100644 index 00000000..595ded21 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/.travis.yml @@ -0,0 +1,8 @@ +node_js: +- "0.8" +- "0.10" +- "0.11" +language: node_js +matrix: + allow_failures: + - node_js: "0.11" \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/Makefile b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/Makefile new file mode 100644 index 00000000..642d6a64 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/Makefile @@ -0,0 +1,13 @@ +NODE ?= node +BIN = ./node_modules/.bin/ + +test: + @${NODE} ${BIN}mocha \ + --reporter spec \ + --bail \ + ./test/index.js + +clean: + @rm -rf node_modules + +.PHONY: test clean diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/README.md b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/README.md new file mode 100644 index 00000000..049ef641 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/README.md @@ -0,0 +1,96 @@ +# Raw Body [![Build Status](https://travis-ci.org/stream-utils/raw-body.png)](https://travis-ci.org/stream-utils/raw-body) + +Gets the entire buffer of a stream either as a `Buffer` or a string. +Validates the stream's length against an expected length and maximum limit. +Ideal for parsing request bodies. + +## API + +```js +var getRawBody = require('raw-body') + +app.use(function (req, res, next) { + getRawBody(req, { + length: req.headers['content-length'], + limit: '1mb', + encoding: 'utf8' + }, function (err, string) { + if (err) + return next(err) + + req.text = string + next() + }) +}) +``` + +or in a Koa generator: + +```js +app.use(function* (next) { + var string = yield getRawBody(this.req, { + length: this.length, + limit: '1mb', + encoding: 'utf8' + }) +}) +``` + +### getRawBody(stream, [options], [callback]) + +Returns a thunk for yielding with generators. + +Options: + +- `length` - The length length of the stream. + If the contents of the stream do not add up to this length, + an `400` error code is returned. +- `limit` - The byte limit of the body. + If the body ends up being larger than this limit, + a `413` error code is returned. +- `encoding` - The requested encoding. + By default, a `Buffer` instance will be returned. + Most likely, you want `utf8`. + You can use any type of encoding supported by [StringDecoder](http://nodejs.org/api/string_decoder.html). + You can also pass `true` which sets it to the default `utf8` + +`callback(err, res)`: + +- `err` - the following attributes will be defined if applicable: + + - `limit` - the limit in bytes + - `length` and `expected` - the expected length of the stream + - `received` - the received bytes + - `status` and `statusCode` - the corresponding status code for the error + - `type` - either `entity.too.large`, `request.size.invalid`, or `stream.encoding.set` + +- `res` - the result, either as a `String` if an encoding was set or a `Buffer` otherwise. + +If an error occurs, the stream will be paused, +and you are responsible for correctly disposing the stream. +For HTTP requests, no handling is required if you send a response. +For streams that use file descriptors, you should `stream.destroy()` or `stream.close()` to prevent leaks. + +## License + +The MIT License (MIT) + +Copyright (c) 2013 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. diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/index.js new file mode 100644 index 00000000..b1798654 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/index.js @@ -0,0 +1,160 @@ +var StringDecoder = require('string_decoder').StringDecoder +var bytes = require('bytes') + +module.exports = function (stream, options, done) { + if (typeof options === 'function') { + done = options + options = {} + } else if (!options) { + options = {} + } + + // convert the limit to an integer + var limit = null + if (typeof options.limit === 'number') + limit = options.limit + if (typeof options.limit === 'string') + limit = bytes(options.limit) + + // convert the expected length to an integer + var length = null + if (!isNaN(options.length)) + length = parseInt(options.length, 10) + + // check the length and limit options. + // note: we intentionally leave the stream paused, + // so users should handle the stream themselves. + if (limit !== null && length !== null && length > limit) { + if (typeof stream.pause === 'function') + stream.pause() + + process.nextTick(function () { + var err = makeError('request entity too large', 'entity.too.large') + err.status = err.statusCode = 413 + err.length = err.expected = length + err.limit = limit + done(err) + }) + return defer + } + + var state = stream._readableState + // streams2+: assert the stream encoding is buffer. + if (state && state.encoding != null) { + if (typeof stream.pause === 'function') + stream.pause() + + process.nextTick(function () { + var err = makeError('stream encoding should not be set', + 'stream.encoding.set') + // developer error + err.status = err.statusCode = 500 + done(err) + }) + return defer + } + + var received = 0 + // note: we delegate any invalid encodings to the constructor + var decoder = options.encoding + ? new StringDecoder(options.encoding === true ? 'utf8' : options.encoding) + : null + var buffer = decoder + ? '' + : [] + + stream.on('data', onData) + stream.once('end', onEnd) + stream.once('error', onEnd) + stream.once('close', cleanup) + + return defer + + // yieldable support + function defer(fn) { + done = fn + } + + function onData(chunk) { + received += chunk.length + decoder + ? buffer += decoder.write(chunk) + : buffer.push(chunk) + + if (limit !== null && received > limit) { + if (typeof stream.pause === 'function') + stream.pause() + var err = makeError('request entity too large', 'entity.too.large') + err.status = err.statusCode = 413 + err.received = received + err.limit = limit + done(err) + cleanup() + } + } + + function onEnd(err) { + if (err) { + if (typeof stream.pause === 'function') + stream.pause() + done(err) + } else if (length !== null && received !== length) { + err = makeError('request size did not match content length', + 'request.size.invalid') + err.status = err.statusCode = 400 + err.received = received + err.length = err.expected = length + done(err) + } else { + done(null, decoder + ? buffer + endStringDecoder(decoder) + : Buffer.concat(buffer) + ) + } + + cleanup() + } + + function cleanup() { + received = buffer = null + + stream.removeListener('data', onData) + stream.removeListener('end', onEnd) + stream.removeListener('error', onEnd) + stream.removeListener('close', cleanup) + } +} + +// to create serializable errors you must re-set message so +// that it is enumerable and you must re configure the type +// property so that is writable and enumerable +function makeError(message, type) { + var error = new Error() + error.message = message + Object.defineProperty(error, 'type', { + value: type, + enumerable: true, + writable: true, + configurable: true + }) + return error +} + +// https://github.com/Raynos/body/blob/2512ced39e31776e5a2f7492b907330badac3a40/index.js#L72 +// bug fix for missing `StringDecoder.end` in v0.8.x +function endStringDecoder(decoder) { + if (decoder.end) { + return decoder.end() + } + + var res = "" + + if (decoder.charReceived) { + var cr = decoder.charReceived + var buf = decoder.charBuffer + var enc = decoder.encoding + res += buf.slice(0, cr).toString(enc) + } + + return res +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/package.json new file mode 100644 index 00000000..5ca4b21a --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/raw-body/package.json @@ -0,0 +1,45 @@ +{ + "name": "raw-body", + "description": "Get and validate the raw body of a readable stream.", + "version": "1.1.2", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/stream-utils/raw-body.git" + }, + "bugs": { + "mail": "me@jongleberry.com", + "url": "https://github.com/stream-utils/raw-body/issues" + }, + "dependencies": { + "bytes": "~0.2.1" + }, + "devDependencies": { + "readable-stream": "~1.0.17", + "co": "2", + "gnode": "~0.0.4", + "mocha": "~1.14.0", + "through": "~2.3.4", + "request": "~2.27.0", + "assert-tap": "~0.1.4" + }, + "scripts": { + "test": "NODE=gnode make test && node ./test/acceptance.js" + }, + "engines": { + "node": ">= 0.8.0" + }, + "readme": "# Raw Body [![Build Status](https://travis-ci.org/stream-utils/raw-body.png)](https://travis-ci.org/stream-utils/raw-body)\n\nGets the entire buffer of a stream either as a `Buffer` or a string.\nValidates the stream's length against an expected length and maximum limit.\nIdeal for parsing request bodies.\n\n## API\n\n```js\nvar getRawBody = require('raw-body')\n\napp.use(function (req, res, next) {\n getRawBody(req, {\n length: req.headers['content-length'],\n limit: '1mb',\n encoding: 'utf8'\n }, function (err, string) {\n if (err)\n return next(err)\n\n req.text = string\n next()\n })\n})\n```\n\nor in a Koa generator:\n\n```js\napp.use(function* (next) {\n var string = yield getRawBody(this.req, {\n length: this.length,\n limit: '1mb',\n encoding: 'utf8'\n })\n})\n```\n\n### getRawBody(stream, [options], [callback])\n\nReturns a thunk for yielding with generators.\n\nOptions:\n\n- `length` - The length length of the stream.\n If the contents of the stream do not add up to this length,\n an `400` error code is returned.\n- `limit` - The byte limit of the body.\n If the body ends up being larger than this limit,\n a `413` error code is returned.\n- `encoding` - The requested encoding.\n By default, a `Buffer` instance will be returned.\n Most likely, you want `utf8`.\n You can use any type of encoding supported by [StringDecoder](http://nodejs.org/api/string_decoder.html).\n You can also pass `true` which sets it to the default `utf8`\n\n`callback(err, res)`:\n\n- `err` - the following attributes will be defined if applicable:\n\n - `limit` - the limit in bytes\n - `length` and `expected` - the expected length of the stream\n - `received` - the received bytes\n - `status` and `statusCode` - the corresponding status code for the error\n - `type` - either `entity.too.large`, `request.size.invalid`, or `stream.encoding.set`\n\n- `res` - the result, either as a `String` if an encoding was set or a `Buffer` otherwise.\n\nIf an error occurs, the stream will be paused,\nand you are responsible for correctly disposing the stream.\nFor HTTP requests, no handling is required if you send a response.\nFor streams that use file descriptors, you should `stream.destroy()` or `stream.close()` to prevent leaks.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "readmeFilename": "README.md", + "_id": "raw-body@1.1.2", + "dist": { + "shasum": "edcf77fcb1c94434f8b6125b1104abf4c6b2edd4" + }, + "_from": "raw-body@1.1.2", + "_resolved": "https://registry.npmjs.org/raw-body/-/raw-body-1.1.2.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/uid2/LICENSE b/realtime/node_modules/express/node_modules/connect/node_modules/uid2/LICENSE new file mode 100644 index 00000000..bdfab69b --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/uid2/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013 Marco Aurelio + +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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/uid2/index.js b/realtime/node_modules/express/node_modules/connect/node_modules/uid2/index.js new file mode 100644 index 00000000..6240b308 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/uid2/index.js @@ -0,0 +1,55 @@ +/** + * Module dependencies + */ + +var crypto = require('crypto'); + +/** + * 62 characters in the ascii range that can be used in URLs without special + * encoding. + */ +var UIDCHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + +/** + * Make a Buffer into a string ready for use in URLs + * + * @param {String} + * @returns {String} + * @api private + */ +function tostr(bytes) { + var chars, r, i; + + r = []; + for (i = 0; i < bytes.length; i++) { + r.push(UIDCHARS[bytes[i] % UIDCHARS.length]); + } + + return r.join(''); +} + +/** + * Generate an Unique Id + * + * @param {Number} length The number of chars of the uid + * @param {Number} cb (optional) Callback for async uid generation + * @api public + */ + +function uid(length, cb) { + + if (typeof cb === 'undefined') { + return tostr(crypto.pseudoRandomBytes(length)); + } else { + crypto.pseudoRandomBytes(length, function(err, bytes) { + if (err) return cb(err); + cb(null, tostr(bytes)); + }) + } +} + +/** + * Exports + */ + +module.exports = uid; diff --git a/realtime/node_modules/express/node_modules/connect/node_modules/uid2/package.json b/realtime/node_modules/express/node_modules/connect/node_modules/uid2/package.json new file mode 100644 index 00000000..a98485bd --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/node_modules/uid2/package.json @@ -0,0 +1,16 @@ +{ + "name": "uid2", + "description": "strong uid", + "tags": [ + "uid" + ], + "version": "0.0.3", + "dependencies": {}, + "_id": "uid2@0.0.3", + "readme": "ERROR: No README.md file found!", + "dist": { + "shasum": "8c74151f449949b1bd589cb342e5c8ca77c5b5dc" + }, + "_from": "uid2@0.0.3", + "_resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz" +} diff --git a/realtime/node_modules/express/node_modules/connect/package.json b/realtime/node_modules/express/node_modules/connect/package.json new file mode 100644 index 00000000..35ef5a07 --- /dev/null +++ b/realtime/node_modules/express/node_modules/connect/package.json @@ -0,0 +1,65 @@ +{ + "name": "connect", + "version": "2.12.0", + "description": "High performance middleware framework", + "keywords": [ + "framework", + "web", + "middleware", + "connect", + "rack" + ], + "repository": { + "type": "git", + "url": "git://github.com/senchalabs/connect.git" + }, + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + }, + "dependencies": { + "batch": "0.5.0", + "qs": "0.6.6", + "cookie-signature": "1.0.1", + "buffer-crc32": "0.2.1", + "cookie": "0.1.0", + "send": "0.1.4", + "bytes": "0.2.1", + "fresh": "0.2.0", + "pause": "0.0.1", + "uid2": "0.0.3", + "debug": ">= 0.7.3 < 1", + "methods": "0.1.0", + "raw-body": "1.1.2", + "negotiator": "0.3.0", + "multiparty": "2.2.0" + }, + "devDependencies": { + "should": ">= 2.0.2 < 3", + "mocha": ">= 1.13.0 < 2", + "jade": ">= 0.35.0 < 1", + "dox": ">= 0.4.4 < 1" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/senchalabs/connect/master/LICENSE" + } + ], + "main": "index", + "engines": { + "node": ">= 0.8.0" + }, + "scripts": { + "test": "make" + }, + "readme": "# Connect [![build status](https://secure.travis-ci.org/senchalabs/connect.png)](http://travis-ci.org/senchalabs/connect)\n\n Connect is an extensible HTTP server framework for [node](http://nodejs.org), providing high performance \"plugins\" known as _middleware_.\n\n Connect is bundled with over _20_ commonly used middleware, including\n a logger, session support, cookie parser, and [more](http://senchalabs.github.com/connect). Be sure to view the 2.x [documentation](http://senchalabs.github.com/connect/).\n\n```js\nvar connect = require('connect')\n , http = require('http');\n\nvar app = connect()\n .use(connect.favicon())\n .use(connect.logger('dev'))\n .use(connect.static('public'))\n .use(connect.directory('public'))\n .use(connect.cookieParser())\n .use(connect.session({ secret: 'my secret here' }))\n .use(function(req, res){\n res.end('Hello from Connect!\\n');\n });\n\nhttp.createServer(app).listen(3000);\n```\n\n## Middleware\n\n - [basicAuth](http://www.senchalabs.org/connect/basicAuth.html)\n - [bodyParser](http://www.senchalabs.org/connect/bodyParser.html)\n - [compress](http://www.senchalabs.org/connect/compress.html)\n - [cookieParser](http://www.senchalabs.org/connect/cookieParser.html)\n - [cookieSession](http://www.senchalabs.org/connect/cookieSession.html)\n - [csrf](http://www.senchalabs.org/connect/csrf.html)\n - [directory](http://www.senchalabs.org/connect/directory.html)\n - [errorHandler](http://www.senchalabs.org/connect/errorHandler.html)\n - [favicon](http://www.senchalabs.org/connect/favicon.html)\n - [json](http://www.senchalabs.org/connect/json.html)\n - [limit](http://www.senchalabs.org/connect/limit.html)\n - [logger](http://www.senchalabs.org/connect/logger.html)\n - [methodOverride](http://www.senchalabs.org/connect/methodOverride.html)\n - [multipart](http://www.senchalabs.org/connect/multipart.html)\n - [urlencoded](http://www.senchalabs.org/connect/urlencoded.html)\n - [query](http://www.senchalabs.org/connect/query.html)\n - [responseTime](http://www.senchalabs.org/connect/responseTime.html)\n - [session](http://www.senchalabs.org/connect/session.html)\n - [static](http://www.senchalabs.org/connect/static.html)\n - [staticCache](http://www.senchalabs.org/connect/staticCache.html)\n - [subdomains](http://www.senchalabs.org/connect/subdomains.html)\n - [vhost](http://www.senchalabs.org/connect/vhost.html)\n\n## Running Tests\n\nfirst:\n\n $ npm install -d\n\nthen:\n\n $ make test\n\n## Contributors\n\n https://github.com/senchalabs/connect/graphs/contributors\n\n## Node Compatibility\n\n Connect `< 1.x` is compatible with node 0.2.x\n\n\n Connect `1.x` is compatible with node 0.4.x\n\n\n Connect `2.x` is compatible with node 0.6.x\n\n\n Connect (_master_) is compatible with node 0.8.x\n\n## CLA\n\n [http://sencha.com/cla](http://sencha.com/cla)\n\n## License\n\nView the [LICENSE](https://github.com/senchalabs/connect/blob/master/LICENSE) file. The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons used by the `directory` middleware created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).\n", + "readmeFilename": "Readme.md", + "_id": "connect@2.12.0", + "dist": { + "shasum": "7b5b6303bf6855c9cc6e8cc9d4662b2040e2a7ec" + }, + "_from": "connect@2.12.0", + "_resolved": "https://registry.npmjs.org/connect/-/connect-2.12.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/cookie-signature/.npmignore b/realtime/node_modules/express/node_modules/cookie-signature/.npmignore new file mode 100644 index 00000000..f1250e58 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie-signature/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/realtime/node_modules/express/node_modules/cookie-signature/History.md b/realtime/node_modules/express/node_modules/cookie-signature/History.md new file mode 100644 index 00000000..9e301799 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie-signature/History.md @@ -0,0 +1,11 @@ + +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 diff --git a/realtime/node_modules/express/node_modules/cookie-signature/Makefile b/realtime/node_modules/express/node_modules/cookie-signature/Makefile new file mode 100644 index 00000000..4e9c8d36 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie-signature/Makefile @@ -0,0 +1,7 @@ + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec + +.PHONY: test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/cookie-signature/Readme.md b/realtime/node_modules/express/node_modules/cookie-signature/Readme.md new file mode 100644 index 00000000..2559e841 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie-signature/Readme.md @@ -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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/cookie-signature/index.js b/realtime/node_modules/express/node_modules/cookie-signature/index.js new file mode 100644 index 00000000..ed62814e --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie-signature/index.js @@ -0,0 +1,42 @@ + +/** + * 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('.')); + return exports.sign(str, secret) == val ? str : false; +}; diff --git a/realtime/node_modules/express/node_modules/cookie-signature/package.json b/realtime/node_modules/express/node_modules/cookie-signature/package.json new file mode 100644 index 00000000..83e626ed --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie-signature/package.json @@ -0,0 +1,28 @@ +{ + "name": "cookie-signature", + "version": "1.0.1", + "description": "Sign and unsign cookies", + "keywords": [ + "cookie", + "sign", + "unsign" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@learnboost.com" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "main": "index", + "readme": "\n# cookie-signature\n\n Sign and unsign cookies.\n\n## Example\n\n```js\nvar cookie = require('cookie-signature');\n\nvar val = cookie.sign('hello', 'tobiiscool');\nval.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');\n\nvar val = cookie.sign('hello', 'tobiiscool');\ncookie.unsign(val, 'tobiiscool').should.equal('hello');\ncookie.unsign(val, 'luna').should.be.false;\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 LearnBoost <tj@learnboost.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", + "readmeFilename": "Readme.md", + "_id": "cookie-signature@1.0.1", + "dist": { + "shasum": "7e3df42cfbcdf15f0f8e05ee3152cb6c95cdc681" + }, + "_from": "cookie-signature@1.0.1", + "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.1.tgz" +} diff --git a/realtime/node_modules/express/node_modules/cookie/.npmignore b/realtime/node_modules/express/node_modules/cookie/.npmignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/realtime/node_modules/express/node_modules/cookie/.travis.yml b/realtime/node_modules/express/node_modules/cookie/.travis.yml new file mode 100644 index 00000000..9400c118 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.6" + - "0.8" + - "0.10" diff --git a/realtime/node_modules/express/node_modules/cookie/LICENSE b/realtime/node_modules/express/node_modules/cookie/LICENSE new file mode 100644 index 00000000..249d9def --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/LICENSE @@ -0,0 +1,9 @@ +// MIT License + +Copyright (C) Roman Shtylman + +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. diff --git a/realtime/node_modules/express/node_modules/cookie/README.md b/realtime/node_modules/express/node_modules/cookie/README.md new file mode 100644 index 00000000..5187ed1c --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/README.md @@ -0,0 +1,44 @@ +# cookie [![Build Status](https://secure.travis-ci.org/shtylman/node-cookie.png?branch=master)](http://travis-ci.org/shtylman/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 + diff --git a/realtime/node_modules/express/node_modules/cookie/index.js b/realtime/node_modules/express/node_modules/cookie/index.js new file mode 100644 index 00000000..16bdb65d --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/index.js @@ -0,0 +1,70 @@ + +/// 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 (opt.maxAge) pairs.push('Max-Age=' + opt.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; diff --git a/realtime/node_modules/express/node_modules/cookie/package.json b/realtime/node_modules/express/node_modules/cookie/package.json new file mode 100644 index 00000000..5e5896c7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/package.json @@ -0,0 +1,37 @@ +{ + "author": { + "name": "Roman Shtylman", + "email": "shtylman@gmail.com" + }, + "name": "cookie", + "description": "cookie parsing and serialization", + "version": "0.1.0", + "repository": { + "type": "git", + "url": "git://github.com/shtylman/node-cookie.git" + }, + "keywords": [ + "cookie", + "cookies" + ], + "main": "index.js", + "scripts": { + "test": "mocha" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "1.x.x" + }, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "readme": "# cookie [![Build Status](https://secure.travis-ci.org/shtylman/node-cookie.png?branch=master)](http://travis-ci.org/shtylman/node-cookie) #\n\ncookie 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.\n\nSee [RFC6265](http://tools.ietf.org/html/rfc6265) for details about the http header for cookies.\n\n## how?\n\n```\nnpm install cookie\n```\n\n```javascript\nvar cookie = require('cookie');\n\nvar hdr = cookie.serialize('foo', 'bar');\n// hdr = 'foo=bar';\n\nvar cookies = cookie.parse('foo=bar; cat=meow; dog=ruff');\n// cookies = { foo: 'bar', cat: 'meow', dog: 'ruff' };\n```\n\n## more\n\nThe serialize function takes a third parameter, an object, to set cookie options. See the RFC for valid values.\n\n### path\n> cookie path\n\n### expires\n> absolute expiration date for the cookie (Date object)\n\n### maxAge\n> relative max age of the cookie from when the client receives it (seconds)\n\n### domain\n> domain for the cookie\n\n### secure\n> true or false\n\n### httpOnly\n> true or false\n\n", + "readmeFilename": "README.md", + "_id": "cookie@0.1.0", + "dist": { + "shasum": "e6a72329570ab5a3b38a8a29c5094643959ff286" + }, + "_from": "cookie@0.1.0", + "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.1.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/cookie/test/mocha.opts b/realtime/node_modules/express/node_modules/cookie/test/mocha.opts new file mode 100644 index 00000000..e2bfcc5a --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/test/mocha.opts @@ -0,0 +1 @@ +--ui qunit diff --git a/realtime/node_modules/express/node_modules/cookie/test/parse.js b/realtime/node_modules/express/node_modules/cookie/test/parse.js new file mode 100644 index 00000000..c6c27a20 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/test/parse.js @@ -0,0 +1,44 @@ + +var assert = require('assert'); + +var cookie = require('..'); + +suite('parse'); + +test('basic', function() { + assert.deepEqual({ foo: 'bar' }, cookie.parse('foo=bar')); + assert.deepEqual({ foo: '123' }, cookie.parse('foo=123')); +}); + +test('ignore spaces', function() { + assert.deepEqual({ FOO: 'bar', baz: 'raz' }, + cookie.parse('FOO = bar; baz = raz')); +}); + +test('escaping', function() { + assert.deepEqual({ foo: 'bar=123456789&name=Magic+Mouse' }, + cookie.parse('foo="bar=123456789&name=Magic+Mouse"')); + + assert.deepEqual({ email: ' ",;/' }, + cookie.parse('email=%20%22%2c%3b%2f')); +}); + +test('ignore escaping error and return original value', function() { + assert.deepEqual({ foo: '%1', bar: 'bar' }, cookie.parse('foo=%1;bar=bar')); +}); + +test('ignore non values', function() { + assert.deepEqual({ foo: '%1', bar: 'bar' }, cookie.parse('foo=%1;bar=bar;HttpOnly;Secure')); +}); + +test('unencoded', function() { + assert.deepEqual({ foo: 'bar=123456789&name=Magic+Mouse' }, + cookie.parse('foo="bar=123456789&name=Magic+Mouse"',{ + decode: function(value) { return value; } + })); + + assert.deepEqual({ email: '%20%22%2c%3b%2f' }, + cookie.parse('email=%20%22%2c%3b%2f',{ + decode: function(value) { return value; } + })); +}) diff --git a/realtime/node_modules/express/node_modules/cookie/test/serialize.js b/realtime/node_modules/express/node_modules/cookie/test/serialize.js new file mode 100644 index 00000000..86bb8c93 --- /dev/null +++ b/realtime/node_modules/express/node_modules/cookie/test/serialize.js @@ -0,0 +1,64 @@ +// builtin +var assert = require('assert'); + +var cookie = require('..'); + +suite('serialize'); + +test('basic', function() { + assert.equal('foo=bar', cookie.serialize('foo', 'bar')); + assert.equal('foo=bar%20baz', cookie.serialize('foo', 'bar baz')); +}); + +test('path', function() { + assert.equal('foo=bar; Path=/', cookie.serialize('foo', 'bar', { + path: '/' + })); +}); + +test('secure', function() { + assert.equal('foo=bar; Secure', cookie.serialize('foo', 'bar', { + secure: true + })); + + assert.equal('foo=bar', cookie.serialize('foo', 'bar', { + secure: false + })); +}); + +test('domain', function() { + assert.equal('foo=bar; Domain=example.com', cookie.serialize('foo', 'bar', { + domain: 'example.com' + })); +}); + +test('httpOnly', function() { + assert.equal('foo=bar; HttpOnly', cookie.serialize('foo', 'bar', { + httpOnly: true + })); +}); + +test('maxAge', function() { + assert.equal('foo=bar; Max-Age=1000', cookie.serialize('foo', 'bar', { + maxAge: 1000 + })); +}); + +test('escaping', function() { + assert.deepEqual('cat=%2B%20', cookie.serialize('cat', '+ ')); +}); + +test('parse->serialize', function() { + + assert.deepEqual({ cat: 'foo=123&name=baz five' }, cookie.parse( + cookie.serialize('cat', 'foo=123&name=baz five'))); + + assert.deepEqual({ cat: ' ";/' }, cookie.parse( + cookie.serialize('cat', ' ";/'))); +}); + +test('unencoded', function() { + assert.deepEqual('cat=+ ', cookie.serialize('cat', '+ ', { + encode: function(value) { return value; } + })); +}) diff --git a/realtime/node_modules/express/node_modules/debug/Readme.md b/realtime/node_modules/express/node_modules/debug/Readme.md new file mode 100644 index 00000000..c5a34e8b --- /dev/null +++ b/realtime/node_modules/express/node_modules/debug/Readme.md @@ -0,0 +1,115 @@ +# debug + + tiny node.js debugging utility modelled after node core's debugging technique. + +## Installation + +``` +$ npm install debug +``` + +## Usage + + With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. + +Example _app.js_: + +```js +var debug = require('debug')('http') + , http = require('http') + , name = 'My App'; + +// fake app + +debug('booting %s', name); + +http.createServer(function(req, res){ + debug(req.method + ' ' + req.url); + res.end('hello\n'); +}).listen(3000, function(){ + debug('listening'); +}); + +// fake worker of some kind + +require('./worker'); +``` + +Example _worker.js_: + +```js +var debug = require('debug')('worker'); + +setInterval(function(){ + debug('doing some work'); +}, 1000); +``` + + The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: + + ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) + + ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) + +## Millisecond diff + + When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. + + ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) + + When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: + _(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_ + + ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) + +## Conventions + + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + +## Wildcards + + The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. + + You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with "connect:". + +## Browser support + + Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. + +```js +a = debug('worker:a'); +b = debug('worker:b'); + +setInterval(function(){ + a('doing some work'); +}, 1000); + +setInterval(function(){ + a('doing some work'); +}, 1200); +``` + +## License + +(The MIT License) + +Copyright (c) 2011 TJ Holowaychuk <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. diff --git a/realtime/node_modules/express/node_modules/debug/debug.js b/realtime/node_modules/express/node_modules/debug/debug.js new file mode 100644 index 00000000..509dc0de --- /dev/null +++ b/realtime/node_modules/express/node_modules/debug/debug.js @@ -0,0 +1,137 @@ + +/** + * Expose `debug()` as the module. + */ + +module.exports = debug; + +/** + * Create a debugger with the given `name`. + * + * @param {String} name + * @return {Type} + * @api public + */ + +function debug(name) { + if (!debug.enabled(name)) return function(){}; + + return function(fmt){ + fmt = coerce(fmt); + + var curr = new Date; + var ms = curr - (debug[name] || curr); + debug[name] = curr; + + fmt = name + + ' ' + + fmt + + ' +' + debug.humanize(ms); + + // This hackery is required for IE8 + // where `console.log` doesn't have 'apply' + window.console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); + } +} + +/** + * The currently active debug mode names. + */ + +debug.names = []; +debug.skips = []; + +/** + * Enables a debug mode by name. This can include modes + * separated by a colon and wildcards. + * + * @param {String} name + * @api public + */ + +debug.enable = function(name) { + try { + localStorage.debug = name; + } catch(e){} + + var split = (name || '').split(/[\s,]+/) + , len = split.length; + + for (var i = 0; i < len; i++) { + name = split[i].replace('*', '.*?'); + if (name[0] === '-') { + debug.skips.push(new RegExp('^' + name.substr(1) + '$')); + } + else { + debug.names.push(new RegExp('^' + name + '$')); + } + } +}; + +/** + * Disable debug output. + * + * @api public + */ + +debug.disable = function(){ + debug.enable(''); +}; + +/** + * Humanize the given `ms`. + * + * @param {Number} m + * @return {String} + * @api private + */ + +debug.humanize = function(ms) { + var sec = 1000 + , min = 60 * 1000 + , hour = 60 * min; + + if (ms >= hour) return (ms / hour).toFixed(1) + 'h'; + if (ms >= min) return (ms / min).toFixed(1) + 'm'; + if (ms >= sec) return (ms / sec | 0) + 's'; + return ms + 'ms'; +}; + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +debug.enabled = function(name) { + for (var i = 0, len = debug.skips.length; i < len; i++) { + if (debug.skips[i].test(name)) { + return false; + } + } + for (var i = 0, len = debug.names.length; i < len; i++) { + if (debug.names[i].test(name)) { + return true; + } + } + return false; +}; + +/** + * Coerce `val`. + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +// persist + +try { + if (window.localStorage) debug.enable(localStorage.debug); +} catch(e){} diff --git a/realtime/node_modules/express/node_modules/debug/index.js b/realtime/node_modules/express/node_modules/debug/index.js new file mode 100644 index 00000000..e02c13b7 --- /dev/null +++ b/realtime/node_modules/express/node_modules/debug/index.js @@ -0,0 +1,5 @@ +if ('undefined' == typeof window) { + module.exports = require('./lib/debug'); +} else { + module.exports = require('./debug'); +} diff --git a/realtime/node_modules/express/node_modules/debug/lib/debug.js b/realtime/node_modules/express/node_modules/debug/lib/debug.js new file mode 100644 index 00000000..3b0a9183 --- /dev/null +++ b/realtime/node_modules/express/node_modules/debug/lib/debug.js @@ -0,0 +1,147 @@ +/** + * Module dependencies. + */ + +var tty = require('tty'); + +/** + * Expose `debug()` as the module. + */ + +module.exports = debug; + +/** + * Enabled debuggers. + */ + +var names = [] + , skips = []; + +(process.env.DEBUG || '') + .split(/[\s,]+/) + .forEach(function(name){ + name = name.replace('*', '.*?'); + if (name[0] === '-') { + skips.push(new RegExp('^' + name.substr(1) + '$')); + } else { + names.push(new RegExp('^' + name + '$')); + } + }); + +/** + * Colors. + */ + +var colors = [6, 2, 3, 4, 5, 1]; + +/** + * Previous debug() call. + */ + +var prev = {}; + +/** + * Previously assigned color. + */ + +var prevColor = 0; + +/** + * Is stdout a TTY? Colored output is disabled when `true`. + */ + +var isatty = tty.isatty(2); + +/** + * Select a color. + * + * @return {Number} + * @api private + */ + +function color() { + return colors[prevColor++ % colors.length]; +} + +/** + * Humanize the given `ms`. + * + * @param {Number} m + * @return {String} + * @api private + */ + +function humanize(ms) { + var sec = 1000 + , min = 60 * 1000 + , hour = 60 * min; + + if (ms >= hour) return (ms / hour).toFixed(1) + 'h'; + if (ms >= min) return (ms / min).toFixed(1) + 'm'; + if (ms >= sec) return (ms / sec | 0) + 's'; + return ms + 'ms'; +} + +/** + * Create a debugger with the given `name`. + * + * @param {String} name + * @return {Type} + * @api public + */ + +function debug(name) { + function disabled(){} + disabled.enabled = false; + + var match = skips.some(function(re){ + return re.test(name); + }); + + if (match) return disabled; + + match = names.some(function(re){ + return re.test(name); + }); + + if (!match) return disabled; + var c = color(); + + function colored(fmt) { + fmt = coerce(fmt); + + var curr = new Date; + var ms = curr - (prev[name] || curr); + prev[name] = curr; + + fmt = ' \u001b[9' + c + 'm' + name + ' ' + + '\u001b[3' + c + 'm\u001b[90m' + + fmt + '\u001b[3' + c + 'm' + + ' +' + humanize(ms) + '\u001b[0m'; + + console.error.apply(this, arguments); + } + + function plain(fmt) { + fmt = coerce(fmt); + + fmt = new Date().toUTCString() + + ' ' + name + ' ' + fmt; + console.error.apply(this, arguments); + } + + colored.enabled = plain.enabled = true; + + return isatty || process.env.DEBUG_COLORS + ? colored + : plain; +} + +/** + * Coerce `val`. + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} diff --git a/realtime/node_modules/express/node_modules/debug/package.json b/realtime/node_modules/express/node_modules/debug/package.json new file mode 100644 index 00000000..dc5d7223 --- /dev/null +++ b/realtime/node_modules/express/node_modules/debug/package.json @@ -0,0 +1,46 @@ +{ + "name": "debug", + "version": "0.7.4", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" + }, + "description": "small debugging utility", + "keywords": [ + "debug", + "log", + "debugger" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "*" + }, + "main": "lib/debug.js", + "browser": "./debug.js", + "engines": { + "node": "*" + }, + "files": [ + "lib/debug.js", + "debug.js", + "index.js" + ], + "component": { + "scripts": { + "debug/index.js": "index.js", + "debug/debug.js": "debug.js" + } + }, + "readme": "# debug\n\n tiny node.js debugging utility modelled after node core's debugging technique.\n\n## Installation\n\n```\n$ npm install debug\n```\n\n## Usage\n\n With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.\n \nExample _app.js_:\n\n```js\nvar debug = require('debug')('http')\n , http = require('http')\n , name = 'My App';\n\n// fake app\n\ndebug('booting %s', name);\n\nhttp.createServer(function(req, res){\n debug(req.method + ' ' + req.url);\n res.end('hello\\n');\n}).listen(3000, function(){\n debug('listening');\n});\n\n// fake worker of some kind\n\nrequire('./worker');\n```\n\nExample _worker.js_:\n\n```js\nvar debug = require('debug')('worker');\n\nsetInterval(function(){\n debug('doing some work');\n}, 1000);\n```\n\n The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:\n\n ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png)\n\n ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png)\n\n## Millisecond diff\n\n When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the \"+NNNms\" will show you how much time was spent between calls.\n\n ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)\n\n When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:\n _(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_\n \n ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png)\n \n## Conventions\n\n If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use \":\" to separate features. For example \"bodyParser\" from Connect would then be \"connect:bodyParser\". \n\n## Wildcards\n\n The \"*\" character may be used as a wildcard. Suppose for example your library has debuggers named \"connect:bodyParser\", \"connect:compress\", \"connect:session\", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.\n\n You can also exclude specific debuggers by prefixing them with a \"-\" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with \"connect:\".\n\n## Browser support\n\n Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. \n\n```js\na = debug('worker:a');\nb = debug('worker:b');\n\nsetInterval(function(){\n a('doing some work');\n}, 1000);\n\nsetInterval(function(){\n a('doing some work');\n}, 1200);\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "Readme.md", + "_id": "debug@0.7.4", + "dist": { + "shasum": "d00d9af32ec718b7d3120b8a08f01fac85a49a3e" + }, + "_from": "debug@>= 0.7.3 < 1", + "_resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz" +} diff --git a/realtime/node_modules/express/node_modules/fresh/.npmignore b/realtime/node_modules/express/node_modules/fresh/.npmignore new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/fresh/.npmignore @@ -0,0 +1 @@ +test diff --git a/realtime/node_modules/express/node_modules/fresh/History.md b/realtime/node_modules/express/node_modules/fresh/History.md new file mode 100644 index 00000000..60a2903f --- /dev/null +++ b/realtime/node_modules/express/node_modules/fresh/History.md @@ -0,0 +1,5 @@ + +0.2.0 / 2013-08-11 +================== + + * fix: return false for no-cache diff --git a/realtime/node_modules/express/node_modules/fresh/Makefile b/realtime/node_modules/express/node_modules/fresh/Makefile new file mode 100644 index 00000000..8e8640f2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/fresh/Makefile @@ -0,0 +1,7 @@ + +test: + @./node_modules/.bin/mocha \ + --reporter spec \ + --require should + +.PHONY: test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/fresh/Readme.md b/realtime/node_modules/express/node_modules/fresh/Readme.md new file mode 100644 index 00000000..61366c57 --- /dev/null +++ b/realtime/node_modules/express/node_modules/fresh/Readme.md @@ -0,0 +1,57 @@ + +# node-fresh + + HTTP response freshness testing + +## fresh(req, res) + + Check freshness of `req` and `res` headers. + + When the cache is "fresh" __true__ is returned, + otherwise __false__ is returned to indicate that + the cache is now stale. + +## Example: + +```js +var req = { 'if-none-match': 'tobi' }; +var res = { 'etag': 'luna' }; +fresh(req, res); +// => false + +var req = { 'if-none-match': 'tobi' }; +var res = { 'etag': 'tobi' }; +fresh(req, res); +// => true +``` + +## Installation + +``` +$ npm install fresh +``` + +## 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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/fresh/index.js b/realtime/node_modules/express/node_modules/fresh/index.js new file mode 100644 index 00000000..9c3f47d1 --- /dev/null +++ b/realtime/node_modules/express/node_modules/fresh/index.js @@ -0,0 +1,53 @@ + +/** + * Expose `fresh()`. + */ + +module.exports = fresh; + +/** + * Check freshness of `req` and `res` headers. + * + * When the cache is "fresh" __true__ is returned, + * otherwise __false__ is returned to indicate that + * the cache is now stale. + * + * @param {Object} req + * @param {Object} res + * @return {Boolean} + * @api public + */ + +function fresh(req, res) { + // defaults + var etagMatches = true; + var notModified = true; + + // fields + var modifiedSince = req['if-modified-since']; + var noneMatch = req['if-none-match']; + var lastModified = res['last-modified']; + var etag = res['etag']; + var cc = req['cache-control']; + + // unconditional request + if (!modifiedSince && !noneMatch) return false; + + // check for no-cache cache request directive + if (cc && cc.indexOf('no-cache') !== -1) return false; + + // parse if-none-match + if (noneMatch) noneMatch = noneMatch.split(/ *, */); + + // if-none-match + if (noneMatch) etagMatches = ~noneMatch.indexOf(etag) || '*' == noneMatch[0]; + + // if-modified-since + if (modifiedSince) { + modifiedSince = new Date(modifiedSince); + lastModified = new Date(lastModified); + notModified = lastModified <= modifiedSince; + } + + return !! (etagMatches && notModified); +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/fresh/package.json b/realtime/node_modules/express/node_modules/fresh/package.json new file mode 100644 index 00000000..eb675f45 --- /dev/null +++ b/realtime/node_modules/express/node_modules/fresh/package.json @@ -0,0 +1,28 @@ +{ + "name": "fresh", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + }, + "description": "HTTP response freshness testing", + "version": "0.2.0", + "main": "index.js", + "repository": { + "type": "git", + "url": "https://github.com/visionmedia/node-fresh.git" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "readme": "\n# node-fresh\n\n HTTP response freshness testing\n\n## fresh(req, res)\n\n Check freshness of `req` and `res` headers.\n\n When the cache is \"fresh\" __true__ is returned,\n otherwise __false__ is returned to indicate that\n the cache is now stale.\n\n## Example:\n\n```js\nvar req = { 'if-none-match': 'tobi' };\nvar res = { 'etag': 'luna' };\nfresh(req, res);\n// => false\n\nvar req = { 'if-none-match': 'tobi' };\nvar res = { 'etag': 'tobi' };\nfresh(req, res);\n// => true\n```\n\n## Installation\n\n```\n$ npm install fresh\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", + "readmeFilename": "Readme.md", + "_id": "fresh@0.2.0", + "dist": { + "shasum": "8ed184bd05f8b23f122ac0c2f16de9e570cea06b" + }, + "_from": "fresh@0.2.0", + "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/merge-descriptors/.npmignore b/realtime/node_modules/express/node_modules/merge-descriptors/.npmignore new file mode 100644 index 00000000..f62e6050 --- /dev/null +++ b/realtime/node_modules/express/node_modules/merge-descriptors/.npmignore @@ -0,0 +1,59 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store* +ehthumbs.db +Icon? +Thumbs.db + +# Node.js # +########### +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +node_modules +npm-debug.log + +# Components # +############## + +/build +/components +/vendors \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/merge-descriptors/README.md b/realtime/node_modules/express/node_modules/merge-descriptors/README.md new file mode 100644 index 00000000..34d715df --- /dev/null +++ b/realtime/node_modules/express/node_modules/merge-descriptors/README.md @@ -0,0 +1,49 @@ +# Merge Descriptors [![Build Status](https://travis-ci.org/jonathanong/merge-descriptors.png)](https://travis-ci.org/jonathanong/merge-descriptors) + +Merge objects using descriptors. + +```js +var thing = { + get name() { + return 'jon' + } +} + +var animal = { + +} + +merge(animal, thing) + +animal.name === 'jon' +``` + +## API + +### merge(destination, source) + +Overwrites `destination`'s descriptors with `source`'s. + +## License + +The MIT License (MIT) + +Copyright (c) 2013 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. \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/merge-descriptors/component.json b/realtime/node_modules/express/node_modules/merge-descriptors/component.json new file mode 100644 index 00000000..26b1b8e8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/merge-descriptors/component.json @@ -0,0 +1,10 @@ +{ + "name": "merge-descriptors", + "description": "Merge objects using descriptors", + "version": "0.0.1", + "scripts": [ + "index.js" + ], + "repo": "jonathanong/merge-descriptors", + "license": "MIT" +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/merge-descriptors/index.js b/realtime/node_modules/express/node_modules/merge-descriptors/index.js new file mode 100644 index 00000000..e4e23793 --- /dev/null +++ b/realtime/node_modules/express/node_modules/merge-descriptors/index.js @@ -0,0 +1,8 @@ +module.exports = function (dest, src) { + Object.getOwnPropertyNames(src).forEach(function (name) { + var descriptor = Object.getOwnPropertyDescriptor(src, name) + Object.defineProperty(dest, name, descriptor) + }) + + return dest +} \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/merge-descriptors/package.json b/realtime/node_modules/express/node_modules/merge-descriptors/package.json new file mode 100644 index 00000000..c18d515f --- /dev/null +++ b/realtime/node_modules/express/node_modules/merge-descriptors/package.json @@ -0,0 +1,30 @@ +{ + "name": "merge-descriptors", + "description": "Merge objects using descriptors", + "version": "0.0.1", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/jonathanong/merge-descriptors.git" + }, + "bugs": { + "mail": "me@jongleberry.com", + "url": "https://github.com/jonathanong/merge-descriptors/issues" + }, + "scripts": { + "test": "make test;" + }, + "readme": "# Merge Descriptors [![Build Status](https://travis-ci.org/jonathanong/merge-descriptors.png)](https://travis-ci.org/jonathanong/merge-descriptors)\n\nMerge objects using descriptors.\n\n```js\nvar thing = {\n get name() {\n return 'jon'\n }\n}\n\nvar animal = {\n\n}\n\nmerge(animal, thing)\n\nanimal.name === 'jon'\n```\n\n## API\n\n### merge(destination, source)\n\nOverwrites `destination`'s descriptors with `source`'s.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.", + "readmeFilename": "README.md", + "_id": "merge-descriptors@0.0.1", + "dist": { + "shasum": "0ba3fd59783848bd46ee4dc8f8b2b524b5ba5ae4" + }, + "_from": "merge-descriptors@0.0.1", + "_resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-0.0.1.tgz" +} diff --git a/realtime/node_modules/express/node_modules/methods/History.md b/realtime/node_modules/express/node_modules/methods/History.md new file mode 100644 index 00000000..1d0e229f --- /dev/null +++ b/realtime/node_modules/express/node_modules/methods/History.md @@ -0,0 +1,5 @@ + +0.1.0 / 2013-10-28 +================== + + * add http.METHODS support diff --git a/realtime/node_modules/express/node_modules/methods/Readme.md b/realtime/node_modules/express/node_modules/methods/Readme.md new file mode 100644 index 00000000..ac0658e2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/methods/Readme.md @@ -0,0 +1,4 @@ + +# Methods + + HTTP verbs that node core's parser supports. diff --git a/realtime/node_modules/express/node_modules/methods/index.js b/realtime/node_modules/express/node_modules/methods/index.js new file mode 100644 index 00000000..95b93f5f --- /dev/null +++ b/realtime/node_modules/express/node_modules/methods/index.js @@ -0,0 +1,37 @@ + +var http = require('http'); + +if (http.METHODS) { + module.exports = http.METHODS.map(function(method){ + return method.toLowerCase(); + }); + + return; +} + +module.exports = [ + 'get', + 'post', + 'put', + 'head', + 'delete', + 'options', + 'trace', + 'copy', + 'lock', + 'mkcol', + 'move', + 'propfind', + 'proppatch', + 'unlock', + 'report', + 'mkactivity', + 'checkout', + 'merge', + 'm-search', + 'notify', + 'subscribe', + 'unsubscribe', + 'patch', + 'search' +]; diff --git a/realtime/node_modules/express/node_modules/methods/package.json b/realtime/node_modules/express/node_modules/methods/package.json new file mode 100644 index 00000000..407c5700 --- /dev/null +++ b/realtime/node_modules/express/node_modules/methods/package.json @@ -0,0 +1,29 @@ +{ + "name": "methods", + "version": "0.1.0", + "description": "HTTP methods that node supports", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "http", + "methods" + ], + "author": { + "name": "TJ Holowaychuk" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/node-methods.git" + }, + "readme": "\n# Methods\n\n HTTP verbs that node core's parser supports.\n", + "readmeFilename": "Readme.md", + "_id": "methods@0.1.0", + "dist": { + "shasum": "c4649cfe2de1d509524a20c84dd06394280ef8d2" + }, + "_from": "methods@0.1.0", + "_resolved": "https://registry.npmjs.org/methods/-/methods-0.1.0.tgz" +} diff --git a/realtime/node_modules/express/node_modules/mkdirp/.npmignore b/realtime/node_modules/express/node_modules/mkdirp/.npmignore new file mode 100644 index 00000000..9303c347 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/.npmignore @@ -0,0 +1,2 @@ +node_modules/ +npm-debug.log \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/mkdirp/.travis.yml b/realtime/node_modules/express/node_modules/mkdirp/.travis.yml new file mode 100644 index 00000000..84fd7ca2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.6 + - 0.8 + - 0.9 diff --git a/realtime/node_modules/express/node_modules/mkdirp/LICENSE b/realtime/node_modules/express/node_modules/mkdirp/LICENSE new file mode 100644 index 00000000..432d1aeb --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/LICENSE @@ -0,0 +1,21 @@ +Copyright 2010 James Halliday (mail@substack.net) + +This project is free software released under the MIT/X11 license: + +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. diff --git a/realtime/node_modules/express/node_modules/mkdirp/examples/pow.js b/realtime/node_modules/express/node_modules/mkdirp/examples/pow.js new file mode 100644 index 00000000..e6924212 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/examples/pow.js @@ -0,0 +1,6 @@ +var mkdirp = require('mkdirp'); + +mkdirp('/tmp/foo/bar/baz', function (err) { + if (err) console.error(err) + else console.log('pow!') +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/index.js b/realtime/node_modules/express/node_modules/mkdirp/index.js new file mode 100644 index 00000000..fda6de8a --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/index.js @@ -0,0 +1,82 @@ +var path = require('path'); +var fs = require('fs'); + +module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; + +function mkdirP (p, mode, f, made) { + if (typeof mode === 'function' || mode === undefined) { + f = mode; + mode = 0777 & (~process.umask()); + } + if (!made) made = null; + + var cb = f || function () {}; + if (typeof mode === 'string') mode = parseInt(mode, 8); + p = path.resolve(p); + + fs.mkdir(p, mode, function (er) { + if (!er) { + made = made || p; + return cb(null, made); + } + switch (er.code) { + case 'ENOENT': + mkdirP(path.dirname(p), mode, function (er, made) { + if (er) cb(er, made); + else mkdirP(p, mode, cb, made); + }); + break; + + // In the case of any other error, just see if there's a dir + // there already. If so, then hooray! If not, then something + // is borked. + default: + fs.stat(p, function (er2, stat) { + // if the stat fails, then that's super weird. + // let the original error be the failure reason. + if (er2 || !stat.isDirectory()) cb(er, made) + else cb(null, made); + }); + break; + } + }); +} + +mkdirP.sync = function sync (p, mode, made) { + if (mode === undefined) { + mode = 0777 & (~process.umask()); + } + if (!made) made = null; + + if (typeof mode === 'string') mode = parseInt(mode, 8); + p = path.resolve(p); + + try { + fs.mkdirSync(p, mode); + made = made || p; + } + catch (err0) { + switch (err0.code) { + case 'ENOENT' : + made = sync(path.dirname(p), mode, made); + sync(p, mode, made); + break; + + // In the case of any other error, just see if there's a dir + // there already. If so, then hooray! If not, then something + // is borked. + default: + var stat; + try { + stat = fs.statSync(p); + } + catch (err1) { + throw err0; + } + if (!stat.isDirectory()) throw err0; + break; + } + } + + return made; +}; diff --git a/realtime/node_modules/express/node_modules/mkdirp/package.json b/realtime/node_modules/express/node_modules/mkdirp/package.json new file mode 100644 index 00000000..70918597 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/package.json @@ -0,0 +1,34 @@ +{ + "name": "mkdirp", + "description": "Recursively mkdir, like `mkdir -p`", + "version": "0.3.5", + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "main": "./index", + "keywords": [ + "mkdir", + "directory" + ], + "repository": { + "type": "git", + "url": "http://github.com/substack/node-mkdirp.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "devDependencies": { + "tap": "~0.4.0" + }, + "license": "MIT", + "readme": "# mkdirp\n\nLike `mkdir -p`, but in node.js!\n\n[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)\n\n# example\n\n## pow.js\n\n```js\nvar mkdirp = require('mkdirp');\n \nmkdirp('/tmp/foo/bar/baz', function (err) {\n if (err) console.error(err)\n else console.log('pow!')\n});\n```\n\nOutput\n\n```\npow!\n```\n\nAnd now /tmp/foo/bar/baz exists, huzzah!\n\n# methods\n\n```js\nvar mkdirp = require('mkdirp');\n```\n\n## mkdirp(dir, mode, cb)\n\nCreate a new directory and any necessary subdirectories at `dir` with octal\npermission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\n`cb(err, made)` fires with the error or the first directory `made`\nthat had to be created, if any.\n\n## mkdirp.sync(dir, mode)\n\nSynchronously create a new directory and any necessary subdirectories at `dir`\nwith octal permission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\nReturns the first directory that had to be created, if any.\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install mkdirp\n```\n\n# license\n\nMIT\n", + "readmeFilename": "readme.markdown", + "_id": "mkdirp@0.3.5", + "dist": { + "shasum": "022350c83d33be2796bd255202861e63386a158a" + }, + "_from": "mkdirp@0.3.5", + "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz" +} diff --git a/realtime/node_modules/express/node_modules/mkdirp/readme.markdown b/realtime/node_modules/express/node_modules/mkdirp/readme.markdown new file mode 100644 index 00000000..83b0216a --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/readme.markdown @@ -0,0 +1,63 @@ +# mkdirp + +Like `mkdir -p`, but in node.js! + +[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp) + +# example + +## pow.js + +```js +var mkdirp = require('mkdirp'); + +mkdirp('/tmp/foo/bar/baz', function (err) { + if (err) console.error(err) + else console.log('pow!') +}); +``` + +Output + +``` +pow! +``` + +And now /tmp/foo/bar/baz exists, huzzah! + +# methods + +```js +var mkdirp = require('mkdirp'); +``` + +## mkdirp(dir, mode, cb) + +Create a new directory and any necessary subdirectories at `dir` with octal +permission string `mode`. + +If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. + +`cb(err, made)` fires with the error or the first directory `made` +that had to be created, if any. + +## mkdirp.sync(dir, mode) + +Synchronously create a new directory and any necessary subdirectories at `dir` +with octal permission string `mode`. + +If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. + +Returns the first directory that had to be created, if any. + +# install + +With [npm](http://npmjs.org) do: + +``` +npm install mkdirp +``` + +# license + +MIT diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/chmod.js b/realtime/node_modules/express/node_modules/mkdirp/test/chmod.js new file mode 100644 index 00000000..520dcb8e --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/chmod.js @@ -0,0 +1,38 @@ +var mkdirp = require('../').mkdirp; +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +var ps = [ '', 'tmp' ]; + +for (var i = 0; i < 25; i++) { + var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + ps.push(dir); +} + +var file = ps.join('/'); + +test('chmod-pre', function (t) { + var mode = 0744 + mkdirp(file, mode, function (er) { + t.ifError(er, 'should not error'); + fs.stat(file, function (er, stat) { + t.ifError(er, 'should exist'); + t.ok(stat && stat.isDirectory(), 'should be directory'); + t.equal(stat && stat.mode & 0777, mode, 'should be 0744'); + t.end(); + }); + }); +}); + +test('chmod', function (t) { + var mode = 0755 + mkdirp(file, mode, function (er) { + t.ifError(er, 'should not error'); + fs.stat(file, function (er, stat) { + t.ifError(er, 'should exist'); + t.ok(stat && stat.isDirectory(), 'should be directory'); + t.end(); + }); + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/clobber.js b/realtime/node_modules/express/node_modules/mkdirp/test/clobber.js new file mode 100644 index 00000000..0eb70998 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/clobber.js @@ -0,0 +1,37 @@ +var mkdirp = require('../').mkdirp; +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +var ps = [ '', 'tmp' ]; + +for (var i = 0; i < 25; i++) { + var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + ps.push(dir); +} + +var file = ps.join('/'); + +// a file in the way +var itw = ps.slice(0, 3).join('/'); + + +test('clobber-pre', function (t) { + console.error("about to write to "+itw) + fs.writeFileSync(itw, 'I AM IN THE WAY, THE TRUTH, AND THE LIGHT.'); + + fs.stat(itw, function (er, stat) { + t.ifError(er) + t.ok(stat && stat.isFile(), 'should be file') + t.end() + }) +}) + +test('clobber', function (t) { + t.plan(2); + mkdirp(file, 0755, function (err) { + t.ok(err); + t.equal(err.code, 'ENOTDIR'); + t.end(); + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/mkdirp.js b/realtime/node_modules/express/node_modules/mkdirp/test/mkdirp.js new file mode 100644 index 00000000..b07cd70c --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/mkdirp.js @@ -0,0 +1,28 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('woo', function (t) { + t.plan(2); + var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + + var file = '/tmp/' + [x,y,z].join('/'); + + mkdirp(file, 0755, function (err) { + if (err) t.fail(err); + else path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.equal(stat.mode & 0777, 0755); + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }) + }) + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/perm.js b/realtime/node_modules/express/node_modules/mkdirp/test/perm.js new file mode 100644 index 00000000..23a7abbd --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/perm.js @@ -0,0 +1,32 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('async perm', function (t) { + t.plan(2); + var file = '/tmp/' + (Math.random() * (1<<30)).toString(16); + + mkdirp(file, 0755, function (err) { + if (err) t.fail(err); + else path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.equal(stat.mode & 0777, 0755); + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }) + }) + }); +}); + +test('async root perm', function (t) { + mkdirp('/tmp', 0755, function (err) { + if (err) t.fail(err); + t.end(); + }); + t.end(); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/perm_sync.js b/realtime/node_modules/express/node_modules/mkdirp/test/perm_sync.js new file mode 100644 index 00000000..f685f609 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/perm_sync.js @@ -0,0 +1,39 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('sync perm', function (t) { + t.plan(2); + var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json'; + + mkdirp.sync(file, 0755); + path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.equal(stat.mode & 0777, 0755); + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }) + }); +}); + +test('sync root perm', function (t) { + t.plan(1); + + var file = '/tmp'; + mkdirp.sync(file, 0755); + path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }) + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/race.js b/realtime/node_modules/express/node_modules/mkdirp/test/race.js new file mode 100644 index 00000000..96a04476 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/race.js @@ -0,0 +1,41 @@ +var mkdirp = require('../').mkdirp; +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('race', function (t) { + t.plan(4); + var ps = [ '', 'tmp' ]; + + for (var i = 0; i < 25; i++) { + var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + ps.push(dir); + } + var file = ps.join('/'); + + var res = 2; + mk(file, function () { + if (--res === 0) t.end(); + }); + + mk(file, function () { + if (--res === 0) t.end(); + }); + + function mk (file, cb) { + mkdirp(file, 0755, function (err) { + if (err) t.fail(err); + else path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.equal(stat.mode & 0777, 0755); + t.ok(stat.isDirectory(), 'target not a directory'); + if (cb) cb(); + } + }) + }) + }); + } +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/rel.js b/realtime/node_modules/express/node_modules/mkdirp/test/rel.js new file mode 100644 index 00000000..79858243 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/rel.js @@ -0,0 +1,32 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('rel', function (t) { + t.plan(2); + var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + + var cwd = process.cwd(); + process.chdir('/tmp'); + + var file = [x,y,z].join('/'); + + mkdirp(file, 0755, function (err) { + if (err) t.fail(err); + else path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + process.chdir(cwd); + t.equal(stat.mode & 0777, 0755); + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }) + }) + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/return.js b/realtime/node_modules/express/node_modules/mkdirp/test/return.js new file mode 100644 index 00000000..bce68e56 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/return.js @@ -0,0 +1,25 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('return value', function (t) { + t.plan(4); + var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + + var file = '/tmp/' + [x,y,z].join('/'); + + // should return the first dir created. + // By this point, it would be profoundly surprising if /tmp didn't + // already exist, since every other test makes things in there. + mkdirp(file, function (err, made) { + t.ifError(err); + t.equal(made, '/tmp/' + x); + mkdirp(file, function (err, made) { + t.ifError(err); + t.equal(made, null); + }); + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/return_sync.js b/realtime/node_modules/express/node_modules/mkdirp/test/return_sync.js new file mode 100644 index 00000000..7c222d35 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/return_sync.js @@ -0,0 +1,24 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('return value', function (t) { + t.plan(2); + var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + + var file = '/tmp/' + [x,y,z].join('/'); + + // should return the first dir created. + // By this point, it would be profoundly surprising if /tmp didn't + // already exist, since every other test makes things in there. + // Note that this will throw on failure, which will fail the test. + var made = mkdirp.sync(file); + t.equal(made, '/tmp/' + x); + + // making the same file again should have no effect. + made = mkdirp.sync(file); + t.equal(made, null); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/root.js b/realtime/node_modules/express/node_modules/mkdirp/test/root.js new file mode 100644 index 00000000..97ad7a2f --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/root.js @@ -0,0 +1,18 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('root', function (t) { + // '/' on unix, 'c:/' on windows. + var file = path.resolve('/'); + + mkdirp(file, 0755, function (err) { + if (err) throw err + fs.stat(file, function (er, stat) { + if (er) throw er + t.ok(stat.isDirectory(), 'target is a directory'); + t.end(); + }) + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/sync.js b/realtime/node_modules/express/node_modules/mkdirp/test/sync.js new file mode 100644 index 00000000..7530cada --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/sync.js @@ -0,0 +1,32 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('sync', function (t) { + t.plan(2); + var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + + var file = '/tmp/' + [x,y,z].join('/'); + + try { + mkdirp.sync(file, 0755); + } catch (err) { + t.fail(err); + return t.end(); + } + + path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.equal(stat.mode & 0777, 0755); + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }); + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/umask.js b/realtime/node_modules/express/node_modules/mkdirp/test/umask.js new file mode 100644 index 00000000..64ccafe2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/umask.js @@ -0,0 +1,28 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('implicit mode from umask', function (t) { + t.plan(2); + var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + + var file = '/tmp/' + [x,y,z].join('/'); + + mkdirp(file, function (err) { + if (err) t.fail(err); + else path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.equal(stat.mode & 0777, 0777 & (~process.umask())); + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }) + }) + }); +}); diff --git a/realtime/node_modules/express/node_modules/mkdirp/test/umask_sync.js b/realtime/node_modules/express/node_modules/mkdirp/test/umask_sync.js new file mode 100644 index 00000000..35bd5cbb --- /dev/null +++ b/realtime/node_modules/express/node_modules/mkdirp/test/umask_sync.js @@ -0,0 +1,32 @@ +var mkdirp = require('../'); +var path = require('path'); +var fs = require('fs'); +var test = require('tap').test; + +test('umask sync modes', function (t) { + t.plan(2); + var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); + + var file = '/tmp/' + [x,y,z].join('/'); + + try { + mkdirp.sync(file); + } catch (err) { + t.fail(err); + return t.end(); + } + + path.exists(file, function (ex) { + if (!ex) t.fail('file not created') + else fs.stat(file, function (err, stat) { + if (err) t.fail(err) + else { + t.equal(stat.mode & 0777, (0777 & (~process.umask()))); + t.ok(stat.isDirectory(), 'target not a directory'); + t.end(); + } + }); + }); +}); diff --git a/realtime/node_modules/express/node_modules/range-parser/.npmignore b/realtime/node_modules/express/node_modules/range-parser/.npmignore new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/realtime/node_modules/express/node_modules/range-parser/.npmignore @@ -0,0 +1 @@ +test diff --git a/realtime/node_modules/express/node_modules/range-parser/History.md b/realtime/node_modules/express/node_modules/range-parser/History.md new file mode 100644 index 00000000..82df7b1e --- /dev/null +++ b/realtime/node_modules/express/node_modules/range-parser/History.md @@ -0,0 +1,15 @@ + +0.0.4 / 2012-06-17 +================== + + * changed: ret -1 for unsatisfiable and -2 when invalid + +0.0.3 / 2012-06-17 +================== + + * fix last-byte-pos default to len - 1 + +0.0.2 / 2012-06-14 +================== + + * add `.type` diff --git a/realtime/node_modules/express/node_modules/range-parser/Makefile b/realtime/node_modules/express/node_modules/range-parser/Makefile new file mode 100644 index 00000000..8e8640f2 --- /dev/null +++ b/realtime/node_modules/express/node_modules/range-parser/Makefile @@ -0,0 +1,7 @@ + +test: + @./node_modules/.bin/mocha \ + --reporter spec \ + --require should + +.PHONY: test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/range-parser/Readme.md b/realtime/node_modules/express/node_modules/range-parser/Readme.md new file mode 100644 index 00000000..b2a67fe8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/range-parser/Readme.md @@ -0,0 +1,28 @@ + +# node-range-parser + + Range header field parser. + +## Example: + +```js +assert(-1 == parse(200, 'bytes=500-20')); +assert(-2 == parse(200, 'bytes=malformed')); +parse(200, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 199 }])); +parse(1000, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 499 }])); +parse(1000, 'bytes=40-80').should.eql(arr('bytes', [{ start: 40, end: 80 }])); +parse(1000, 'bytes=-500').should.eql(arr('bytes', [{ start: 500, end: 999 }])); +parse(1000, 'bytes=-400').should.eql(arr('bytes', [{ start: 600, end: 999 }])); +parse(1000, 'bytes=500-').should.eql(arr('bytes', [{ start: 500, end: 999 }])); +parse(1000, 'bytes=400-').should.eql(arr('bytes', [{ start: 400, end: 999 }])); +parse(1000, 'bytes=0-0').should.eql(arr('bytes', [{ start: 0, end: 0 }])); +parse(1000, 'bytes=-1').should.eql(arr('bytes', [{ start: 999, end: 999 }])); +parse(1000, 'items=0-5').should.eql(arr('items', [{ start: 0, end: 5 }])); +parse(1000, 'bytes=40-80,-1').should.eql(arr('bytes', [{ start: 40, end: 80 }, { start: 999, end: 999 }])); +``` + +## Installation + +``` +$ npm install range-parser +``` \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/range-parser/index.js b/realtime/node_modules/express/node_modules/range-parser/index.js new file mode 100644 index 00000000..9b0f7a8e --- /dev/null +++ b/realtime/node_modules/express/node_modules/range-parser/index.js @@ -0,0 +1,49 @@ + +/** + * Parse "Range" header `str` relative to the given file `size`. + * + * @param {Number} size + * @param {String} str + * @return {Array} + * @api public + */ + +module.exports = function(size, str){ + var valid = true; + var i = str.indexOf('='); + + if (-1 == i) return -2; + + var arr = str.slice(i + 1).split(',').map(function(range){ + var range = range.split('-') + , start = parseInt(range[0], 10) + , end = parseInt(range[1], 10); + + // -nnn + if (isNaN(start)) { + start = size - end; + end = size - 1; + // nnn- + } else if (isNaN(end)) { + end = size - 1; + } + + // limit last-byte-pos to current length + if (end > size - 1) end = size - 1; + + // invalid + if (isNaN(start) + || isNaN(end) + || start > end + || start < 0) valid = false; + + return { + start: start, + end: end + }; + }); + + arr.type = str.slice(0, i); + + return valid ? arr : -1; +}; \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/range-parser/package.json b/realtime/node_modules/express/node_modules/range-parser/package.json new file mode 100644 index 00000000..56103c54 --- /dev/null +++ b/realtime/node_modules/express/node_modules/range-parser/package.json @@ -0,0 +1,24 @@ +{ + "name": "range-parser", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + }, + "description": "Range header field string parser", + "version": "0.0.4", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "readme": "\n# node-range-parser\n\n Range header field parser.\n\n## Example:\n\n```js\nassert(-1 == parse(200, 'bytes=500-20'));\nassert(-2 == parse(200, 'bytes=malformed'));\nparse(200, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 199 }]));\nparse(1000, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 499 }]));\nparse(1000, 'bytes=40-80').should.eql(arr('bytes', [{ start: 40, end: 80 }]));\nparse(1000, 'bytes=-500').should.eql(arr('bytes', [{ start: 500, end: 999 }]));\nparse(1000, 'bytes=-400').should.eql(arr('bytes', [{ start: 600, end: 999 }]));\nparse(1000, 'bytes=500-').should.eql(arr('bytes', [{ start: 500, end: 999 }]));\nparse(1000, 'bytes=400-').should.eql(arr('bytes', [{ start: 400, end: 999 }]));\nparse(1000, 'bytes=0-0').should.eql(arr('bytes', [{ start: 0, end: 0 }]));\nparse(1000, 'bytes=-1').should.eql(arr('bytes', [{ start: 999, end: 999 }]));\nparse(1000, 'items=0-5').should.eql(arr('items', [{ start: 0, end: 5 }]));\nparse(1000, 'bytes=40-80,-1').should.eql(arr('bytes', [{ start: 40, end: 80 }, { start: 999, end: 999 }]));\n```\n\n## Installation\n\n```\n$ npm install range-parser\n```", + "readmeFilename": "Readme.md", + "_id": "range-parser@0.0.4", + "dist": { + "shasum": "28dbcf2e97f57e5b69a77032fe2cc3f9d20c6726" + }, + "_from": "range-parser@0.0.4", + "_resolved": "https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz" +} diff --git a/realtime/node_modules/express/node_modules/send/.npmignore b/realtime/node_modules/express/node_modules/send/.npmignore new file mode 100644 index 00000000..f1250e58 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/realtime/node_modules/express/node_modules/send/History.md b/realtime/node_modules/express/node_modules/send/History.md new file mode 100644 index 00000000..55c4af74 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/History.md @@ -0,0 +1,40 @@ + +0.1.4 / 2013-08-11 +================== + + * update fresh + +0.1.3 / 2013-07-08 +================== + + * Revert "Fix fd leak" + +0.1.2 / 2013-07-03 +================== + + * Fix fd leak + +0.1.0 / 2012-08-25 +================== + + * add options parameter to send() that is passed to fs.createReadStream() [kanongil] + +0.0.4 / 2012-08-16 +================== + + * allow custom "Accept-Ranges" definition + +0.0.3 / 2012-07-16 +================== + + * fix normalization of the root directory. Closes #3 + +0.0.2 / 2012-07-09 +================== + + * add passing of req explicitly for now (YUCK) + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/realtime/node_modules/express/node_modules/send/Makefile b/realtime/node_modules/express/node_modules/send/Makefile new file mode 100644 index 00000000..a9dcfd50 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/Makefile @@ -0,0 +1,8 @@ + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec \ + --bail + +.PHONY: test \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/send/Readme.md b/realtime/node_modules/express/node_modules/send/Readme.md new file mode 100644 index 00000000..ea7b2341 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/Readme.md @@ -0,0 +1,128 @@ +# send + + Send is Connect's `static()` extracted for generalized use, a streaming static file + server supporting partial responses (Ranges), conditional-GET negotiation, high test coverage, and granular events which may be leveraged to take appropriate actions in your application or framework. + +## Installation + + $ npm install send + +## Examples + + Small: + +```js +var http = require('http'); +var send = require('send'); + +var app = http.createServer(function(req, res){ + send(req, req.url).pipe(res); +}).listen(3000); +``` + + Serving from a root directory with custom error-handling: + +```js +var http = require('http'); +var send = require('send'); +var url = require('url'); + +var app = http.createServer(function(req, res){ + // your custom error-handling logic: + function error(err) { + res.statusCode = err.status || 500; + res.end(err.message); + } + + // your custom directory handling logic: + function redirect() { + res.statusCode = 301; + res.setHeader('Location', req.url + '/'); + res.end('Redirecting to ' + req.url + '/'); + } + + // transfer arbitrary files from within + // /www/example.com/public/* + send(req, url.parse(req.url).pathname) + .root('/www/example.com/public') + .on('error', error) + .on('directory', redirect) + .pipe(res); +}).listen(3000); +``` + +## API + +### Events + + - `error` an error occurred `(err)` + - `directory` a directory was requested + - `file` a file was requested `(path, stat)` + - `stream` file streaming has started `(stream)` + - `end` streaming has completed + +### .root(dir) + + Serve files relative to `path`. Aliased as `.from(dir)`. + +### .index(path) + + By default send supports "index.html" files, to disable this + invoke `.index(false)` or to supply a new index pass a string. + +### .maxage(ms) + + Provide a max-age in milliseconds for http caching, defaults to 0. + +### .hidden(bool) + + Enable or disable transfer of hidden files, defaults to false. + +## Error-handling + + By default when no `error` listeners are present an automatic response will be made, otherwise you have full control over the response, aka you may show a 5xx page etc. + +## Caching + + It does _not_ perform internal caching, you should use a reverse proxy cache such + as Varnish for this, or those fancy things called CDNs. If your application is small enough that it would benefit from single-node memory caching, it's small enough that it does not need caching at all ;). + +## Debugging + + To enable `debug()` instrumentation output export __DEBUG__: + +``` +$ DEBUG=send node app +``` + +## Running tests + +``` +$ npm install +$ make test +``` + +## 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. diff --git a/realtime/node_modules/express/node_modules/send/index.js b/realtime/node_modules/express/node_modules/send/index.js new file mode 100644 index 00000000..f17158d8 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/index.js @@ -0,0 +1,2 @@ + +module.exports = require('./lib/send'); \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/send/lib/send.js b/realtime/node_modules/express/node_modules/send/lib/send.js new file mode 100644 index 00000000..a3d94a69 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/lib/send.js @@ -0,0 +1,474 @@ + +/** + * Module dependencies. + */ + +var debug = require('debug')('send') + , parseRange = require('range-parser') + , Stream = require('stream') + , mime = require('mime') + , fresh = require('fresh') + , path = require('path') + , http = require('http') + , fs = require('fs') + , basename = path.basename + , normalize = path.normalize + , join = path.join + , utils = require('./utils'); + +/** + * Expose `send`. + */ + +exports = module.exports = send; + +/** + * Expose mime module. + */ + +exports.mime = mime; + +/** + * Return a `SendStream` for `req` and `path`. + * + * @param {Request} req + * @param {String} path + * @param {Object} options + * @return {SendStream} + * @api public + */ + +function send(req, path, options) { + return new SendStream(req, path, options); +} + +/** + * Initialize a `SendStream` with the given `path`. + * + * Events: + * + * - `error` an error occurred + * - `stream` file streaming has started + * - `end` streaming has completed + * - `directory` a directory was requested + * + * @param {Request} req + * @param {String} path + * @param {Object} options + * @api private + */ + +function SendStream(req, path, options) { + var self = this; + this.req = req; + this.path = path; + this.options = options || {}; + this.maxage(0); + this.hidden(false); + this.index('index.html'); +} + +/** + * Inherits from `Stream.prototype`. + */ + +SendStream.prototype.__proto__ = Stream.prototype; + +/** + * Enable or disable "hidden" (dot) files. + * + * @param {Boolean} path + * @return {SendStream} + * @api public + */ + +SendStream.prototype.hidden = function(val){ + debug('hidden %s', val); + this._hidden = val; + return this; +}; + +/** + * Set index `path`, set to a falsy + * value to disable index support. + * + * @param {String|Boolean} path + * @return {SendStream} + * @api public + */ + +SendStream.prototype.index = function(path){ + debug('index %s', path); + this._index = path; + return this; +}; + +/** + * Set root `path`. + * + * @param {String} path + * @return {SendStream} + * @api public + */ + +SendStream.prototype.root = +SendStream.prototype.from = function(path){ + this._root = normalize(path); + return this; +}; + +/** + * Set max-age to `ms`. + * + * @param {Number} ms + * @return {SendStream} + * @api public + */ + +SendStream.prototype.maxage = function(ms){ + if (Infinity == ms) ms = 60 * 60 * 24 * 365 * 1000; + debug('max-age %d', ms); + this._maxage = ms; + return this; +}; + +/** + * Emit error with `status`. + * + * @param {Number} status + * @api private + */ + +SendStream.prototype.error = function(status, err){ + var res = this.res; + var msg = http.STATUS_CODES[status]; + err = err || new Error(msg); + err.status = status; + if (this.listeners('error').length) return this.emit('error', err); + res.statusCode = err.status; + res.end(msg); +}; + +/** + * Check if the pathname is potentially malicious. + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isMalicious = function(){ + return !this._root && ~this.path.indexOf('..'); +}; + +/** + * Check if the pathname ends with "/". + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.hasTrailingSlash = function(){ + return '/' == this.path[this.path.length - 1]; +}; + +/** + * Check if the basename leads with ".". + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.hasLeadingDot = function(){ + return '.' == basename(this.path)[0]; +}; + +/** + * Check if this is a conditional GET request. + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isConditionalGET = function(){ + return this.req.headers['if-none-match'] + || this.req.headers['if-modified-since']; +}; + +/** + * Strip content-* header fields. + * + * @api private + */ + +SendStream.prototype.removeContentHeaderFields = function(){ + var res = this.res; + Object.keys(res._headers).forEach(function(field){ + if (0 == field.indexOf('content')) { + res.removeHeader(field); + } + }); +}; + +/** + * Respond with 304 not modified. + * + * @api private + */ + +SendStream.prototype.notModified = function(){ + var res = this.res; + debug('not modified'); + this.removeContentHeaderFields(); + res.statusCode = 304; + res.end(); +}; + +/** + * Check if the request is cacheable, aka + * responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}). + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isCachable = function(){ + var res = this.res; + return (res.statusCode >= 200 && res.statusCode < 300) || 304 == res.statusCode; +}; + +/** + * Handle stat() error. + * + * @param {Error} err + * @api private + */ + +SendStream.prototype.onStatError = function(err){ + var notfound = ['ENOENT', 'ENAMETOOLONG', 'ENOTDIR']; + if (~notfound.indexOf(err.code)) return this.error(404, err); + this.error(500, err); +}; + +/** + * Check if the cache is fresh. + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isFresh = function(){ + return fresh(this.req.headers, this.res._headers); +}; + +/** + * Redirect to `path`. + * + * @param {String} path + * @api private + */ + +SendStream.prototype.redirect = function(path){ + if (this.listeners('directory').length) return this.emit('directory'); + var res = this.res; + path += '/'; + res.statusCode = 301; + res.setHeader('Location', path); + res.end('Redirecting to ' + utils.escape(path)); +}; + +/** + * Pipe to `res. + * + * @param {Stream} res + * @return {Stream} res + * @api public + */ + +SendStream.prototype.pipe = function(res){ + var self = this + , args = arguments + , path = this.path + , root = this._root; + + // references + this.res = res; + + // invalid request uri + path = utils.decode(path); + if (-1 == path) return this.error(400); + + // null byte(s) + if (~path.indexOf('\0')) return this.error(400); + + // join / normalize from optional root dir + if (root) path = normalize(join(this._root, path)); + + // ".." is malicious without "root" + if (this.isMalicious()) return this.error(403); + + // malicious path + if (root && 0 != path.indexOf(root)) return this.error(403); + + // hidden file support + if (!this._hidden && this.hasLeadingDot()) return this.error(404); + + // index file support + if (this._index && this.hasTrailingSlash()) path += this._index; + + debug('stat "%s"', path); + fs.stat(path, function(err, stat){ + if (err) return self.onStatError(err); + if (stat.isDirectory()) return self.redirect(self.path); + self.emit('file', path, stat); + self.send(path, stat); + }); + + return res; +}; + +/** + * Transfer `path`. + * + * @param {String} path + * @api public + */ + +SendStream.prototype.send = function(path, stat){ + var options = this.options; + var len = stat.size; + var res = this.res; + var req = this.req; + var ranges = req.headers.range; + var offset = options.start || 0; + + // set header fields + this.setHeader(stat); + + // set content-type + this.type(path); + + // conditional GET support + if (this.isConditionalGET() + && this.isCachable() + && this.isFresh()) { + return this.notModified(); + } + + // adjust len to start/end options + len = Math.max(0, len - offset); + if (options.end !== undefined) { + var bytes = options.end - offset + 1; + if (len > bytes) len = bytes; + } + + // Range support + if (ranges) { + ranges = parseRange(len, ranges); + + // unsatisfiable + if (-1 == ranges) { + res.setHeader('Content-Range', 'bytes */' + stat.size); + return this.error(416); + } + + // valid (syntactically invalid ranges are treated as a regular response) + if (-2 != ranges) { + options.start = offset + ranges[0].start; + options.end = offset + ranges[0].end; + + // Content-Range + res.statusCode = 206; + res.setHeader('Content-Range', 'bytes ' + + ranges[0].start + + '-' + + ranges[0].end + + '/' + + len); + len = options.end - options.start + 1; + } + } + + // content-length + res.setHeader('Content-Length', len); + + // HEAD support + if ('HEAD' == req.method) return res.end(); + + this.stream(path, options); +}; + +/** + * Stream `path` to the response. + * + * @param {String} path + * @param {Object} options + * @api private + */ + +SendStream.prototype.stream = function(path, options){ + // TODO: this is all lame, refactor meeee + var self = this; + var res = this.res; + var req = this.req; + + // pipe + var stream = fs.createReadStream(path, options); + this.emit('stream', stream); + stream.pipe(res); + + // socket closed, done with the fd + req.on('close', stream.destroy.bind(stream)); + + // error handling code-smell + stream.on('error', function(err){ + // no hope in responding + if (res._header) { + console.error(err.stack); + req.destroy(); + return; + } + + // 500 + err.status = 500; + self.emit('error', err); + }); + + // end + stream.on('end', function(){ + self.emit('end'); + }); +}; + +/** + * Set content-type based on `path` + * if it hasn't been explicitly set. + * + * @param {String} path + * @api private + */ + +SendStream.prototype.type = function(path){ + var res = this.res; + if (res.getHeader('Content-Type')) return; + var type = mime.lookup(path); + var charset = mime.charsets.lookup(type); + debug('content-type %s', type); + res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : '')); +}; + +/** + * Set reaponse header fields, most + * fields may be pre-defined. + * + * @param {Object} stat + * @api private + */ + +SendStream.prototype.setHeader = function(stat){ + var res = this.res; + if (!res.getHeader('Accept-Ranges')) res.setHeader('Accept-Ranges', 'bytes'); + if (!res.getHeader('ETag')) res.setHeader('ETag', utils.etag(stat)); + if (!res.getHeader('Date')) res.setHeader('Date', new Date().toUTCString()); + if (!res.getHeader('Cache-Control')) res.setHeader('Cache-Control', 'public, max-age=' + (this._maxage / 1000)); + if (!res.getHeader('Last-Modified')) res.setHeader('Last-Modified', stat.mtime.toUTCString()); +}; diff --git a/realtime/node_modules/express/node_modules/send/lib/utils.js b/realtime/node_modules/express/node_modules/send/lib/utils.js new file mode 100644 index 00000000..950e5a2c --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/lib/utils.js @@ -0,0 +1,47 @@ + +/** + * Return an ETag in the form of `"-"` + * from the given `stat`. + * + * @param {Object} stat + * @return {String} + * @api private + */ + +exports.etag = function(stat) { + return '"' + stat.size + '-' + Number(stat.mtime) + '"'; +}; + +/** + * decodeURIComponent. + * + * Allows V8 to only deoptimize this fn instead of all + * of send(). + * + * @param {String} path + * @api private + */ + +exports.decode = function(path){ + try { + return decodeURIComponent(path); + } catch (err) { + return -1; + } +}; + +/** + * Escape the given string of `html`. + * + * @param {String} html + * @return {String} + * @api private + */ + +exports.escape = function(html){ + return String(html) + .replace(/&(?!\w+;)/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); +}; \ No newline at end of file diff --git a/realtime/node_modules/express/node_modules/send/node_modules/mime/LICENSE b/realtime/node_modules/express/node_modules/send/node_modules/mime/LICENSE new file mode 100644 index 00000000..451fc455 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/node_modules/mime/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010 Benjamin Thomas, Robert Kieffer + +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. diff --git a/realtime/node_modules/express/node_modules/send/node_modules/mime/README.md b/realtime/node_modules/express/node_modules/send/node_modules/mime/README.md new file mode 100644 index 00000000..6ca19bd1 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/node_modules/mime/README.md @@ -0,0 +1,66 @@ +# mime + +Comprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community. + +## Install + +Install with [npm](http://github.com/isaacs/npm): + + npm install mime + +## API - Queries + +### mime.lookup(path) +Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g. + + var mime = require('mime'); + + mime.lookup('/path/to/file.txt'); // => 'text/plain' + mime.lookup('file.txt'); // => 'text/plain' + mime.lookup('.TXT'); // => 'text/plain' + mime.lookup('htm'); // => 'text/html' + +### mime.default_type +Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.) + +### mime.extension(type) +Get the default extension for `type` + + mime.extension('text/html'); // => 'html' + mime.extension('application/octet-stream'); // => 'bin' + +### mime.charsets.lookup() + +Map mime-type to charset + + mime.charsets.lookup('text/plain'); // => 'UTF-8' + +(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.) + +## API - Defining Custom Types + +The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types). + +### mime.define() + +Add custom mime/extension mappings + + mime.define({ + 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'], + 'application/x-my-type': ['x-mt', 'x-mtt'], + // etc ... + }); + + mime.lookup('x-sft'); // => 'text/x-some-format' + +The first entry in the extensions array is returned by `mime.extension()`. E.g. + + mime.extension('text/x-some-format'); // => 'x-sf' + +### mime.load(filepath) + +Load mappings from an Apache ".types" format file + + mime.load('./my_project.types'); + +The .types file format is simple - See the `types` dir for examples. diff --git a/realtime/node_modules/express/node_modules/send/node_modules/mime/mime.js b/realtime/node_modules/express/node_modules/send/node_modules/mime/mime.js new file mode 100644 index 00000000..48be0c5e --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/node_modules/mime/mime.js @@ -0,0 +1,114 @@ +var path = require('path'); +var fs = require('fs'); + +function Mime() { + // Map of extension -> mime type + this.types = Object.create(null); + + // Map of mime type -> extension + this.extensions = Object.create(null); +} + +/** + * Define mimetype -> extension mappings. Each key is a mime-type that maps + * to an array of extensions associated with the type. The first extension is + * used as the default extension for the type. + * + * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); + * + * @param map (Object) type definitions + */ +Mime.prototype.define = function (map) { + for (var type in map) { + var exts = map[type]; + + for (var i = 0; i < exts.length; i++) { + if (process.env.DEBUG_MIME && this.types[exts]) { + console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' + + this.types[exts] + ' to ' + type); + } + + this.types[exts[i]] = type; + } + + // Default extension is the first one we encounter + if (!this.extensions[type]) { + this.extensions[type] = exts[0]; + } + } +}; + +/** + * Load an Apache2-style ".types" file + * + * This may be called multiple times (it's expected). Where files declare + * overlapping types/extensions, the last file wins. + * + * @param file (String) path of file to load. + */ +Mime.prototype.load = function(file) { + + this._loading = file; + // Read file and split into lines + var map = {}, + content = fs.readFileSync(file, 'ascii'), + lines = content.split(/[\r\n]+/); + + lines.forEach(function(line) { + // Clean up whitespace/comments, and split into fields + var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/); + map[fields.shift()] = fields; + }); + + this.define(map); + + this._loading = null; +}; + +/** + * Lookup a mime type based on extension + */ +Mime.prototype.lookup = function(path, fallback) { + var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase(); + + return this.types[ext] || fallback || this.default_type; +}; + +/** + * Return file extension associated with a mime type + */ +Mime.prototype.extension = function(mimeType) { + var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase(); + return this.extensions[type]; +}; + +// Default instance +var mime = new Mime(); + +// Load local copy of +// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types +mime.load(path.join(__dirname, 'types/mime.types')); + +// Load additional types from node.js community +mime.load(path.join(__dirname, 'types/node.types')); + +// Default type +mime.default_type = mime.lookup('bin'); + +// +// Additional API specific to the default instance +// + +mime.Mime = Mime; + +/** + * Lookup a charset based on mime type. + */ +mime.charsets = { + lookup: function(mimeType, fallback) { + // Assume text types are utf8 + return (/^text\//).test(mimeType) ? 'UTF-8' : fallback; + } +}; + +module.exports = mime; diff --git a/realtime/node_modules/express/node_modules/send/node_modules/mime/package.json b/realtime/node_modules/express/node_modules/send/node_modules/mime/package.json new file mode 100644 index 00000000..1644767f --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/node_modules/mime/package.json @@ -0,0 +1,32 @@ +{ + "author": { + "name": "Robert Kieffer", + "email": "robert@broofa.com", + "url": "http://github.com/broofa" + }, + "contributors": [ + { + "name": "Benjamin Thomas", + "email": "benjamin@benjaminthomas.org", + "url": "http://github.com/bentomas" + } + ], + "dependencies": {}, + "description": "A comprehensive library for mime-type mapping", + "devDependencies": {}, + "keywords": [ + "util", + "mime" + ], + "main": "mime.js", + "name": "mime", + "repository": { + "url": "https://github.com/broofa/node-mime", + "type": "git" + }, + "version": "1.2.11", + "readme": "# mime\n\nComprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.\n\n## Install\n\nInstall with [npm](http://github.com/isaacs/npm):\n\n npm install mime\n\n## API - Queries\n\n### mime.lookup(path)\nGet the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.\n\n var mime = require('mime');\n\n mime.lookup('/path/to/file.txt'); // => 'text/plain'\n mime.lookup('file.txt'); // => 'text/plain'\n mime.lookup('.TXT'); // => 'text/plain'\n mime.lookup('htm'); // => 'text/html'\n\n### mime.default_type\nSets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)\n\n### mime.extension(type)\nGet the default extension for `type`\n\n mime.extension('text/html'); // => 'html'\n mime.extension('application/octet-stream'); // => 'bin'\n\n### mime.charsets.lookup()\n\nMap mime-type to charset\n\n mime.charsets.lookup('text/plain'); // => 'UTF-8'\n\n(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)\n\n## API - Defining Custom Types\n\nThe following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).\n\n### mime.define()\n\nAdd custom mime/extension mappings\n\n mime.define({\n 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],\n 'application/x-my-type': ['x-mt', 'x-mtt'],\n // etc ...\n });\n\n mime.lookup('x-sft'); // => 'text/x-some-format'\n\nThe first entry in the extensions array is returned by `mime.extension()`. E.g.\n\n mime.extension('text/x-some-format'); // => 'x-sf'\n\n### mime.load(filepath)\n\nLoad mappings from an Apache \".types\" format file\n\n mime.load('./my_project.types');\n\nThe .types file format is simple - See the `types` dir for examples.\n", + "readmeFilename": "README.md", + "_id": "mime@1.2.11", + "_from": "mime@~1.2.9" +} diff --git a/realtime/node_modules/express/node_modules/send/node_modules/mime/test.js b/realtime/node_modules/express/node_modules/send/node_modules/mime/test.js new file mode 100644 index 00000000..2cda1c7a --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/node_modules/mime/test.js @@ -0,0 +1,84 @@ +/** + * Usage: node test.js + */ + +var mime = require('./mime'); +var assert = require('assert'); +var path = require('path'); + +function eq(a, b) { + console.log('Test: ' + a + ' === ' + b); + assert.strictEqual.apply(null, arguments); +} + +console.log(Object.keys(mime.extensions).length + ' types'); +console.log(Object.keys(mime.types).length + ' extensions\n'); + +// +// Test mime lookups +// + +eq('text/plain', mime.lookup('text.txt')); // normal file +eq('text/plain', mime.lookup('TEXT.TXT')); // uppercase +eq('text/plain', mime.lookup('dir/text.txt')); // dir + file +eq('text/plain', mime.lookup('.text.txt')); // hidden file +eq('text/plain', mime.lookup('.txt')); // nameless +eq('text/plain', mime.lookup('txt')); // extension-only +eq('text/plain', mime.lookup('/txt')); // extension-less () +eq('text/plain', mime.lookup('\\txt')); // Windows, extension-less +eq('application/octet-stream', mime.lookup('text.nope')); // unrecognized +eq('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default + +// +// Test extensions +// + +eq('txt', mime.extension(mime.types.text)); +eq('html', mime.extension(mime.types.htm)); +eq('bin', mime.extension('application/octet-stream')); +eq('bin', mime.extension('application/octet-stream ')); +eq('html', mime.extension(' text/html; charset=UTF-8')); +eq('html', mime.extension('text/html; charset=UTF-8 ')); +eq('html', mime.extension('text/html; charset=UTF-8')); +eq('html', mime.extension('text/html ; charset=UTF-8')); +eq('html', mime.extension('text/html;charset=UTF-8')); +eq('html', mime.extension('text/Html;charset=UTF-8')); +eq(undefined, mime.extension('unrecognized')); + +// +// Test node.types lookups +// + +eq('application/font-woff', mime.lookup('file.woff')); +eq('application/octet-stream', mime.lookup('file.buffer')); +eq('audio/mp4', mime.lookup('file.m4a')); +eq('font/opentype', mime.lookup('file.otf')); + +// +// Test charsets +// + +eq('UTF-8', mime.charsets.lookup('text/plain')); +eq(undefined, mime.charsets.lookup(mime.types.js)); +eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback')); + +// +// Test for overlaps between mime.types and node.types +// + +var apacheTypes = new mime.Mime(), nodeTypes = new mime.Mime(); +apacheTypes.load(path.join(__dirname, 'types/mime.types')); +nodeTypes.load(path.join(__dirname, 'types/node.types')); + +var keys = [].concat(Object.keys(apacheTypes.types)) + .concat(Object.keys(nodeTypes.types)); +keys.sort(); +for (var i = 1; i < keys.length; i++) { + if (keys[i] == keys[i-1]) { + console.warn('Warning: ' + + 'node.types defines ' + keys[i] + '->' + nodeTypes.types[keys[i]] + + ', mime.types defines ' + keys[i] + '->' + apacheTypes.types[keys[i]]); + } +} + +console.log('\nOK'); diff --git a/realtime/node_modules/express/node_modules/send/node_modules/mime/types/mime.types b/realtime/node_modules/express/node_modules/send/node_modules/mime/types/mime.types new file mode 100644 index 00000000..da8cd691 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/node_modules/mime/types/mime.types @@ -0,0 +1,1588 @@ +# This file maps Internet media types to unique file extension(s). +# Although created for httpd, this file is used by many software systems +# and has been placed in the public domain for unlimited redisribution. +# +# The table below contains both registered and (common) unregistered types. +# A type that has no unique extension can be ignored -- they are listed +# here to guide configurations toward known types and to make it easier to +# identify "new" types. File extensions are also commonly used to indicate +# content languages and encodings, so choose them carefully. +# +# Internet media types should be registered as described in RFC 4288. +# The registry is at . +# +# MIME type (lowercased) Extensions +# ============================================ ========== +# application/1d-interleaved-parityfec +# application/3gpp-ims+xml +# application/activemessage +application/andrew-inset ez +# application/applefile +application/applixware aw +application/atom+xml atom +application/atomcat+xml atomcat +# application/atomicmail +application/atomsvc+xml atomsvc +# application/auth-policy+xml +# application/batch-smtp +# application/beep+xml +# application/calendar+xml +# application/cals-1840 +# application/ccmp+xml +application/ccxml+xml ccxml +application/cdmi-capability cdmia +application/cdmi-container cdmic +application/cdmi-domain cdmid +application/cdmi-object cdmio +application/cdmi-queue cdmiq +# application/cea-2018+xml +# application/cellml+xml +# application/cfw +# application/cnrp+xml +# application/commonground +# application/conference-info+xml +# application/cpl+xml +# application/csta+xml +# application/cstadata+xml +application/cu-seeme cu +# application/cybercash +application/davmount+xml davmount +# application/dca-rft +# application/dec-dx +# application/dialog-info+xml +# application/dicom +# application/dns +application/docbook+xml dbk +# application/dskpp+xml +application/dssc+der dssc +application/dssc+xml xdssc +# application/dvcs +application/ecmascript ecma +# application/edi-consent +# application/edi-x12 +# application/edifact +application/emma+xml emma +# application/epp+xml +application/epub+zip epub +# application/eshop +# application/example +application/exi exi +# application/fastinfoset +# application/fastsoap +# application/fits +application/font-tdpfr pfr +# application/framework-attributes+xml +application/gml+xml gml +application/gpx+xml gpx +application/gxf gxf +# application/h224 +# application/held+xml +# application/http +application/hyperstudio stk +# application/ibe-key-request+xml +# application/ibe-pkg-reply+xml +# application/ibe-pp-data +# application/iges +# application/im-iscomposing+xml +# application/index +# application/index.cmd +# application/index.obj +# application/index.response +# application/index.vnd +application/inkml+xml ink inkml +# application/iotp +application/ipfix ipfix +# application/ipp +# application/isup +application/java-archive jar +application/java-serialized-object ser +application/java-vm class +application/javascript js +application/json json +application/jsonml+json jsonml +# application/kpml-request+xml +# application/kpml-response+xml +application/lost+xml lostxml +application/mac-binhex40 hqx +application/mac-compactpro cpt +# application/macwriteii +application/mads+xml mads +application/marc mrc +application/marcxml+xml mrcx +application/mathematica ma nb mb +# application/mathml-content+xml +# application/mathml-presentation+xml +application/mathml+xml mathml +# application/mbms-associated-procedure-description+xml +# application/mbms-deregister+xml +# application/mbms-envelope+xml +# application/mbms-msk+xml +# application/mbms-msk-response+xml +# application/mbms-protection-description+xml +# application/mbms-reception-report+xml +# application/mbms-register+xml +# application/mbms-register-response+xml +# application/mbms-user-service-description+xml +application/mbox mbox +# application/media_control+xml +application/mediaservercontrol+xml mscml +application/metalink+xml metalink +application/metalink4+xml meta4 +application/mets+xml mets +# application/mikey +application/mods+xml mods +# application/moss-keys +# application/moss-signature +# application/mosskey-data +# application/mosskey-request +application/mp21 m21 mp21 +application/mp4 mp4s +# application/mpeg4-generic +# application/mpeg4-iod +# application/mpeg4-iod-xmt +# application/msc-ivr+xml +# application/msc-mixer+xml +application/msword doc dot +application/mxf mxf +# application/nasdata +# application/news-checkgroups +# application/news-groupinfo +# application/news-transmission +# application/nss +# application/ocsp-request +# application/ocsp-response +application/octet-stream bin dms lrf mar so dist distz pkg bpk dump elc deploy +application/oda oda +application/oebps-package+xml opf +application/ogg ogx +application/omdoc+xml omdoc +application/onenote onetoc onetoc2 onetmp onepkg +application/oxps oxps +# application/parityfec +application/patch-ops-error+xml xer +application/pdf pdf +application/pgp-encrypted pgp +# application/pgp-keys +application/pgp-signature asc sig +application/pics-rules prf +# application/pidf+xml +# application/pidf-diff+xml +application/pkcs10 p10 +application/pkcs7-mime p7m p7c +application/pkcs7-signature p7s +application/pkcs8 p8 +application/pkix-attr-cert ac +application/pkix-cert cer +application/pkix-crl crl +application/pkix-pkipath pkipath +application/pkixcmp pki +application/pls+xml pls +# application/poc-settings+xml +application/postscript ai eps ps +# application/prs.alvestrand.titrax-sheet +application/prs.cww cww +# application/prs.nprend +# application/prs.plucker +# application/prs.rdf-xml-crypt +# application/prs.xsf+xml +application/pskc+xml pskcxml +# application/qsig +application/rdf+xml rdf +application/reginfo+xml rif +application/relax-ng-compact-syntax rnc +# application/remote-printing +application/resource-lists+xml rl +application/resource-lists-diff+xml rld +# application/riscos +# application/rlmi+xml +application/rls-services+xml rs +application/rpki-ghostbusters gbr +application/rpki-manifest mft +application/rpki-roa roa +# application/rpki-updown +application/rsd+xml rsd +application/rss+xml rss +application/rtf rtf +# application/rtx +# application/samlassertion+xml +# application/samlmetadata+xml +application/sbml+xml sbml +application/scvp-cv-request scq +application/scvp-cv-response scs +application/scvp-vp-request spq +application/scvp-vp-response spp +application/sdp sdp +# application/set-payment +application/set-payment-initiation setpay +# application/set-registration +application/set-registration-initiation setreg +# application/sgml +# application/sgml-open-catalog +application/shf+xml shf +# application/sieve +# application/simple-filter+xml +# application/simple-message-summary +# application/simplesymbolcontainer +# application/slate +# application/smil +application/smil+xml smi smil +# application/soap+fastinfoset +# application/soap+xml +application/sparql-query rq +application/sparql-results+xml srx +# application/spirits-event+xml +application/srgs gram +application/srgs+xml grxml +application/sru+xml sru +application/ssdl+xml ssdl +application/ssml+xml ssml +# application/tamp-apex-update +# application/tamp-apex-update-confirm +# application/tamp-community-update +# application/tamp-community-update-confirm +# application/tamp-error +# application/tamp-sequence-adjust +# application/tamp-sequence-adjust-confirm +# application/tamp-status-query +# application/tamp-status-response +# application/tamp-update +# application/tamp-update-confirm +application/tei+xml tei teicorpus +application/thraud+xml tfi +# application/timestamp-query +# application/timestamp-reply +application/timestamped-data tsd +# application/tve-trigger +# application/ulpfec +# application/vcard+xml +# application/vemmi +# application/vividence.scriptfile +# application/vnd.3gpp.bsf+xml +application/vnd.3gpp.pic-bw-large plb +application/vnd.3gpp.pic-bw-small psb +application/vnd.3gpp.pic-bw-var pvb +# application/vnd.3gpp.sms +# application/vnd.3gpp2.bcmcsinfo+xml +# application/vnd.3gpp2.sms +application/vnd.3gpp2.tcap tcap +application/vnd.3m.post-it-notes pwn +application/vnd.accpac.simply.aso aso +application/vnd.accpac.simply.imp imp +application/vnd.acucobol acu +application/vnd.acucorp atc acutc +application/vnd.adobe.air-application-installer-package+zip air +application/vnd.adobe.formscentral.fcdt fcdt +application/vnd.adobe.fxp fxp fxpl +# application/vnd.adobe.partial-upload +application/vnd.adobe.xdp+xml xdp +application/vnd.adobe.xfdf xfdf +# application/vnd.aether.imp +# application/vnd.ah-barcode +application/vnd.ahead.space ahead +application/vnd.airzip.filesecure.azf azf +application/vnd.airzip.filesecure.azs azs +application/vnd.amazon.ebook azw +application/vnd.americandynamics.acc acc +application/vnd.amiga.ami ami +# application/vnd.amundsen.maze+xml +application/vnd.android.package-archive apk +application/vnd.anser-web-certificate-issue-initiation cii +application/vnd.anser-web-funds-transfer-initiation fti +application/vnd.antix.game-component atx +application/vnd.apple.installer+xml mpkg +application/vnd.apple.mpegurl m3u8 +# application/vnd.arastra.swi +application/vnd.aristanetworks.swi swi +application/vnd.astraea-software.iota iota +application/vnd.audiograph aep +# application/vnd.autopackage +# application/vnd.avistar+xml +application/vnd.blueice.multipass mpm +# application/vnd.bluetooth.ep.oob +application/vnd.bmi bmi +application/vnd.businessobjects rep +# application/vnd.cab-jscript +# application/vnd.canon-cpdl +# application/vnd.canon-lips +# application/vnd.cendio.thinlinc.clientconf +application/vnd.chemdraw+xml cdxml +application/vnd.chipnuts.karaoke-mmd mmd +application/vnd.cinderella cdy +# application/vnd.cirpack.isdn-ext +application/vnd.claymore cla +application/vnd.cloanto.rp9 rp9 +application/vnd.clonk.c4group c4g c4d c4f c4p c4u +application/vnd.cluetrust.cartomobile-config c11amc +application/vnd.cluetrust.cartomobile-config-pkg c11amz +# application/vnd.collection+json +# application/vnd.commerce-battelle +application/vnd.commonspace csp +application/vnd.contact.cmsg cdbcmsg +application/vnd.cosmocaller cmc +application/vnd.crick.clicker clkx +application/vnd.crick.clicker.keyboard clkk +application/vnd.crick.clicker.palette clkp +application/vnd.crick.clicker.template clkt +application/vnd.crick.clicker.wordbank clkw +application/vnd.criticaltools.wbs+xml wbs +application/vnd.ctc-posml pml +# application/vnd.ctct.ws+xml +# application/vnd.cups-pdf +# application/vnd.cups-postscript +application/vnd.cups-ppd ppd +# application/vnd.cups-raster +# application/vnd.cups-raw +# application/vnd.curl +application/vnd.curl.car car +application/vnd.curl.pcurl pcurl +# application/vnd.cybank +application/vnd.dart dart +application/vnd.data-vision.rdz rdz +application/vnd.dece.data uvf uvvf uvd uvvd +application/vnd.dece.ttml+xml uvt uvvt +application/vnd.dece.unspecified uvx uvvx +application/vnd.dece.zip uvz uvvz +application/vnd.denovo.fcselayout-link fe_launch +# application/vnd.dir-bi.plate-dl-nosuffix +application/vnd.dna dna +application/vnd.dolby.mlp mlp +# application/vnd.dolby.mobile.1 +# application/vnd.dolby.mobile.2 +application/vnd.dpgraph dpg +application/vnd.dreamfactory dfac +application/vnd.ds-keypoint kpxx +application/vnd.dvb.ait ait +# application/vnd.dvb.dvbj +# application/vnd.dvb.esgcontainer +# application/vnd.dvb.ipdcdftnotifaccess +# application/vnd.dvb.ipdcesgaccess +# application/vnd.dvb.ipdcesgaccess2 +# application/vnd.dvb.ipdcesgpdd +# application/vnd.dvb.ipdcroaming +# application/vnd.dvb.iptv.alfec-base +# application/vnd.dvb.iptv.alfec-enhancement +# application/vnd.dvb.notif-aggregate-root+xml +# application/vnd.dvb.notif-container+xml +# application/vnd.dvb.notif-generic+xml +# application/vnd.dvb.notif-ia-msglist+xml +# application/vnd.dvb.notif-ia-registration-request+xml +# application/vnd.dvb.notif-ia-registration-response+xml +# application/vnd.dvb.notif-init+xml +# application/vnd.dvb.pfr +application/vnd.dvb.service svc +# application/vnd.dxr +application/vnd.dynageo geo +# application/vnd.easykaraoke.cdgdownload +# application/vnd.ecdis-update +application/vnd.ecowin.chart mag +# application/vnd.ecowin.filerequest +# application/vnd.ecowin.fileupdate +# application/vnd.ecowin.series +# application/vnd.ecowin.seriesrequest +# application/vnd.ecowin.seriesupdate +# application/vnd.emclient.accessrequest+xml +application/vnd.enliven nml +# application/vnd.eprints.data+xml +application/vnd.epson.esf esf +application/vnd.epson.msf msf +application/vnd.epson.quickanime qam +application/vnd.epson.salt slt +application/vnd.epson.ssf ssf +# application/vnd.ericsson.quickcall +application/vnd.eszigno3+xml es3 et3 +# application/vnd.etsi.aoc+xml +# application/vnd.etsi.cug+xml +# application/vnd.etsi.iptvcommand+xml +# application/vnd.etsi.iptvdiscovery+xml +# application/vnd.etsi.iptvprofile+xml +# application/vnd.etsi.iptvsad-bc+xml +# application/vnd.etsi.iptvsad-cod+xml +# application/vnd.etsi.iptvsad-npvr+xml +# application/vnd.etsi.iptvservice+xml +# application/vnd.etsi.iptvsync+xml +# application/vnd.etsi.iptvueprofile+xml +# application/vnd.etsi.mcid+xml +# application/vnd.etsi.overload-control-policy-dataset+xml +# application/vnd.etsi.sci+xml +# application/vnd.etsi.simservs+xml +# application/vnd.etsi.tsl+xml +# application/vnd.etsi.tsl.der +# application/vnd.eudora.data +application/vnd.ezpix-album ez2 +application/vnd.ezpix-package ez3 +# application/vnd.f-secure.mobile +application/vnd.fdf fdf +application/vnd.fdsn.mseed mseed +application/vnd.fdsn.seed seed dataless +# application/vnd.ffsns +# application/vnd.fints +application/vnd.flographit gph +application/vnd.fluxtime.clip ftc +# application/vnd.font-fontforge-sfd +application/vnd.framemaker fm frame maker book +application/vnd.frogans.fnc fnc +application/vnd.frogans.ltf ltf +application/vnd.fsc.weblaunch fsc +application/vnd.fujitsu.oasys oas +application/vnd.fujitsu.oasys2 oa2 +application/vnd.fujitsu.oasys3 oa3 +application/vnd.fujitsu.oasysgp fg5 +application/vnd.fujitsu.oasysprs bh2 +# application/vnd.fujixerox.art-ex +# application/vnd.fujixerox.art4 +# application/vnd.fujixerox.hbpl +application/vnd.fujixerox.ddd ddd +application/vnd.fujixerox.docuworks xdw +application/vnd.fujixerox.docuworks.binder xbd +# application/vnd.fut-misnet +application/vnd.fuzzysheet fzs +application/vnd.genomatix.tuxedo txd +# application/vnd.geocube+xml +application/vnd.geogebra.file ggb +application/vnd.geogebra.tool ggt +application/vnd.geometry-explorer gex gre +application/vnd.geonext gxt +application/vnd.geoplan g2w +application/vnd.geospace g3w +# application/vnd.globalplatform.card-content-mgt +# application/vnd.globalplatform.card-content-mgt-response +application/vnd.gmx gmx +application/vnd.google-earth.kml+xml kml +application/vnd.google-earth.kmz kmz +application/vnd.grafeq gqf gqs +# application/vnd.gridmp +application/vnd.groove-account gac +application/vnd.groove-help ghf +application/vnd.groove-identity-message gim +application/vnd.groove-injector grv +application/vnd.groove-tool-message gtm +application/vnd.groove-tool-template tpl +application/vnd.groove-vcard vcg +# application/vnd.hal+json +application/vnd.hal+xml hal +application/vnd.handheld-entertainment+xml zmm +application/vnd.hbci hbci +# application/vnd.hcl-bireports +application/vnd.hhe.lesson-player les +application/vnd.hp-hpgl hpgl +application/vnd.hp-hpid hpid +application/vnd.hp-hps hps +application/vnd.hp-jlyt jlt +application/vnd.hp-pcl pcl +application/vnd.hp-pclxl pclxl +# application/vnd.httphone +application/vnd.hydrostatix.sof-data sfd-hdstx +# application/vnd.hzn-3d-crossword +# application/vnd.ibm.afplinedata +# application/vnd.ibm.electronic-media +application/vnd.ibm.minipay mpy +application/vnd.ibm.modcap afp listafp list3820 +application/vnd.ibm.rights-management irm +application/vnd.ibm.secure-container sc +application/vnd.iccprofile icc icm +application/vnd.igloader igl +application/vnd.immervision-ivp ivp +application/vnd.immervision-ivu ivu +# application/vnd.informedcontrol.rms+xml +# application/vnd.informix-visionary +# application/vnd.infotech.project +# application/vnd.infotech.project+xml +# application/vnd.innopath.wamp.notification +application/vnd.insors.igm igm +application/vnd.intercon.formnet xpw xpx +application/vnd.intergeo i2g +# application/vnd.intertrust.digibox +# application/vnd.intertrust.nncp +application/vnd.intu.qbo qbo +application/vnd.intu.qfx qfx +# application/vnd.iptc.g2.conceptitem+xml +# application/vnd.iptc.g2.knowledgeitem+xml +# application/vnd.iptc.g2.newsitem+xml +# application/vnd.iptc.g2.newsmessage+xml +# application/vnd.iptc.g2.packageitem+xml +# application/vnd.iptc.g2.planningitem+xml +application/vnd.ipunplugged.rcprofile rcprofile +application/vnd.irepository.package+xml irp +application/vnd.is-xpr xpr +application/vnd.isac.fcs fcs +application/vnd.jam jam +# application/vnd.japannet-directory-service +# application/vnd.japannet-jpnstore-wakeup +# application/vnd.japannet-payment-wakeup +# application/vnd.japannet-registration +# application/vnd.japannet-registration-wakeup +# application/vnd.japannet-setstore-wakeup +# application/vnd.japannet-verification +# application/vnd.japannet-verification-wakeup +application/vnd.jcp.javame.midlet-rms rms +application/vnd.jisp jisp +application/vnd.joost.joda-archive joda +application/vnd.kahootz ktz ktr +application/vnd.kde.karbon karbon +application/vnd.kde.kchart chrt +application/vnd.kde.kformula kfo +application/vnd.kde.kivio flw +application/vnd.kde.kontour kon +application/vnd.kde.kpresenter kpr kpt +application/vnd.kde.kspread ksp +application/vnd.kde.kword kwd kwt +application/vnd.kenameaapp htke +application/vnd.kidspiration kia +application/vnd.kinar kne knp +application/vnd.koan skp skd skt skm +application/vnd.kodak-descriptor sse +application/vnd.las.las+xml lasxml +# application/vnd.liberty-request+xml +application/vnd.llamagraphics.life-balance.desktop lbd +application/vnd.llamagraphics.life-balance.exchange+xml lbe +application/vnd.lotus-1-2-3 123 +application/vnd.lotus-approach apr +application/vnd.lotus-freelance pre +application/vnd.lotus-notes nsf +application/vnd.lotus-organizer org +application/vnd.lotus-screencam scm +application/vnd.lotus-wordpro lwp +application/vnd.macports.portpkg portpkg +# application/vnd.marlin.drm.actiontoken+xml +# application/vnd.marlin.drm.conftoken+xml +# application/vnd.marlin.drm.license+xml +# application/vnd.marlin.drm.mdcf +application/vnd.mcd mcd +application/vnd.medcalcdata mc1 +application/vnd.mediastation.cdkey cdkey +# application/vnd.meridian-slingshot +application/vnd.mfer mwf +application/vnd.mfmp mfm +application/vnd.micrografx.flo flo +application/vnd.micrografx.igx igx +application/vnd.mif mif +# application/vnd.minisoft-hp3000-save +# application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf daf +application/vnd.mobius.dis dis +application/vnd.mobius.mbk mbk +application/vnd.mobius.mqy mqy +application/vnd.mobius.msl msl +application/vnd.mobius.plc plc +application/vnd.mobius.txf txf +application/vnd.mophun.application mpn +application/vnd.mophun.certificate mpc +# application/vnd.motorola.flexsuite +# application/vnd.motorola.flexsuite.adsi +# application/vnd.motorola.flexsuite.fis +# application/vnd.motorola.flexsuite.gotap +# application/vnd.motorola.flexsuite.kmr +# application/vnd.motorola.flexsuite.ttc +# application/vnd.motorola.flexsuite.wem +# application/vnd.motorola.iprm +application/vnd.mozilla.xul+xml xul +application/vnd.ms-artgalry cil +# application/vnd.ms-asf +application/vnd.ms-cab-compressed cab +# application/vnd.ms-color.iccprofile +application/vnd.ms-excel xls xlm xla xlc xlt xlw +application/vnd.ms-excel.addin.macroenabled.12 xlam +application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb +application/vnd.ms-excel.sheet.macroenabled.12 xlsm +application/vnd.ms-excel.template.macroenabled.12 xltm +application/vnd.ms-fontobject eot +application/vnd.ms-htmlhelp chm +application/vnd.ms-ims ims +application/vnd.ms-lrm lrm +# application/vnd.ms-office.activex+xml +application/vnd.ms-officetheme thmx +# application/vnd.ms-opentype +# application/vnd.ms-package.obfuscated-opentype +application/vnd.ms-pki.seccat cat +application/vnd.ms-pki.stl stl +# application/vnd.ms-playready.initiator+xml +application/vnd.ms-powerpoint ppt pps pot +application/vnd.ms-powerpoint.addin.macroenabled.12 ppam +application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm +application/vnd.ms-powerpoint.slide.macroenabled.12 sldm +application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm +application/vnd.ms-powerpoint.template.macroenabled.12 potm +# application/vnd.ms-printing.printticket+xml +application/vnd.ms-project mpp mpt +# application/vnd.ms-tnef +# application/vnd.ms-wmdrm.lic-chlg-req +# application/vnd.ms-wmdrm.lic-resp +# application/vnd.ms-wmdrm.meter-chlg-req +# application/vnd.ms-wmdrm.meter-resp +application/vnd.ms-word.document.macroenabled.12 docm +application/vnd.ms-word.template.macroenabled.12 dotm +application/vnd.ms-works wps wks wcm wdb +application/vnd.ms-wpl wpl +application/vnd.ms-xpsdocument xps +application/vnd.mseq mseq +# application/vnd.msign +# application/vnd.multiad.creator +# application/vnd.multiad.creator.cif +# application/vnd.music-niff +application/vnd.musician mus +application/vnd.muvee.style msty +application/vnd.mynfc taglet +# application/vnd.ncd.control +# application/vnd.ncd.reference +# application/vnd.nervana +# application/vnd.netfpx +application/vnd.neurolanguage.nlu nlu +application/vnd.nitf ntf nitf +application/vnd.noblenet-directory nnd +application/vnd.noblenet-sealer nns +application/vnd.noblenet-web nnw +# application/vnd.nokia.catalogs +# application/vnd.nokia.conml+wbxml +# application/vnd.nokia.conml+xml +# application/vnd.nokia.isds-radio-presets +# application/vnd.nokia.iptv.config+xml +# application/vnd.nokia.landmark+wbxml +# application/vnd.nokia.landmark+xml +# application/vnd.nokia.landmarkcollection+xml +# application/vnd.nokia.n-gage.ac+xml +application/vnd.nokia.n-gage.data ngdat +application/vnd.nokia.n-gage.symbian.install n-gage +# application/vnd.nokia.ncd +# application/vnd.nokia.pcd+wbxml +# application/vnd.nokia.pcd+xml +application/vnd.nokia.radio-preset rpst +application/vnd.nokia.radio-presets rpss +application/vnd.novadigm.edm edm +application/vnd.novadigm.edx edx +application/vnd.novadigm.ext ext +# application/vnd.ntt-local.file-transfer +# application/vnd.ntt-local.sip-ta_remote +# application/vnd.ntt-local.sip-ta_tcp_stream +application/vnd.oasis.opendocument.chart odc +application/vnd.oasis.opendocument.chart-template otc +application/vnd.oasis.opendocument.database odb +application/vnd.oasis.opendocument.formula odf +application/vnd.oasis.opendocument.formula-template odft +application/vnd.oasis.opendocument.graphics odg +application/vnd.oasis.opendocument.graphics-template otg +application/vnd.oasis.opendocument.image odi +application/vnd.oasis.opendocument.image-template oti +application/vnd.oasis.opendocument.presentation odp +application/vnd.oasis.opendocument.presentation-template otp +application/vnd.oasis.opendocument.spreadsheet ods +application/vnd.oasis.opendocument.spreadsheet-template ots +application/vnd.oasis.opendocument.text odt +application/vnd.oasis.opendocument.text-master odm +application/vnd.oasis.opendocument.text-template ott +application/vnd.oasis.opendocument.text-web oth +# application/vnd.obn +# application/vnd.oftn.l10n+json +# application/vnd.oipf.contentaccessdownload+xml +# application/vnd.oipf.contentaccessstreaming+xml +# application/vnd.oipf.cspg-hexbinary +# application/vnd.oipf.dae.svg+xml +# application/vnd.oipf.dae.xhtml+xml +# application/vnd.oipf.mippvcontrolmessage+xml +# application/vnd.oipf.pae.gem +# application/vnd.oipf.spdiscovery+xml +# application/vnd.oipf.spdlist+xml +# application/vnd.oipf.ueprofile+xml +# application/vnd.oipf.userprofile+xml +application/vnd.olpc-sugar xo +# application/vnd.oma-scws-config +# application/vnd.oma-scws-http-request +# application/vnd.oma-scws-http-response +# application/vnd.oma.bcast.associated-procedure-parameter+xml +# application/vnd.oma.bcast.drm-trigger+xml +# application/vnd.oma.bcast.imd+xml +# application/vnd.oma.bcast.ltkm +# application/vnd.oma.bcast.notification+xml +# application/vnd.oma.bcast.provisioningtrigger +# application/vnd.oma.bcast.sgboot +# application/vnd.oma.bcast.sgdd+xml +# application/vnd.oma.bcast.sgdu +# application/vnd.oma.bcast.simple-symbol-container +# application/vnd.oma.bcast.smartcard-trigger+xml +# application/vnd.oma.bcast.sprov+xml +# application/vnd.oma.bcast.stkm +# application/vnd.oma.cab-address-book+xml +# application/vnd.oma.cab-feature-handler+xml +# application/vnd.oma.cab-pcc+xml +# application/vnd.oma.cab-user-prefs+xml +# application/vnd.oma.dcd +# application/vnd.oma.dcdc +application/vnd.oma.dd2+xml dd2 +# application/vnd.oma.drm.risd+xml +# application/vnd.oma.group-usage-list+xml +# application/vnd.oma.pal+xml +# application/vnd.oma.poc.detailed-progress-report+xml +# application/vnd.oma.poc.final-report+xml +# application/vnd.oma.poc.groups+xml +# application/vnd.oma.poc.invocation-descriptor+xml +# application/vnd.oma.poc.optimized-progress-report+xml +# application/vnd.oma.push +# application/vnd.oma.scidm.messages+xml +# application/vnd.oma.xcap-directory+xml +# application/vnd.omads-email+xml +# application/vnd.omads-file+xml +# application/vnd.omads-folder+xml +# application/vnd.omaloc-supl-init +application/vnd.openofficeorg.extension oxt +# application/vnd.openxmlformats-officedocument.custom-properties+xml +# application/vnd.openxmlformats-officedocument.customxmlproperties+xml +# application/vnd.openxmlformats-officedocument.drawing+xml +# application/vnd.openxmlformats-officedocument.drawingml.chart+xml +# application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml +# application/vnd.openxmlformats-officedocument.extended-properties+xml +# application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml +# application/vnd.openxmlformats-officedocument.presentationml.comments+xml +# application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml +# application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml +# application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml +application/vnd.openxmlformats-officedocument.presentationml.presentation pptx +# application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml +# application/vnd.openxmlformats-officedocument.presentationml.presprops+xml +application/vnd.openxmlformats-officedocument.presentationml.slide sldx +# application/vnd.openxmlformats-officedocument.presentationml.slide+xml +# application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml +# application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml +application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx +# application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml +# application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml +# application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml +# application/vnd.openxmlformats-officedocument.presentationml.tags+xml +application/vnd.openxmlformats-officedocument.presentationml.template potx +# application/vnd.openxmlformats-officedocument.presentationml.template.main+xml +# application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml +application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx +# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml +application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx +# application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml +# application/vnd.openxmlformats-officedocument.theme+xml +# application/vnd.openxmlformats-officedocument.themeoverride+xml +# application/vnd.openxmlformats-officedocument.vmldrawing +# application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml +application/vnd.openxmlformats-officedocument.wordprocessingml.document docx +# application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml +application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx +# application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml +# application/vnd.openxmlformats-package.core-properties+xml +# application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml +# application/vnd.openxmlformats-package.relationships+xml +# application/vnd.quobject-quoxdocument +# application/vnd.osa.netdeploy +application/vnd.osgeo.mapguide.package mgp +# application/vnd.osgi.bundle +application/vnd.osgi.dp dp +application/vnd.osgi.subsystem esa +# application/vnd.otps.ct-kip+xml +application/vnd.palm pdb pqa oprc +# application/vnd.paos.xml +application/vnd.pawaafile paw +application/vnd.pg.format str +application/vnd.pg.osasli ei6 +# application/vnd.piaccess.application-licence +application/vnd.picsel efif +application/vnd.pmi.widget wg +# application/vnd.poc.group-advertisement+xml +application/vnd.pocketlearn plf +application/vnd.powerbuilder6 pbd +# application/vnd.powerbuilder6-s +# application/vnd.powerbuilder7 +# application/vnd.powerbuilder7-s +# application/vnd.powerbuilder75 +# application/vnd.powerbuilder75-s +# application/vnd.preminet +application/vnd.previewsystems.box box +application/vnd.proteus.magazine mgz +application/vnd.publishare-delta-tree qps +application/vnd.pvi.ptid1 ptid +# application/vnd.pwg-multiplexed +# application/vnd.pwg-xhtml-print+xml +# application/vnd.qualcomm.brew-app-res +application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb +# application/vnd.radisys.moml+xml +# application/vnd.radisys.msml+xml +# application/vnd.radisys.msml-audit+xml +# application/vnd.radisys.msml-audit-conf+xml +# application/vnd.radisys.msml-audit-conn+xml +# application/vnd.radisys.msml-audit-dialog+xml +# application/vnd.radisys.msml-audit-stream+xml +# application/vnd.radisys.msml-conf+xml +# application/vnd.radisys.msml-dialog+xml +# application/vnd.radisys.msml-dialog-base+xml +# application/vnd.radisys.msml-dialog-fax-detect+xml +# application/vnd.radisys.msml-dialog-fax-sendrecv+xml +# application/vnd.radisys.msml-dialog-group+xml +# application/vnd.radisys.msml-dialog-speech+xml +# application/vnd.radisys.msml-dialog-transform+xml +# application/vnd.rainstor.data +# application/vnd.rapid +application/vnd.realvnc.bed bed +application/vnd.recordare.musicxml mxl +application/vnd.recordare.musicxml+xml musicxml +# application/vnd.renlearn.rlprint +application/vnd.rig.cryptonote cryptonote +application/vnd.rim.cod cod +application/vnd.rn-realmedia rm +application/vnd.rn-realmedia-vbr rmvb +application/vnd.route66.link66+xml link66 +# application/vnd.rs-274x +# application/vnd.ruckus.download +# application/vnd.s3sms +application/vnd.sailingtracker.track st +# application/vnd.sbm.cid +# application/vnd.sbm.mid2 +# application/vnd.scribus +# application/vnd.sealed.3df +# application/vnd.sealed.csf +# application/vnd.sealed.doc +# application/vnd.sealed.eml +# application/vnd.sealed.mht +# application/vnd.sealed.net +# application/vnd.sealed.ppt +# application/vnd.sealed.tiff +# application/vnd.sealed.xls +# application/vnd.sealedmedia.softseal.html +# application/vnd.sealedmedia.softseal.pdf +application/vnd.seemail see +application/vnd.sema sema +application/vnd.semd semd +application/vnd.semf semf +application/vnd.shana.informed.formdata ifm +application/vnd.shana.informed.formtemplate itp +application/vnd.shana.informed.interchange iif +application/vnd.shana.informed.package ipk +application/vnd.simtech-mindmapper twd twds +application/vnd.smaf mmf +# application/vnd.smart.notebook +application/vnd.smart.teacher teacher +# application/vnd.software602.filler.form+xml +# application/vnd.software602.filler.form-xml-zip +application/vnd.solent.sdkm+xml sdkm sdkd +application/vnd.spotfire.dxp dxp +application/vnd.spotfire.sfs sfs +# application/vnd.sss-cod +# application/vnd.sss-dtf +# application/vnd.sss-ntf +application/vnd.stardivision.calc sdc +application/vnd.stardivision.draw sda +application/vnd.stardivision.impress sdd +application/vnd.stardivision.math smf +application/vnd.stardivision.writer sdw vor +application/vnd.stardivision.writer-global sgl +application/vnd.stepmania.package smzip +application/vnd.stepmania.stepchart sm +# application/vnd.street-stream +application/vnd.sun.xml.calc sxc +application/vnd.sun.xml.calc.template stc +application/vnd.sun.xml.draw sxd +application/vnd.sun.xml.draw.template std +application/vnd.sun.xml.impress sxi +application/vnd.sun.xml.impress.template sti +application/vnd.sun.xml.math sxm +application/vnd.sun.xml.writer sxw +application/vnd.sun.xml.writer.global sxg +application/vnd.sun.xml.writer.template stw +# application/vnd.sun.wadl+xml +application/vnd.sus-calendar sus susp +application/vnd.svd svd +# application/vnd.swiftview-ics +application/vnd.symbian.install sis sisx +application/vnd.syncml+xml xsm +application/vnd.syncml.dm+wbxml bdm +application/vnd.syncml.dm+xml xdm +# application/vnd.syncml.dm.notification +# application/vnd.syncml.ds.notification +application/vnd.tao.intent-module-archive tao +application/vnd.tcpdump.pcap pcap cap dmp +application/vnd.tmobile-livetv tmo +application/vnd.trid.tpt tpt +application/vnd.triscape.mxs mxs +application/vnd.trueapp tra +# application/vnd.truedoc +# application/vnd.ubisoft.webplayer +application/vnd.ufdl ufd ufdl +application/vnd.uiq.theme utz +application/vnd.umajin umj +application/vnd.unity unityweb +application/vnd.uoml+xml uoml +# application/vnd.uplanet.alert +# application/vnd.uplanet.alert-wbxml +# application/vnd.uplanet.bearer-choice +# application/vnd.uplanet.bearer-choice-wbxml +# application/vnd.uplanet.cacheop +# application/vnd.uplanet.cacheop-wbxml +# application/vnd.uplanet.channel +# application/vnd.uplanet.channel-wbxml +# application/vnd.uplanet.list +# application/vnd.uplanet.list-wbxml +# application/vnd.uplanet.listcmd +# application/vnd.uplanet.listcmd-wbxml +# application/vnd.uplanet.signal +application/vnd.vcx vcx +# application/vnd.vd-study +# application/vnd.vectorworks +# application/vnd.verimatrix.vcas +# application/vnd.vidsoft.vidconference +application/vnd.visio vsd vst vss vsw +application/vnd.visionary vis +# application/vnd.vividence.scriptfile +application/vnd.vsf vsf +# application/vnd.wap.sic +# application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo wtb +# application/vnd.wfa.wsc +# application/vnd.wmc +# application/vnd.wmf.bootstrap +# application/vnd.wolfram.mathematica +# application/vnd.wolfram.mathematica.package +application/vnd.wolfram.player nbp +application/vnd.wordperfect wpd +application/vnd.wqd wqd +# application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf stf +# application/vnd.wv.csp+wbxml +# application/vnd.wv.csp+xml +# application/vnd.wv.ssp+xml +application/vnd.xara xar +application/vnd.xfdl xfdl +# application/vnd.xfdl.webform +# application/vnd.xmi+xml +# application/vnd.xmpie.cpkg +# application/vnd.xmpie.dpkg +# application/vnd.xmpie.plan +# application/vnd.xmpie.ppkg +# application/vnd.xmpie.xlim +application/vnd.yamaha.hv-dic hvd +application/vnd.yamaha.hv-script hvs +application/vnd.yamaha.hv-voice hvp +application/vnd.yamaha.openscoreformat osf +application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg +# application/vnd.yamaha.remote-setup +application/vnd.yamaha.smaf-audio saf +application/vnd.yamaha.smaf-phrase spf +# application/vnd.yamaha.through-ngn +# application/vnd.yamaha.tunnel-udpencap +application/vnd.yellowriver-custom-menu cmp +application/vnd.zul zir zirz +application/vnd.zzazz.deck+xml zaz +application/voicexml+xml vxml +# application/vq-rtcpxr +# application/watcherinfo+xml +# application/whoispp-query +# application/whoispp-response +application/widget wgt +application/winhlp hlp +# application/wita +# application/wordperfect5.1 +application/wsdl+xml wsdl +application/wspolicy+xml wspolicy +application/x-7z-compressed 7z +application/x-abiword abw +application/x-ace-compressed ace +# application/x-amf +application/x-apple-diskimage dmg +application/x-authorware-bin aab x32 u32 vox +application/x-authorware-map aam +application/x-authorware-seg aas +application/x-bcpio bcpio +application/x-bittorrent torrent +application/x-blorb blb blorb +application/x-bzip bz +application/x-bzip2 bz2 boz +application/x-cbr cbr cba cbt cbz cb7 +application/x-cdlink vcd +application/x-cfs-compressed cfs +application/x-chat chat +application/x-chess-pgn pgn +application/x-conference nsc +# application/x-compress +application/x-cpio cpio +application/x-csh csh +application/x-debian-package deb udeb +application/x-dgc-compressed dgc +application/x-director dir dcr dxr cst cct cxt w3d fgd swa +application/x-doom wad +application/x-dtbncx+xml ncx +application/x-dtbook+xml dtb +application/x-dtbresource+xml res +application/x-dvi dvi +application/x-envoy evy +application/x-eva eva +application/x-font-bdf bdf +# application/x-font-dos +# application/x-font-framemaker +application/x-font-ghostscript gsf +# application/x-font-libgrx +application/x-font-linux-psf psf +application/x-font-otf otf +application/x-font-pcf pcf +application/x-font-snf snf +# application/x-font-speedo +# application/x-font-sunos-news +application/x-font-ttf ttf ttc +application/x-font-type1 pfa pfb pfm afm +application/font-woff woff +# application/x-font-vfont +application/x-freearc arc +application/x-futuresplash spl +application/x-gca-compressed gca +application/x-glulx ulx +application/x-gnumeric gnumeric +application/x-gramps-xml gramps +application/x-gtar gtar +# application/x-gzip +application/x-hdf hdf +application/x-install-instructions install +application/x-iso9660-image iso +application/x-java-jnlp-file jnlp +application/x-latex latex +application/x-lzh-compressed lzh lha +application/x-mie mie +application/x-mobipocket-ebook prc mobi +application/x-ms-application application +application/x-ms-shortcut lnk +application/x-ms-wmd wmd +application/x-ms-wmz wmz +application/x-ms-xbap xbap +application/x-msaccess mdb +application/x-msbinder obd +application/x-mscardfile crd +application/x-msclip clp +application/x-msdownload exe dll com bat msi +application/x-msmediaview mvb m13 m14 +application/x-msmetafile wmf wmz emf emz +application/x-msmoney mny +application/x-mspublisher pub +application/x-msschedule scd +application/x-msterminal trm +application/x-mswrite wri +application/x-netcdf nc cdf +application/x-nzb nzb +application/x-pkcs12 p12 pfx +application/x-pkcs7-certificates p7b spc +application/x-pkcs7-certreqresp p7r +application/x-rar-compressed rar +application/x-research-info-systems ris +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-silverlight-app xap +application/x-sql sql +application/x-stuffit sit +application/x-stuffitx sitx +application/x-subrip srt +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-t3vm-image t3 +application/x-tads gam +application/x-tar tar +application/x-tcl tcl +application/x-tex tex +application/x-tex-tfm tfm +application/x-texinfo texinfo texi +application/x-tgif obj +application/x-ustar ustar +application/x-wais-source src +application/x-x509-ca-cert der crt +application/x-xfig fig +application/x-xliff+xml xlf +application/x-xpinstall xpi +application/x-xz xz +application/x-zmachine z1 z2 z3 z4 z5 z6 z7 z8 +# application/x400-bp +application/xaml+xml xaml +# application/xcap-att+xml +# application/xcap-caps+xml +application/xcap-diff+xml xdf +# application/xcap-el+xml +# application/xcap-error+xml +# application/xcap-ns+xml +# application/xcon-conference-info-diff+xml +# application/xcon-conference-info+xml +application/xenc+xml xenc +application/xhtml+xml xhtml xht +# application/xhtml-voice+xml +application/xml xml xsl +application/xml-dtd dtd +# application/xml-external-parsed-entity +# application/xmpp+xml +application/xop+xml xop +application/xproc+xml xpl +application/xslt+xml xslt +application/xspf+xml xspf +application/xv+xml mxml xhvml xvml xvm +application/yang yang +application/yin+xml yin +application/zip zip +# audio/1d-interleaved-parityfec +# audio/32kadpcm +# audio/3gpp +# audio/3gpp2 +# audio/ac3 +audio/adpcm adp +# audio/amr +# audio/amr-wb +# audio/amr-wb+ +# audio/asc +# audio/atrac-advanced-lossless +# audio/atrac-x +# audio/atrac3 +audio/basic au snd +# audio/bv16 +# audio/bv32 +# audio/clearmode +# audio/cn +# audio/dat12 +# audio/dls +# audio/dsr-es201108 +# audio/dsr-es202050 +# audio/dsr-es202211 +# audio/dsr-es202212 +# audio/dv +# audio/dvi4 +# audio/eac3 +# audio/evrc +# audio/evrc-qcp +# audio/evrc0 +# audio/evrc1 +# audio/evrcb +# audio/evrcb0 +# audio/evrcb1 +# audio/evrcwb +# audio/evrcwb0 +# audio/evrcwb1 +# audio/example +# audio/fwdred +# audio/g719 +# audio/g722 +# audio/g7221 +# audio/g723 +# audio/g726-16 +# audio/g726-24 +# audio/g726-32 +# audio/g726-40 +# audio/g728 +# audio/g729 +# audio/g7291 +# audio/g729d +# audio/g729e +# audio/gsm +# audio/gsm-efr +# audio/gsm-hr-08 +# audio/ilbc +# audio/ip-mr_v2.5 +# audio/isac +# audio/l16 +# audio/l20 +# audio/l24 +# audio/l8 +# audio/lpc +audio/midi mid midi kar rmi +# audio/mobile-xmf +audio/mp4 mp4a +# audio/mp4a-latm +# audio/mpa +# audio/mpa-robust +audio/mpeg mpga mp2 mp2a mp3 m2a m3a +# audio/mpeg4-generic +# audio/musepack +audio/ogg oga ogg spx +# audio/opus +# audio/parityfec +# audio/pcma +# audio/pcma-wb +# audio/pcmu-wb +# audio/pcmu +# audio/prs.sid +# audio/qcelp +# audio/red +# audio/rtp-enc-aescm128 +# audio/rtp-midi +# audio/rtx +audio/s3m s3m +audio/silk sil +# audio/smv +# audio/smv0 +# audio/smv-qcp +# audio/sp-midi +# audio/speex +# audio/t140c +# audio/t38 +# audio/telephone-event +# audio/tone +# audio/uemclip +# audio/ulpfec +# audio/vdvi +# audio/vmr-wb +# audio/vnd.3gpp.iufp +# audio/vnd.4sb +# audio/vnd.audiokoz +# audio/vnd.celp +# audio/vnd.cisco.nse +# audio/vnd.cmles.radio-events +# audio/vnd.cns.anp1 +# audio/vnd.cns.inf1 +audio/vnd.dece.audio uva uvva +audio/vnd.digital-winds eol +# audio/vnd.dlna.adts +# audio/vnd.dolby.heaac.1 +# audio/vnd.dolby.heaac.2 +# audio/vnd.dolby.mlp +# audio/vnd.dolby.mps +# audio/vnd.dolby.pl2 +# audio/vnd.dolby.pl2x +# audio/vnd.dolby.pl2z +# audio/vnd.dolby.pulse.1 +audio/vnd.dra dra +audio/vnd.dts dts +audio/vnd.dts.hd dtshd +# audio/vnd.dvb.file +# audio/vnd.everad.plj +# audio/vnd.hns.audio +audio/vnd.lucent.voice lvp +audio/vnd.ms-playready.media.pya pya +# audio/vnd.nokia.mobile-xmf +# audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 ecelp4800 +audio/vnd.nuera.ecelp7470 ecelp7470 +audio/vnd.nuera.ecelp9600 ecelp9600 +# audio/vnd.octel.sbc +# audio/vnd.qcelp +# audio/vnd.rhetorex.32kadpcm +audio/vnd.rip rip +# audio/vnd.sealedmedia.softseal.mpeg +# audio/vnd.vmx.cvsd +# audio/vorbis +# audio/vorbis-config +audio/webm weba +audio/x-aac aac +audio/x-aiff aif aiff aifc +audio/x-caf caf +audio/x-flac flac +audio/x-matroska mka +audio/x-mpegurl m3u +audio/x-ms-wax wax +audio/x-ms-wma wma +audio/x-pn-realaudio ram ra +audio/x-pn-realaudio-plugin rmp +# audio/x-tta +audio/x-wav wav +audio/xm xm +chemical/x-cdx cdx +chemical/x-cif cif +chemical/x-cmdf cmdf +chemical/x-cml cml +chemical/x-csml csml +# chemical/x-pdb +chemical/x-xyz xyz +image/bmp bmp +image/cgm cgm +# image/example +# image/fits +image/g3fax g3 +image/gif gif +image/ief ief +# image/jp2 +image/jpeg jpeg jpg jpe +# image/jpm +# image/jpx +image/ktx ktx +# image/naplps +image/png png +image/prs.btif btif +# image/prs.pti +image/sgi sgi +image/svg+xml svg svgz +# image/t38 +image/tiff tiff tif +# image/tiff-fx +image/vnd.adobe.photoshop psd +# image/vnd.cns.inf2 +image/vnd.dece.graphic uvi uvvi uvg uvvg +image/vnd.dvb.subtitle sub +image/vnd.djvu djvu djv +image/vnd.dwg dwg +image/vnd.dxf dxf +image/vnd.fastbidsheet fbs +image/vnd.fpx fpx +image/vnd.fst fst +image/vnd.fujixerox.edmics-mmr mmr +image/vnd.fujixerox.edmics-rlc rlc +# image/vnd.globalgraphics.pgb +# image/vnd.microsoft.icon +# image/vnd.mix +image/vnd.ms-modi mdi +image/vnd.ms-photo wdp +image/vnd.net-fpx npx +# image/vnd.radiance +# image/vnd.sealed.png +# image/vnd.sealedmedia.softseal.gif +# image/vnd.sealedmedia.softseal.jpg +# image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff xif +image/webp webp +image/x-3ds 3ds +image/x-cmu-raster ras +image/x-cmx cmx +image/x-freehand fh fhc fh4 fh5 fh7 +image/x-icon ico +image/x-mrsid-image sid +image/x-pcx pcx +image/x-pict pic pct +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-tga tga +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +# message/cpim +# message/delivery-status +# message/disposition-notification +# message/example +# message/external-body +# message/feedback-report +# message/global +# message/global-delivery-status +# message/global-disposition-notification +# message/global-headers +# message/http +# message/imdn+xml +# message/news +# message/partial +message/rfc822 eml mime +# message/s-http +# message/sip +# message/sipfrag +# message/tracking-status +# message/vnd.si.simp +# model/example +model/iges igs iges +model/mesh msh mesh silo +model/vnd.collada+xml dae +model/vnd.dwf dwf +# model/vnd.flatland.3dml +model/vnd.gdl gdl +# model/vnd.gs-gdl +# model/vnd.gs.gdl +model/vnd.gtw gtw +# model/vnd.moml+xml +model/vnd.mts mts +# model/vnd.parasolid.transmit.binary +# model/vnd.parasolid.transmit.text +model/vnd.vtu vtu +model/vrml wrl vrml +model/x3d+binary x3db x3dbz +model/x3d+vrml x3dv x3dvz +model/x3d+xml x3d x3dz +# multipart/alternative +# multipart/appledouble +# multipart/byteranges +# multipart/digest +# multipart/encrypted +# multipart/example +# multipart/form-data +# multipart/header-set +# multipart/mixed +# multipart/parallel +# multipart/related +# multipart/report +# multipart/signed +# multipart/voice-message +# text/1d-interleaved-parityfec +text/cache-manifest appcache +text/calendar ics ifb +text/css css +text/csv csv +# text/directory +# text/dns +# text/ecmascript +# text/enriched +# text/example +# text/fwdred +text/html html htm +# text/javascript +text/n3 n3 +# text/parityfec +text/plain txt text conf def list log in +# text/prs.fallenstein.rst +text/prs.lines.tag dsc +# text/vnd.radisys.msml-basic-layout +# text/red +# text/rfc822-headers +text/richtext rtx +# text/rtf +# text/rtp-enc-aescm128 +# text/rtx +text/sgml sgml sgm +# text/t140 +text/tab-separated-values tsv +text/troff t tr roff man me ms +text/turtle ttl +# text/ulpfec +text/uri-list uri uris urls +text/vcard vcard +# text/vnd.abc +text/vnd.curl curl +text/vnd.curl.dcurl dcurl +text/vnd.curl.scurl scurl +text/vnd.curl.mcurl mcurl +# text/vnd.dmclientscript +text/vnd.dvb.subtitle sub +# text/vnd.esmertec.theme-descriptor +text/vnd.fly fly +text/vnd.fmi.flexstor flx +text/vnd.graphviz gv +text/vnd.in3d.3dml 3dml +text/vnd.in3d.spot spot +# text/vnd.iptc.newsml +# text/vnd.iptc.nitf +# text/vnd.latex-z +# text/vnd.motorola.reflex +# text/vnd.ms-mediapackage +# text/vnd.net2phone.commcenter.command +# text/vnd.si.uricatalogue +text/vnd.sun.j2me.app-descriptor jad +# text/vnd.trolltech.linguist +# text/vnd.wap.si +# text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-asm s asm +text/x-c c cc cxx cpp h hh dic +text/x-fortran f for f77 f90 +text/x-java-source java +text/x-opml opml +text/x-pascal p pas +text/x-nfo nfo +text/x-setext etx +text/x-sfv sfv +text/x-uuencode uu +text/x-vcalendar vcs +text/x-vcard vcf +# text/xml +# text/xml-external-parsed-entity +# video/1d-interleaved-parityfec +video/3gpp 3gp +# video/3gpp-tt +video/3gpp2 3g2 +# video/bmpeg +# video/bt656 +# video/celb +# video/dv +# video/example +video/h261 h261 +video/h263 h263 +# video/h263-1998 +# video/h263-2000 +video/h264 h264 +# video/h264-rcdo +# video/h264-svc +video/jpeg jpgv +# video/jpeg2000 +video/jpm jpm jpgm +video/mj2 mj2 mjp2 +# video/mp1s +# video/mp2p +# video/mp2t +video/mp4 mp4 mp4v mpg4 +# video/mp4v-es +video/mpeg mpeg mpg mpe m1v m2v +# video/mpeg4-generic +# video/mpv +# video/nv +video/ogg ogv +# video/parityfec +# video/pointer +video/quicktime qt mov +# video/raw +# video/rtp-enc-aescm128 +# video/rtx +# video/smpte292m +# video/ulpfec +# video/vc1 +# video/vnd.cctv +video/vnd.dece.hd uvh uvvh +video/vnd.dece.mobile uvm uvvm +# video/vnd.dece.mp4 +video/vnd.dece.pd uvp uvvp +video/vnd.dece.sd uvs uvvs +video/vnd.dece.video uvv uvvv +# video/vnd.directv.mpeg +# video/vnd.directv.mpeg-tts +# video/vnd.dlna.mpeg-tts +video/vnd.dvb.file dvb +video/vnd.fvt fvt +# video/vnd.hns.video +# video/vnd.iptvforum.1dparityfec-1010 +# video/vnd.iptvforum.1dparityfec-2005 +# video/vnd.iptvforum.2dparityfec-1010 +# video/vnd.iptvforum.2dparityfec-2005 +# video/vnd.iptvforum.ttsavc +# video/vnd.iptvforum.ttsmpeg2 +# video/vnd.motorola.video +# video/vnd.motorola.videop +video/vnd.mpegurl mxu m4u +video/vnd.ms-playready.media.pyv pyv +# video/vnd.nokia.interleaved-multimedia +# video/vnd.nokia.videovoip +# video/vnd.objectvideo +# video/vnd.sealed.mpeg1 +# video/vnd.sealed.mpeg4 +# video/vnd.sealed.swf +# video/vnd.sealedmedia.softseal.mov +video/vnd.uvvu.mp4 uvu uvvu +video/vnd.vivo viv +video/webm webm +video/x-f4v f4v +video/x-fli fli +video/x-flv flv +video/x-m4v m4v +video/x-matroska mkv mk3d mks +video/x-mng mng +video/x-ms-asf asf asx +video/x-ms-vob vob +video/x-ms-wm wm +video/x-ms-wmv wmv +video/x-ms-wmx wmx +video/x-ms-wvx wvx +video/x-msvideo avi +video/x-sgi-movie movie +video/x-smv smv +x-conference/x-cooltalk ice diff --git a/realtime/node_modules/express/node_modules/send/node_modules/mime/types/node.types b/realtime/node_modules/express/node_modules/send/node_modules/mime/types/node.types new file mode 100644 index 00000000..55b2cf79 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/node_modules/mime/types/node.types @@ -0,0 +1,77 @@ +# What: WebVTT +# Why: To allow formats intended for marking up external text track resources. +# http://dev.w3.org/html5/webvtt/ +# Added by: niftylettuce +text/vtt vtt + +# What: Google Chrome Extension +# Why: To allow apps to (work) be served with the right content type header. +# http://codereview.chromium.org/2830017 +# Added by: niftylettuce +application/x-chrome-extension crx + +# What: HTC support +# Why: To properly render .htc files such as CSS3PIE +# Added by: niftylettuce +text/x-component htc + +# What: HTML5 application cache manifes ('.manifest' extension) +# Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps +# per https://developer.mozilla.org/en/offline_resources_in_firefox +# Added by: louisremi +text/cache-manifest manifest + +# What: node binary buffer format +# Why: semi-standard extension w/in the node community +# Added by: tootallnate +application/octet-stream buffer + +# What: The "protected" MP-4 formats used by iTunes. +# Why: Required for streaming music to browsers (?) +# Added by: broofa +application/mp4 m4p +audio/mp4 m4a + +# What: Video format, Part of RFC1890 +# Why: See https://github.com/bentomas/node-mime/pull/6 +# Added by: mjrusso +video/MP2T ts + +# What: EventSource mime type +# Why: mime type of Server-Sent Events stream +# http://www.w3.org/TR/eventsource/#text-event-stream +# Added by: francois2metz +text/event-stream event-stream + +# What: Mozilla App manifest mime type +# Why: https://developer.mozilla.org/en/Apps/Manifest#Serving_manifests +# Added by: ednapiranha +application/x-web-app-manifest+json webapp + +# What: Lua file types +# Why: Googling around shows de-facto consensus on these +# Added by: creationix (Issue #45) +text/x-lua lua +application/x-lua-bytecode luac + +# What: Markdown files, as per http://daringfireball.net/projects/markdown/syntax +# Why: http://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown +# Added by: avoidwork +text/x-markdown markdown md mkd + +# What: ini files +# Why: because they're just text files +# Added by: Matthew Kastor +text/plain ini + +# What: DASH Adaptive Streaming manifest +# Why: https://developer.mozilla.org/en-US/docs/DASH_Adaptive_Streaming_for_HTML_5_Video +# Added by: eelcocramer +application/dash+xml mdp + +# What: OpenType font files - http://www.microsoft.com/typography/otspec/ +# Why: Browsers usually ignore the font MIME types and sniff the content, +# but Chrome, shows a warning if OpenType fonts aren't served with +# the `font/opentype` MIME type: http://i.imgur.com/8c5RN8M.png. +# Added by: alrra +font/opentype otf diff --git a/realtime/node_modules/express/node_modules/send/package.json b/realtime/node_modules/express/node_modules/send/package.json new file mode 100644 index 00000000..789de722 --- /dev/null +++ b/realtime/node_modules/express/node_modules/send/package.json @@ -0,0 +1,42 @@ +{ + "name": "send", + "version": "0.1.4", + "description": "Better streaming static file server with Range and conditional-GET support", + "keywords": [ + "static", + "file", + "server" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "dependencies": { + "debug": "*", + "mime": "~1.2.9", + "fresh": "0.2.0", + "range-parser": "0.0.4" + }, + "devDependencies": { + "mocha": "*", + "should": "*", + "supertest": "0.0.1", + "connect": "2.x" + }, + "scripts": { + "test": "make test" + }, + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/send.git" + }, + "main": "index", + "readme": "# send\n\n Send is Connect's `static()` extracted for generalized use, a streaming static file\n server supporting partial responses (Ranges), conditional-GET negotiation, high test coverage, and granular events which may be leveraged to take appropriate actions in your application or framework.\n\n## Installation\n\n $ npm install send\n\n## Examples\n\n Small:\n\n```js\nvar http = require('http');\nvar send = require('send');\n\nvar app = http.createServer(function(req, res){\n send(req, req.url).pipe(res);\n}).listen(3000);\n```\n\n Serving from a root directory with custom error-handling:\n\n```js\nvar http = require('http');\nvar send = require('send');\nvar url = require('url');\n\nvar app = http.createServer(function(req, res){\n // your custom error-handling logic:\n function error(err) {\n res.statusCode = err.status || 500;\n res.end(err.message);\n }\n\n // your custom directory handling logic:\n function redirect() {\n res.statusCode = 301;\n res.setHeader('Location', req.url + '/');\n res.end('Redirecting to ' + req.url + '/');\n }\n\n // transfer arbitrary files from within\n // /www/example.com/public/*\n send(req, url.parse(req.url).pathname)\n .root('/www/example.com/public')\n .on('error', error)\n .on('directory', redirect)\n .pipe(res);\n}).listen(3000);\n```\n\n## API\n\n### Events\n\n - `error` an error occurred `(err)`\n - `directory` a directory was requested\n - `file` a file was requested `(path, stat)`\n - `stream` file streaming has started `(stream)`\n - `end` streaming has completed\n\n### .root(dir)\n\n Serve files relative to `path`. Aliased as `.from(dir)`.\n\n### .index(path)\n\n By default send supports \"index.html\" files, to disable this\n invoke `.index(false)` or to supply a new index pass a string.\n\n### .maxage(ms)\n\n Provide a max-age in milliseconds for http caching, defaults to 0.\n\n### .hidden(bool)\n\n Enable or disable transfer of hidden files, defaults to false.\n\n## Error-handling\n\n By default when no `error` listeners are present an automatic response will be made, otherwise you have full control over the response, aka you may show a 5xx page etc.\n\n## Caching\n\n It does _not_ perform internal caching, you should use a reverse proxy cache such\n as Varnish for this, or those fancy things called CDNs. If your application is small enough that it would benefit from single-node memory caching, it's small enough that it does not need caching at all ;).\n\n## Debugging\n\n To enable `debug()` instrumentation output export __DEBUG__:\n\n```\n$ DEBUG=send node app\n```\n\n## Running tests\n\n```\n$ npm install\n$ make test\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "Readme.md", + "_id": "send@0.1.4", + "dist": { + "shasum": "b27c692077345c00996c8e930e3fa0b60cb27cf4" + }, + "_from": "send@0.1.4", + "_resolved": "https://registry.npmjs.org/send/-/send-0.1.4.tgz" +} diff --git a/realtime/node_modules/express/package.json b/realtime/node_modules/express/package.json new file mode 100644 index 00000000..6fe058c5 --- /dev/null +++ b/realtime/node_modules/express/package.json @@ -0,0 +1,87 @@ +{ + "name": "express", + "description": "Sinatra inspired web development framework", + "version": "3.4.8", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "contributors": [ + { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "Aaron Heckmann", + "email": "aaron.heckmann+github@gmail.com" + }, + { + "name": "Ciaran Jessup", + "email": "ciaranj@gmail.com" + }, + { + "name": "Guillermo Rauch", + "email": "rauchg@gmail.com" + } + ], + "dependencies": { + "connect": "2.12.0", + "commander": "1.3.2", + "range-parser": "0.0.4", + "mkdirp": "0.3.5", + "cookie": "0.1.0", + "buffer-crc32": "0.2.1", + "fresh": "0.2.0", + "methods": "0.1.0", + "send": "0.1.4", + "cookie-signature": "1.0.1", + "merge-descriptors": "0.0.1", + "debug": ">= 0.7.3 < 1" + }, + "devDependencies": { + "ejs": "~0.8.4", + "mocha": "~1.15.1", + "jade": "~0.30.0", + "hjs": "~0.0.6", + "stylus": "~0.40.0", + "should": "~2.1.1", + "connect-redis": "~1.4.5", + "marked": "0.2.10", + "supertest": "~0.8.1" + }, + "keywords": [ + "express", + "framework", + "sinatra", + "web", + "rest", + "restful", + "router", + "app", + "api" + ], + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/express" + }, + "main": "index", + "bin": { + "express": "./bin/express" + }, + "scripts": { + "prepublish": "npm prune", + "test": "make test" + }, + "engines": { + "node": ">= 0.8.0" + }, + "license": "MIT", + "readme": "[![express logo](http://f.cl.ly/items/0V2S1n0K1i3y1c122g04/Screen%20Shot%202012-04-11%20at%209.59.42%20AM.png)](http://expressjs.com/)\n\n Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).\n\n [![Build Status](https://secure.travis-ci.org/visionmedia/express.png)](http://travis-ci.org/visionmedia/express) [![Gittip](http://img.shields.io/gittip/visionmedia.png)](https://www.gittip.com/visionmedia/)\n\n```js\nvar express = require('express');\nvar app = express();\n\napp.get('/', function(req, res){\n res.send('Hello World');\n});\n\napp.listen(3000);\n```\n\n## Installation\n\n $ npm install -g express\n\n## Quick Start\n\n The quickest way to get started with express is to utilize the executable `express(1)` to generate an application as shown below:\n\n Create the app:\n\n $ npm install -g express\n $ express /tmp/foo && cd /tmp/foo\n\n Install dependencies:\n\n $ npm install\n\n Start the server:\n\n $ node app\n\n## Features\n\n * Built on [Connect](http://github.com/senchalabs/connect)\n * Robust routing\n * HTTP helpers (redirection, caching, etc)\n * View system supporting 14+ template engines\n * Content negotiation\n * Focus on high performance\n * Environment based configuration\n * Executable for generating applications quickly\n * High test coverage\n\n## Philosophy\n\n The Express philosophy is to provide small, robust tooling for HTTP servers, making\n it a great solution for single page applications, web sites, hybrids, or public\n HTTP APIs.\n\n Built on Connect, you can use _only_ what you need, and nothing more. Applications\n can be as big or as small as you like, even a single file. Express does\n not force you to use any specific ORM or template engine. With support for over\n 14 template engines via [Consolidate.js](http://github.com/visionmedia/consolidate.js),\n you can quickly craft your perfect framework.\n\n## More Information\n\n * [Website and Documentation](http://expressjs.com/) stored at [visionmedia/expressjs.com](https://github.com/visionmedia/expressjs.com)\n * Join #express on freenode\n * [Google Group](http://groups.google.com/group/express-js) for discussion\n * Follow [tjholowaychuk](http://twitter.com/tjholowaychuk) on twitter for updates\n * Visit the [Wiki](http://github.com/visionmedia/express/wiki)\n * [Русскоязычная документация](http://jsman.ru/express/)\n * Run express examples [online](https://runnable.com/express)\n\n## Viewing Examples\n\nClone the Express repo, then install the dev dependencies to install all the example / test suite dependencies:\n\n $ git clone git://github.com/visionmedia/express.git --depth 1\n $ cd express\n $ npm install\n\nThen run whichever tests you want:\n\n $ node examples/content-negotiation\n\nYou can also view live examples here:\n\n\n\n## Running Tests\n\nTo run the test suite, first invoke the following command within the repo, installing the development dependencies:\n\n $ npm install\n\nThen run the tests:\n\n $ make test\n\n## Contributors\n\n https://github.com/visionmedia/express/graphs/contributors\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2009-2012 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "Readme.md", + "_id": "express@3.4.8", + "dist": { + "shasum": "4cbd4fad204275fc4cfee0cc7711d71f13f637e7" + }, + "_from": "express@", + "_resolved": "https://registry.npmjs.org/express/-/express-3.4.8.tgz" +} diff --git a/realtime/node_modules/redis-url/.npmignore b/realtime/node_modules/redis-url/.npmignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/realtime/node_modules/redis-url/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/realtime/node_modules/redis-url/README.md b/realtime/node_modules/redis-url/README.md new file mode 100644 index 00000000..9ca34f75 --- /dev/null +++ b/realtime/node_modules/redis-url/README.md @@ -0,0 +1,18 @@ +# redis-url + +## Usage + + // use $REDIS_URL or redis://localhost:6379 + var redis = require('redis-url').connect(); + + // specify a url + var redis = require('redis-url').connect(process.env.SOMEREDIS_URL); + +## Url format + + redis://[db-number[:password]@]host:port[?option=value] +**db-number** is integer from 1 to 15 + +## License + +MIT diff --git a/realtime/node_modules/redis-url/index.js b/realtime/node_modules/redis-url/index.js new file mode 100644 index 00000000..88e2d7de --- /dev/null +++ b/realtime/node_modules/redis-url/index.js @@ -0,0 +1,28 @@ +var url = require('url'); +var querystring = require('querystring'); + +module.exports.createClient = module.exports.connect = function(redis_url) { + var password, database; + var parsed_url = url.parse(redis_url || process.env.REDIS_URL || 'redis://localhost:6379'); + var parsed_auth = (parsed_url.auth || '').split(':'); + var options = querystring.parse(parsed_url.query); + + var redis = require('redis').createClient(parsed_url.port, parsed_url.hostname, options); + + if (password = parsed_auth[1]) { + redis.auth(password, function(err) { + if (err) throw err; + }); + } + + if (database = parsed_auth[0]) { + redis.select(database); + redis.on('connect', function() { + redis.send_anyways = true + redis.select(database); + redis.send_anyways = false; + }); + } + + return(redis); +} diff --git a/realtime/node_modules/redis-url/package.json b/realtime/node_modules/redis-url/package.json new file mode 100644 index 00000000..6b1672e4 --- /dev/null +++ b/realtime/node_modules/redis-url/package.json @@ -0,0 +1,21 @@ +{ + "name": "redis-url", + "version": "0.2.0", + "description": "Use a REDIS_URL to connect to Redis", + "author": { + "name": "David Dollar", + "email": "ddollar@gmail.com" + }, + "main": "./index.js", + "dependencies": { + "redis": ">= 0.0.1" + }, + "readme": "# redis-url\n\n## Usage\n\n // use $REDIS_URL or redis://localhost:6379\n var redis = require('redis-url').connect();\n\n // specify a url\n var redis = require('redis-url').connect(process.env.SOMEREDIS_URL);\n\n## Url format\n\n redis://[db-number[:password]@]host:port[?option=value]\n**db-number** is integer from 1 to 15\n\n## License\n\nMIT\n", + "readmeFilename": "README.md", + "_id": "redis-url@0.2.0", + "dist": { + "shasum": "5c76d5e5383540ce7c49962e5b2c858236d75d45" + }, + "_from": "redis-url@", + "_resolved": "https://registry.npmjs.org/redis-url/-/redis-url-0.2.0.tgz" +} diff --git a/realtime/node_modules/redis-url/test.js b/realtime/node_modules/redis-url/test.js new file mode 100644 index 00000000..1ec37df0 --- /dev/null +++ b/realtime/node_modules/redis-url/test.js @@ -0,0 +1,18 @@ +var redis = require('./index').createClient(); +redis.set('foo', 'bar'); +redis.get('foo', function(err, res) { + console.log('got1: ' + res); +}); +redis.keys('*', function(err, res) { + console.log('keys1: ' + res.length); +}); + +var redis = require('./index').createClient(process.env.REDISTOGO_URL); +redis.set('foo', 'bar'); +redis.get('foo', function(err, res) { + console.log('got2: ' + res); +}); +redis.keys('*', function(err, res) { + console.log('keys2: ' + res.length); +}); + diff --git a/realtime/package.json b/realtime/package.json index c2298aca..cc5448ee 100644 --- a/realtime/package.json +++ b/realtime/package.json @@ -1,9 +1,10 @@ { - "name" : "RoR-real-time", - "description" : "providing real-time sychronization for ruby on rails", - "version" : "0.0.1", - "dependencies" : { - "socket.io" : "0.9.12", - "redis": "0.7.3" + "name": "RoR-real-time", + "description": "providing real-time sychronization for ruby on rails", + "version": "0.0.1", + "dependencies": { + "socket.io": "0.9.12", + "redis": "0.7.3", + "express": "3.4.8" } -} \ No newline at end of file +} diff --git a/realtime/realtime-server.js b/realtime/realtime-server.js index f6a800a9..87f4bc78 100644 --- a/realtime/realtime-server.js +++ b/realtime/realtime-server.js @@ -1,14 +1,44 @@ -var io = require('socket.io').listen(5001), - redis = require('redis').createClient(); - -redis.subscribe('maps'); - -io.on('connection', function(socket){ - redis.on('message', function(channel, message){ - var m = JSON.parse(message); - var room; - room = 'maps-' + m.mapid; +/*var http = require('http'), + express = require('express'), + port = process.env.PORT || 5001, + app = express(), + server = http.createServer(app).listen(port), + io = require('socket.io').listen(server); - socket.emit(room, m); +console.log(port); + +app.configure(function() { + app.use(function(req, res, next) { + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Methods', 'GET, OPTIONS'); + res.header('Access-Control-Allow-Headers', 'Content-Type'); + return next(); + }); +}); */ + +//var rtg = require("url").parse("redis://redistogo:0ca046a3d56533cc162e2447db383192@pearlfish.redistogo.com:9060/"), + //redis = require('redis').createClient(rtg.port, rtg.hostname, {no_ready_check: true}); + +var io = require('socket.io').listen(5001); +var redis = require('redis').createClient(); + +//redis.auth(rtg.auth.split(":")[1], function() { +// start(); +//}); + +function start() { + redis.subscribe('maps'); + + io.on('connection', function(socket){ + redis.on('message', function(channel, message){ + console.log(message); + var m = JSON.parse(message); + var room; + room = 'maps-' + m.mapid; + + socket.emit(room, m); + }); }); -}); \ No newline at end of file +} + +start(); \ No newline at end of file