From dc0f2cf530c9211dfa0d7d4948d1bfde9d65f714 Mon Sep 17 00:00:00 2001 From: Jim Frederick Date: Fri, 15 Jan 2016 17:56:08 -0500 Subject: [PATCH 1/2] Started the tutorial --- comments.json | 17 ++++++++++++++- public/index.html | 6 +----- public/scripts/jim.js | 50 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 public/scripts/jim.js diff --git a/comments.json b/comments.json index 7bef77ad..36e9f6fe 100644 --- a/comments.json +++ b/comments.json @@ -8,5 +8,20 @@ "id": 1420070400000, "author": "Paul O’Shannessy", "text": "React is *great*!" + }, + { + "id": 1452894030484, + "author": "Jim", + "text": "hello" + }, + { + "id": 1452894052928, + "author": "Another person", + "text": "also says hello" + }, + { + "id": 1452894062395, + "author": "hey", + "text": "hey" } -] +] \ No newline at end of file diff --git a/public/index.html b/public/index.html index c6494446..642f6c99 100644 --- a/public/index.html +++ b/public/index.html @@ -10,13 +10,9 @@ +
- - diff --git a/public/scripts/jim.js b/public/scripts/jim.js new file mode 100644 index 00000000..a4d2d4d2 --- /dev/null +++ b/public/scripts/jim.js @@ -0,0 +1,50 @@ +var CommentBox = React.createClass({ + render: function() { + return ( +
+

Comments

+ + +
+ ); + } +}); + +var CommentList = React.createClass({ + render: function() { + return ( +
+ Meooowww + What?? +
+ ); + } +}); + +var CommentForm = React.createClass({ + render: function() { + return ( +
+ Hello, world! I am a CommentForm. +
+ ); + } +}); + +var Comment = React.createClass({ + render: function() { + return ( +
+

+ {this.props.author} +

+ {this.props.children} +
+ ); + } +}); + +ReactDOM.render( + , + document.getElementById('content') + ); \ No newline at end of file From 72b32e4d6ec916b8f2dff3309862a5bd0389e111 Mon Sep 17 00:00:00 2001 From: Jim Frederick Date: Fri, 22 Jan 2016 16:55:19 -0500 Subject: [PATCH 2/2] Trying to convert to superagent --- .gitignore | 1 - comments.json | 45 +- public/index.html | 1 + public/node_modules/.bin/mime | 1 + public/node_modules/async/.travis.yml | 5 + public/node_modules/async/LICENSE | 19 + public/node_modules/async/README.md | 1647 +++++ public/node_modules/async/bower.json | 38 + public/node_modules/async/component.json | 16 + public/node_modules/async/lib/async.js | 1123 +++ public/node_modules/async/package.json | 110 + .../async/support/sync-package-managers.js | 53 + public/node_modules/combined-stream/License | 19 + public/node_modules/combined-stream/Readme.md | 132 + .../combined-stream/lib/combined_stream.js | 188 + .../node_modules/combined-stream/package.json | 85 + .../node_modules/component-emitter/History.md | 63 + public/node_modules/component-emitter/LICENSE | 24 + .../node_modules/component-emitter/Readme.md | 74 + .../node_modules/component-emitter/index.js | 161 + .../component-emitter/package.json | 200 + public/node_modules/cookiejar/.npmignore | 1 + public/node_modules/cookiejar/LICENSE | 9 + public/node_modules/cookiejar/cookiejar.js | 261 + public/node_modules/cookiejar/package.json | 80 + public/node_modules/cookiejar/readme.md | 57 + public/node_modules/cookiejar/tests/test.js | 82 + public/node_modules/core-util-is/LICENSE | 19 + public/node_modules/core-util-is/README.md | 3 + public/node_modules/core-util-is/float.patch | 604 ++ public/node_modules/core-util-is/lib/util.js | 107 + public/node_modules/core-util-is/package.json | 86 + public/node_modules/core-util-is/test.js | 68 + public/node_modules/debug/.jshintrc | 3 + public/node_modules/debug/.npmignore | 6 + public/node_modules/debug/History.md | 195 + public/node_modules/debug/Makefile | 36 + public/node_modules/debug/Readme.md | 188 + public/node_modules/debug/bower.json | 28 + public/node_modules/debug/browser.js | 168 + public/node_modules/debug/component.json | 19 + public/node_modules/debug/debug.js | 197 + public/node_modules/debug/node.js | 209 + public/node_modules/debug/package.json | 98 + public/node_modules/delayed-stream/.npmignore | 2 + public/node_modules/delayed-stream/License | 19 + public/node_modules/delayed-stream/Makefile | 7 + public/node_modules/delayed-stream/Readme.md | 154 + .../delayed-stream/lib/delayed_stream.js | 99 + .../node_modules/delayed-stream/package.json | 67 + .../delayed-stream/test/common.js | 6 + .../integration/test-delayed-http-upload.js | 38 + .../test-delayed-stream-auto-pause.js | 21 + .../integration/test-delayed-stream-pause.js | 14 + .../test/integration/test-delayed-stream.js | 48 + .../integration/test-handle-source-errors.js | 15 + .../test/integration/test-max-data-size.js | 18 + .../test/integration/test-pipe-resumes.js | 13 + .../test/integration/test-proxy-readable.js | 13 + .../node_modules/delayed-stream/test/run.js | 7 + public/node_modules/extend/.npmignore | 1 + public/node_modules/extend/.travis.yml | 5 + public/node_modules/extend/README.md | 59 + public/node_modules/extend/index.js | 78 + public/node_modules/extend/package.json | 87 + public/node_modules/form-data/License | 19 + public/node_modules/form-data/Readme.md | 175 + .../node_modules/form-data/lib/form_data.js | 351 + public/node_modules/form-data/package.json | 105 + public/node_modules/formidable/.npmignore | 7 + public/node_modules/formidable/.travis.yml | 5 + public/node_modules/formidable/LICENSE | 7 + public/node_modules/formidable/Readme.md | 425 ++ public/node_modules/formidable/index.js | 1 + public/node_modules/formidable/lib/file.js | 72 + .../formidable/lib/incoming_form.js | 555 ++ public/node_modules/formidable/lib/index.js | 3 + .../formidable/lib/json_parser.js | 35 + .../formidable/lib/multipart_parser.js | 332 + .../formidable/lib/octet_parser.js | 20 + .../formidable/lib/querystring_parser.js | 27 + public/node_modules/formidable/package.json | 90 + public/node_modules/inherits/LICENSE | 16 + public/node_modules/inherits/README.md | 42 + public/node_modules/inherits/inherits.js | 1 + .../node_modules/inherits/inherits_browser.js | 23 + public/node_modules/inherits/package.json | 77 + public/node_modules/inherits/test.js | 25 + public/node_modules/isarray/README.md | 54 + public/node_modules/isarray/build/build.js | 209 + public/node_modules/isarray/component.json | 19 + public/node_modules/isarray/index.js | 3 + public/node_modules/isarray/package.json | 78 + public/node_modules/methods/HISTORY.md | 29 + public/node_modules/methods/LICENSE | 24 + public/node_modules/methods/README.md | 51 + public/node_modules/methods/index.js | 69 + public/node_modules/methods/package.json | 114 + public/node_modules/mime-db/HISTORY.md | 212 + public/node_modules/mime-db/LICENSE | 22 + public/node_modules/mime-db/README.md | 76 + public/node_modules/mime-db/db.json | 6359 +++++++++++++++++ public/node_modules/mime-db/index.js | 11 + public/node_modules/mime-db/package.json | 120 + public/node_modules/mime-types/HISTORY.md | 115 + public/node_modules/mime-types/LICENSE | 22 + public/node_modules/mime-types/README.md | 102 + public/node_modules/mime-types/index.js | 63 + public/node_modules/mime-types/package.json | 109 + public/node_modules/mime/.npmignore | 0 public/node_modules/mime/LICENSE | 19 + public/node_modules/mime/README.md | 90 + public/node_modules/mime/build/build.js | 11 + public/node_modules/mime/build/test.js | 57 + public/node_modules/mime/cli.js | 8 + public/node_modules/mime/mime.js | 108 + public/node_modules/mime/package.json | 98 + public/node_modules/mime/types.json | 1 + public/node_modules/ms/.npmignore | 5 + public/node_modules/ms/History.md | 66 + public/node_modules/ms/LICENSE | 20 + public/node_modules/ms/README.md | 35 + public/node_modules/ms/index.js | 125 + public/node_modules/ms/package.json | 74 + public/node_modules/qs/.jshintignore | 1 + public/node_modules/qs/.jshintrc | 10 + public/node_modules/qs/.npmignore | 18 + public/node_modules/qs/.travis.yml | 4 + public/node_modules/qs/CHANGELOG.md | 68 + public/node_modules/qs/CONTRIBUTING.md | 1 + public/node_modules/qs/LICENSE | 28 + public/node_modules/qs/Makefile | 8 + public/node_modules/qs/README.md | 222 + public/node_modules/qs/index.js | 1 + public/node_modules/qs/lib/index.js | 15 + public/node_modules/qs/lib/parse.js | 157 + public/node_modules/qs/lib/stringify.js | 77 + public/node_modules/qs/lib/utils.js | 132 + public/node_modules/qs/package.json | 84 + public/node_modules/qs/test/parse.js | 413 ++ public/node_modules/qs/test/stringify.js | 179 + .../node_modules/readable-stream/.npmignore | 5 + public/node_modules/readable-stream/LICENSE | 27 + public/node_modules/readable-stream/README.md | 15 + public/node_modules/readable-stream/duplex.js | 1 + .../readable-stream/lib/_stream_duplex.js | 89 + .../lib/_stream_passthrough.js | 46 + .../readable-stream/lib/_stream_readable.js | 959 +++ .../readable-stream/lib/_stream_transform.js | 210 + .../readable-stream/lib/_stream_writable.js | 387 + .../node_modules/readable-stream/package.json | 94 + .../readable-stream/passthrough.js | 1 + .../node_modules/readable-stream/readable.js | 6 + .../node_modules/readable-stream/transform.js | 1 + .../node_modules/readable-stream/writable.js | 1 + .../node_modules/reduce-component/.npmignore | 3 + .../node_modules/reduce-component/History.md | 0 public/node_modules/reduce-component/LICENSE | 176 + public/node_modules/reduce-component/Makefile | 16 + .../node_modules/reduce-component/Readme.md | 32 + .../reduce-component/component.json | 13 + public/node_modules/reduce-component/index.js | 24 + .../reduce-component/package.json | 72 + .../reduce-component/test/index.html | 30 + .../reduce-component/test/reduce.js | 49 + public/node_modules/string_decoder/.npmignore | 2 + public/node_modules/string_decoder/LICENSE | 20 + public/node_modules/string_decoder/README.md | 7 + public/node_modules/string_decoder/index.js | 221 + .../node_modules/string_decoder/package.json | 79 + public/node_modules/superagent/.npmignore | 6 + public/node_modules/superagent/.travis.yml | 18 + public/node_modules/superagent/.zuul.yml | 15 + .../node_modules/superagent/Contributing.md | 7 + public/node_modules/superagent/History.md | 522 ++ public/node_modules/superagent/LICENSE | 22 + public/node_modules/superagent/Makefile | 57 + public/node_modules/superagent/Readme.md | 113 + public/node_modules/superagent/bower.json | 4 + public/node_modules/superagent/component.json | 21 + public/node_modules/superagent/docs/head.html | 21 + .../node_modules/superagent/docs/highlight.js | 17 + .../superagent/docs/images/bg.png | Bin 0 -> 8856 bytes public/node_modules/superagent/docs/index.md | 448 ++ .../superagent/docs/jquery-ui.min.js | 6 + public/node_modules/superagent/docs/jquery.js | 4 + .../superagent/docs/jquery.tocify.min.js | 4 + public/node_modules/superagent/docs/style.css | 81 + public/node_modules/superagent/docs/tail.html | 4 + public/node_modules/superagent/docs/test.html | 2082 ++++++ public/node_modules/superagent/lib/client.js | 1191 +++ .../node_modules/superagent/lib/node/agent.js | 76 + .../node_modules/superagent/lib/node/index.js | 1234 ++++ .../superagent/lib/node/parsers/image.js | 10 + .../superagent/lib/node/parsers/index.js | 5 + .../superagent/lib/node/parsers/json.js | 17 + .../superagent/lib/node/parsers/text.js | 7 + .../superagent/lib/node/parsers/urlencoded.js | 19 + .../node_modules/superagent/lib/node/part.js | 150 + .../superagent/lib/node/response.js | 210 + .../node_modules/superagent/lib/node/utils.js | 142 + public/node_modules/superagent/package.json | 160 + public/node_modules/superagent/superagent.js | 1383 ++++ public/node_modules/superagent/test.js | 6 + public/scripts/jim.js | 123 +- 205 files changed, 30453 insertions(+), 27 deletions(-) create mode 120000 public/node_modules/.bin/mime create mode 100644 public/node_modules/async/.travis.yml create mode 100644 public/node_modules/async/LICENSE create mode 100644 public/node_modules/async/README.md create mode 100644 public/node_modules/async/bower.json create mode 100644 public/node_modules/async/component.json create mode 100644 public/node_modules/async/lib/async.js create mode 100644 public/node_modules/async/package.json create mode 100755 public/node_modules/async/support/sync-package-managers.js create mode 100644 public/node_modules/combined-stream/License create mode 100644 public/node_modules/combined-stream/Readme.md create mode 100644 public/node_modules/combined-stream/lib/combined_stream.js create mode 100644 public/node_modules/combined-stream/package.json create mode 100644 public/node_modules/component-emitter/History.md create mode 100644 public/node_modules/component-emitter/LICENSE create mode 100644 public/node_modules/component-emitter/Readme.md create mode 100644 public/node_modules/component-emitter/index.js create mode 100644 public/node_modules/component-emitter/package.json create mode 100644 public/node_modules/cookiejar/.npmignore create mode 100644 public/node_modules/cookiejar/LICENSE create mode 100644 public/node_modules/cookiejar/cookiejar.js create mode 100644 public/node_modules/cookiejar/package.json create mode 100644 public/node_modules/cookiejar/readme.md create mode 100755 public/node_modules/cookiejar/tests/test.js create mode 100644 public/node_modules/core-util-is/LICENSE create mode 100644 public/node_modules/core-util-is/README.md create mode 100644 public/node_modules/core-util-is/float.patch create mode 100644 public/node_modules/core-util-is/lib/util.js create mode 100644 public/node_modules/core-util-is/package.json create mode 100644 public/node_modules/core-util-is/test.js create mode 100644 public/node_modules/debug/.jshintrc create mode 100644 public/node_modules/debug/.npmignore create mode 100644 public/node_modules/debug/History.md create mode 100644 public/node_modules/debug/Makefile create mode 100644 public/node_modules/debug/Readme.md create mode 100644 public/node_modules/debug/bower.json create mode 100644 public/node_modules/debug/browser.js create mode 100644 public/node_modules/debug/component.json create mode 100644 public/node_modules/debug/debug.js create mode 100644 public/node_modules/debug/node.js create mode 100644 public/node_modules/debug/package.json create mode 100644 public/node_modules/delayed-stream/.npmignore create mode 100644 public/node_modules/delayed-stream/License create mode 100644 public/node_modules/delayed-stream/Makefile create mode 100644 public/node_modules/delayed-stream/Readme.md create mode 100644 public/node_modules/delayed-stream/lib/delayed_stream.js create mode 100644 public/node_modules/delayed-stream/package.json create mode 100644 public/node_modules/delayed-stream/test/common.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-delayed-stream.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-handle-source-errors.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-max-data-size.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-pipe-resumes.js create mode 100644 public/node_modules/delayed-stream/test/integration/test-proxy-readable.js create mode 100755 public/node_modules/delayed-stream/test/run.js create mode 100644 public/node_modules/extend/.npmignore create mode 100644 public/node_modules/extend/.travis.yml create mode 100644 public/node_modules/extend/README.md create mode 100644 public/node_modules/extend/index.js create mode 100644 public/node_modules/extend/package.json create mode 100644 public/node_modules/form-data/License create mode 100644 public/node_modules/form-data/Readme.md create mode 100644 public/node_modules/form-data/lib/form_data.js create mode 100644 public/node_modules/form-data/package.json create mode 100644 public/node_modules/formidable/.npmignore create mode 100644 public/node_modules/formidable/.travis.yml create mode 100644 public/node_modules/formidable/LICENSE create mode 100644 public/node_modules/formidable/Readme.md create mode 100644 public/node_modules/formidable/index.js create mode 100644 public/node_modules/formidable/lib/file.js create mode 100644 public/node_modules/formidable/lib/incoming_form.js create mode 100644 public/node_modules/formidable/lib/index.js create mode 100644 public/node_modules/formidable/lib/json_parser.js create mode 100644 public/node_modules/formidable/lib/multipart_parser.js create mode 100644 public/node_modules/formidable/lib/octet_parser.js create mode 100644 public/node_modules/formidable/lib/querystring_parser.js create mode 100644 public/node_modules/formidable/package.json create mode 100644 public/node_modules/inherits/LICENSE create mode 100644 public/node_modules/inherits/README.md create mode 100644 public/node_modules/inherits/inherits.js create mode 100644 public/node_modules/inherits/inherits_browser.js create mode 100644 public/node_modules/inherits/package.json create mode 100644 public/node_modules/inherits/test.js create mode 100644 public/node_modules/isarray/README.md create mode 100644 public/node_modules/isarray/build/build.js create mode 100644 public/node_modules/isarray/component.json create mode 100644 public/node_modules/isarray/index.js create mode 100644 public/node_modules/isarray/package.json create mode 100644 public/node_modules/methods/HISTORY.md create mode 100644 public/node_modules/methods/LICENSE create mode 100644 public/node_modules/methods/README.md create mode 100644 public/node_modules/methods/index.js create mode 100644 public/node_modules/methods/package.json create mode 100644 public/node_modules/mime-db/HISTORY.md create mode 100644 public/node_modules/mime-db/LICENSE create mode 100644 public/node_modules/mime-db/README.md create mode 100644 public/node_modules/mime-db/db.json create mode 100644 public/node_modules/mime-db/index.js create mode 100644 public/node_modules/mime-db/package.json create mode 100644 public/node_modules/mime-types/HISTORY.md create mode 100644 public/node_modules/mime-types/LICENSE create mode 100644 public/node_modules/mime-types/README.md create mode 100644 public/node_modules/mime-types/index.js create mode 100644 public/node_modules/mime-types/package.json create mode 100644 public/node_modules/mime/.npmignore create mode 100644 public/node_modules/mime/LICENSE create mode 100644 public/node_modules/mime/README.md create mode 100644 public/node_modules/mime/build/build.js create mode 100644 public/node_modules/mime/build/test.js create mode 100755 public/node_modules/mime/cli.js create mode 100644 public/node_modules/mime/mime.js create mode 100644 public/node_modules/mime/package.json create mode 100644 public/node_modules/mime/types.json create mode 100644 public/node_modules/ms/.npmignore create mode 100644 public/node_modules/ms/History.md create mode 100644 public/node_modules/ms/LICENSE create mode 100644 public/node_modules/ms/README.md create mode 100644 public/node_modules/ms/index.js create mode 100644 public/node_modules/ms/package.json create mode 100644 public/node_modules/qs/.jshintignore create mode 100644 public/node_modules/qs/.jshintrc create mode 100644 public/node_modules/qs/.npmignore create mode 100644 public/node_modules/qs/.travis.yml create mode 100644 public/node_modules/qs/CHANGELOG.md create mode 100644 public/node_modules/qs/CONTRIBUTING.md create mode 100755 public/node_modules/qs/LICENSE create mode 100644 public/node_modules/qs/Makefile create mode 100755 public/node_modules/qs/README.md create mode 100644 public/node_modules/qs/index.js create mode 100755 public/node_modules/qs/lib/index.js create mode 100755 public/node_modules/qs/lib/parse.js create mode 100755 public/node_modules/qs/lib/stringify.js create mode 100755 public/node_modules/qs/lib/utils.js create mode 100644 public/node_modules/qs/package.json create mode 100755 public/node_modules/qs/test/parse.js create mode 100755 public/node_modules/qs/test/stringify.js create mode 100644 public/node_modules/readable-stream/.npmignore create mode 100644 public/node_modules/readable-stream/LICENSE create mode 100644 public/node_modules/readable-stream/README.md create mode 100644 public/node_modules/readable-stream/duplex.js create mode 100644 public/node_modules/readable-stream/lib/_stream_duplex.js create mode 100644 public/node_modules/readable-stream/lib/_stream_passthrough.js create mode 100644 public/node_modules/readable-stream/lib/_stream_readable.js create mode 100644 public/node_modules/readable-stream/lib/_stream_transform.js create mode 100644 public/node_modules/readable-stream/lib/_stream_writable.js create mode 100644 public/node_modules/readable-stream/package.json create mode 100644 public/node_modules/readable-stream/passthrough.js create mode 100644 public/node_modules/readable-stream/readable.js create mode 100644 public/node_modules/readable-stream/transform.js create mode 100644 public/node_modules/readable-stream/writable.js create mode 100644 public/node_modules/reduce-component/.npmignore create mode 100644 public/node_modules/reduce-component/History.md create mode 100644 public/node_modules/reduce-component/LICENSE create mode 100644 public/node_modules/reduce-component/Makefile create mode 100644 public/node_modules/reduce-component/Readme.md create mode 100644 public/node_modules/reduce-component/component.json create mode 100644 public/node_modules/reduce-component/index.js create mode 100644 public/node_modules/reduce-component/package.json create mode 100644 public/node_modules/reduce-component/test/index.html create mode 100644 public/node_modules/reduce-component/test/reduce.js create mode 100644 public/node_modules/string_decoder/.npmignore create mode 100644 public/node_modules/string_decoder/LICENSE create mode 100644 public/node_modules/string_decoder/README.md create mode 100644 public/node_modules/string_decoder/index.js create mode 100644 public/node_modules/string_decoder/package.json create mode 100644 public/node_modules/superagent/.npmignore create mode 100644 public/node_modules/superagent/.travis.yml create mode 100644 public/node_modules/superagent/.zuul.yml create mode 100644 public/node_modules/superagent/Contributing.md create mode 100644 public/node_modules/superagent/History.md create mode 100644 public/node_modules/superagent/LICENSE create mode 100644 public/node_modules/superagent/Makefile create mode 100644 public/node_modules/superagent/Readme.md create mode 100644 public/node_modules/superagent/bower.json create mode 100644 public/node_modules/superagent/component.json create mode 100644 public/node_modules/superagent/docs/head.html create mode 100644 public/node_modules/superagent/docs/highlight.js create mode 100644 public/node_modules/superagent/docs/images/bg.png create mode 100644 public/node_modules/superagent/docs/index.md create mode 100644 public/node_modules/superagent/docs/jquery-ui.min.js create mode 100644 public/node_modules/superagent/docs/jquery.js create mode 100755 public/node_modules/superagent/docs/jquery.tocify.min.js create mode 100644 public/node_modules/superagent/docs/style.css create mode 100644 public/node_modules/superagent/docs/tail.html create mode 100644 public/node_modules/superagent/docs/test.html create mode 100644 public/node_modules/superagent/lib/client.js create mode 100644 public/node_modules/superagent/lib/node/agent.js create mode 100644 public/node_modules/superagent/lib/node/index.js create mode 100644 public/node_modules/superagent/lib/node/parsers/image.js create mode 100644 public/node_modules/superagent/lib/node/parsers/index.js create mode 100644 public/node_modules/superagent/lib/node/parsers/json.js create mode 100644 public/node_modules/superagent/lib/node/parsers/text.js create mode 100644 public/node_modules/superagent/lib/node/parsers/urlencoded.js create mode 100644 public/node_modules/superagent/lib/node/part.js create mode 100644 public/node_modules/superagent/lib/node/response.js create mode 100644 public/node_modules/superagent/lib/node/utils.js create mode 100644 public/node_modules/superagent/package.json create mode 100644 public/node_modules/superagent/superagent.js create mode 100644 public/node_modules/superagent/test.js diff --git a/.gitignore b/.gitignore index daeba5f9..93bfd12e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ *~ -node_modules .DS_Store diff --git a/comments.json b/comments.json index 36e9f6fe..f7bef7c5 100644 --- a/comments.json +++ b/comments.json @@ -1,14 +1,4 @@ [ - { - "id": 1388534400000, - "author": "Pete Hunt", - "text": "Hey there!" - }, - { - "id": 1420070400000, - "author": "Paul O’Shannessy", - "text": "React is *great*!" - }, { "id": 1452894030484, "author": "Jim", @@ -23,5 +13,40 @@ "id": 1452894062395, "author": "hey", "text": "hey" + }, + { + "id": 1452894062396, + "author": "koala bear", + "text": "im always hungry" + }, + { + "id": 1452894062399, + "author": "brown bear", + "text": "i already ate." + }, + { + "id": 1453330152651, + "author": "plant", + "text": "where are my eyes" + }, + { + "id": 1453330182029, + "author": "tree", + "text": "i need shoes" + }, + { + "id": 1453330430562, + "author": "test", + "text": "test" + }, + { + "id": 1453330597664, + "author": "webdev", + "text": "make the server crash" + }, + { + "id": 1453387039315, + "author": "thursday", + "text": "is good" } ] \ No newline at end of file diff --git a/public/index.html b/public/index.html index 642f6c99..bcf2410a 100644 --- a/public/index.html +++ b/public/index.html @@ -10,6 +10,7 @@ + diff --git a/public/node_modules/.bin/mime b/public/node_modules/.bin/mime new file mode 120000 index 00000000..fbb7ee0e --- /dev/null +++ b/public/node_modules/.bin/mime @@ -0,0 +1 @@ +../mime/cli.js \ No newline at end of file diff --git a/public/node_modules/async/.travis.yml b/public/node_modules/async/.travis.yml new file mode 100644 index 00000000..6064ca09 --- /dev/null +++ b/public/node_modules/async/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.10" + - "0.12" + - "iojs" diff --git a/public/node_modules/async/LICENSE b/public/node_modules/async/LICENSE new file mode 100644 index 00000000..8f296985 --- /dev/null +++ b/public/node_modules/async/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010-2014 Caolan McMahon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/public/node_modules/async/README.md b/public/node_modules/async/README.md new file mode 100644 index 00000000..6cfb922c --- /dev/null +++ b/public/node_modules/async/README.md @@ -0,0 +1,1647 @@ +# Async.js + +[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async) + + +Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with [Node.js](http://nodejs.org) and installable via `npm install async`, +it can also be used directly in the browser. + +Async is also installable via: + +- [bower](http://bower.io/): `bower install async` +- [component](https://github.com/component/component): `component install + caolan/async` +- [jam](http://jamjs.org/): `jam install async` +- [spm](http://spmjs.io/): `spm install async` + +Async provides around 20 functions that include the usual 'functional' +suspects (`map`, `reduce`, `filter`, `each`…) as well as some common patterns +for asynchronous control flow (`parallel`, `series`, `waterfall`…). All these +functions assume you follow the Node.js convention of providing a single +callback as the last argument of your `async` function. + + +## Quick Examples + +```javascript +async.map(['file1','file2','file3'], fs.stat, function(err, results){ + // results is now an array of stats for each file +}); + +async.filter(['file1','file2','file3'], fs.exists, function(results){ + // results now equals an array of the existing files +}); + +async.parallel([ + function(){ ... }, + function(){ ... } +], callback); + +async.series([ + function(){ ... }, + function(){ ... } +]); +``` + +There are many more functions available so take a look at the docs below for a +full list. This module aims to be comprehensive, so if you feel anything is +missing please create a GitHub issue for it. + +## Common Pitfalls + +### Binding a context to an iterator + +This section is really about `bind`, not about `async`. If you are wondering how to +make `async` execute your iterators in a given context, or are confused as to why +a method of another library isn't working as an iterator, study this example: + +```js +// Here is a simple object with an (unnecessarily roundabout) squaring method +var AsyncSquaringLibrary = { + squareExponent: 2, + square: function(number, callback){ + var result = Math.pow(number, this.squareExponent); + setTimeout(function(){ + callback(null, result); + }, 200); + } +}; + +async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result){ + // result is [NaN, NaN, NaN] + // This fails because the `this.squareExponent` expression in the square + // function is not evaluated in the context of AsyncSquaringLibrary, and is + // therefore undefined. +}); + +async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){ + // result is [1, 4, 9] + // With the help of bind we can attach a context to the iterator before + // passing it to async. Now the square function will be executed in its + // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent` + // will be as expected. +}); +``` + +## Download + +The source is available for download from +[GitHub](http://github.com/caolan/async). +Alternatively, you can install using Node Package Manager (`npm`): + + npm install async + +__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 29.6kb Uncompressed + +## In the Browser + +So far it's been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. + +Usage: + +```html + + +``` + +## Documentation + +### Collections + +* [`each`](#each) +* [`eachSeries`](#eachSeries) +* [`eachLimit`](#eachLimit) +* [`map`](#map) +* [`mapSeries`](#mapSeries) +* [`mapLimit`](#mapLimit) +* [`filter`](#filter) +* [`filterSeries`](#filterSeries) +* [`reject`](#reject) +* [`rejectSeries`](#rejectSeries) +* [`reduce`](#reduce) +* [`reduceRight`](#reduceRight) +* [`detect`](#detect) +* [`detectSeries`](#detectSeries) +* [`sortBy`](#sortBy) +* [`some`](#some) +* [`every`](#every) +* [`concat`](#concat) +* [`concatSeries`](#concatSeries) + +### Control Flow + +* [`series`](#seriestasks-callback) +* [`parallel`](#parallel) +* [`parallelLimit`](#parallellimittasks-limit-callback) +* [`whilst`](#whilst) +* [`doWhilst`](#doWhilst) +* [`until`](#until) +* [`doUntil`](#doUntil) +* [`forever`](#forever) +* [`waterfall`](#waterfall) +* [`compose`](#compose) +* [`seq`](#seq) +* [`applyEach`](#applyEach) +* [`applyEachSeries`](#applyEachSeries) +* [`queue`](#queue) +* [`priorityQueue`](#priorityQueue) +* [`cargo`](#cargo) +* [`auto`](#auto) +* [`retry`](#retry) +* [`iterator`](#iterator) +* [`apply`](#apply) +* [`nextTick`](#nextTick) +* [`times`](#times) +* [`timesSeries`](#timesSeries) + +### Utils + +* [`memoize`](#memoize) +* [`unmemoize`](#unmemoize) +* [`log`](#log) +* [`dir`](#dir) +* [`noConflict`](#noConflict) + + +## Collections + + + +### each(arr, iterator, callback) + +Applies the function `iterator` to each item in `arr`, in parallel. +The `iterator` is called with an item from the list, and a callback for when it +has finished. If the `iterator` passes an error to its `callback`, the main +`callback` (for the `each` function) is immediately called with the error. + +Note, that since this function applies `iterator` to each item in parallel, +there is no guarantee that the iterator functions will complete in order. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err)` which must be called once it has + completed. If no error has occurred, the `callback` should be run without + arguments or with an explicit `null` argument. +* `callback(err)` - A callback which is called when all `iterator` functions + have finished, or an error occurs. + +__Examples__ + + +```js +// assuming openFiles is an array of file names and saveFile is a function +// to save the modified contents of that file: + +async.each(openFiles, saveFile, function(err){ + // if any of the saves produced an error, err would equal that error +}); +``` + +```js +// assuming openFiles is an array of file names + +async.each(openFiles, function(file, callback) { + + // Perform operation on file here. + console.log('Processing file ' + file); + + if( file.length > 32 ) { + console.log('This file name is too long'); + callback('File name too long'); + } else { + // Do work to process file here + console.log('File processed'); + callback(); + } +}, function(err){ + // if any of the file processing produced an error, err would equal that error + if( err ) { + // One of the iterations produced an error. + // All processing will now stop. + console.log('A file failed to process'); + } else { + console.log('All files have been processed successfully'); + } +}); +``` + +--------------------------------------- + + + +### eachSeries(arr, iterator, callback) + +The same as [`each`](#each), only `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +This means the `iterator` functions will complete in order. + + +--------------------------------------- + + + +### eachLimit(arr, limit, iterator, callback) + +The same as [`each`](#each), only no more than `limit` `iterator`s will be simultaneously +running at any time. + +Note that the items in `arr` are not processed in batches, so there is no guarantee that +the first `limit` `iterator` functions will complete before any others are started. + +__Arguments__ + +* `arr` - An array to iterate over. +* `limit` - The maximum number of `iterator`s to run at any time. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err)` which must be called once it has + completed. If no error has occurred, the callback should be run without + arguments or with an explicit `null` argument. +* `callback(err)` - A callback which is called when all `iterator` functions + have finished, or an error occurs. + +__Example__ + +```js +// Assume documents is an array of JSON objects and requestApi is a +// function that interacts with a rate-limited REST api. + +async.eachLimit(documents, 20, requestApi, function(err){ + // if any of the saves produced an error, err would equal that error +}); +``` + +--------------------------------------- + + +### map(arr, iterator, callback) + +Produces a new array of values by mapping each value in `arr` through +the `iterator` function. The `iterator` is called with an item from `arr` and a +callback for when it has finished processing. Each of these callback takes 2 arguments: +an `error`, and the transformed item from `arr`. If `iterator` passes an error to his +callback, the main `callback` (for the `map` function) is immediately called with the error. + +Note, that since this function applies the `iterator` to each item in parallel, +there is no guarantee that the `iterator` functions will complete in order. +However, the results array will be in the same order as the original `arr`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, transformed)` which must be called once + it has completed with an error (which can be `null`) and a transformed item. +* `callback(err, results)` - A callback which is called when all `iterator` + functions have finished, or an error occurs. Results is an array of the + transformed items from the `arr`. + +__Example__ + +```js +async.map(['file1','file2','file3'], fs.stat, function(err, results){ + // results is now an array of stats for each file +}); +``` + +--------------------------------------- + + +### mapSeries(arr, iterator, callback) + +The same as [`map`](#map), only the `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + + +--------------------------------------- + + +### mapLimit(arr, limit, iterator, callback) + +The same as [`map`](#map), only no more than `limit` `iterator`s will be simultaneously +running at any time. + +Note that the items are not processed in batches, so there is no guarantee that +the first `limit` `iterator` functions will complete before any others are started. + +__Arguments__ + +* `arr` - An array to iterate over. +* `limit` - The maximum number of `iterator`s to run at any time. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, transformed)` which must be called once + it has completed with an error (which can be `null`) and a transformed item. +* `callback(err, results)` - A callback which is called when all `iterator` + calls have finished, or an error occurs. The result is an array of the + transformed items from the original `arr`. + +__Example__ + +```js +async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){ + // results is now an array of stats for each file +}); +``` + +--------------------------------------- + + + +### filter(arr, iterator, callback) + +__Alias:__ `select` + +Returns a new array of all the values in `arr` which pass an async truth test. +_The callback for each `iterator` call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. This operation is +performed in parallel, but the results array will be in the same order as the +original. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in `arr`. + The `iterator` is passed a `callback(truthValue)`, which must be called with a + boolean argument once it has completed. +* `callback(results)` - A callback which is called after all the `iterator` + functions have finished. + +__Example__ + +```js +async.filter(['file1','file2','file3'], fs.exists, function(results){ + // results now equals an array of the existing files +}); +``` + +--------------------------------------- + + + +### filterSeries(arr, iterator, callback) + +__Alias:__ `selectSeries` + +The same as [`filter`](#filter) only the `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + +--------------------------------------- + + +### reject(arr, iterator, callback) + +The opposite of [`filter`](#filter). Removes values that pass an `async` truth test. + +--------------------------------------- + + +### rejectSeries(arr, iterator, callback) + +The same as [`reject`](#reject), only the `iterator` is applied to each item in `arr` +in series. + + +--------------------------------------- + + +### reduce(arr, memo, iterator, callback) + +__Aliases:__ `inject`, `foldl` + +Reduces `arr` into a single value using an async `iterator` to return +each successive step. `memo` is the initial state of the reduction. +This function only operates in series. + +For performance reasons, it may make sense to split a call to this function into +a parallel map, and then use the normal `Array.prototype.reduce` on the results. +This function is for situations where each step in the reduction needs to be async; +if you can get the data before reducing it, then it's probably a good idea to do so. + +__Arguments__ + +* `arr` - An array to iterate over. +* `memo` - The initial state of the reduction. +* `iterator(memo, item, callback)` - A function applied to each item in the + array to produce the next step in the reduction. The `iterator` is passed a + `callback(err, reduction)` which accepts an optional error as its first + argument, and the state of the reduction as the second. If an error is + passed to the callback, the reduction is stopped and the main `callback` is + immediately called with the error. +* `callback(err, result)` - A callback which is called after all the `iterator` + functions have finished. Result is the reduced value. + +__Example__ + +```js +async.reduce([1,2,3], 0, function(memo, item, callback){ + // pointless async: + process.nextTick(function(){ + callback(null, memo + item) + }); +}, function(err, result){ + // result is now equal to the last value of memo, which is 6 +}); +``` + +--------------------------------------- + + +### reduceRight(arr, memo, iterator, callback) + +__Alias:__ `foldr` + +Same as [`reduce`](#reduce), only operates on `arr` in reverse order. + + +--------------------------------------- + + +### detect(arr, iterator, callback) + +Returns the first value in `arr` that passes an async truth test. The +`iterator` is applied in parallel, meaning the first iterator to return `true` will +fire the detect `callback` with that result. That means the result might not be +the first item in the original `arr` (in terms of order) that passes the test. + +If order within the original `arr` is important, then look at [`detectSeries`](#detectSeries). + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in `arr`. + The iterator is passed a `callback(truthValue)` which must be called with a + boolean argument once it has completed. +* `callback(result)` - A callback which is called as soon as any iterator returns + `true`, or after all the `iterator` functions have finished. Result will be + the first item in the array that passes the truth test (iterator) or the + value `undefined` if none passed. + +__Example__ + +```js +async.detect(['file1','file2','file3'], fs.exists, function(result){ + // result now equals the first file in the list that exists +}); +``` + +--------------------------------------- + + +### detectSeries(arr, iterator, callback) + +The same as [`detect`](#detect), only the `iterator` is applied to each item in `arr` +in series. This means the result is always the first in the original `arr` (in +terms of array order) that passes the truth test. + + +--------------------------------------- + + +### sortBy(arr, iterator, callback) + +Sorts a list by the results of running each `arr` value through an async `iterator`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, sortValue)` which must be called once it + has completed with an error (which can be `null`) and a value to use as the sort + criteria. +* `callback(err, results)` - A callback which is called after all the `iterator` + functions have finished, or an error occurs. Results is the items from + the original `arr` sorted by the values returned by the `iterator` calls. + +__Example__ + +```js +async.sortBy(['file1','file2','file3'], function(file, callback){ + fs.stat(file, function(err, stats){ + callback(err, stats.mtime); + }); +}, function(err, results){ + // results is now the original array of files sorted by + // modified date +}); +``` + +__Sort Order__ + +By modifying the callback parameter the sorting order can be influenced: + +```js +//ascending order +async.sortBy([1,9,3,5], function(x, callback){ + callback(null, x); +}, function(err,result){ + //result callback +} ); + +//descending order +async.sortBy([1,9,3,5], function(x, callback){ + callback(null, x*-1); //<- x*-1 instead of x, turns the order around +}, function(err,result){ + //result callback +} ); +``` + +--------------------------------------- + + +### some(arr, iterator, callback) + +__Alias:__ `any` + +Returns `true` if at least one element in the `arr` satisfies an async test. +_The callback for each iterator call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. Once any iterator +call returns `true`, the main `callback` is immediately called. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in the array + in parallel. The iterator is passed a callback(truthValue) which must be + called with a boolean argument once it has completed. +* `callback(result)` - A callback which is called as soon as any iterator returns + `true`, or after all the iterator functions have finished. Result will be + either `true` or `false` depending on the values of the async tests. + +__Example__ + +```js +async.some(['file1','file2','file3'], fs.exists, function(result){ + // if result is true then at least one of the files exists +}); +``` + +--------------------------------------- + + +### every(arr, iterator, callback) + +__Alias:__ `all` + +Returns `true` if every element in `arr` satisfies an async test. +_The callback for each `iterator` call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in the array + in parallel. The iterator is passed a callback(truthValue) which must be + called with a boolean argument once it has completed. +* `callback(result)` - A callback which is called after all the `iterator` + functions have finished. Result will be either `true` or `false` depending on + the values of the async tests. + +__Example__ + +```js +async.every(['file1','file2','file3'], fs.exists, function(result){ + // if result is true then every file exists +}); +``` + +--------------------------------------- + + +### concat(arr, iterator, callback) + +Applies `iterator` to each item in `arr`, concatenating the results. Returns the +concatenated list. The `iterator`s are called in parallel, and the results are +concatenated as they return. There is no guarantee that the results array will +be returned in the original order of `arr` passed to the `iterator` function. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, results)` which must be called once it + has completed with an error (which can be `null`) and an array of results. +* `callback(err, results)` - A callback which is called after all the `iterator` + functions have finished, or an error occurs. Results is an array containing + the concatenated results of the `iterator` function. + +__Example__ + +```js +async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){ + // files is now a list of filenames that exist in the 3 directories +}); +``` + +--------------------------------------- + + +### concatSeries(arr, iterator, callback) + +Same as [`concat`](#concat), but executes in series instead of parallel. + + +## Control Flow + + +### series(tasks, [callback]) + +Run the functions in the `tasks` array in series, each one running once the previous +function has completed. If any functions in the series pass an error to its +callback, no more functions are run, and `callback` is immediately called with the value of the error. +Otherwise, `callback` receives an array of results when `tasks` have completed. + +It is also possible to use an object instead of an array. Each property will be +run as a function, and the results will be passed to the final `callback` as an object +instead of an array. This can be a more readable way of handling results from +[`series`](#series). + +**Note** that while many implementations preserve the order of object properties, the +[ECMAScript Language Specifcation](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) +explicitly states that + +> The mechanics and order of enumerating the properties is not specified. + +So if you rely on the order in which your series of functions are executed, and want +this to work on all platforms, consider using an array. + +__Arguments__ + +* `tasks` - An array or object containing functions to run, each function is passed + a `callback(err, result)` it must call on completion with an error `err` (which can + be `null`) and an optional `result` value. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the `task` callbacks. + +__Example__ + +```js +async.series([ + function(callback){ + // do some stuff ... + callback(null, 'one'); + }, + function(callback){ + // do some more stuff ... + callback(null, 'two'); + } +], +// optional callback +function(err, results){ + // results is now equal to ['one', 'two'] +}); + + +// an example using an object instead of an array +async.series({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +}, +function(err, results) { + // results is now equal to: {one: 1, two: 2} +}); +``` + +--------------------------------------- + + +### parallel(tasks, [callback]) + +Run the `tasks` array of functions in parallel, without waiting until the previous +function has completed. If any of the functions pass an error to its +callback, the main `callback` is immediately called with the value of the error. +Once the `tasks` have completed, the results are passed to the final `callback` as an +array. + +It is also possible to use an object instead of an array. Each property will be +run as a function and the results will be passed to the final `callback` as an object +instead of an array. This can be a more readable way of handling results from +[`parallel`](#parallel). + + +__Arguments__ + +* `tasks` - An array or object containing functions to run. Each function is passed + a `callback(err, result)` which it must call on completion with an error `err` + (which can be `null`) and an optional `result` value. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the task callbacks. + +__Example__ + +```js +async.parallel([ + function(callback){ + setTimeout(function(){ + callback(null, 'one'); + }, 200); + }, + function(callback){ + setTimeout(function(){ + callback(null, 'two'); + }, 100); + } +], +// optional callback +function(err, results){ + // the results array will equal ['one','two'] even though + // the second function had a shorter timeout. +}); + + +// an example using an object instead of an array +async.parallel({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +}, +function(err, results) { + // results is now equals to: {one: 1, two: 2} +}); +``` + +--------------------------------------- + + +### parallelLimit(tasks, limit, [callback]) + +The same as [`parallel`](#parallel), only `tasks` are executed in parallel +with a maximum of `limit` tasks executing at any time. + +Note that the `tasks` are not executed in batches, so there is no guarantee that +the first `limit` tasks will complete before any others are started. + +__Arguments__ + +* `tasks` - An array or object containing functions to run, each function is passed + a `callback(err, result)` it must call on completion with an error `err` (which can + be `null`) and an optional `result` value. +* `limit` - The maximum number of `tasks` to run at any time. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the `task` callbacks. + +--------------------------------------- + + +### whilst(test, fn, callback) + +Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when stopped, +or an error occurs. + +__Arguments__ + +* `test()` - synchronous truth test to perform before each execution of `fn`. +* `fn(callback)` - A function which is called each time `test` passes. The function is + passed a `callback(err)`, which must be called once it has completed with an + optional `err` argument. +* `callback(err)` - A callback which is called after the test fails and repeated + execution of `fn` has stopped. + +__Example__ + +```js +var count = 0; + +async.whilst( + function () { return count < 5; }, + function (callback) { + count++; + setTimeout(callback, 1000); + }, + function (err) { + // 5 seconds have passed + } +); +``` + +--------------------------------------- + + +### doWhilst(fn, test, callback) + +The post-check version of [`whilst`](#whilst). To reflect the difference in +the order of operations, the arguments `test` and `fn` are switched. + +`doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. + +--------------------------------------- + + +### until(test, fn, callback) + +Repeatedly call `fn` until `test` returns `true`. Calls `callback` when stopped, +or an error occurs. + +The inverse of [`whilst`](#whilst). + +--------------------------------------- + + +### doUntil(fn, test, callback) + +Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument ordering differs from `until`. + +--------------------------------------- + + +### forever(fn, errback) + +Calls the asynchronous function `fn` with a callback parameter that allows it to +call itself again, in series, indefinitely. + +If an error is passed to the callback then `errback` is called with the +error, and execution stops, otherwise it will never be called. + +```js +async.forever( + function(next) { + // next is suitable for passing to things that need a callback(err [, whatever]); + // it will result in this function being called again. + }, + function(err) { + // if next is called with a value in its first parameter, it will appear + // in here as 'err', and execution will stop. + } +); +``` + +--------------------------------------- + + +### waterfall(tasks, [callback]) + +Runs the `tasks` array of functions in series, each passing their results to the next in +the array. However, if any of the `tasks` pass an error to their own callback, the +next function is not executed, and the main `callback` is immediately called with +the error. + +__Arguments__ + +* `tasks` - An array of functions to run, each function is passed a + `callback(err, result1, result2, ...)` it must call on completion. The first + argument is an error (which can be `null`) and any further arguments will be + passed as arguments in order to the next task. +* `callback(err, [results])` - An optional callback to run once all the functions + have completed. This will be passed the results of the last task's callback. + + + +__Example__ + +```js +async.waterfall([ + function(callback) { + callback(null, 'one', 'two'); + }, + function(arg1, arg2, callback) { + // arg1 now equals 'one' and arg2 now equals 'two' + callback(null, 'three'); + }, + function(arg1, callback) { + // arg1 now equals 'three' + callback(null, 'done'); + } +], function (err, result) { + // result now equals 'done' +}); +``` + +--------------------------------------- + +### compose(fn1, fn2...) + +Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions `f()`, `g()`, and `h()` would produce the result of +`f(g(h()))`, only this version uses callbacks to obtain the return values. + +Each function is executed with the `this` binding of the composed function. + +__Arguments__ + +* `functions...` - the asynchronous functions to compose + + +__Example__ + +```js +function add1(n, callback) { + setTimeout(function () { + callback(null, n + 1); + }, 10); +} + +function mul3(n, callback) { + setTimeout(function () { + callback(null, n * 3); + }, 10); +} + +var add1mul3 = async.compose(mul3, add1); + +add1mul3(4, function (err, result) { + // result now equals 15 +}); +``` + +--------------------------------------- + +### seq(fn1, fn2...) + +Version of the compose function that is more natural to read. +Each function consumes the return value of the previous function. +It is the equivalent of [`compose`](#compose) with the arguments reversed. + +Each function is executed with the `this` binding of the composed function. + +__Arguments__ + +* functions... - the asynchronous functions to compose + + +__Example__ + +```js +// Requires lodash (or underscore), express3 and dresende's orm2. +// Part of an app, that fetches cats of the logged user. +// This example uses `seq` function to avoid overnesting and error +// handling clutter. +app.get('/cats', function(request, response) { + var User = request.models.User; + async.seq( + _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data)) + function(user, fn) { + user.getCats(fn); // 'getCats' has signature (callback(err, data)) + } + )(req.session.user_id, function (err, cats) { + if (err) { + console.error(err); + response.json({ status: 'error', message: err.message }); + } else { + response.json({ status: 'ok', message: 'Cats found', data: cats }); + } + }); +}); +``` + +--------------------------------------- + +### applyEach(fns, args..., callback) + +Applies the provided arguments to each function in the array, calling +`callback` after all functions have completed. If you only provide the first +argument, then it will return a function which lets you pass in the +arguments as if it were a single function call. + +__Arguments__ + +* `fns` - the asynchronous functions to all call with the same arguments +* `args...` - any number of separate arguments to pass to the function +* `callback` - the final argument should be the callback, called when all + functions have completed processing + + +__Example__ + +```js +async.applyEach([enableSearch, updateSchema], 'bucket', callback); + +// partial application example: +async.each( + buckets, + async.applyEach([enableSearch, updateSchema]), + callback +); +``` + +--------------------------------------- + + +### applyEachSeries(arr, iterator, callback) + +The same as [`applyEach`](#applyEach) only the functions are applied in series. + +--------------------------------------- + + +### queue(worker, concurrency) + +Creates a `queue` object with the specified `concurrency`. Tasks added to the +`queue` are processed in parallel (up to the `concurrency` limit). If all +`worker`s are in progress, the task is queued until one becomes available. +Once a `worker` completes a `task`, that `task`'s callback is called. + +__Arguments__ + +* `worker(task, callback)` - An asynchronous function for processing a queued + task, which must call its `callback(err)` argument when finished, with an + optional `error` as an argument. +* `concurrency` - An `integer` for determining how many `worker` functions should be + run in parallel. + +__Queue objects__ + +The `queue` object returned by this function has the following properties and +methods: + +* `length()` - a function returning the number of items waiting to be processed. +* `started` - a function returning whether or not any items have been pushed and processed by the queue +* `running()` - a function returning the number of items currently being processed. +* `idle()` - a function returning false if there are items waiting or being processed, or true if not. +* `concurrency` - an integer for determining how many `worker` functions should be + run in parallel. This property can be changed after a `queue` is created to + alter the concurrency on-the-fly. +* `push(task, [callback])` - add a new task to the `queue`. Calls `callback` once + the `worker` has finished processing the task. Instead of a single task, a `tasks` array + can be submitted. The respective callback is used for every task in the list. +* `unshift(task, [callback])` - add a new task to the front of the `queue`. +* `saturated` - a callback that is called when the `queue` length hits the `concurrency` limit, + and further tasks will be queued. +* `empty` - a callback that is called when the last item from the `queue` is given to a `worker`. +* `drain` - a callback that is called when the last item from the `queue` has returned from the `worker`. +* `paused` - a boolean for determining whether the queue is in a paused state +* `pause()` - a function that pauses the processing of tasks until `resume()` is called. +* `resume()` - a function that resumes the processing of queued tasks when the queue is paused. +* `kill()` - a function that removes the `drain` callback and empties remaining tasks from the queue forcing it to go idle. + +__Example__ + +```js +// create a queue object with concurrency 2 + +var q = async.queue(function (task, callback) { + console.log('hello ' + task.name); + callback(); +}, 2); + + +// assign a callback +q.drain = function() { + console.log('all items have been processed'); +} + +// add some items to the queue + +q.push({name: 'foo'}, function (err) { + console.log('finished processing foo'); +}); +q.push({name: 'bar'}, function (err) { + console.log('finished processing bar'); +}); + +// add some items to the queue (batch-wise) + +q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) { + console.log('finished processing item'); +}); + +// add some items to the front of the queue + +q.unshift({name: 'bar'}, function (err) { + console.log('finished processing bar'); +}); +``` + + +--------------------------------------- + + +### priorityQueue(worker, concurrency) + +The same as [`queue`](#queue) only tasks are assigned a priority and completed in ascending priority order. There are two differences between `queue` and `priorityQueue` objects: + +* `push(task, priority, [callback])` - `priority` should be a number. If an array of + `tasks` is given, all tasks will be assigned the same priority. +* The `unshift` method was removed. + +--------------------------------------- + + +### cargo(worker, [payload]) + +Creates a `cargo` object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the `payload` limit). If the +`worker` is in progress, the task is queued until it becomes available. Once +the `worker` has completed some tasks, each callback of those tasks is called. +Check out [this animation](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) for how `cargo` and `queue` work. + +While [queue](#queue) passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished. + +__Arguments__ + +* `worker(tasks, callback)` - An asynchronous function for processing an array of + queued tasks, which must call its `callback(err)` argument when finished, with + an optional `err` argument. +* `payload` - An optional `integer` for determining how many tasks should be + processed per round; if omitted, the default is unlimited. + +__Cargo objects__ + +The `cargo` object returned by this function has the following properties and +methods: + +* `length()` - A function returning the number of items waiting to be processed. +* `payload` - An `integer` for determining how many tasks should be + process per round. This property can be changed after a `cargo` is created to + alter the payload on-the-fly. +* `push(task, [callback])` - Adds `task` to the `queue`. The callback is called + once the `worker` has finished processing the task. Instead of a single task, an array of `tasks` + can be submitted. The respective callback is used for every task in the list. +* `saturated` - A callback that is called when the `queue.length()` hits the concurrency and further tasks will be queued. +* `empty` - A callback that is called when the last item from the `queue` is given to a `worker`. +* `drain` - A callback that is called when the last item from the `queue` has returned from the `worker`. + +__Example__ + +```js +// create a cargo object with payload 2 + +var cargo = async.cargo(function (tasks, callback) { + for(var i=0; i +### auto(tasks, [callback]) + +Determines the best order for running the functions in `tasks`, based on their +requirements. Each function can optionally depend on other functions being completed +first, and each function is run as soon as its requirements are satisfied. + +If any of the functions pass an error to their callback, it will not +complete (so any other functions depending on it will not run), and the main +`callback` is immediately called with the error. Functions also receive an +object containing the results of functions which have completed so far. + +Note, all functions are called with a `results` object as a second argument, +so it is unsafe to pass functions in the `tasks` object which cannot handle the +extra argument. + +For example, this snippet of code: + +```js +async.auto({ + readData: async.apply(fs.readFile, 'data.txt', 'utf-8') +}, callback); +``` + +will have the effect of calling `readFile` with the results object as the last +argument, which will fail: + +```js +fs.readFile('data.txt', 'utf-8', cb, {}); +``` + +Instead, wrap the call to `readFile` in a function which does not forward the +`results` object: + +```js +async.auto({ + readData: function(cb, results){ + fs.readFile('data.txt', 'utf-8', cb); + } +}, callback); +``` + +__Arguments__ + +* `tasks` - An object. Each of its properties is either a function or an array of + requirements, with the function itself the last item in the array. The object's key + of a property serves as the name of the task defined by that property, + i.e. can be used when specifying requirements for other tasks. + The function receives two arguments: (1) a `callback(err, result)` which must be + called when finished, passing an `error` (which can be `null`) and the result of + the function's execution, and (2) a `results` object, containing the results of + the previously executed functions. +* `callback(err, results)` - An optional callback which is called when all the + tasks have been completed. It receives the `err` argument if any `tasks` + pass an error to their callback. Results are always returned; however, if + an error occurs, no further `tasks` will be performed, and the results + object will only contain partial results. + + +__Example__ + +```js +async.auto({ + get_data: function(callback){ + console.log('in get_data'); + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + make_folder: function(callback){ + console.log('in make_folder'); + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + }, + write_file: ['get_data', 'make_folder', function(callback, results){ + console.log('in write_file', JSON.stringify(results)); + // once there is some data and the directory exists, + // write the data to a file in the directory + callback(null, 'filename'); + }], + email_link: ['write_file', function(callback, results){ + console.log('in email_link', JSON.stringify(results)); + // once the file is written let's email a link to it... + // results.write_file contains the filename returned by write_file. + callback(null, {'file':results.write_file, 'email':'user@example.com'}); + }] +}, function(err, results) { + console.log('err = ', err); + console.log('results = ', results); +}); +``` + +This is a fairly trivial example, but to do this using the basic parallel and +series functions would look like this: + +```js +async.parallel([ + function(callback){ + console.log('in get_data'); + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + function(callback){ + console.log('in make_folder'); + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + } +], +function(err, results){ + async.series([ + function(callback){ + console.log('in write_file', JSON.stringify(results)); + // once there is some data and the directory exists, + // write the data to a file in the directory + results.push('filename'); + callback(null); + }, + function(callback){ + console.log('in email_link', JSON.stringify(results)); + // once the file is written let's email a link to it... + callback(null, {'file':results.pop(), 'email':'user@example.com'}); + } + ]); +}); +``` + +For a complicated series of `async` tasks, using the [`auto`](#auto) function makes adding +new tasks much easier (and the code more readable). + + +--------------------------------------- + + +### retry([times = 5], task, [callback]) + +Attempts to get a successful response from `task` no more than `times` times before +returning an error. If the task is successful, the `callback` will be passed the result +of the successful task. If all attempts fail, the callback will be passed the error and +result (if any) of the final attempt. + +__Arguments__ + +* `times` - An integer indicating how many times to attempt the `task` before giving up. Defaults to 5. +* `task(callback, results)` - A function which receives two arguments: (1) a `callback(err, result)` + which must be called when finished, passing `err` (which can be `null`) and the `result` of + the function's execution, and (2) a `results` object, containing the results of + the previously executed functions (if nested inside another control flow). +* `callback(err, results)` - An optional callback which is called when the + task has succeeded, or after the final failed attempt. It receives the `err` and `result` arguments of the last attempt at completing the `task`. + +The [`retry`](#retry) function can be used as a stand-alone control flow by passing a +callback, as shown below: + +```js +async.retry(3, apiMethod, function(err, result) { + // do something with the result +}); +``` + +It can also be embeded within other control flow functions to retry individual methods +that are not as reliable, like this: + +```js +async.auto({ + users: api.getUsers.bind(api), + payments: async.retry(3, api.getPayments.bind(api)) +}, function(err, results) { + // do something with the results +}); +``` + + +--------------------------------------- + + +### iterator(tasks) + +Creates an iterator function which calls the next function in the `tasks` array, +returning a continuation to call the next one after that. It's also possible to +“peek” at the next iterator with `iterator.next()`. + +This function is used internally by the `async` module, but can be useful when +you want to manually control the flow of functions in series. + +__Arguments__ + +* `tasks` - An array of functions to run. + +__Example__ + +```js +var iterator = async.iterator([ + function(){ sys.p('one'); }, + function(){ sys.p('two'); }, + function(){ sys.p('three'); } +]); + +node> var iterator2 = iterator(); +'one' +node> var iterator3 = iterator2(); +'two' +node> iterator3(); +'three' +node> var nextfn = iterator2.next(); +node> nextfn(); +'three' +``` + +--------------------------------------- + + +### apply(function, arguments..) + +Creates a continuation function with some arguments already applied. + +Useful as a shorthand when combined with other control flow functions. Any arguments +passed to the returned function are added to the arguments originally passed +to apply. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to automatically apply when the + continuation is called. + +__Example__ + +```js +// using apply + +async.parallel([ + async.apply(fs.writeFile, 'testfile1', 'test1'), + async.apply(fs.writeFile, 'testfile2', 'test2'), +]); + + +// the same process without using apply + +async.parallel([ + function(callback){ + fs.writeFile('testfile1', 'test1', callback); + }, + function(callback){ + fs.writeFile('testfile2', 'test2', callback); + } +]); +``` + +It's possible to pass any number of additional arguments when calling the +continuation: + +```js +node> var fn = async.apply(sys.puts, 'one'); +node> fn('two', 'three'); +one +two +three +``` + +--------------------------------------- + + +### nextTick(callback), setImmediate(callback) + +Calls `callback` on a later loop around the event loop. In Node.js this just +calls `process.nextTick`; in the browser it falls back to `setImmediate(callback)` +if available, otherwise `setTimeout(callback, 0)`, which means other higher priority +events may precede the execution of `callback`. + +This is used internally for browser-compatibility purposes. + +__Arguments__ + +* `callback` - The function to call on a later loop around the event loop. + +__Example__ + +```js +var call_order = []; +async.nextTick(function(){ + call_order.push('two'); + // call_order now equals ['one','two'] +}); +call_order.push('one') +``` + + +### times(n, callback) + +Calls the `callback` function `n` times, and accumulates results in the same manner +you would use with [`map`](#map). + +__Arguments__ + +* `n` - The number of times to run the function. +* `callback` - The function to call `n` times. + +__Example__ + +```js +// Pretend this is some complicated async factory +var createUser = function(id, callback) { + callback(null, { + id: 'user' + id + }) +} +// generate 5 users +async.times(5, function(n, next){ + createUser(n, function(err, user) { + next(err, user) + }) +}, function(err, users) { + // we should now have 5 users +}); +``` + + +### timesSeries(n, callback) + +The same as [`times`](#times), only the iterator is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + + +## Utils + + +### memoize(fn, [hasher]) + +Caches the results of an `async` function. When creating a hash to store function +results against, the callback is omitted from the hash and an optional hash +function can be used. + +The cache of results is exposed as the `memo` property of the function returned +by `memoize`. + +__Arguments__ + +* `fn` - The function to proxy and cache results from. +* `hasher` - Tn optional function for generating a custom hash for storing + results. It has all the arguments applied to it apart from the callback, and + must be synchronous. + +__Example__ + +```js +var slow_fn = function (name, callback) { + // do something + callback(null, result); +}; +var fn = async.memoize(slow_fn); + +// fn can now be used as if it were slow_fn +fn('some name', function () { + // callback +}); +``` + + +### unmemoize(fn) + +Undoes a [`memoize`](#memoize)d function, reverting it to the original, unmemoized +form. Handy for testing. + +__Arguments__ + +* `fn` - the memoized function + + +### log(function, arguments) + +Logs the result of an `async` function to the `console`. Only works in Node.js or +in browsers that support `console.log` and `console.error` (such as FF and Chrome). +If multiple arguments are returned from the async function, `console.log` is +called on each argument in order. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to apply to the function. + +__Example__ + +```js +var hello = function(name, callback){ + setTimeout(function(){ + callback(null, 'hello ' + name); + }, 1000); +}; +``` +```js +node> async.log(hello, 'world'); +'hello world' +``` + +--------------------------------------- + + +### dir(function, arguments) + +Logs the result of an `async` function to the `console` using `console.dir` to +display the properties of the resulting object. Only works in Node.js or +in browsers that support `console.dir` and `console.error` (such as FF and Chrome). +If multiple arguments are returned from the async function, `console.dir` is +called on each argument in order. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to apply to the function. + +__Example__ + +```js +var hello = function(name, callback){ + setTimeout(function(){ + callback(null, {hello: name}); + }, 1000); +}; +``` +```js +node> async.dir(hello, 'world'); +{hello: 'world'} +``` + +--------------------------------------- + + +### noConflict() + +Changes the value of `async` back to its original value, returning a reference to the +`async` object. diff --git a/public/node_modules/async/bower.json b/public/node_modules/async/bower.json new file mode 100644 index 00000000..18176881 --- /dev/null +++ b/public/node_modules/async/bower.json @@ -0,0 +1,38 @@ +{ + "name": "async", + "description": "Higher-order functions and common patterns for asynchronous code", + "version": "0.9.2", + "main": "lib/async.js", + "keywords": [ + "async", + "callback", + "utility", + "module" + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/caolan/async.git" + }, + "devDependencies": { + "nodeunit": ">0.0.0", + "uglify-js": "1.2.x", + "nodelint": ">0.0.0", + "lodash": ">=2.4.1" + }, + "moduleType": [ + "amd", + "globals", + "node" + ], + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "authors": [ + "Caolan McMahon" + ] +} \ No newline at end of file diff --git a/public/node_modules/async/component.json b/public/node_modules/async/component.json new file mode 100644 index 00000000..5003a7c5 --- /dev/null +++ b/public/node_modules/async/component.json @@ -0,0 +1,16 @@ +{ + "name": "async", + "description": "Higher-order functions and common patterns for asynchronous code", + "version": "0.9.2", + "keywords": [ + "async", + "callback", + "utility", + "module" + ], + "license": "MIT", + "repository": "caolan/async", + "scripts": [ + "lib/async.js" + ] +} \ No newline at end of file diff --git a/public/node_modules/async/lib/async.js b/public/node_modules/async/lib/async.js new file mode 100644 index 00000000..394c41ca --- /dev/null +++ b/public/node_modules/async/lib/async.js @@ -0,0 +1,1123 @@ +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */ +/*jshint onevar: false, indent:4 */ +/*global setImmediate: false, setTimeout: false, console: false */ +(function () { + + var async = {}; + + // global on the server, window in the browser + var root, previous_async; + + root = this; + if (root != null) { + previous_async = root.async; + } + + async.noConflict = function () { + root.async = previous_async; + return async; + }; + + function only_once(fn) { + var called = false; + return function() { + if (called) throw new Error("Callback was already called."); + called = true; + fn.apply(root, arguments); + } + } + + //// cross-browser compatiblity functions //// + + var _toString = Object.prototype.toString; + + var _isArray = Array.isArray || function (obj) { + return _toString.call(obj) === '[object Array]'; + }; + + var _each = function (arr, iterator) { + for (var i = 0; i < arr.length; i += 1) { + iterator(arr[i], i, arr); + } + }; + + var _map = function (arr, iterator) { + if (arr.map) { + return arr.map(iterator); + } + var results = []; + _each(arr, function (x, i, a) { + results.push(iterator(x, i, a)); + }); + return results; + }; + + var _reduce = function (arr, iterator, memo) { + if (arr.reduce) { + return arr.reduce(iterator, memo); + } + _each(arr, function (x, i, a) { + memo = iterator(memo, x, i, a); + }); + return memo; + }; + + var _keys = function (obj) { + if (Object.keys) { + return Object.keys(obj); + } + var keys = []; + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + keys.push(k); + } + } + return keys; + }; + + //// exported async module functions //// + + //// nextTick implementation with browser-compatible fallback //// + if (typeof process === 'undefined' || !(process.nextTick)) { + if (typeof setImmediate === 'function') { + async.nextTick = function (fn) { + // not a direct alias for IE10 compatibility + setImmediate(fn); + }; + async.setImmediate = async.nextTick; + } + else { + async.nextTick = function (fn) { + setTimeout(fn, 0); + }; + async.setImmediate = async.nextTick; + } + } + else { + async.nextTick = process.nextTick; + if (typeof setImmediate !== 'undefined') { + async.setImmediate = function (fn) { + // not a direct alias for IE10 compatibility + setImmediate(fn); + }; + } + else { + async.setImmediate = async.nextTick; + } + } + + async.each = function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length) { + return callback(); + } + var completed = 0; + _each(arr, function (x) { + iterator(x, only_once(done) ); + }); + function done(err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + if (completed >= arr.length) { + callback(); + } + } + } + }; + async.forEach = async.each; + + async.eachSeries = function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length) { + return callback(); + } + var completed = 0; + var iterate = function () { + iterator(arr[completed], function (err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + if (completed >= arr.length) { + callback(); + } + else { + iterate(); + } + } + }); + }; + iterate(); + }; + async.forEachSeries = async.eachSeries; + + async.eachLimit = function (arr, limit, iterator, callback) { + var fn = _eachLimit(limit); + fn.apply(null, [arr, iterator, callback]); + }; + async.forEachLimit = async.eachLimit; + + var _eachLimit = function (limit) { + + return function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length || limit <= 0) { + return callback(); + } + var completed = 0; + var started = 0; + var running = 0; + + (function replenish () { + if (completed >= arr.length) { + return callback(); + } + + while (running < limit && started < arr.length) { + started += 1; + running += 1; + iterator(arr[started - 1], function (err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + running -= 1; + if (completed >= arr.length) { + callback(); + } + else { + replenish(); + } + } + }); + } + })(); + }; + }; + + + var doParallel = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.each].concat(args)); + }; + }; + var doParallelLimit = function(limit, fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [_eachLimit(limit)].concat(args)); + }; + }; + var doSeries = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.eachSeries].concat(args)); + }; + }; + + + var _asyncMap = function (eachfn, arr, iterator, callback) { + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + if (!callback) { + eachfn(arr, function (x, callback) { + iterator(x.value, function (err) { + callback(err); + }); + }); + } else { + var results = []; + eachfn(arr, function (x, callback) { + iterator(x.value, function (err, v) { + results[x.index] = v; + callback(err); + }); + }, function (err) { + callback(err, results); + }); + } + }; + async.map = doParallel(_asyncMap); + async.mapSeries = doSeries(_asyncMap); + async.mapLimit = function (arr, limit, iterator, callback) { + return _mapLimit(limit)(arr, iterator, callback); + }; + + var _mapLimit = function(limit) { + return doParallelLimit(limit, _asyncMap); + }; + + // reduce only has a series version, as doing reduce in parallel won't + // work in many situations. + async.reduce = function (arr, memo, iterator, callback) { + async.eachSeries(arr, function (x, callback) { + iterator(memo, x, function (err, v) { + memo = v; + callback(err); + }); + }, function (err) { + callback(err, memo); + }); + }; + // inject alias + async.inject = async.reduce; + // foldl alias + async.foldl = async.reduce; + + async.reduceRight = function (arr, memo, iterator, callback) { + var reversed = _map(arr, function (x) { + return x; + }).reverse(); + async.reduce(reversed, memo, iterator, callback); + }; + // foldr alias + async.foldr = async.reduceRight; + + var _filter = function (eachfn, arr, iterator, callback) { + var results = []; + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + eachfn(arr, function (x, callback) { + iterator(x.value, function (v) { + if (v) { + results.push(x); + } + callback(); + }); + }, function (err) { + callback(_map(results.sort(function (a, b) { + return a.index - b.index; + }), function (x) { + return x.value; + })); + }); + }; + async.filter = doParallel(_filter); + async.filterSeries = doSeries(_filter); + // select alias + async.select = async.filter; + async.selectSeries = async.filterSeries; + + var _reject = function (eachfn, arr, iterator, callback) { + var results = []; + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + eachfn(arr, function (x, callback) { + iterator(x.value, function (v) { + if (!v) { + results.push(x); + } + callback(); + }); + }, function (err) { + callback(_map(results.sort(function (a, b) { + return a.index - b.index; + }), function (x) { + return x.value; + })); + }); + }; + async.reject = doParallel(_reject); + async.rejectSeries = doSeries(_reject); + + var _detect = function (eachfn, arr, iterator, main_callback) { + eachfn(arr, function (x, callback) { + iterator(x, function (result) { + if (result) { + main_callback(x); + main_callback = function () {}; + } + else { + callback(); + } + }); + }, function (err) { + main_callback(); + }); + }; + async.detect = doParallel(_detect); + async.detectSeries = doSeries(_detect); + + async.some = function (arr, iterator, main_callback) { + async.each(arr, function (x, callback) { + iterator(x, function (v) { + if (v) { + main_callback(true); + main_callback = function () {}; + } + callback(); + }); + }, function (err) { + main_callback(false); + }); + }; + // any alias + async.any = async.some; + + async.every = function (arr, iterator, main_callback) { + async.each(arr, function (x, callback) { + iterator(x, function (v) { + if (!v) { + main_callback(false); + main_callback = function () {}; + } + callback(); + }); + }, function (err) { + main_callback(true); + }); + }; + // all alias + async.all = async.every; + + async.sortBy = function (arr, iterator, callback) { + async.map(arr, function (x, callback) { + iterator(x, function (err, criteria) { + if (err) { + callback(err); + } + else { + callback(null, {value: x, criteria: criteria}); + } + }); + }, function (err, results) { + if (err) { + return callback(err); + } + else { + var fn = function (left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + }; + callback(null, _map(results.sort(fn), function (x) { + return x.value; + })); + } + }); + }; + + async.auto = function (tasks, callback) { + callback = callback || function () {}; + var keys = _keys(tasks); + var remainingTasks = keys.length + if (!remainingTasks) { + return callback(); + } + + var results = {}; + + var listeners = []; + var addListener = function (fn) { + listeners.unshift(fn); + }; + var removeListener = function (fn) { + for (var i = 0; i < listeners.length; i += 1) { + if (listeners[i] === fn) { + listeners.splice(i, 1); + return; + } + } + }; + var taskComplete = function () { + remainingTasks-- + _each(listeners.slice(0), function (fn) { + fn(); + }); + }; + + addListener(function () { + if (!remainingTasks) { + var theCallback = callback; + // prevent final callback from calling itself if it errors + callback = function () {}; + + theCallback(null, results); + } + }); + + _each(keys, function (k) { + var task = _isArray(tasks[k]) ? tasks[k]: [tasks[k]]; + var taskCallback = function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + if (err) { + var safeResults = {}; + _each(_keys(results), function(rkey) { + safeResults[rkey] = results[rkey]; + }); + safeResults[k] = args; + callback(err, safeResults); + // stop subsequent errors hitting callback multiple times + callback = function () {}; + } + else { + results[k] = args; + async.setImmediate(taskComplete); + } + }; + var requires = task.slice(0, Math.abs(task.length - 1)) || []; + var ready = function () { + return _reduce(requires, function (a, x) { + return (a && results.hasOwnProperty(x)); + }, true) && !results.hasOwnProperty(k); + }; + if (ready()) { + task[task.length - 1](taskCallback, results); + } + else { + var listener = function () { + if (ready()) { + removeListener(listener); + task[task.length - 1](taskCallback, results); + } + }; + addListener(listener); + } + }); + }; + + async.retry = function(times, task, callback) { + var DEFAULT_TIMES = 5; + var attempts = []; + // Use defaults if times not passed + if (typeof times === 'function') { + callback = task; + task = times; + times = DEFAULT_TIMES; + } + // Make sure times is a number + times = parseInt(times, 10) || DEFAULT_TIMES; + var wrappedTask = function(wrappedCallback, wrappedResults) { + var retryAttempt = function(task, finalAttempt) { + return function(seriesCallback) { + task(function(err, result){ + seriesCallback(!err || finalAttempt, {err: err, result: result}); + }, wrappedResults); + }; + }; + while (times) { + attempts.push(retryAttempt(task, !(times-=1))); + } + async.series(attempts, function(done, data){ + data = data[data.length - 1]; + (wrappedCallback || callback)(data.err, data.result); + }); + } + // If a callback is passed, run this as a controll flow + return callback ? wrappedTask() : wrappedTask + }; + + async.waterfall = function (tasks, callback) { + callback = callback || function () {}; + if (!_isArray(tasks)) { + var err = new Error('First argument to waterfall must be an array of functions'); + return callback(err); + } + if (!tasks.length) { + return callback(); + } + var wrapIterator = function (iterator) { + return function (err) { + if (err) { + callback.apply(null, arguments); + callback = function () {}; + } + else { + var args = Array.prototype.slice.call(arguments, 1); + var next = iterator.next(); + if (next) { + args.push(wrapIterator(next)); + } + else { + args.push(callback); + } + async.setImmediate(function () { + iterator.apply(null, args); + }); + } + }; + }; + wrapIterator(async.iterator(tasks))(); + }; + + var _parallel = function(eachfn, tasks, callback) { + callback = callback || function () {}; + if (_isArray(tasks)) { + eachfn.map(tasks, function (fn, callback) { + if (fn) { + fn(function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + callback.call(null, err, args); + }); + } + }, callback); + } + else { + var results = {}; + eachfn.each(_keys(tasks), function (k, callback) { + tasks[k](function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + results[k] = args; + callback(err); + }); + }, function (err) { + callback(err, results); + }); + } + }; + + async.parallel = function (tasks, callback) { + _parallel({ map: async.map, each: async.each }, tasks, callback); + }; + + async.parallelLimit = function(tasks, limit, callback) { + _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback); + }; + + async.series = function (tasks, callback) { + callback = callback || function () {}; + if (_isArray(tasks)) { + async.mapSeries(tasks, function (fn, callback) { + if (fn) { + fn(function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + callback.call(null, err, args); + }); + } + }, callback); + } + else { + var results = {}; + async.eachSeries(_keys(tasks), function (k, callback) { + tasks[k](function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + results[k] = args; + callback(err); + }); + }, function (err) { + callback(err, results); + }); + } + }; + + async.iterator = function (tasks) { + var makeCallback = function (index) { + var fn = function () { + if (tasks.length) { + tasks[index].apply(null, arguments); + } + return fn.next(); + }; + fn.next = function () { + return (index < tasks.length - 1) ? makeCallback(index + 1): null; + }; + return fn; + }; + return makeCallback(0); + }; + + async.apply = function (fn) { + var args = Array.prototype.slice.call(arguments, 1); + return function () { + return fn.apply( + null, args.concat(Array.prototype.slice.call(arguments)) + ); + }; + }; + + var _concat = function (eachfn, arr, fn, callback) { + var r = []; + eachfn(arr, function (x, cb) { + fn(x, function (err, y) { + r = r.concat(y || []); + cb(err); + }); + }, function (err) { + callback(err, r); + }); + }; + async.concat = doParallel(_concat); + async.concatSeries = doSeries(_concat); + + async.whilst = function (test, iterator, callback) { + if (test()) { + iterator(function (err) { + if (err) { + return callback(err); + } + async.whilst(test, iterator, callback); + }); + } + else { + callback(); + } + }; + + async.doWhilst = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + var args = Array.prototype.slice.call(arguments, 1); + if (test.apply(null, args)) { + async.doWhilst(iterator, test, callback); + } + else { + callback(); + } + }); + }; + + async.until = function (test, iterator, callback) { + if (!test()) { + iterator(function (err) { + if (err) { + return callback(err); + } + async.until(test, iterator, callback); + }); + } + else { + callback(); + } + }; + + async.doUntil = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + var args = Array.prototype.slice.call(arguments, 1); + if (!test.apply(null, args)) { + async.doUntil(iterator, test, callback); + } + else { + callback(); + } + }); + }; + + async.queue = function (worker, concurrency) { + if (concurrency === undefined) { + concurrency = 1; + } + function _insert(q, data, pos, callback) { + if (!q.started){ + q.started = true; + } + if (!_isArray(data)) { + data = [data]; + } + if(data.length == 0) { + // call drain immediately if there are no tasks + return async.setImmediate(function() { + if (q.drain) { + q.drain(); + } + }); + } + _each(data, function(task) { + var item = { + data: task, + callback: typeof callback === 'function' ? callback : null + }; + + if (pos) { + q.tasks.unshift(item); + } else { + q.tasks.push(item); + } + + if (q.saturated && q.tasks.length === q.concurrency) { + q.saturated(); + } + async.setImmediate(q.process); + }); + } + + var workers = 0; + var q = { + tasks: [], + concurrency: concurrency, + saturated: null, + empty: null, + drain: null, + started: false, + paused: false, + push: function (data, callback) { + _insert(q, data, false, callback); + }, + kill: function () { + q.drain = null; + q.tasks = []; + }, + unshift: function (data, callback) { + _insert(q, data, true, callback); + }, + process: function () { + if (!q.paused && workers < q.concurrency && q.tasks.length) { + var task = q.tasks.shift(); + if (q.empty && q.tasks.length === 0) { + q.empty(); + } + workers += 1; + var next = function () { + workers -= 1; + if (task.callback) { + task.callback.apply(task, arguments); + } + if (q.drain && q.tasks.length + workers === 0) { + q.drain(); + } + q.process(); + }; + var cb = only_once(next); + worker(task.data, cb); + } + }, + length: function () { + return q.tasks.length; + }, + running: function () { + return workers; + }, + idle: function() { + return q.tasks.length + workers === 0; + }, + pause: function () { + if (q.paused === true) { return; } + q.paused = true; + }, + resume: function () { + if (q.paused === false) { return; } + q.paused = false; + // Need to call q.process once per concurrent + // worker to preserve full concurrency after pause + for (var w = 1; w <= q.concurrency; w++) { + async.setImmediate(q.process); + } + } + }; + return q; + }; + + async.priorityQueue = function (worker, concurrency) { + + function _compareTasks(a, b){ + return a.priority - b.priority; + }; + + function _binarySearch(sequence, item, compare) { + var beg = -1, + end = sequence.length - 1; + while (beg < end) { + var mid = beg + ((end - beg + 1) >>> 1); + if (compare(item, sequence[mid]) >= 0) { + beg = mid; + } else { + end = mid - 1; + } + } + return beg; + } + + function _insert(q, data, priority, callback) { + if (!q.started){ + q.started = true; + } + if (!_isArray(data)) { + data = [data]; + } + if(data.length == 0) { + // call drain immediately if there are no tasks + return async.setImmediate(function() { + if (q.drain) { + q.drain(); + } + }); + } + _each(data, function(task) { + var item = { + data: task, + priority: priority, + callback: typeof callback === 'function' ? callback : null + }; + + q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item); + + if (q.saturated && q.tasks.length === q.concurrency) { + q.saturated(); + } + async.setImmediate(q.process); + }); + } + + // Start with a normal queue + var q = async.queue(worker, concurrency); + + // Override push to accept second parameter representing priority + q.push = function (data, priority, callback) { + _insert(q, data, priority, callback); + }; + + // Remove unshift function + delete q.unshift; + + return q; + }; + + async.cargo = function (worker, payload) { + var working = false, + tasks = []; + + var cargo = { + tasks: tasks, + payload: payload, + saturated: null, + empty: null, + drain: null, + drained: true, + push: function (data, callback) { + if (!_isArray(data)) { + data = [data]; + } + _each(data, function(task) { + tasks.push({ + data: task, + callback: typeof callback === 'function' ? callback : null + }); + cargo.drained = false; + if (cargo.saturated && tasks.length === payload) { + cargo.saturated(); + } + }); + async.setImmediate(cargo.process); + }, + process: function process() { + if (working) return; + if (tasks.length === 0) { + if(cargo.drain && !cargo.drained) cargo.drain(); + cargo.drained = true; + return; + } + + var ts = typeof payload === 'number' + ? tasks.splice(0, payload) + : tasks.splice(0, tasks.length); + + var ds = _map(ts, function (task) { + return task.data; + }); + + if(cargo.empty) cargo.empty(); + working = true; + worker(ds, function () { + working = false; + + var args = arguments; + _each(ts, function (data) { + if (data.callback) { + data.callback.apply(null, args); + } + }); + + process(); + }); + }, + length: function () { + return tasks.length; + }, + running: function () { + return working; + } + }; + return cargo; + }; + + var _console_fn = function (name) { + return function (fn) { + var args = Array.prototype.slice.call(arguments, 1); + fn.apply(null, args.concat([function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (typeof console !== 'undefined') { + if (err) { + if (console.error) { + console.error(err); + } + } + else if (console[name]) { + _each(args, function (x) { + console[name](x); + }); + } + } + }])); + }; + }; + async.log = _console_fn('log'); + async.dir = _console_fn('dir'); + /*async.info = _console_fn('info'); + async.warn = _console_fn('warn'); + async.error = _console_fn('error');*/ + + async.memoize = function (fn, hasher) { + var memo = {}; + var queues = {}; + hasher = hasher || function (x) { + return x; + }; + var memoized = function () { + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + var key = hasher.apply(null, args); + if (key in memo) { + async.nextTick(function () { + callback.apply(null, memo[key]); + }); + } + else if (key in queues) { + queues[key].push(callback); + } + else { + queues[key] = [callback]; + fn.apply(null, args.concat([function () { + memo[key] = arguments; + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i].apply(null, arguments); + } + }])); + } + }; + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; + }; + + async.unmemoize = function (fn) { + return function () { + return (fn.unmemoized || fn).apply(null, arguments); + }; + }; + + async.times = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.map(counter, iterator, callback); + }; + + async.timesSeries = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.mapSeries(counter, iterator, callback); + }; + + async.seq = function (/* functions... */) { + var fns = arguments; + return function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + async.reduce(fns, args, function (newargs, fn, cb) { + fn.apply(that, newargs.concat([function () { + var err = arguments[0]; + var nextargs = Array.prototype.slice.call(arguments, 1); + cb(err, nextargs); + }])) + }, + function (err, results) { + callback.apply(that, [err].concat(results)); + }); + }; + }; + + async.compose = function (/* functions... */) { + return async.seq.apply(null, Array.prototype.reverse.call(arguments)); + }; + + var _applyEach = function (eachfn, fns /*args...*/) { + var go = function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + return eachfn(fns, function (fn, cb) { + fn.apply(that, args.concat([cb])); + }, + callback); + }; + if (arguments.length > 2) { + var args = Array.prototype.slice.call(arguments, 2); + return go.apply(this, args); + } + else { + return go; + } + }; + async.applyEach = doParallel(_applyEach); + async.applyEachSeries = doSeries(_applyEach); + + async.forever = function (fn, callback) { + function next(err) { + if (err) { + if (callback) { + return callback(err); + } + throw err; + } + fn(next); + } + next(); + }; + + // Node.js + if (typeof module !== 'undefined' && module.exports) { + module.exports = async; + } + // AMD / RequireJS + else if (typeof define !== 'undefined' && define.amd) { + define([], function () { + return async; + }); + } + // included directly via + + + \ No newline at end of file diff --git a/public/node_modules/reduce-component/test/reduce.js b/public/node_modules/reduce-component/test/reduce.js new file mode 100644 index 00000000..d44af28c --- /dev/null +++ b/public/node_modules/reduce-component/test/reduce.js @@ -0,0 +1,49 @@ + +var reduce = require('..'); + +describe('reduce', function(){ + + describe('when adding prev and current', function(){ + it('should be sum all the values', function(){ + var numbers = [2,2,2]; + var fn = function(prev, curr){ + return prev + curr; + }; + + var a = numbers.reduce(fn); + var b = reduce(numbers, fn); + + a.should.equal(6); + b.should.equal(a); + }); + }); + + describe('when passing in an initial value', function(){ + it('should default to it', function(){ + var items = []; + var fn = function(prev){ + return prev; + }; + + var a = items.reduce(fn, 'foo'); + var b = reduce(items, fn, 'foo'); + + a.should.equal('foo'); + b.should.equal(a); + }); + + it('should start with it', function(){ + var items = [10, 10]; + var fn = function(prev, curr){ + return prev + curr; + }; + + var a = items.reduce(fn, 10); + var b = reduce(items, fn, 10); + + a.should.equal(30); + b.should.equal(a); + }); + }); + +}); \ No newline at end of file diff --git a/public/node_modules/string_decoder/.npmignore b/public/node_modules/string_decoder/.npmignore new file mode 100644 index 00000000..206320cc --- /dev/null +++ b/public/node_modules/string_decoder/.npmignore @@ -0,0 +1,2 @@ +build +test diff --git a/public/node_modules/string_decoder/LICENSE b/public/node_modules/string_decoder/LICENSE new file mode 100644 index 00000000..6de584a4 --- /dev/null +++ b/public/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/public/node_modules/string_decoder/README.md b/public/node_modules/string_decoder/README.md new file mode 100644 index 00000000..4d2aa001 --- /dev/null +++ b/public/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/public/node_modules/string_decoder/index.js b/public/node_modules/string_decoder/index.js new file mode 100644 index 00000000..b00e54fb --- /dev/null +++ b/public/node_modules/string_decoder/index.js @@ -0,0 +1,221 @@ +// 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); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +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; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; + + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // 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 available = (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, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: 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 (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: 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); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +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; + } + } + this.charReceived = 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) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} diff --git a/public/node_modules/string_decoder/package.json b/public/node_modules/string_decoder/package.json new file mode 100644 index 00000000..6d655141 --- /dev/null +++ b/public/node_modules/string_decoder/package.json @@ -0,0 +1,79 @@ +{ + "_args": [ + [ + "string_decoder@~0.10.x", + "/Users/jfrederick/repos/react-tutorial/node_modules/readable-stream" + ] + ], + "_from": "string_decoder@>=0.10.0 <0.11.0", + "_id": "string_decoder@0.10.31", + "_inCache": true, + "_installable": true, + "_location": "/string_decoder", + "_npmUser": { + "email": "rod@vagg.org", + "name": "rvagg" + }, + "_npmVersion": "1.4.23", + "_phantomChildren": {}, + "_requested": { + "name": "string_decoder", + "raw": "string_decoder@~0.10.x", + "rawSpec": "~0.10.x", + "scope": null, + "spec": ">=0.10.0 <0.11.0", + "type": "range" + }, + "_requiredBy": [ + "/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "_shrinkwrap": null, + "_spec": "string_decoder@~0.10.x", + "_where": "/Users/jfrederick/repos/react-tutorial/node_modules/readable-stream", + "bugs": { + "url": "https://github.com/rvagg/string_decoder/issues" + }, + "dependencies": {}, + "description": "The string_decoder module from Node core", + "devDependencies": { + "tap": "~0.4.8" + }, + "directories": {}, + "dist": { + "shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "tarball": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + }, + "gitHead": "d46d4fd87cf1d06e031c23f1ba170ca7d4ade9a0", + "homepage": "https://github.com/rvagg/string_decoder", + "keywords": [ + "browser", + "browserify", + "decoder", + "string" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + }, + { + "name": "rvagg", + "email": "rod@vagg.org" + } + ], + "name": "string_decoder", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/rvagg/string_decoder.git" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "version": "0.10.31" +} diff --git a/public/node_modules/superagent/.npmignore b/public/node_modules/superagent/.npmignore new file mode 100644 index 00000000..90d998b0 --- /dev/null +++ b/public/node_modules/superagent/.npmignore @@ -0,0 +1,6 @@ +support +test +examples +*.sock +lib-cov +coverage.html diff --git a/public/node_modules/superagent/.travis.yml b/public/node_modules/superagent/.travis.yml new file mode 100644 index 00000000..0262c015 --- /dev/null +++ b/public/node_modules/superagent/.travis.yml @@ -0,0 +1,18 @@ +sudo: false +language: node_js +node_js: + - "5.4" + - "4.2" + - "0.12" + - "0.10" + - "iojs" + +env: + global: + - SAUCE_USERNAME='shtylman-superagent' + - SAUCE_ACCESS_KEY='39a45464-cb1d-4b8d-aa1f-83c7c04fa673' + +matrix: + include: + - node_js: "4.2" + env: BROWSER=1 diff --git a/public/node_modules/superagent/.zuul.yml b/public/node_modules/superagent/.zuul.yml new file mode 100644 index 00000000..031c56a8 --- /dev/null +++ b/public/node_modules/superagent/.zuul.yml @@ -0,0 +1,15 @@ +ui: mocha-bdd +server: ./test/support/server.js +browsers: + - name: chrome + version: latest + - name: firefox + version: latest + - name: safari + version: latest + - name: iphone + version: latest + - name: android + version: latest + - name: ie + version: 9..latest diff --git a/public/node_modules/superagent/Contributing.md b/public/node_modules/superagent/Contributing.md new file mode 100644 index 00000000..1eca5926 --- /dev/null +++ b/public/node_modules/superagent/Contributing.md @@ -0,0 +1,7 @@ +When submitting a PR, your chance of acceptance increases if you do the following: + +* Code style is consistent with existing in the file. +* Tests are passing (client and server). +* You add a test for the failing issue you are fixing. +* Code changes are focused on the area of discussion. +* Do not rebuild the distribution files or increment version numbers. diff --git a/public/node_modules/superagent/History.md b/public/node_modules/superagent/History.md new file mode 100644 index 00000000..7ed91f94 --- /dev/null +++ b/public/node_modules/superagent/History.md @@ -0,0 +1,522 @@ +# 1.7.0 (2016-01-18) + + * When attaching files, read default filename from the `File` object (JD Isaacks) + * Add `direction` property to `progress` events (Joseph Dykstra) + * Update component-emitter & formidable (Kornel Lesiński) + * Don't re-encode query string needlessly (Ruben Verborgh) + * ensure querystring is appended when doing `stream.pipe(request)` (Keith Grennan) + * change set header function, not call `this.request()` until call `this.end()` (vicanso) + * Add no-op `withCredentials` to Node API (markdalgleish) + * fix `delete` breaking on ie8 (kenjiokabe) + * Don't let request error override responses (Clay Reimann) + * Increased number of tests shared between node and client (Kornel Lesiński) + +# 1.6.0/1.6.1 (2015-12-09) + + * avoid misleading CORS error message + * added 'progress' event on file/form upload in Node (Olivier Lalonde) + * return raw response if the response parsing fails (Rei Colina) + * parse content-types ending with `+json` as JSON (Eiryyy) + * fix to avoid throwing errors on aborted requests (gjurgens) + * retain cookies on redirect when hosts match (Tom Conroy) + * added Bower manifest (Johnny Freeman) + * upgrade to latest cookiejar (Andy Burke) + +# 1.5.0 (2015-11-30) + + * encode array values as `key=1&key=2&key=3` etc... (aalpern, Davis Kim) + * avoid the error which is omitted from 'socket hang up' + * faster JSON parsing, handling of zlib errors (jbellenger) + * fix IE11 sends 'undefined' string if data was undefined (Vadim Goncharov) + * alias `del()` method as `delete()` (Aaron Krause) + * revert Request#parse since it was actually Response#parse + +# 1.4.0 (2015-09-14) + + * add Request#parse method to client library + * add missing statusCode in client response + * don't apply JSON heuristics if a valid parser is found + * fix detection of root object for webworkers + +# 1.3.0 (2015-08-05) + + * fix incorrect content-length of data set to buffer + * serialize request data takes into account charsets + * add basic promise support via a `then` function + +# 1.2.0 (2015-04-13) + + * add progress events to downlodas + * make usable in webworkers + * add support for 308 redirects + * update node-form-data dependency + * update to work in react native + * update node-mime dependency + +# 1.1.0 (2015-03-13) + + * Fix responseType checks without xhr2 and ie9 tests (rase-) + * errors have .status and .response fields if applicable (defunctzombie) + * fix end callback called before saving cookies (rase-) + +1.0.0 / 2015-03-08 +================== + + * All non-200 responses are treated as errors now. (The callback is called with an error when the response has a status < 200 or >= 300 now. In previous versions this would not have raised an error and the client would have to check the `res` object. See [#283](https://github.com/visionmedia/superagent/issues/283). + * keep timeouts intact across redirects (hopkinsth) + * handle falsy json values (themaarten) + * fire response events in browser version (Schoonology) + * getXHR exported in client version (KidsKilla) + * remove arity check on `.end()` callbacks (defunctzombie) + * avoid setting content-type for host objects (rexxars) + * don't index array strings in querystring (travisjeffery) + * fix pipe() with redirects (cyrilis) + * add xhr2 file download (vstirbu) + * set default response type to text/plain if not specified (warrenseine) + +0.21.0 / 2014-11-11 +================== + + * Trim text before parsing json (gjohnson) + * Update tests to express 4 (gaastonsr) + * Prevent double callback when error is thrown (pgn-vole) + * Fix missing clearTimeout (nickdima) + * Update debug (TooTallNate) + +0.20.0 / 2014-10-02 +================== + + * Add toJSON() to request and response instances. (yields) + * Prevent HEAD requests from getting parsed. (gjohnson) + * Update debug. (TooTallNate) + +0.19.1 / 2014-09-24 +================== + + * Fix basic auth issue when password is falsey value. (gjohnson) + +0.19.0 / 2014-09-24 +================== + + * Add unset() to browser. (shesek) + * Prefer XHR over ActiveX. (omeid) + * Catch parse errors. (jacwright) + * Update qs dependency. (wercker) + * Add use() to node. (Financial-Times) + * Add response text to errors. (yields) + * Don't send empty cookie headers. (undoZen) + * Don't parse empty response bodies. (DveMac) + * Use hostname when setting cookie host. (prasunsultania) + +0.18.2 / 2014-07-12 +================== + + * Handle parser errors. (kof) + * Ensure not to use default parsers when there is a user defined one. (kof) + +0.18.1 / 2014-07-05 +================== + + * Upgrade cookiejar dependency (juanpin) + * Support image mime types (nebulade) + * Make .agent chainable (kof) + * Upgrade debug (TooTallNate) + * Fix docs (aheckmann) + +0.18.0 / 2014-04-29 +=================== + +* Use "form-data" module for the multipart/form-data implementation. (TooTallNate) +* Add basic `field()` and `attach()` functions for HTML5 FormData. (TooTallNate) +* Deprecate `part()`. (TooTallNate) +* Set default user-agent header. (bevacqua) +* Add `unset()` method for removing headers. (bevacqua) +* Update cookiejar. (missinglink) +* Fix response error formatting. (shesek) + +0.17.0 / 2014-03-06 +=================== + + * supply uri malformed error to the callback (yields) + * add request event (yields) + * allow simple auth (yields) + * add request event (yields) + * switch to component/reduce (visionmedia) + * fix part content-disposition (mscdex) + * add browser testing via zuul (defunctzombie) + * adds request.use() (johntron) + +0.16.0 / 2014-01-07 +================== + + * remove support for 0.6 (superjoe30) + * fix CORS withCredentials (wejendorp) + * add "test" script (superjoe30) + * add request .accept() method (nickl-) + * add xml to mime types mappings (nickl-) + * fix parse body error on HEAD requests (gjohnson) + * fix documentation typos (matteofigus) + * fix content-type + charset (bengourley) + * fix null values on query parameters (cristiandouce) + +0.15.7 / 2013-10-19 +================== + + * pin should.js to 1.3.0 due to breaking change in 2.0.x + * fix browserify regression + +0.15.5 / 2013-10-09 +================== + + * add browser field to support browserify + * fix .field() value number support + +0.15.4 / 2013-07-09 +================== + + * node: add a Request#agent() function to set the http Agent to use + +0.15.3 / 2013-07-05 +================== + + * fix .pipe() unzipping on more recent nodes. Closes #240 + * fix passing an empty object to .query() no longer appends "?" + * fix formidable error handling + * update formidable + +0.15.2 / 2013-07-02 +================== + + * fix: emit 'end' when piping. + +0.15.1 / 2013-06-26 +================== + + * add try/catch around parseLinks + +0.15.0 / 2013-06-25 +================== + + * make `Response#toError()` have a more meaningful `message` + +0.14.9 / 2013-06-15 +================== + + * add debug()s to the node client + * add .abort() method to node client + +0.14.8 / 2013-06-13 +================== + + * set .agent = false always + * remove X-Requested-With. Closes #189 + +0.14.7 / 2013-06-06 +================== + + * fix unzip error handling + +0.14.6 / 2013-05-23 +================== + + * fix HEAD unzip bug + +0.14.5 / 2013-05-23 +================== + + * add flag to ensure the callback is __never__ invoked twice + +0.14.4 / 2013-05-22 +================== + + * add superagent.js build output + * update qs + * update emitter-component + * revert "add browser field to support browserify" see GH-221 + +0.14.3 / 2013-05-18 +================== + + * add browser field to support browserify + +0.14.2/ 2013-05-07 +================== + + * add host object check to fix serialization of File/Blobs etc as json + +0.14.1 / 2013-04-09 +================== + + * update qs + +0.14.0 / 2013-04-02 +================== + + * add client-side basic auth + * fix retaining of .set() header field case + +0.13.0 / 2013-03-13 +================== + + * add progress events to client + * add simple example + * add res.headers as alias of res.header for browser client + * add res.get(field) to node/client + +0.12.4 / 2013-02-11 +================== + + * fix get content-type even if can't get other headers in firefox. fixes #181 + +0.12.3 / 2013-02-11 +================== + + * add quick "progress" event support + +0.12.2 / 2013-02-04 +================== + + * add test to check if response acts as a readable stream + * add ReadableStream in the Response prototype. + * add test to assert correct redirection when the host changes in the location header. + * add default Accept-Encoding. Closes #155 + * fix req.pipe() return value of original stream for node parity. Closes #171 + * remove the host header when cleaning headers to properly follow the redirection. + +0.12.1 / 2013-01-10 +================== + + * add x-domain error handling + +0.12.0 / 2013-01-04 +================== + + * add header persistence on redirects + +0.11.0 / 2013-01-02 +================== + + * add .error Error object. Closes #156 + * add forcing of res.text removal for FF HEAD responses. Closes #162 + * add reduce component usage. Closes #90 + * move better-assert dep to development deps + +0.10.0 / 2012-11-14 +================== + + * add req.timeout(ms) support for the client + +0.9.10 / 2012-11-14 +================== + + * fix client-side .query(str) support + +0.9.9 / 2012-11-14 +================== + + * add .parse(fn) support + * fix socket hangup with dates in querystring. Closes #146 + * fix socket hangup "error" event when a callback of arity 2 is provided + +0.9.8 / 2012-11-03 +================== + + * add emission of error from `Request#callback()` + * add a better fix for nodes weird socket hang up error + * add PUT/POST/PATCH data support to client short-hand functions + * add .license property to component.json + * change client portion to build using component(1) + * fix GET body support [guille] + +0.9.7 / 2012-10-19 +================== + + * fix `.buffer()` `res.text` when no parser matches + +0.9.6 / 2012-10-17 +================== + + * change: use `this` when `window` is undefined + * update to new component spec [juliangruber] + * fix emission of "data" events for compressed responses without encoding. Closes #125 + +0.9.5 / 2012-10-01 +================== + + * add field name to .attach() + * add text "parser" + * refactor isObject() + * remove wtf isFunction() helper + +0.9.4 / 2012-09-20 +================== + + * fix `Buffer` responses [TooTallNate] + * fix `res.type` when a "type" param is present [TooTallNate] + +0.9.3 / 2012-09-18 +================== + + * remove __GET__ `.send()` == `.query()` special-case (__API__ change !!!) + +0.9.2 / 2012-09-17 +================== + + * add `.aborted` prop + * add `.abort()`. Closes #115 + +0.9.1 / 2012-09-07 +================== + + * add `.forbidden` response property + * add component.json + * change emitter-component to 0.0.5 + * fix client-side tests + +0.9.0 / 2012-08-28 +================== + + * add `.timeout(ms)`. Closes #17 + +0.8.2 / 2012-08-28 +================== + + * fix pathname relative redirects. Closes #112 + +0.8.1 / 2012-08-21 +================== + + * fix redirects when schema is specified + +0.8.0 / 2012-08-19 +================== + + * add `res.buffered` flag + * add buffering of text/*, json and forms only by default. Closes #61 + * add `.buffer(false)` cancellation + * add cookie jar support [hunterloftis] + * add agent functionality [hunterloftis] + +0.7.0 / 2012-08-03 +================== + + * allow `query()` to be called after the internal `req` has been created [tootallnate] + +0.6.0 / 2012-07-17 +================== + + * add `res.send('foo=bar')` default of "application/x-www-form-urlencoded" + +0.5.1 / 2012-07-16 +================== + + * add "methods" dep + * add `.end()` arity check to node callbacks + * fix unzip support due to weird node internals + +0.5.0 / 2012-06-16 +================== + + * Added "Link" response header field parsing, exposing `res.links` + +0.4.3 / 2012-06-15 +================== + + * Added 303, 305 and 307 as redirect status codes [slaskis] + * Fixed passing an object as the url + +0.4.2 / 2012-06-02 +================== + + * Added component support + * Fixed redirect data + +0.4.1 / 2012-04-13 +================== + + * Added HTTP PATCH support + * Fixed: GET / HEAD when following redirects. Closes #86 + * Fixed Content-Length detection for multibyte chars + +0.4.0 / 2012-03-04 +================== + + * Added `.head()` method [browser]. Closes #78 + * Added `make test-cov` support + * Added multipart request support. Closes #11 + * Added all methods that node supports. Closes #71 + * Added "response" event providing a Response object. Closes #28 + * Added `.query(obj)`. Closes #59 + * Added `res.type` (browser). Closes #54 + * Changed: default `res.body` and `res.files` to {} + * Fixed: port existing query-string fix (browser). Closes #57 + +0.3.0 / 2012-01-24 +================== + + * Added deflate/gzip support [guillermo] + * Added `res.type` (Content-Type void of params) + * Added `res.statusCode` to mirror node + * Added `res.headers` to mirror node + * Changed: parsers take callbacks + * Fixed optional schema support. Closes #49 + +0.2.0 / 2012-01-05 +================== + + * Added url auth support + * Added `.auth(username, password)` + * Added basic auth support [node]. Closes #41 + * Added `make test-docs` + * Added guillermo's EventEmitter. Closes #16 + * Removed `Request#data()` for SS, renamed to `send()` + * Removed `Request#data()` from client, renamed to `send()` + * Fixed array support. [browser] + * Fixed array support. Closes #35 [node] + * Fixed `EventEmitter#emit()` + +0.1.3 / 2011-10-25 +================== + + * Added error to callback + * Bumped node dep for 0.5.x + +0.1.2 / 2011-09-24 +================== + + * Added markdown documentation + * Added `request(url[, fn])` support to the client + * Added `qs` dependency to package.json + * Added options for `Request#pipe()` + * Added support for `request(url, callback)` + * Added `request(url)` as shortcut for `request.get(url)` + * Added `Request#pipe(stream)` + * Added inherit from `Stream` + * Added multipart support + * Added ssl support (node) + * Removed Content-Length field from client + * Fixed buffering, `setEncoding()` to utf8 [reported by stagas] + * Fixed "end" event when piping + +0.1.1 / 2011-08-20 +================== + + * Added `res.redirect` flag (node) + * Added redirect support (node) + * Added `Request#redirects(n)` (node) + * Added `.set(object)` header field support + * Fixed `Content-Length` support + +0.1.0 / 2011-08-09 +================== + + * Added support for multiple calls to `.data()` + * Added support for `.get(uri, obj)` + * Added GET `.data()` querystring support + * Added IE{6,7,8} support [alexyoung] + +0.0.1 / 2011-08-05 +================== + + * Initial commit + diff --git a/public/node_modules/superagent/LICENSE b/public/node_modules/superagent/LICENSE new file mode 100644 index 00000000..1b188ba5 --- /dev/null +++ b/public/node_modules/superagent/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2014-2016 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. diff --git a/public/node_modules/superagent/Makefile b/public/node_modules/superagent/Makefile new file mode 100644 index 00000000..bac2be55 --- /dev/null +++ b/public/node_modules/superagent/Makefile @@ -0,0 +1,57 @@ + +NODETESTS ?= test/*.js test/node/*.js +BROWSERTESTS ?= test/*.js test/client/*.js +REPORTER = spec + +all: superagent.js + +test: + @if [ "x$(BROWSER)" = "x" ]; then make test-node; else make test-browser; fi + +test-node: + @NODE_ENV=test NODE_TLS_REJECT_UNAUTHORIZED=0 ./node_modules/.bin/mocha \ + --require should \ + --reporter $(REPORTER) \ + --timeout 5000 \ + --growl \ + $(NODETESTS) + +test-cov: lib-cov + SUPERAGENT_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html + +test-browser: + ./node_modules/.bin/zuul -- $(BROWSERTESTS) + +test-browser-local: + ./node_modules/.bin/zuul --local 4000 -- $(BROWSERTESTS) + +lib-cov: + jscoverage lib lib-cov + +superagent.js: lib/node/*.js lib/node/parsers/*.js + @./node_modules/.bin/browserify \ + --standalone superagent \ + --outfile superagent.js . + +test-server: + @node test/server + +docs: index.html test-docs + +index.html: docs/index.md + marked < $< \ + | cat docs/head.html - docs/tail.html \ + > $@ + +docclean: + rm -f index.html test.html + +test-docs: + make test REPORTER=doc \ + | cat docs/head.html - docs/tail.html \ + > test.html + +clean: + rm -fr superagent.js components + +.PHONY: test-cov test docs test-docs clean test-browser-local diff --git a/public/node_modules/superagent/Readme.md b/public/node_modules/superagent/Readme.md new file mode 100644 index 00000000..56eac0cf --- /dev/null +++ b/public/node_modules/superagent/Readme.md @@ -0,0 +1,113 @@ +# SuperAgent [![Build Status](https://travis-ci.org/visionmedia/superagent.svg?branch=master)](https://travis-ci.org/visionmedia/superagent) + +[![Sauce Test Status](https://saucelabs.com/browser-matrix/shtylman-superagent.svg)](https://saucelabs.com/u/shtylman-superagent) + +SuperAgent is a small progressive __client-side__ HTTP request library, and __Node.js__ module with the same API, sporting many high-level HTTP client features. View the [docs](http://visionmedia.github.io/superagent/). + +![super agent](http://f.cl.ly/items/3d282n3A0h0Z0K2w0q2a/Screenshot.png) + +## Installation + +node: + +``` +$ npm install superagent +``` + +component: + +``` +$ component install visionmedia/superagent +``` + +Works with [browserify](https://github.com/substack/node-browserify) and should work with [webpack](https://github.com/visionmedia/superagent/wiki/Superagent-for-Webpack) + +```js +request + .post('/api/pet') + .send({ name: 'Manny', species: 'cat' }) + .set('X-API-Key', 'foobar') + .set('Accept', 'application/json') + .end(function(err, res){ + // Calling the end function will send the request + }); +``` + +## Supported browsers + +Tested browsers: + +- Latest Android +- Latest Firefox +- Latest Chrome +- IE9 through latest +- Latest iPhone +- Latest Safari + +Even though IE9 is supported, a polyfill `window.btoa` is needed to use basic auth. + +# Plugins + +Superagent is easily extended via plugins. + +```js +var nocache = require('superagent-no-cache'); +var request = require('superagent'); +var prefix = require('superagent-prefix')('/static'); + +request +.get('/some-url') +.use(prefix) // Prefixes *only* this request +.use(nocache) // Prevents caching of *only* this request +.end(function(err, res){ + // Do something +}); +``` + +Existing plugins: + * [superagent-no-cache](https://github.com/johntron/superagent-no-cache) - prevents caching by including Cache-Control header + * [superagent-prefix](https://github.com/johntron/superagent-prefix) - prefixes absolute URLs (useful in test environment) + * [superagent-mock](https://github.com/M6Web/superagent-mock) - simulate HTTP calls by returning data fixtures based on the requested URL + * [superagent-mocker](https://github.com/shuvalov-anton/superagent-mocker) — simulate REST API + * [superagent-cache](https://github.com/jpodwys/superagent-cache) - superagent with built-in, flexible caching + * [superagent-jsonapify](https://github.com/alex94puchades/superagent-jsonapify) - A lightweight [json-api](http://jsonapi.org/format/) client addon for superagent + * [superagent-serializer](https://github.com/zzarcon/superagent-serializer) - Converts server payload into different cases + +Please prefix your plugin with `superagent-*` so that it can easily be found by others. + +For superagent extensions such as couchdb and oauth visit the [wiki](https://github.com/visionmedia/superagent/wiki). + +## Running node tests + +Install dependencies: + +```shell +$ npm install +``` +Run em! + +```shell +$ make test +``` + +## Running browser tests + +Install dependencies: + +```shell +$ npm install +``` + +Start the test runner: + +```shell +$ make test-browser-local +``` + +Visit `http://localhost:4000/__zuul` in your browser. + +Edit tests and refresh your browser. You do not have to restart the test runner. + +## License + +MIT diff --git a/public/node_modules/superagent/bower.json b/public/node_modules/superagent/bower.json new file mode 100644 index 00000000..f1f1eb58 --- /dev/null +++ b/public/node_modules/superagent/bower.json @@ -0,0 +1,4 @@ +{ + "name": "superagent", + "main": "lib/client.js" +} \ No newline at end of file diff --git a/public/node_modules/superagent/component.json b/public/node_modules/superagent/component.json new file mode 100644 index 00000000..e5ec7d42 --- /dev/null +++ b/public/node_modules/superagent/component.json @@ -0,0 +1,21 @@ +{ + "name": "superagent", + "repo": "visionmedia/superagent", + "description": "awesome http requests", + "version": "1.2.0", + "keywords": [ + "http", + "ajax", + "request", + "agent" + ], + "scripts": [ + "lib/client.js" + ], + "main": "lib/client.js", + "dependencies": { + "component/emitter": "*", + "component/reduce": "*" + }, + "license": "MIT" +} diff --git a/public/node_modules/superagent/docs/head.html b/public/node_modules/superagent/docs/head.html new file mode 100644 index 00000000..4d3bc501 --- /dev/null +++ b/public/node_modules/superagent/docs/head.html @@ -0,0 +1,21 @@ + + + + SuperAgent - Ajax with less suck + + + + + + + + + +
diff --git a/public/node_modules/superagent/docs/highlight.js b/public/node_modules/superagent/docs/highlight.js new file mode 100644 index 00000000..b37eefbd --- /dev/null +++ b/public/node_modules/superagent/docs/highlight.js @@ -0,0 +1,17 @@ + +$(function(){ + $('code').each(function(){ + $(this).html(highlight($(this).text())); + }); +}); + +function highlight(js) { + return js + .replace(//g, '>') + .replace(/('.*?')/gm, '$1') + .replace(/(\d+\.\d+)/gm, '$1') + .replace(/(\d+)/gm, '$1') + .replace(/\bnew *(\w+)/gm, 'new $1') + .replace(/\b(function|new|throw|return|var|if|else)\b/gm, '$1') +} \ No newline at end of file diff --git a/public/node_modules/superagent/docs/images/bg.png b/public/node_modules/superagent/docs/images/bg.png new file mode 100644 index 0000000000000000000000000000000000000000..ca3d2679cd62c18b0f30e1d5ad006d37ffd7ba12 GIT binary patch literal 8856 zcmV;JB4^!+P)5GBPnUGb$`CEiEl6Dl053Ei^SYFfcMO zF*GSFD<~-{FEBAJFEBPaIWaReD=RE7FE1)9D>F4VIXgQlDl9rWJ1{UYF*G$ODk?KH zH7_tSGBh?dHaIpmIXO8xGcz?bHa0joIU*w^A|oU?IXNycF(xP~FfueSF)=GGE-EW5 zFflVBA|oj(Dk&>1EiN!5B_}a7G%qhPF*G(ZG&CkCDLFYiB_=32Iy)pKCNVQKD=jY| zAtEp_GAJl1H8nLQB_$^(C@?TEI5;>WA|oLoB0M}iIyyQzIXNjQDkCE#J3BivGBPPC zD=aK5Iy*cyHaTm2wxj?6AlXSoK~#9!GvXNX&g0&D9{Zkq&i{UA*1czRbY!%RBTVL;zxjKVAWG#*m89re z{fuTS(RpoJH605CNz~7+3sSCh>piQlooi;DQS1iM zAhb&X3w(QE4ck54Q7*~R8<%tpS>tG8M0;=jG1Zi4Y+^TUPxL#(VHuht3DMlv436f7 z4>Te4XEN=i%nobjy=fp?B5Uv6_i@o;okmy0+pa~ZQ~#rMjRk+KhQT<~)Oq|T?n)wTcN>A`aEaz{=G#wfv4PeezwLQ_1&5!YN;Tr@oH zrwbC9zG)xrEzuM9LQjyij>Xjpx+M_0Wbkc1uidNp2l_m13Rvg$GAUcC&>{(vS19_F z@&Y3c4gS`oYmHA8LMOHzBYWSYJEE=BZa-_ab}UE+(_nO@b#4io;Fi>iGU6rWEUtY^ z{h5o9i|K`fHo+3nXxa~hhl>(Uvdz1~Plrt`Lnmo(O)aT#Z>bY|L%Ax=$;iYZr@fnh zT4GvqgM>Sv+@HiNdrj#$B#_0k4qZ!wHy={Q;`8BcNY}_OjaZQDyw%dYU0A;pd-Twf z>O4s_xYRUw@ovlMgZ8;%Dv3pWt=@)h|LdLT3T5HEPLK@gr{Nnny(9y%Y`E;5MZ|8l zeZ00E?8Nuk!^P%eipFU2?i-q*KWFPdSmh=OpxLNjCrV|AGnwuwSCwO?VATB_k= z8qC#I|B2H2^WY}1pr=Qi?Ay@O2kaohJ0{;?(s-@+jL1`CkX98>GX=BG>zwhIEkm9( zq*Zf5=TpDbA_t|;%(n>3t%pV*zIHUi!1ui1)Gv35aH@wwnY_r&*JTBX#O{=z*qD}# zvM!UbH)2ba|UTlK;Xg-S29BP`za=aM|qa*xjttx#pKKfJ7@UPX}Hr0F& z-NbID4aeNUe@neyOsMr@w{R)fHZu($MrQV~SNxT2+Eb!iA(VtZtJl6WI~(?ZrzPcG z>WX~Iw1f1n-n9lK^pCF5gq8^>t&=y!Me48v`pm$MR(@{rqGw3jNxy5WySsLc^mB=A zz8dIiepggAv*hnuCBl!m>EqO+RX13vKYNx6)3JZRWMFcWgP94)l~;!eU_|1Zfs1JB z+rQ{B?O{im_;MLyoZXRjERs7Vw|79k( zDY{t-uX?0?#n6lrT5+AZ8kEizf7_Z7#hGZQa*44BjbgDSlg;;;;t0LQiKX(g!Ydyd z3zDfbEG5(|-a7sLq2AO9gD9!_IXw^v$@QXahOX`LemQE45-Q3}O7q|DzftonO{UTs z9WH3j;U?-^j|>WKgCkGy=BkMf0gb1sxo|n*BEs``harut_$F!NjXhqhJOQn!BemoT zv?BT`^uv%U7x@b|w-nFnq?h?Xp|&-RDe>guO@}4O&w8IUSyyvJ%4!Ks!PTT$i+w>2 zO0T87&gZt)BWrY-J~x^IuVcNOOI9c@$V-xc&CtYRxu*e#;OVFW%j%qiKG~u7gL8x1 zQDm=@$X2)qJ32U&$hjl=5G{6G7bVE?c9|1QaN#S-K?*NECfmbQy;kYzW;oBjVJ!=} zDOx{T6ubwbTXzMX^y~0O)6ZLMNX8u*=3e7V5nAqU0r>l?=4dMYg*6Q+<#sieXX}g~hTFtoA;@7Tl-r$u$k@6;~k|(xDo(rnN(5Asyh$blG(}vpElUTGLvN;#| zf(?K6-(tgy)TQd8x^#eT|A+_D0Vjr-JGz4>lR*5zIfu|@@$zY1EhsEgo zZ<~<=QyK-PH}~1mjrT1m`j)*$$zJAIf}rh`(PZ(igkSTG6I?@8549#Bon$de%`&Z6 za5Og^7{gLE?TJryuFbFv+*{JEBSzGqcu{f>AQ(HM)&W= z{@70v(ktu@+)iUujOG_@?q|4SANv(Qk3;U;=qjEP@x4pB^ks_mLH(&Vx-ZTbU*NFlMutE<~}FOuZ#Fe}q}XE4+yX+f~<#m73$ZH1&?QHM&k*?k0Oi z%i)Gwssc*5CY4YE4$&lAQoHP6C&TaP?PKIQ3&lSsk+4#Upz-&xKU%FcpqU*fO4fj$n&- z!W}TBvhE1d7?TWJvj*ajB`(+?!b{{n?zk1T^jw?dj&ahDMpl2UPVhBV1QUNsO)hS| zLXFh*Cz4tZlPuxLWIU=$E)p_#AN5yup}K0sk&6x9aLGZuFzxZs;RJQe!JUF?Jmasw z`{_T3YWk02{Q9rI{}cV!-{XJ&AM`?u+l=@RiYof_|NLKn{TKYN@xT1rzyAB*79!K` z=kf2s-xxjqTc`cMm4DO!pf8YI+=>PtYB=fuXuYaXGzY}{0 zs!5R>Ko_Xgufje*#B4wMZ5kKq7Eh@|@ZbY3jV9DsCDrDqhzjju>MWvuF`}UwGpLU8 z{z`Hdu1a#zBF7Ex5W6FDXh1dQV$2E2gz!ne;CD`n6}bJCuBMVin>T>L!0o@YE-lY; z*}=x1Z3>cYEOqQ-vdfhq!E>T1$` zm1eBZf-1P63qIF<+7XD|oq=~e*}3nL5?xN4fXG-sk*?JfIFiWuEh8R`7hTXXuwv48 zjWb}|gi=$6hP(^u&h2pPR66=e2>#Fo1hw>khP|2eGLd#(4CdrZJj;Ys_ z{`RxN=MIa6COc?!8{HkDwT#S?VD8+lXMNDhLPsEm*NfZafja`bsl)ugMZl*0Ik(KN zvtmCFVAh6}*pz-ie=K#Jnf;|y&!)pAHtnq{t7~j>v_HQvV>fPto_k2F?1qax*DHQ< zDF;}cKmn5@c(JVaSU>NGU!Doe7o3Kpb!G`!rUypLNQ%!wOY3T!QKrvm`MWpk-JU6~ zs0!h8ll=Ujw)okoiM*B>AH<%{mvD&}T4G=kfE&y$0#14kyftG9j-|~0HP_@yl#8ZR zS1obN(HgFgrWXDNo2ml44hs4=3rEl&z&Ew)H{%s2pe9~rE~;cMma|P@`G?UO1ELI_ zIHKtN2H#-N5lI9JAtXZ071a8#R#=fs+_qNg?f42uhWETe(9=d}og2KalAV;d%=;v- zkuA6=BQa!oqilHws7jbMi9Hv)B*6~J7WuhCr5&M_wyt8mBbrKBl3t%uLT##(!x1JO zbTA5iK@ErI-hC&^ zyHV%r+|EHatbq@_eJsJ(+z$6!!kq25yycL00(#vdYhpKFC{?;!Z#6utHj~Jc^{BOS z0(h~l@u}P9w-kK;;PnT<3Uh0|=$GxUBw;aRkhX+@fQ+(0Y_W223%CZXT-|n|D&kXw zOwUlm=@Rr!C4QoA;?;|Oj6pw+cCa(Y7yU?0;&~#!{5^OA>&)0!xd+b7QuG!sl8j#e z;R*b#wgI89Idb>_oXm9FlzKmVsB_6n0WMUH0jlQk$3 zrF`F{`Kx!&{Js3$(R|w6b@T8UftNEd2r_wQ3YjKIs?p2&?~dV=T&vYc-Vf?M;HZeM zDRKcSb+oig@LuPO8&w0YB~#4>xk!Q>-fF{c?jPX!EcGGSNaj$mt69`q8 zs99Mf8s!}ab5w>qf)zOjG#0q4mL}6x@{z5H1M*DwZ{_;u^dwN$nRd5j-e8)iLEqhn z0>kp+qT*OJy0i1eDtI<8_k51-``5M!cw8)iJA;Ffj+Xn){wvfSoDck$OsmB-&r2s80euPqT<(QAnul`EEcv zUpcyC-I0vtD~u)WFugY%vJC#&qb3!hc&* zx6Kk!C&u9ASOn>jC#c)K2k*2P)GrMJZx$@x;6#lm5>NZfz}&Mq0e(^-8np1r8~d~j zOeS&Sd=LMwKHwSUWG}p0*-!i>@ao-9z|15kc;P=$VqCaG7yZcSQIyQ>gGw(z2NJT# zziDZlQWHKjWFyc{fWRj0edpObLDtpA0CA{vBw_Fh zurIB>?`XXok=@rPS}k>RysOT9VX);DTv1aZDRD>O1Kp7YKXuMQUq&A(Gg)D9miA`+ zZO$TXhMO_ts;fhwJ_dI8Fo?^nl>b*rx9cg?M8hY}THtKLgIq{H6yg!7KKK zx`Ez=hACpQ`p2wex_R#a2bJ1{=+N$VPuA|w^NzB(t&wFG_J+oEnRIsC*DgD#GkV5K z3h?dQe!ZjPS7jxh^{gHplscNE@mlcSu?D(pQQKafK!?K;jfV|xxiDe-+mz#(I7CWN z026j>1HBC*>Y#%5>H}+`XfCIkR5KCOH7d9pEcov5PrfN>qnG_Tf;M%~Do&}V#c>hE z0(VfaA04$s^md>gE&jHnQJ~uZt=WLYa5*mvP@~pBXwsBUSm&ZiW20<*vC5UCK?ps~ zHGJ@$9N?hPHNE0#BW{rbV#0xUY-cymVvqm?;9$zqdoRF$t^dJ zk0=V1eS%jUY_ac9M>N3}F#jq#qPD-n2{3K_B6^&>bM3;9_K|7^nsk)ja`~r9HpXMD z`>UbpnQGzvX*9(TaS9!866ck{EK~ruSm4Dp0#6KP$MSN1#zQw$YoOiLYZ_8|dPrZg zzGbrfRoPGt!Z-=M;N1dCYuuHn+*Ep7z7pI^R;Qkkpf5<74(h~}skIu98lfu4O{Vs0 zq2MVONk7p2B9crLakp@DfHitEdpeB{*O>D8fSDUSo z1UURtdkym+d2f^HKF{U|5}3Z0fagk0 z3>P~00MpjZNNya=L9hL1vgu#rZ7_{ZZkoY&O-;Zx8pGbyPhVxxrR^Or%7tkm(rtV$ zo!?_k61wlJ^nQ1)RU76G!4>JHd`=0BhBYVkD|~ua5ElOXbKpR=N&t>X_f6|-3$lVU zxHsVNY#9N%u2k;_BH>T{Iu)Vi0q%M5FkSg;Tng6GI(|y(6sS;j;%UPvY|@f4@CIFb zfBG#&8x^Jrwj7itB|nm&*G#komU;9hz5&@4V1(M{HfjW)x>q6VAwCP2R?G0AH)aZ2 zxb%`#+_j+}C6la@{cRKaRIB&3ngIUTd+we|!|#p|LvPCUvi_4^6BvV0R2p1_Mu*ID zNtDRntgd)gl3tB&C5;iCb|4Vy7Fgm(d8KY&_Qp05?1yZkpE>3K?~NtFJ&&isJr@CX zuVHV-us07B>=}9(&hhKf12}>kU-{{0@0yxX(e%If=3zhCD>#9@F$u;vS0u$P5j*#* z$I8OMYHFOw@0t}1i6AgdvR232^D6@OVn{+BbeI{0SQVD5tg}^_!^&XxHaQFsCpYA_xM$=4I1-u3nbNvc()j6JG zO&y~s*`So0c=M5YQQ(kU0v6;6__!S499{y#zi{Y{4H=y`4IH(IXa00J_s3WxoafA9 z=q4>|YW~8X&nqu{3wZTy46b08zSEK|;2cW`0S&$&s2Z+5*zs*hLp6C<(|*x7%c;0J z@n_0#>46C7_a;mUg;FHII9&LeD_-VAJi#H-`^VoN;;H|Y0|nrBhhkE`qnRg{IJv$gBGn$JzAJr~o!Et13Mm3#v=|Cp!TndiDT#1fH})|xAQQOBNYwPfF$A<2bJ6}=zled+ z5WWz)CYy7>EqL*w$_bJ0|x;*D?jB;IvcG5{aC% z1}t;MY-8Z8A@Iz%;;)4(a*Zz8tOHuIu40lk1D6Q(8F%B2dQelmS`;Jjn6jq7MjJ|t zBOll(5*DEklb=}L>Zg^TAQqc2eI_!Jjkn2GSjRGk#A&$onz4gfe4{>5Yt`CE0pzN1jqhokavQXOiWL#D;W8I#;;iuw~j5 zY~uqwbNIXvAkSrGNJ2mzk%?8d2!pwQ6z)oVg>S?!DLnj48N*DW>%|S^t+!~Z&e1i} zeUk%+U?hI}VJ}Ax5{D0Xg2$+y6@NGc0yjYk=Yk&kf12(+1zWG0nVHEy& zK#o(1=a8*mk95C_mvC=%dy`E7sRR_l-pG4emC>d@RR#1X$V)#i-UQXm9fnv8+(&0* zA?OR2CmOy1JMfFKJ_z7$1EO~oP6S3Y8*B;4$Vp`Wq2<}& zhn>U!4zQ9nX!*@3wg2lyZ*i9W;^wSJ5TvS8(AQhFNv)wC@O;r^1UD6O&N=MU^WqR3 zvWi``P41|Q$v2qLgfh5jxFJs8AsI|@&IruCdB6BhXuNS(_bvX<=X99b756Qa^A6M9&TM-|oC zKO{eM6;PiMqzF}i37P!+Ac`Mw5|H5LhWIV<3v1qA(1ZFQ1za;)8V_DgTyK%GQ6^Qm zHcwWQUF4sydW~vnL^r?kkn3Q>y=N?0_rzW)Ed7yUi!UiQ%qCz0c!H3!RbP4aGtk&> ziLz=HqQCN@#S#_v82_ML{Opg1FFD&iIO%KP{%w>eGURNQH0i(HFF{Lxq^{!#S-{^w ze~#MdNL|01_$gX_T0+iNcn+Y4F?>ndmLqK+f)`SFGlEDdi-9>GXlMowY&)EBWJfWr zY7ToKbhe$XIwR;a5|~$`Tt85k0U@ZFxJo z;tTic?EjW%?#qcHaTLZ2B4v;kOKxHY+C+($fq*+;gh~JtOCxctjjPT~;@0l`v3ZA` zci)rj8#FZZ?>pz~)JxB0kz+D6;b@ATkGmzZF#qCHWyodM!U&T?jpoCk63}*>yFms* z?$2D)2*)Mr??BM*+BLHUZcIo5Os}@j_>2A684~er< zXmRz%YZmUuNJpQdGjHC#6lkZ)Ic(Rmt#cCS8_rV$7RH=Jl1Tm{Wh;B_k)Mw(k`*vn zN&|hcZmo)Ul=QeF+0-NC0q~v9O!g6r9E>*^t6&y?IE~rLFE@!76IoDP^UF-rHOC$8 zZYQa5@9o_srsEGgsrY^MBJ^fdKAw*S%E1nvi-G~4%C+|MFW**ppjwd-MHatuib)17XQ--`toZJnK>D0 zW;7kE{exk8_Ys>Uedlx=txwa~sZ6P*O$~JGv|#7sz>|?>L)WxPX2ySDf78h-%43r; zQ?s7H3mkJrAA-e1sdg9hPKkkK_DD@0bguLXIkK&~VtIdyXWdR$w)Kr}f~k?^i1=YY zX}-xt$$*=~NsSi1YgGxgF8K!Av<$1-Vcy>#ntrS4Bsifa>*n14Cs_z<0kaPl`c;Fk zy=Z7`G}n9=jlXvIXxX`4NT;wNsvBy*R*{^yl7g%)a@&^4ujk}bqY=Rx= ze(K3Pd}*dWE_9{u^_P_LJ?>~7Z)iSvPqPB@e`LiC(6VA!a0DwYzmT;b30ChFs2M+3 zX5K1RK31o;o++)for(s in a[o])n=a[o][s],a[o].hasOwnProperty(s)&&void 0!==n&&(t[s]=e.isPlainObject(n)?e.isPlainObject(t[s])?e.widget.extend({},t[s],n):e.widget.extend({},n):n);return t},e.widget.bridge=function(t,s){var n=s.prototype.widgetFullName||t;e.fn[t]=function(a){var o="string"==typeof a,r=i.call(arguments,1),h=this;return o?this.each(function(){var i,s=e.data(this,n);return"instance"===a?(h=s,!1):s?e.isFunction(s[a])&&"_"!==a.charAt(0)?(i=s[a].apply(s,r),i!==s&&void 0!==i?(h=i&&i.jquery?h.pushStack(i.get()):i,!1):void 0):e.error("no such method '"+a+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; "+"attempted to call method '"+a+"'")}):(r.length&&(a=e.widget.extend.apply(null,[a].concat(r))),this.each(function(){var t=e.data(this,n);t?(t.option(a||{}),t._init&&t._init()):e.data(this,n,new s(a,this))})),h}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{disabled:!1,create:null},_createWidget:function(i,s){s=e(s||this.defaultElement||this)[0],this.element=e(s),this.uuid=t++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=e(),this.hoverable=e(),this.focusable=e(),s!==this&&(e.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===s&&this.destroy()}}),this.document=e(s.style?s.ownerDocument:s.document||s),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this.options=e.widget.extend({},this.options,this._getCreateOptions(),i),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(t,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(i).undelegate(i),this.bindings=e(this.bindings.not(t).get()),this.focusable=e(this.focusable.not(t).get()),this.hoverable=e(this.hoverable.not(t).get())},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget}); \ No newline at end of file diff --git a/public/node_modules/superagent/docs/jquery.js b/public/node_modules/superagent/docs/jquery.js new file mode 100644 index 00000000..d2424e65 --- /dev/null +++ b/public/node_modules/superagent/docs/jquery.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7 jquery.com | jquery.org/license */ +(function(a,b){function cA(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cx(a){if(!cm[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cn||(cn=c.createElement("iframe"),cn.frameBorder=cn.width=cn.height=0),b.appendChild(cn);if(!co||!cn.createElement)co=(cn.contentWindow||cn.contentDocument).document,co.write((c.compatMode==="CSS1Compat"?"":"")+""),co.close();d=co.createElement(a),co.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cn)}cm[a]=e}return cm[a]}function cw(a,b){var c={};f.each(cs.concat.apply([],cs.slice(0,b)),function(){c[this]=a});return c}function cv(){ct=b}function cu(){setTimeout(cv,0);return ct=f.now()}function cl(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ck(){try{return new a.XMLHttpRequest}catch(b){}}function ce(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bB(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function br(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bi,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bq(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bp(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bp)}function bp(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bo(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bn(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bm(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(){return!0}function M(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7",length:0,size:function(){return this.length},toArray:function(){return G.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?F.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),B.add(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(G.apply(this,arguments),"slice",G.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:F,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;B.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return a!=null&&m.test(a)&&!isNaN(a)},type:function(a){return a==null?String(a):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,unknownElems:!!a.getElementsByTagName("nav").length,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",enctype:!!c.createElement("form").enctype,submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.lastChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-999px",top:"-999px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;f(function(){var a,b,d,e,g,h,i=1,j="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",l="visibility:hidden;border:0;",n="style='"+j+"border:5px solid #000;padding:0;'",p="
"+""+"
";m=c.getElementsByTagName("body")[0];!m||(a=c.createElement("div"),a.style.cssText=l+"width:0;height:0;position:static;top:0;margin-top:"+i+"px",m.insertBefore(a,m.firstChild),o=c.createElement("div"),o.style.cssText=j+l,o.innerHTML=p,a.appendChild(o),b=o.firstChild,d=b.firstChild,g=b.nextSibling.firstChild.firstChild,h={doesNotAddBorder:d.offsetTop!==5,doesAddBorderForTableAndCells:g.offsetTop===5},d.style.position="fixed",d.style.top="20px",h.fixedPosition=d.offsetTop===20||d.offsetTop===15,d.style.position=d.style.top="",b.style.overflow="hidden",b.style.position="relative",h.subtractsBorderForOverflowNotVisible=d.offsetTop===-5,h.doesNotIncludeMarginInBodyOffset=m.offsetTop!==i,m.removeChild(a),o=a=null,f.extend(k,h))}),o.innerHTML="",n.removeChild(o),o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[f.expando]:a[f.expando]&&f.expando,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[f.expando]=n=++f.uuid:n=f.expando),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[f.expando]:f.expando;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)?b=b:b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" "));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];if(!arguments.length){if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}return b}e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!a||j===3||j===8||j===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g},removeAttr:function(a,b){var c,d,e,g,h=0;if(a.nodeType===1){d=(b||"").split(p),g=d.length;for(;h=0}})});var z=/\.(.*)$/,A=/^(?:textarea|input|select)$/i,B=/\./g,C=/ /g,D=/[^\w\s.|`]/g,E=/^([^\.]*)?(?:\.(.+))?$/,F=/\bhover(\.\S+)?/,G=/^key/,H=/^(?:mouse|contextmenu)|click/,I=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,J=function(a){var b=I.exec(a);b&& +(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},K=function(a,b){return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||a.id===b[2])&&(!b[3]||b[3].test(a.className))},L=function(a){return f.event.special.hover?a:a.replace(F,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=L(c).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"",(g||!e)&&c.preventDefault();if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,n=null;for(m=e.parentNode;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l=0:t===b&&(t=o[s]=r.quick?K(m,r.quick):f(m).is(s)),t&&q.push(r);q.length&&j.push({elem:m,matches:q})}d.length>e&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),G.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),H.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var Y="abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",Z=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,_=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,ba=/<([\w:]+)/,bb=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bk=X(c);bj.optgroup=bj.option,bj.tbody=bj.tfoot=bj.colgroup=bj.caption=bj.thead,bj.th=bj.td,f.support.htmlSerialize||(bj._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after" +,arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Z,""):null;if(typeof a=="string"&&!bd.test(a)&&(f.support.leadingWhitespace||!$.test(a))&&!bj[(ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(_,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bn(a,d),e=bo(a),g=bo(d);for(h=0;e[h];++h)g[h]&&bn(e[h],g[h])}if(b){bm(a,d);if(c){e=bo(a),g=bo(d);for(h=0;e[h];++h)bm(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!bc.test(k))k=b.createTextNode(k);else{k=k.replace(_,"<$1>");var l=(ba.exec(k)||["",""])[1].toLowerCase(),m=bj[l]||bj._default,n=m[0],o=b.createElement("div");b===c?bk.appendChild(o):X(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=bb.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&$.test(k)&&o.insertBefore(b.createTextNode($.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bt.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bs,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bs.test(g)?g.replace(bs,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bB(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bC=function(a,c){var d,e,g;c=c.replace(bu,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bD=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bv.test(f)&&bw.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bB=bC||bD,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bF=/%20/g,bG=/\[\]$/,bH=/\r?\n/g,bI=/#.*$/,bJ=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bK=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bL=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bM=/^(?:GET|HEAD)$/,bN=/^\/\//,bO=/\?/,bP=/)<[^<]*)*<\/script>/gi,bQ=/^(?:select|textarea)/i,bR=/\s+/,bS=/([?&])_=[^&]*/,bT=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bU=f.fn.load,bV={},bW={},bX,bY,bZ=["*/"]+["*"];try{bX=e.href}catch(b$){bX=c.createElement("a"),bX.href="",bX=bX.href}bY=bT.exec(bX.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bU)return bU.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bP,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bQ.test(this.nodeName)||bK.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bH,"\r\n")}}):{name:b.name,value:c.replace(bH,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?cb(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),cb(a,b);return a},ajaxSettings:{url:bX,isLocal:bL.test(bY[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bZ},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:b_(bV),ajaxTransport:b_(bW),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cd(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=ce(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bJ.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bI,"").replace(bN,bY[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bR),d.crossDomain==null&&(r=bT.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bY[1]&&r[2]==bY[2]&&(r[3]||(r[1]==="http:"?80:443))==(bY[3]||(bY[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),ca(bV,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bM.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bO.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bS,"$1_="+x);d.url=y+(y===d.url?(bO.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bZ+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=ca(bW,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)cc(g,a[g],c,e);return d.join("&").replace(bF,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cf=f.now(),cg=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cf++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cg.test(b.url)||e&&cg.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cg,l),b.url===j&&(e&&(k=k.replace(cg,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ch=a.ActiveXObject?function(){for(var a in cj)cj[a](0,1)}:!1,ci=0,cj;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ck()||cl()}:ck,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ch&&delete cj[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++ci,ch&&(cj||(cj={},f(a).unload(ch)),cj[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cm={},cn,co,cp=/^(?:toggle|show|hide)$/,cq=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cr,cs=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],ct;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cw("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cz.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cz.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cA(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cA(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file diff --git a/public/node_modules/superagent/docs/jquery.tocify.min.js b/public/node_modules/superagent/docs/jquery.tocify.min.js new file mode 100755 index 00000000..0fc0442f --- /dev/null +++ b/public/node_modules/superagent/docs/jquery.tocify.min.js @@ -0,0 +1,4 @@ +/*! jquery.tocify - v1.9.0 - 2013-10-01 +* http://gregfranko.com/jquery.tocify.js/ +* Copyright (c) 2013 Greg Franko; Licensed MIT*/ +(function(e){"use strict";e(window.jQuery,window,document)})(function(e,t,s){"use strict";var i="tocify",o="tocify-focus",n="tocify-hover",a="tocify-hide",l="tocify-header",h="."+l,r="tocify-subheader",d="."+r,c="tocify-item",f="."+c,u="tocify-extend-page",p="."+u;e.widget("toc.tocify",{version:"1.9.0",options:{context:"body",ignoreSelector:null,selectors:"h1, h2, h3",showAndHide:!0,showEffect:"slideDown",showEffectSpeed:"medium",hideEffect:"slideUp",hideEffectSpeed:"medium",smoothScroll:!0,smoothScrollSpeed:"medium",scrollTo:0,showAndHideOnScroll:!0,highlightOnScroll:!0,highlightOffset:40,theme:"bootstrap",extendPage:!0,extendPageOffset:100,history:!0,scrollHistory:!1,hashGenerator:"compact",highlightDefault:!0},_create:function(){var s=this;s.extendPageScroll=!0,s.items=[],s._generateToc(),s._addCSSClasses(),s.webkit=function(){for(var e in t)if(e&&-1!==e.toLowerCase().indexOf("webkit"))return!0;return!1}(),s._setEventHandlers(),e(t).load(function(){s._setActiveElement(!0),e("html, body").promise().done(function(){setTimeout(function(){s.extendPageScroll=!1},0)})})},_generateToc:function(){var t,s,o=this,n=o.options.ignoreSelector;return t=-1!==this.options.selectors.indexOf(",")?e(this.options.context).find(this.options.selectors.replace(/ /g,"").substr(0,this.options.selectors.indexOf(","))):e(this.options.context).find(this.options.selectors.replace(/ /g,"")),t.length?(o.element.addClass(i),t.each(function(t){e(this).is(n)||(s=e("
    ",{id:l+t,"class":l}).append(o._nestElements(e(this),t)),o.element.append(s),e(this).nextUntil(this.nodeName.toLowerCase()).each(function(){0===e(this).find(o.options.selectors).length?e(this).filter(o.options.selectors).each(function(){e(this).is(n)||o._appendSubheaders.call(this,o,s)}):e(this).find(o.options.selectors).each(function(){e(this).is(n)||o._appendSubheaders.call(this,o,s)})}))}),undefined):(o.element.addClass(a),undefined)},_setActiveElement:function(e){var s=this,i=t.location.hash.substring(1),o=s.element.find('li[data-unique="'+i+'"]');return i.length?(s.element.find("."+s.focusClass).removeClass(s.focusClass),o.addClass(s.focusClass),s.options.showAndHide&&o.click()):(s.element.find("."+s.focusClass).removeClass(s.focusClass),!i.length&&e&&s.options.highlightDefault&&s.element.find(f).first().addClass(s.focusClass)),s},_nestElements:function(t,s){var i,o,n;return i=e.grep(this.items,function(e){return e===t.text()}),i.length?this.items.push(t.text()+s):this.items.push(t.text()),n=this._generateHashValue(i,t,s),o=e("
  • ",{"class":c,"data-unique":n}).append(e("",{text:t.text()})),t.before(e("
    ",{name:n,"data-unique":n})),o},_generateHashValue:function(e,t,s){var i="",o=this.options.hashGenerator;if("pretty"===o){for(i=t.text().toLowerCase().replace(/\s/g,"-");i.indexOf("--")>-1;)i=i.replace(/--/g,"-");for(;i.indexOf(":-")>-1;)i=i.replace(/:-/g,"-")}else i="function"==typeof o?o(t.text(),t):t.text().replace(/\s/g,"");return e.length&&(i+=""+s),i},_appendSubheaders:function(t,s){var i=e(this).index(t.options.selectors),o=e(t.options.selectors).eq(i-1),n=+e(this).prop("tagName").charAt(1),a=+o.prop("tagName").charAt(1);a>n?t.element.find(d+"[data-tag="+n+"]").last().append(t._nestElements(e(this),i)):n===a?s.find(f).last().after(t._nestElements(e(this),i)):s.find(f).last().after(e("
      ",{"class":r,"data-tag":n})).next(d).append(t._nestElements(e(this),i))},_setEventHandlers:function(){var i=this;this.element.on("click.tocify","li",function(){if(i.options.history&&(t.location.hash=e(this).attr("data-unique")),i.element.find("."+i.focusClass).removeClass(i.focusClass),e(this).addClass(i.focusClass),i.options.showAndHide){var s=e('li[data-unique="'+e(this).attr("data-unique")+'"]');i._triggerShow(s)}i._scrollTo(e(this))}),this.element.find("li").on({"mouseenter.tocify":function(){e(this).addClass(i.hoverClass),e(this).css("cursor","pointer")},"mouseleave.tocify":function(){"bootstrap"!==i.options.theme&&e(this).removeClass(i.hoverClass)}}),(i.options.extendPage||i.options.highlightOnScroll||i.options.scrollHistory||i.options.showAndHideOnScroll)&&e(t).on("scroll.tocify",function(){e("html, body").promise().done(function(){var o,n,a,l,h=e(t).scrollTop(),r=e(t).height(),d=e(s).height(),c=e("body")[0].scrollHeight;if(i.options.extendPage&&(i.webkit&&h>=c-r-i.options.extendPageOffset||!i.webkit&&r+h>d-i.options.extendPageOffset)&&!e(p).length){if(n=e('div[data-unique="'+e(f).last().attr("data-unique")+'"]'),!n.length)return;a=n.offset().top,e(i.options.context).append(e("
      ",{"class":u,height:Math.abs(a-h)+"px","data-unique":u})),i.extendPageScroll&&(l=i.element.find("li.active"),i._scrollTo(e('div[data-unique="'+l.attr("data-unique")+'"]')))}setTimeout(function(){var s,n=null,a=null,l=e(i.options.context).find("div[data-unique]");l.each(function(t){var s=Math.abs((e(this).next().length?e(this).next():e(this)).offset().top-h-i.options.highlightOffset);return null==n||n>s?(n=s,a=t,undefined):!1}),s=e(l[a]).attr("data-unique"),o=e('li[data-unique="'+s+'"]'),i.options.highlightOnScroll&&o.length&&(i.element.find("."+i.focusClass).removeClass(i.focusClass),o.addClass(i.focusClass)),i.options.scrollHistory&&t.location.hash!=="#"+s&&t.location.replace("#"+s),i.options.showAndHideOnScroll&&i.options.showAndHide&&i._triggerShow(o,!0)},0)})})},show:function(t){var s=this;if(!t.is(":visible"))switch(t.find(d).length||t.parent().is(h)||t.parent().is(":visible")?t.children(d).length||t.parent().is(h)||(t=t.closest(d)):t=t.parents(d).add(t),s.options.showEffect){case"none":t.show();break;case"show":t.show(s.options.showEffectSpeed);break;case"slideDown":t.slideDown(s.options.showEffectSpeed);break;case"fadeIn":t.fadeIn(s.options.showEffectSpeed);break;default:t.show()}return t.parent().is(h)?s.hide(e(d).not(t)):s.hide(e(d).not(t.closest(h).find(d).not(t.siblings()))),s},hide:function(e){var t=this;switch(t.options.hideEffect){case"none":e.hide();break;case"hide":e.hide(t.options.hideEffectSpeed);break;case"slideUp":e.slideUp(t.options.hideEffectSpeed);break;case"fadeOut":e.fadeOut(t.options.hideEffectSpeed);break;default:e.hide()}return t},_triggerShow:function(e,t){var s=this;return e.parent().is(h)||e.next().is(d)?s.show(e.next(d),t):e.parent().is(d)&&s.show(e.parent(),t),s},_addCSSClasses:function(){return"jqueryui"===this.options.theme?(this.focusClass="ui-state-default",this.hoverClass="ui-state-hover",this.element.addClass("ui-widget").find(".toc-title").addClass("ui-widget-header").end().find("li").addClass("ui-widget-content")):"bootstrap"===this.options.theme?(this.element.find(h+","+d).addClass("nav nav-list"),this.focusClass="active"):(this.focusClass=o,this.hoverClass=n),this},setOption:function(){e.Widget.prototype._setOption.apply(this,arguments)},setOptions:function(){e.Widget.prototype._setOptions.apply(this,arguments)},_scrollTo:function(t){var s=this,i=s.options.smoothScroll||0,o=s.options.scrollTo,n=e('div[data-unique="'+t.attr("data-unique")+'"]');return n.length?(e("html, body").promise().done(function(){e("html, body").animate({scrollTop:n.offset().top-(e.isFunction(o)?o.call():o)+"px"},{duration:i})}),s):s}})}); \ No newline at end of file diff --git a/public/node_modules/superagent/docs/style.css b/public/node_modules/superagent/docs/style.css new file mode 100644 index 00000000..9ca0e5c5 --- /dev/null +++ b/public/node_modules/superagent/docs/style.css @@ -0,0 +1,81 @@ +body { + padding: 40px 80px; + font: 14px/1.5 "Helvetica Neue", Helvetica, sans-serif; + background: #181818 url(images/bg.png); + text-align: center; +} + +#content { + margin: 0 auto; + padding: 10px 40px; + text-align: left; + background: white; + width: 50%; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; + -webkit-box-shadow: 0 2px 5px 0 black; +} + +#menu { + font-size: 13px; + margin: 0; + padding: 0; + text-align: left; + position: fixed; + top: 15px; + left: 15px; +} + +#menu ul { + margin: 0; + padding: 0; +} + +#menu li { + list-style: none; +} + +#menu a { + color: rgba(255,255,255,.5); + text-decoration: none; +} + +#menu a:hover { + color: white; +} + +#menu .active a { + color: white; +} + +pre { + padding: 10px; +} + +code { + font: 12px/1 monaco, monospace; +} + +p code { + border: 1px solid #ECEA75; + padding: 1px 3px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; + background: #FDFCD1; +} + +pre { + padding: 20px 25px; + border: 1px solid #ddd; + -webkit-box-shadow: inset 0 0 5px #eee; + -moz-box-shadow: inset 0 0 5px #eee; + box-shadow: inset 0 0 5px #eee; +} + +code .comment { color: #ddd } +code .init { color: #2F6FAD } +code .string { color: #5890AD } +code .keyword { color: #8A6343 } +code .number { color: #2F6FAD } \ No newline at end of file diff --git a/public/node_modules/superagent/docs/tail.html b/public/node_modules/superagent/docs/tail.html new file mode 100644 index 00000000..09994c90 --- /dev/null +++ b/public/node_modules/superagent/docs/tail.html @@ -0,0 +1,4 @@ +
      +
      Fork me on GitHub + + \ No newline at end of file diff --git a/public/node_modules/superagent/docs/test.html b/public/node_modules/superagent/docs/test.html new file mode 100644 index 00000000..3dff111e --- /dev/null +++ b/public/node_modules/superagent/docs/test.html @@ -0,0 +1,2082 @@ + + + + SuperAgent - Ajax with less suck + + + + + + + + + +
      +

      request

      +
      +
      +

      with a callback

      +
      +
      should invoke .end()
      +
      request
      +.get(uri + '/login', function(err, res){
      +  assert(res.status == 200);
      +  done();
      +})
      +
      +
      +
      +

      .end()

      +
      +
      should issue a request
      +
      request
      +.get(uri + '/login')
      +.end(function(err, res){
      +  assert(res.status == 200);
      +  done();
      +});
      +
      +
      +
      +

      res.error

      +
      +
      should should be an Error object
      +
      request
      +.get(uri + '/error')
      +.end(function(err, res){
      +  if (NODE) {
      +    res.error.message.should.equal('cannot GET /error (500)');
      +  }
      +  else {
      +    res.error.message.should.equal('cannot GET ' + uri + '/error (500)');
      +  }
      +  assert(res.error.status === 500);
      +  assert(err, 'should have an error for 500');
      +  assert.equal(err.message, 'Internal Server Error');
      +  done();
      +});
      +
      +
      +
      +

      res.header

      +
      +
      should be an object
      +
      request
      +.get(uri + '/login')
      +.end(function(err, res){
      +  assert('Express' == res.header['x-powered-by']);
      +  done();
      +});
      +
      +
      +
      +

      res.charset

      +
      +
      should be set when present
      +
      request
      +.get(uri + '/login')
      +.end(function(err, res){
      +  res.charset.should.equal('utf-8');
      +  done();
      +});
      +
      +
      +
      +

      res.statusType

      +
      +
      should provide the first digit
      +
      request
      +.get(uri + '/login')
      +.end(function(err, res){
      +  assert(!err, 'should not have an error for success responses');
      +  assert(200 == res.status);
      +  assert(2 == res.statusType);
      +  done();
      +});
      +
      +
      +
      +

      res.type

      +
      +
      should provide the mime-type void of params
      +
      request
      +.get(uri + '/login')
      +.end(function(err, res){
      +  res.type.should.equal('text/html');
      +  res.charset.should.equal('utf-8');
      +  done();
      +});
      +
      +
      +
      +

      req.set(field, val)

      +
      +
      should set the header field
      +
      request
      +.post(uri + '/echo')
      +.set('X-Foo', 'bar')
      +.set('X-Bar', 'baz')
      +.end(function(err, res){
      +  assert('bar' == res.header['x-foo']);
      +  assert('baz' == res.header['x-bar']);
      +  done();
      +})
      +
      +
      +
      +

      req.set(obj)

      +
      +
      should set the header fields
      +
      request
      +.post(uri + '/echo')
      +.set({ 'X-Foo': 'bar', 'X-Bar': 'baz' })
      +.end(function(err, res){
      +  assert('bar' == res.header['x-foo']);
      +  assert('baz' == res.header['x-bar']);
      +  done();
      +})
      +
      +
      +
      +

      req.type(str)

      +
      +
      should set the Content-Type
      +
      request
      +.post(uri + '/echo')
      +.type('text/x-foo')
      +.end(function(err, res){
      +  res.header['content-type'].should.equal('text/x-foo');
      +  done();
      +});
      +
      should map "json"
      +
      request
      +.post(uri + '/echo')
      +.type('json')
      +.send('{"a": 1}')
      +.end(function(err, res){
      +  res.should.be.json;
      +  done();
      +});
      +
      should map "html"
      +
      request
      +.post(uri + '/echo')
      +.type('html')
      +.end(function(err, res){
      +  res.header['content-type'].should.equal('text/html');
      +  done();
      +});
      +
      +
      +
      +

      req.accept(str)

      +
      +
      should set Accept
      +
      request
      +.get(uri + '/echo')
      +.accept('text/x-foo')
      +.end(function(err, res){
      +   res.header['accept'].should.equal('text/x-foo');
      +   done();
      +});
      +
      should map "json"
      +
      request
      +.get(uri + '/echo')
      +.accept('json')
      +.end(function(err, res){
      +  res.header['accept'].should.equal('application/json');
      +  done();
      +});
      +
      should map "xml"
      +
      request
      +.get(uri + '/echo')
      +.accept('xml')
      +.end(function(err, res){
      +  res.header['accept'].should.equal('application/xml');
      +  done();
      +});
      +
      should map "html"
      +
      request
      +.get(uri + '/echo')
      +.accept('html')
      +.end(function(err, res){
      +  res.header['accept'].should.equal('text/html');
      +  done();
      +});
      +
      +
      +
      +

      req.send(str)

      +
      +
      should write the string
      +
      request
      +.post(uri + '/echo')
      +.type('json')
      +.send('{"name":"tobi"}')
      +.end(function(err, res){
      +  res.text.should.equal('{"name":"tobi"}');
      +  done();
      +});
      +
      +
      +
      +

      req.send(Object)

      +
      +
      should default to json
      +
      request
      +.post(uri + '/echo')
      +.send({ name: 'tobi' })
      +.end(function(err, res){
      +  res.should.be.json
      +  res.text.should.equal('{"name":"tobi"}');
      +  done();
      +});
      +
      +

      when called several times

      +
      +
      should merge the objects
      +
      request
      +.post(uri + '/echo')
      +.send({ name: 'tobi' })
      +.send({ age: 1 })
      +.end(function(err, res){
      +  res.should.be.json
      +  if (NODE) {
      +    res.buffered.should.be.true;
      +  }
      +  res.text.should.equal('{"name":"tobi","age":1}');
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      .end(fn)

      +
      +
      should check arity
      +
      request
      +.post(uri + '/echo')
      +.send({ name: 'tobi' })
      +.end(function(err, res){
      +  assert(null == err);
      +  res.text.should.equal('{"name":"tobi"}');
      +  done();
      +});
      +
      should emit request
      +
      var req = request.post(uri + '/echo');
      +req.on('request', function(request){
      +  assert(req == request);
      +  done();
      +});
      +req.end();
      +
      should emit response
      +
      request
      +.post(uri + '/echo')
      +.send({ name: 'tobi' })
      +.on('response', function(res){
      +  res.text.should.equal('{"name":"tobi"}');
      +  done();
      +})
      +.end();
      +
      +
      +
      +

      .then(fulfill, reject)

      +
      +
      should support successful fulfills with .then(fulfill)
      +
      request
      +.post(uri + '/echo')
      +.send({ name: 'tobi' })
      +.then(function(res) {
      +  res.text.should.equal('{"name":"tobi"}');
      +  done();
      +})
      +
      should reject an error with .then(null, reject)
      +
      request
      +.get(uri + '/error')
      +.then(null, function(err) {
      +  assert(err.status == 500);
      +  assert(err.response.text == 'boom');
      +  done();
      +})
      +
      +
      +
      +

      .abort()

      +
      +
      should abort the request
      +
      var req = request
      +.get(uri + '/delay/3000')
      +.end(function(err, res){
      +  assert(false, 'should not complete the request');
      +});
      +req.on('abort', done);
      +setTimeout(function() {
      +  req.abort();
      +}, 1000);
      +
      +
      +
      +
      +
      +

      request

      +
      +
      +

      persistent agent

      +
      +
      should gain a session on POST
      +
      agent3
      +  .post('http://localhost:4000/signin')
      +  .end(function(err, res) {
      +    should.not.exist(err);
      +    res.should.have.status(200);
      +    should.not.exist(res.headers['set-cookie']);
      +    res.text.should.include('dashboard');
      +    done();
      +  });
      +
      should start with empty session (set cookies)
      +
      agent1
      +  .get('http://localhost:4000/dashboard')
      +  .end(function(err, res) {
      +    should.exist(err);
      +    res.should.have.status(401);
      +    should.exist(res.headers['set-cookie']);
      +    done();
      +  });
      +
      should gain a session (cookies already set)
      +
      agent1
      +  .post('http://localhost:4000/signin')
      +  .end(function(err, res) {
      +    should.not.exist(err);
      +    res.should.have.status(200);
      +    should.not.exist(res.headers['set-cookie']);
      +    res.text.should.include('dashboard');
      +    done();
      +  });
      +
      should persist cookies across requests
      +
      agent1
      +  .get('http://localhost:4000/dashboard')
      +  .end(function(err, res) {
      +    should.not.exist(err);
      +    res.should.have.status(200);
      +    done();
      +  });
      +
      should have the cookie set in the end callback
      +
      agent4
      +  .post('http://localhost:4000/setcookie')
      +  .end(function(err, res) {
      +    agent4
      +      .get('http://localhost:4000/getcookie')
      +      .end(function(err, res) {
      +        should.not.exist(err);
      +        res.should.have.status(200);
      +        assert(res.text === 'jar');
      +        done();
      +      });
      +  });
      +
      should not share cookies
      +
      agent2
      +  .get('http://localhost:4000/dashboard')
      +  .end(function(err, res) {
      +    should.exist(err);
      +    res.should.have.status(401);
      +    done();
      +  });
      +
      should not lose cookies between agents
      +
      agent1
      +  .get('http://localhost:4000/dashboard')
      +  .end(function(err, res) {
      +    should.not.exist(err);
      +    res.should.have.status(200);
      +    done();
      +  });
      +
      should be able to follow redirects
      +
      agent1
      +  .get('http://localhost:4000/')
      +  .end(function(err, res) {
      +    should.not.exist(err);
      +    res.should.have.status(200);
      +    res.text.should.include('dashboard');
      +    done();
      +  });
      +
      should be able to post redirects
      +
      agent1
      +  .post('http://localhost:4000/redirect')
      +  .send({ foo: 'bar', baz: 'blaaah' })
      +  .end(function(err, res) {
      +    should.not.exist(err);
      +    res.should.have.status(200);
      +    res.text.should.include('simple');
      +    res.redirects.should.eql(['http://localhost:4000/simple']);
      +    done();
      +  });
      +
      should be able to limit redirects
      +
      agent1
      +  .get('http://localhost:4000/')
      +  .redirects(0)
      +  .end(function(err, res) {
      +    should.exist(err);
      +    res.should.have.status(302);
      +    res.redirects.should.eql([]);
      +    res.header.location.should.equal('/dashboard');
      +    done();
      +  });
      +
      should be able to create a new session (clear cookie)
      +
      agent1
      +  .post('http://localhost:4000/signout')
      +  .end(function(err, res) {
      +    should.not.exist(err);
      +    res.should.have.status(200);
      +    should.exist(res.headers['set-cookie']);
      +    done();
      +  });
      +
      should regenerate with an empty session
      +
      agent1
      +  .get('http://localhost:4000/dashboard')
      +  .end(function(err, res) {
      +    should.exist(err);
      +    res.should.have.status(401);
      +    should.not.exist(res.headers['set-cookie']);
      +    done();
      +  });
      +
      +
      +
      +
      +
      +

      Basic auth

      +
      +
      +

      when credentials are present in url

      +
      +
      should set Authorization
      +
      request
      +.get('http://tobi:learnboost@localhost:3010')
      +.end(function(err, res){
      +  res.status.should.equal(200);
      +  done();
      +});
      +
      +
      +
      +

      req.auth(user, pass)

      +
      +
      should set Authorization
      +
      request
      +.get('http://localhost:3010')
      +.auth('tobi', 'learnboost')
      +.end(function(err, res){
      +  res.status.should.equal(200);
      +  done();
      +});
      +
      +
      +
      +

      req.auth(user + ":" + pass)

      +
      +
      should set authorization
      +
      request
      +.get('http://localhost:3010/again')
      +.auth('tobi')
      +.end(function(err, res){
      +  res.status.should.eql(200);
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      [node] request

      +
      +
      +

      res.statusCode

      +
      +
      should set statusCode
      +
      request
      +.get('http://localhost:5000/login', function(err, res){
      +  assert(res.statusCode === 200);
      +  done();
      +})
      +
      +
      +
      +

      with an object

      +
      +
      should format the url
      +
      request
      +.get(url.parse('http://localhost:5000/login'))
      +.end(function(err, res){
      +  assert(res.ok);
      +  done();
      +})
      +
      +
      +
      +

      without a schema

      +
      +
      should default to http
      +
      request
      +.get('localhost:5000/login')
      +.end(function(err, res){
      +  assert(res.status == 200);
      +  done();
      +})
      +
      +
      +
      +

      req.toJSON()

      +
      +
      should describe the request
      +
      request
      +.post(':5000/echo')
      +.send({ foo: 'baz' })
      +.end(function(err, res){
      +  var obj = res.request.toJSON();
      +  assert('POST' == obj.method);
      +  assert(':5000/echo' == obj.url);
      +  assert('baz' == obj.data.foo);
      +  done();
      +});
      +
      +
      +
      +

      should allow the send shorthand

      +
      +
      with callback in the method call
      +
      request
      +.get('http://localhost:5000/login', function(err, res) {
      +    assert(res.status == 200);
      +    done();
      +});
      +
      with data in the method call
      +
      request
      +.post('http://localhost:5000/echo', { foo: 'bar' })
      +.end(function(err, res) {
      +  assert('{"foo":"bar"}' == res.text);
      +  done();
      +});
      +
      with callback and data in the method call
      +
      request
      +.post('http://localhost:5000/echo', { foo: 'bar' }, function(err, res) {
      +  assert('{"foo":"bar"}' == res.text);
      +  done();
      +});
      +
      +
      +
      +

      res.toJSON()

      +
      +
      should describe the response
      +
      request
      +.post('http://localhost:5000/echo')
      +.send({ foo: 'baz' })
      +.end(function(err, res){
      +  var obj = res.toJSON();
      +  assert('object' == typeof obj.header);
      +  assert('object' == typeof obj.req);
      +  assert(200 == obj.status);
      +  assert('{"foo":"baz"}' == obj.text);
      +  done();
      +});
      +
      +
      +
      +

      res.links

      +
      +
      should default to an empty object
      +
      request
      +.get('http://localhost:5000/login')
      +.end(function(err, res){
      +  res.links.should.eql({});
      +  done();
      +})
      +
      should parse the Link header field
      +
      request
      +.get('http://localhost:5000/links')
      +.end(function(err, res){
      +  res.links.next.should.equal('https://api.github.com/repos/visionmedia/mocha/issues?page=2');
      +  done();
      +})
      +
      +
      +
      +

      req.unset(field)

      +
      +
      should remove the header field
      +
      request
      +.post('http://localhost:5000/echo')
      +.unset('User-Agent')
      +.end(function(err, res){
      +  assert(void 0 == res.header['user-agent']);
      +  done();
      +})
      +
      +
      +
      +

      req.write(str)

      +
      +
      should write the given data
      +
      var req = request.post('http://localhost:5000/echo');
      +req.set('Content-Type', 'application/json');
      +req.write('{"name"').should.be.a.boolean;
      +req.write(':"tobi"}').should.be.a.boolean;
      +req.end(function(err, res){
      +  res.text.should.equal('{"name":"tobi"}');
      +  done();
      +});
      +
      +
      +
      +

      req.pipe(stream)

      +
      +
      should pipe the response to the given stream
      +
      var stream = new EventEmitter;
      +stream.buf = '';
      +stream.writable = true;
      +stream.write = function(chunk){
      +  this.buf += chunk;
      +};
      +stream.end = function(){
      +  this.buf.should.equal('{"name":"tobi"}');
      +  done();
      +};
      +request
      +.post('http://localhost:5000/echo')
      +.send('{"name":"tobi"}')
      +.pipe(stream);
      +
      +
      +
      +

      .buffer()

      +
      +
      should enable buffering
      +
      request
      +.get('http://localhost:5000/custom')
      +.buffer()
      +.end(function(err, res){
      +  assert(null == err);
      +  assert('custom stuff' == res.text);
      +  assert(res.buffered);
      +  done();
      +});
      +
      +
      +
      +

      .buffer(false)

      +
      +
      should disable buffering
      +
      request
      +.post('http://localhost:5000/echo')
      +.type('application/x-dog')
      +.send('hello this is dog')
      +.buffer(false)
      +.end(function(err, res){
      +  assert(null == err);
      +  assert(null == res.text);
      +  res.body.should.eql({});
      +  var buf = '';
      +  res.setEncoding('utf8');
      +  res.on('data', function(chunk){ buf += chunk });
      +  res.on('end', function(){
      +    buf.should.equal('hello this is dog');
      +    done();
      +  });
      +});
      +
      +
      +
      +

      .agent()

      +
      +
      should return the defaut agent
      +
      var req = request.post('http://localhost:5000/echo');
      +req.agent().should.equal(false);
      +done();
      +
      +
      +
      +

      .agent(undefined)

      +
      +
      should set an agent to undefined and ensure it is chainable
      +
      var req = request.get('http://localhost:5000/echo');
      +var ret = req.agent(undefined);
      +ret.should.equal(req);
      +assert(req.agent() === undefined);
      +done();
      +
      +
      +
      +

      .agent(new http.Agent())

      +
      +
      should set passed agent
      +
      var http = require('http');
      +var req = request.get('http://localhost:5000/echo');
      +var agent = new http.Agent();
      +var ret = req.agent(agent);
      +ret.should.equal(req);
      +req.agent().should.equal(agent)
      +done();
      +
      +
      +
      +

      with a content type other than application/json or text/*

      +
      +
      should disable buffering
      +
      request
      +.post('http://localhost:5000/echo')
      +.type('application/x-dog')
      +.send('hello this is dog')
      +.end(function(err, res){
      +  assert(null == err);
      +  assert(null == res.text);
      +  res.body.should.eql({});
      +  var buf = '';
      +  res.setEncoding('utf8');
      +  res.buffered.should.be.false;
      +  res.on('data', function(chunk){ buf += chunk });
      +  res.on('end', function(){
      +    buf.should.equal('hello this is dog');
      +    done();
      +  });
      +});
      +
      +
      +
      +

      content-length

      +
      +
      should be set to the byte length of a non-buffer object
      +
      var decoder = new StringDecoder('utf8');
      +var img = fs.readFileSync(__dirname + '/fixtures/test.png');
      +img = decoder.write(img);
      +request
      +.post('http://localhost:5000/echo')
      +.type('application/x-image')
      +.send(img)
      +.buffer(false)
      +.end(function(err, res){
      +  assert(null == err);
      +  assert(!res.buffered);
      +  assert(res.header['content-length'] == Buffer.byteLength(img));
      +  done();
      +});
      +
      should be set to the length of a buffer object
      +
      var img = fs.readFileSync(__dirname + '/fixtures/test.png');
      +request
      +.post('http://localhost:5000/echo')
      +.type('application/x-image')
      +.send(img)
      +.buffer(true)
      +.end(function(err, res){
      +  assert(null == err);
      +  assert(res.buffered);
      +  assert(res.header['content-length'] == img.length);
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      req.set("Content-Type", contentType)

      +
      +
      should work with just the contentType component
      +
      request
      +.post('http://localhost:3005/echo')
      +.set('Content-Type', 'application/json')
      +.send({ name: 'tobi' })
      +.end(function(err, res){
      +  assert(!err);
      +  done();
      +});
      +
      should work with the charset component
      +
      request
      +.post('http://localhost:3005/echo')
      +.set('Content-Type', 'application/json; charset=utf-8')
      +.send({ name: 'tobi' })
      +.end(function(err, res){
      +  assert(!err);
      +  done();
      +});
      +
      +
      +
      +

      exports

      +
      +
      should expose Part
      +
      request.Part.should.be.a.function;
      +
      should expose .protocols
      +
      Object.keys(request.protocols)
      +  .should.eql(['http:', 'https:']);
      +
      should expose .serialize
      +
      Object.keys(request.serialize)
      +  .should.eql(['application/x-www-form-urlencoded', 'application/json']);
      +
      should expose .parse
      +
      Object.keys(request.parse)
      +  .should.eql(['application/x-www-form-urlencoded', 'application/json', 'text', 'image']);
      +
      +
      +
      +

      flags

      +
      +
      +

      with 4xx response

      +
      +
      should set res.error and res.clientError
      +
      request
      +.get('http://localhost:3004/notfound')
      +.end(function(err, res){
      +  assert(err);
      +  assert(!res.ok, 'response should not be ok');
      +  assert(res.error, 'response should be an error');
      +  assert(res.clientError, 'response should be a client error');
      +  assert(!res.serverError, 'response should not be a server error');
      +  done();
      +});
      +
      +
      +
      +

      with 5xx response

      +
      +
      should set res.error and res.serverError
      +
      request
      +.get('http://localhost:3004/error')
      +.end(function(err, res){
      +  assert(err);
      +  assert(!res.ok, 'response should not be ok');
      +  assert(!res.notFound, 'response should not be notFound');
      +  assert(res.error, 'response should be an error');
      +  assert(!res.clientError, 'response should not be a client error');
      +  assert(res.serverError, 'response should be a server error');
      +  done();
      +});
      +
      +
      +
      +

      with 404 Not Found

      +
      +
      should res.notFound
      +
      request
      +.get('http://localhost:3004/notfound')
      +.end(function(err, res){
      +  assert(err);
      +  assert(res.notFound, 'response should be .notFound');
      +  done();
      +});
      +
      +
      +
      +

      with 400 Bad Request

      +
      +
      should set req.badRequest
      +
      request
      +.get('http://localhost:3004/bad-request')
      +.end(function(err, res){
      +  assert(err);
      +  assert(res.badRequest, 'response should be .badRequest');
      +  done();
      +});
      +
      +
      +
      +

      with 401 Bad Request

      +
      +
      should set res.unauthorized
      +
      request
      +.get('http://localhost:3004/unauthorized')
      +.end(function(err, res){
      +  assert(err);
      +  assert(res.unauthorized, 'response should be .unauthorized');
      +  done();
      +});
      +
      +
      +
      +

      with 406 Not Acceptable

      +
      +
      should set res.notAcceptable
      +
      request
      +.get('http://localhost:3004/not-acceptable')
      +.end(function(err, res){
      +  assert(err);
      +  assert(res.notAcceptable, 'response should be .notAcceptable');
      +  done();
      +});
      +
      +
      +
      +

      with 204 No Content

      +
      +
      should set res.noContent
      +
      request
      +.get('http://localhost:3004/no-content')
      +.end(function(err, res){
      +  assert(!err);
      +  assert(res.noContent, 'response should be .noContent');
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      req.send(Object) as "form"

      +
      +
      +

      with req.type() set to form

      +
      +
      should send x-www-form-urlencoded data
      +
      request
      +.post('http://localhost:3002/echo')
      +.type('form')
      +.send({ name: 'tobi' })
      +.end(function(err, res){
      +  res.header['content-type'].should.equal('application/x-www-form-urlencoded');
      +  res.text.should.equal('name=tobi');
      +  done();
      +});
      +
      +
      +
      +

      when called several times

      +
      +
      should merge the objects
      +
      request
      +.post('http://localhost:3002/echo')
      +.type('form')
      +.send({ name: { first: 'tobi', last: 'holowaychuk' } })
      +.send({ age: '1' })
      +.end(function(err, res){
      +  res.header['content-type'].should.equal('application/x-www-form-urlencoded');
      +  res.text.should.equal('name%5Bfirst%5D=tobi&name%5Blast%5D=holowaychuk&age=1');
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      req.send(String)

      +
      +
      should default to "form"
      +
      request
      +.post('http://localhost:3002/echo')
      +.send('user[name]=tj')
      +.send('user[email]=tj@vision-media.ca')
      +.end(function(err, res){
      +  res.header['content-type'].should.equal('application/x-www-form-urlencoded');
      +  res.body.should.eql({ user: { name: 'tj', email: 'tj@vision-media.ca' } });
      +  done();
      +})
      +
      +
      +
      +

      res.body

      +
      +
      +

      application/x-www-form-urlencoded

      +
      +
      should parse the body
      +
      request
      +.get('http://localhost:3002/form-data')
      +.end(function(err, res){
      +  res.text.should.equal('pet[name]=manny');
      +  res.body.should.eql({ pet: { name: 'manny' }});
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      https

      +
      +
      +

      request

      +
      +
      should give a good response
      +
      request
      +.get('https://localhost:8443/')
      +.ca(cert)
      +.end(function(err, res){
      +  assert(res.ok);
      +  assert('Safe and secure!' === res.text);
      +  done();
      +});
      +
      +
      +
      +

      .agent

      +
      +
      should be able to make multiple requests without redefining the certificate
      +
      var agent = request.agent({ca: cert});
      +agent
      +.get('https://localhost:8443/')
      +.end(function(err, res){
      +  assert(res.ok);
      +  assert('Safe and secure!' === res.text);
      +  agent
      +  .get(url.parse('https://localhost:8443/'))
      +  .end(function(err, res){
      +    assert(res.ok);
      +    assert('Safe and secure!' === res.text);
      +    done();
      +  });
      +});
      +
      +
      +
      +
      +
      +

      res.body

      +
      +
      +

      image/png

      +
      +
      should parse the body
      +
      request
      +.get('http://localhost:3011/image')
      +.end(function(err, res){
      +  (res.body.length - img.length).should.equal(0);
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      zlib

      +
      +
      should deflate the content
      +
      request
      +  .get('http://localhost:3080')
      +  .end(function(err, res){
      +    res.should.have.status(200);
      +    res.text.should.equal(subject);
      +    res.headers['content-length'].should.be.below(subject.length);
      +    done();
      +  });
      +
      should handle corrupted responses
      +
      request
      +  .get('http://localhost:3080/corrupt')
      +  .end(function(err, res){
      +    assert(err, 'missing error');
      +    assert(!res, 'response should not be defined');
      +    done();
      +  });
      +
      +

      without encoding set

      +
      +
      should emit buffers
      +
      request
      +  .get('http://localhost:3080/binary')
      +  .end(function(err, res){
      +    res.should.have.status(200);
      +    res.headers['content-length'].should.be.below(subject.length);
      +    res.on('data', function(chunk){
      +      chunk.should.have.length(subject.length);
      +    });
      +    res.on('end', done);
      +  });
      +
      +
      +
      +
      +
      +

      req.send(Object) as "json"

      +
      +
      should default to json
      +
      request
      +.post('http://localhost:3005/echo')
      +.send({ name: 'tobi' })
      +.end(function(err, res){
      +  res.should.be.json
      +  res.text.should.equal('{"name":"tobi"}');
      +  done();
      +});
      +
      should work with arrays
      +
      request
      +.post('http://localhost:3005/echo')
      +.send([1,2,3])
      +.end(function(err, res){
      +  res.should.be.json
      +  res.text.should.equal('[1,2,3]');
      +  done();
      +});
      +
      should work with value null
      +
      request
      +.post('http://localhost:3005/echo')
      +.type('json')
      +.send('null')
      +.end(function(err, res){
      +  res.should.be.json
      +  assert(res.body === null);
      +  done();
      +});
      +
      should work with value false
      +
      request
      +.post('http://localhost:3005/echo')
      +.type('json')
      +.send('false')
      +.end(function(err, res){
      +  res.should.be.json
      +  res.body.should.equal(false);
      +  done();
      +});
      +
      should work with value 0
      +
      request
      +.post('http://localhost:3005/echo')
      +.type('json')
      +.send('0')
      +.end(function(err, res){
      +  res.should.be.json
      +  res.body.should.equal(0);
      +  done();
      +});
      +
      should work with empty string value
      +
      request
      +.post('http://localhost:3005/echo')
      +.type('json')
      +.send('""')
      +.end(function(err, res){
      +  res.should.be.json
      +  res.body.should.equal("");
      +  done();
      +});
      +
      should work with GET
      +
      request
      +.get('http://localhost:3005/echo')
      +.send({ tobi: 'ferret' })
      +.end(function(err, res){
      +  res.should.be.json
      +  res.text.should.equal('{"tobi":"ferret"}');
      +  done();
      +});
      +
      should work with vendor MIME type
      +
      request
      +.post('http://localhost:3005/echo')
      +.set('Content-Type', 'application/vnd.example+json')
      +.send({ name: 'vendor' })
      +.end(function(err, res){
      +  res.text.should.equal('{"name":"vendor"}');
      +  done();
      +});
      +
      +

      when called several times

      +
      +
      should merge the objects
      +
      request
      +.post('http://localhost:3005/echo')
      +.send({ name: 'tobi' })
      +.send({ age: 1 })
      +.end(function(err, res){
      +  res.should.be.json
      +  res.text.should.equal('{"name":"tobi","age":1}');
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      res.body

      +
      +
      +

      application/json

      +
      +
      should parse the body
      +
      request
      +.get('http://localhost:3005/json')
      +.end(function(err, res){
      +  res.text.should.equal('{"name":"manny"}');
      +  res.body.should.eql({ name: 'manny' });
      +  done();
      +});
      +
      +
      +
      +

      HEAD requests

      +
      +
      should not throw a parse error
      +
      request
      +.head('http://localhost:3005/json')
      +.end(function(err, res){
      +  assert(err === null);
      +  assert(res.text === undefined)
      +  assert(Object.keys(res.body).length === 0)
      +  done();
      +});
      +
      +
      +
      +

      Invalid JSON response

      +
      +
      should return the raw response
      +
      request
      +.get('http://localhost:3005/invalid-json')
      +.end(function(err, res){
      +  assert.deepEqual(err.rawResponse, ")]}', {'header':{'code':200,'text':'OK','version':'1.0'},'data':'some data'}");
      +  done();
      +});
      +
      +
      +
      +

      No content

      +
      +
      should not throw a parse error
      +
      request
      +.get('http://localhost:3005/no-content')
      +.end(function(err, res){
      +  assert(err === null);
      +  assert(res.text === '');
      +  assert(Object.keys(res.body).length === 0);
      +  done();
      +});
      +
      +
      +
      +

      application/json+hal

      +
      +
      should parse the body
      +
      request
      +.get('http://localhost:3005/json-hal')
      +.end(function(err, res){
      +  if (err) return done(err);
      +  res.text.should.equal('{"name":"hal 5000"}');
      +  res.body.should.eql({ name: 'hal 5000' });
      +  done();
      +});
      +
      +
      +
      +

      vnd.collection+json

      +
      +
      should parse the body
      +
      request
      +.get('http://localhost:3005/collection-json')
      +.end(function(err, res){
      +  res.text.should.equal('{"name":"chewbacca"}');
      +  res.body.should.eql({ name: 'chewbacca' });
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      Request

      +
      +
      +

      #attach(name, path, filename)

      +
      +
      should use the custom filename
      +
      request
      +.post(':3005/echo')
      +.attach('document', 'test/node/fixtures/user.html', 'doc.html')
      +.end(function(err, res){
      +  if (err) return done(err);
      +  var html = res.files.document;
      +  html.name.should.equal('doc.html');
      +  html.type.should.equal('text/html');
      +  read(html.path).should.equal('<h1>name</h1>');
      +  done();
      +})
      +
      should fire progress event
      +
      var loaded = 0;
      +var total = 0;
      +request
      +.post(':3005/echo')
      +.attach('document', 'test/node/fixtures/user.html')
      +.on('progress', function (event) {
      +  total = event.total;
      +  loaded = event.loaded;
      +})
      +.end(function(err, res){
      +  if (err) return done(err);
      +  var html = res.files.document;
      +  html.name.should.equal('user.html');
      +  html.type.should.equal('text/html');
      +  read(html.path).should.equal('<h1>name</h1>');
      +  total.should.equal(221);
      +  loaded.should.equal(221);
      +  done();
      +})
      +
      +
      +
      +
      +
      +

      with network error

      +
      +
      should error
      +
      request
      +.get('http://localhost:' + this.port + '/')
      +.end(function(err, res){
      +  assert(err, 'expected an error');
      +  done();
      +});
      +
      +
      +
      +

      request

      +
      +
      +

      not modified

      +
      +
      should start with 200
      +
      request
      +.get('http://localhost:3008/')
      +.end(function(err, res){
      +  res.should.have.status(200)
      +  res.text.should.match(/^\d+$/);
      +  ts = +res.text;
      +  done();
      +});
      +
      should then be 304
      +
      request
      +.get('http://localhost:3008/')
      +.set('If-Modified-Since', new Date(ts).toUTCString())
      +.end(function(err, res){
      +  res.should.have.status(304)
      +  // res.text.should.be.empty
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      req.parse(fn)

      +
      +
      should take precedence over default parsers
      +
      request
      +.get('http://localhost:3033/manny')
      +.parse(request.parse['application/json'])
      +.end(function(err, res){
      +  assert(res.ok);
      +  assert('{"name":"manny"}' == res.text);
      +  assert('manny' == res.body.name);
      +  done();
      +});
      +
      should be the only parser
      +
      request
      +.get('http://localhost:3033/image')
      +.parse(function(res, fn) {
      +  res.on('data', function() {});
      +})
      +.end(function(err, res){
      +  assert(res.ok);
      +  assert(res.text === undefined);
      +  res.body.should.eql({});
      +  done();
      +});
      +
      should emit error if parser throws
      +
      request
      +.get('http://localhost:3033/manny')
      +.parse(function() {
      +  throw new Error('I am broken');
      +})
      +.on('error', function(err) {
      +  err.message.should.equal('I am broken');
      +  done();
      +})
      +.end();
      +
      should emit error if parser returns an error
      +
      request
      +.get('http://localhost:3033/manny')
      +.parse(function(res, fn) {
      +  fn(new Error('I am broken'));
      +})
      +.on('error', function(err) {
      +  err.message.should.equal('I am broken');
      +  done();
      +})
      +.end()
      +
      should not emit error on chunked json
      +
      request
      +.get('http://localhost:3033/chunked-json')
      +.end(function(err){
      +  assert(!err);
      +  done();
      +});
      +
      should not emit error on aborted chunked json
      +
      var req = request
      +.get('http://localhost:3033/chunked-json')
      +.end(function(err){
      +  assert(!err);
      +  done();
      +});
      +setTimeout(function(){req.abort()},50);
      +
      +
      +
      +

      pipe on redirect

      +
      +
      should follow Location
      +
      var stream = fs.createWriteStream('test/node/fixtures/pipe.txt');
      +var redirects = [];
      +var req = request
      +  .get('http://localhost:3012/')
      +  .on('redirect', function (res) {
      +    redirects.push(res.headers.location);
      +  })
      +  .on('end', function () {
      +    var arr = [];
      +    arr.push('/movies');
      +    arr.push('/movies/all');
      +    arr.push('/movies/all/0');
      +    redirects.should.eql(arr);
      +    fs.readFileSync('test/node/fixtures/pipe.txt', 'utf8').should.eql('first movie page');
      +    done();
      +  });
      +  req.pipe(stream);
      +
      +
      +
      +

      request pipe

      +
      +
      should act as a writable stream
      +
      var req = request.post('http://localhost:3020');
      +var stream = fs.createReadStream('test/node/fixtures/user.json');
      +req.type('json');
      +req.on('response', function(res){
      +  res.body.should.eql({ name: 'tobi' });
      +  done();
      +});
      +stream.pipe(req);
      +
      should act as a readable stream
      +
      var stream = fs.createWriteStream('test/node/fixtures/tmp.json');
      +var req = request.get('http://localhost:3025');
      +req.type('json');
      +req.on('end', function(){
      +  JSON.parse(fs.readFileSync('test/node/fixtures/tmp.json', 'utf8')).should.eql({ name: 'tobi' });
      +  done();
      +});
      +req.pipe(stream);
      +
      +
      +
      +

      req.query(String)

      +
      +
      should supply uri malformed error to the callback
      +
      request
      +.get('http://localhost:3006')
      +.query('name=toby')
      +.query('a=\uD800')
      +.query({ b: '\uD800' })
      +.end(function(err, res){
      +  assert(err instanceof Error);
      +  assert('URIError' == err.name);
      +  done();
      +});
      +
      should support passing in a string
      +
      request
      +.del('http://localhost:3006')
      +.query('name=t%F6bi')
      +.end(function(err, res){
      +  res.body.should.eql({ name: 't%F6bi' });
      +  done();
      +});
      +
      should work with url query-string and string for query
      +
      request
      +.del('http://localhost:3006/?name=tobi')
      +.query('age=2%20')
      +.end(function(err, res){
      +  res.body.should.eql({ name: 'tobi', age: '2 ' });
      +  done();
      +});
      +
      should support compound elements in a string
      +
      request
      +  .del('http://localhost:3006/')
      +  .query('name=t%F6bi&age=2')
      +  .end(function(err, res){
      +    res.body.should.eql({ name: 't%F6bi', age: '2' });
      +    done();
      +  });
      +
      should work when called multiple times with a string
      +
      request
      +.del('http://localhost:3006/')
      +.query('name=t%F6bi')
      +.query('age=2%F6')
      +.end(function(err, res){
      +  res.body.should.eql({ name: 't%F6bi', age: '2%F6' });
      +  done();
      +});
      +
      should work with normal `query` object and query string
      +
      request
      +.del('http://localhost:3006/')
      +.query('name=t%F6bi')
      +.query({ age: '2' })
      +.end(function(err, res){
      +  res.body.should.eql({ name: 't%F6bi', age: '2' });
      +  done();
      +});
      +
      +
      +
      +

      req.query(Object)

      +
      +
      should construct the query-string
      +
      request
      +.del('http://localhost:3006/')
      +.query({ name: 'tobi' })
      +.query({ order: 'asc' })
      +.query({ limit: ['1', '2'] })
      +.end(function(err, res){
      +  res.body.should.eql({ name: 'tobi', order: 'asc', limit: ['1', '2'] });
      +  done();
      +});
      +
      should not error on dates
      +
      var date = new Date(0);
      +request
      +.del('http://localhost:3006/')
      +.query({ at: date })
      +.end(function(err, res){
      +  assert(date.toISOString() == res.body.at);
      +  done();
      +});
      +
      should work after setting header fields
      +
      request
      +.del('http://localhost:3006/')
      +.set('Foo', 'bar')
      +.set('Bar', 'baz')
      +.query({ name: 'tobi' })
      +.query({ order: 'asc' })
      +.query({ limit: ['1', '2'] })
      +.end(function(err, res){
      +  res.body.should.eql({ name: 'tobi', order: 'asc', limit: ['1', '2'] });
      +  done();
      +});
      +
      should append to the original query-string
      +
      request
      +.del('http://localhost:3006/?name=tobi')
      +.query({ order: 'asc' })
      +.end(function(err, res) {
      +  res.body.should.eql({ name: 'tobi', order: 'asc' });
      +  done();
      +});
      +
      should retain the original query-string
      +
      request
      +.del('http://localhost:3006/?name=tobi')
      +.end(function(err, res) {
      +  res.body.should.eql({ name: 'tobi' });
      +  done();
      +});
      +
      +
      +
      +

      request.get

      +
      +
      +

      on 301 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .get('http://localhost:3210/test-301')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +

      on 302 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .get('http://localhost:3210/test-302')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +

      on 303 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .get('http://localhost:3210/test-303')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +

      on 307 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .get('http://localhost:3210/test-307')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +

      on 308 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .get('http://localhost:3210/test-308')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +
      +
      +

      request.post

      +
      +
      +

      on 301 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .post('http://localhost:3210/test-301')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +

      on 302 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .post('http://localhost:3210/test-302')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +

      on 303 redirect

      +
      +
      should follow Location with a GET request
      +
      var req = request
      +  .post('http://localhost:3210/test-303')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('GET');
      +    done();
      +  });
      +
      +
      +
      +

      on 307 redirect

      +
      +
      should follow Location with a POST request
      +
      var req = request
      +  .post('http://localhost:3210/test-307')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('POST');
      +    done();
      +  });
      +
      +
      +
      +

      on 308 redirect

      +
      +
      should follow Location with a POST request
      +
      var req = request
      +  .post('http://localhost:3210/test-308')
      +  .redirects(1)
      +  .end(function(err, res){
      +    req.req._headers.host.should.eql('localhost:3211');
      +    res.status.should.eql(200);
      +    res.text.should.eql('POST');
      +    done();
      +  });
      +
      +
      +
      +
      +
      +

      request

      +
      +
      +

      on redirect

      +
      +
      should follow Location
      +
      var redirects = [];
      +request
      +.get('http://localhost:3003/')
      +.on('redirect', function(res){
      +  redirects.push(res.headers.location);
      +})
      +.end(function(err, res){
      +  var arr = [];
      +  arr.push('/movies');
      +  arr.push('/movies/all');
      +  arr.push('/movies/all/0');
      +  redirects.should.eql(arr);
      +  res.text.should.equal('first movie page');
      +  done();
      +});
      +
      should retain header fields
      +
      request
      +.get('http://localhost:3003/header')
      +.set('X-Foo', 'bar')
      +.end(function(err, res){
      +  res.body.should.have.property('x-foo', 'bar');
      +  done();
      +});
      +
      should remove Content-* fields
      +
      request
      +.post('http://localhost:3003/header')
      +.type('txt')
      +.set('X-Foo', 'bar')
      +.set('X-Bar', 'baz')
      +.send('hey')
      +.end(function(err, res){
      +  res.body.should.have.property('x-foo', 'bar');
      +  res.body.should.have.property('x-bar', 'baz');
      +  res.body.should.not.have.property('content-type');
      +  res.body.should.not.have.property('content-length');
      +  res.body.should.not.have.property('transfer-encoding');
      +  done();
      +});
      +
      should retain cookies
      +
      request
      +.get('http://localhost:3003/header')
      +.set('Cookie', 'foo=bar;')
      +.end(function(err, res){
      +  res.body.should.have.property('cookie', 'foo=bar;');
      +  done();
      +});
      +
      should preserve timeout across redirects
      +
      request
      +.get('http://localhost:3003/movies/random')
      +.timeout(250)
      +.end(function(err, res){
      +  assert(err instanceof Error, 'expected an error');
      +  err.should.have.property('timeout', 250);
      +  done();
      +});
      +
      should not resend query parameters
      +
      var redirects = [];
      +var query = [];
      +request
      +.get('http://localhost:3003/?foo=bar')
      +.on('redirect', function(res){
      +  query.push(res.headers.query);
      +  redirects.push(res.headers.location);
      +})
      +.end(function(err, res){
      +  var arr = [];
      +  arr.push('/movies');
      +  arr.push('/movies/all');
      +  arr.push('/movies/all/0');
      +  redirects.should.eql(arr);
      +  res.text.should.equal('first movie page');
      +  query.should.eql(['{"foo":"bar"}', '{}', '{}']);
      +  res.headers.query.should.eql('{}');
      +  done();
      +});
      +
      should handle no location header
      +
      request
      +.get('http://localhost:3003/bad-redirect')
      +.end(function(err, res){
      +  err.message.should.equal('No location header for redirect');
      +  done();
      +});
      +
      +

      when relative

      +
      +
      should redirect to a sibling path
      +
      var redirects = [];
      +request
      +.get('http://localhost:3003/relative')
      +.on('redirect', function(res){
      +  redirects.push(res.headers.location);
      +})
      +.end(function(err, res){
      +  var arr = [];
      +  redirects.should.eql(['tobi']);
      +  res.text.should.equal('tobi');
      +  done();
      +});
      +
      should redirect to a parent path
      +
      var redirects = [];
      +request
      +.get('http://localhost:3003/relative/sub')
      +.on('redirect', function(res){
      +  redirects.push(res.headers.location);
      +})
      +.end(function(err, res){
      +  var arr = [];
      +  redirects.should.eql(['../tobi']);
      +  res.text.should.equal('tobi');
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      req.redirects(n)

      +
      +
      should alter the default number of redirects to follow
      +
      var redirects = [];
      +request
      +.get('http://localhost:3003/')
      +.redirects(2)
      +.on('redirect', function(res){
      +  redirects.push(res.headers.location);
      +})
      +.end(function(err, res){
      +  var arr = [];
      +  assert(res.redirect, 'res.redirect');
      +  arr.push('/movies');
      +  arr.push('/movies/all');
      +  redirects.should.eql(arr);
      +  res.text.should.match(/Moved Temporarily|Found/);
      +  done();
      +});
      +
      +
      +
      +

      on POST

      +
      +
      should redirect as GET
      +
      var redirects = [];
      +request
      +.post('http://localhost:3003/movie')
      +.send({ name: 'Tobi' })
      +.redirects(2)
      +.on('redirect', function(res){
      +  redirects.push(res.headers.location);
      +})
      +.end(function(err, res){
      +  var arr = [];
      +  arr.push('/movies/all/0');
      +  redirects.should.eql(arr);
      +  res.text.should.equal('first movie page');
      +  done();
      +});
      +
      +
      +
      +

      on 303

      +
      +
      should redirect with same method
      +
      request
      +.put('http://localhost:3003/redirect-303')
      +.send({msg: "hello"})
      +.redirects(1)
      +.on('redirect', function(res) {
      +  res.headers.location.should.equal('/reply-method')
      +})
      +.end(function(err, res){
      +  res.text.should.equal('method=get');
      +  done();
      +})
      +
      +
      +
      +

      on 307

      +
      +
      should redirect with same method
      +
      request
      +.put('http://localhost:3003/redirect-307')
      +.send({msg: "hello"})
      +.redirects(1)
      +.on('redirect', function(res) {
      +  res.headers.location.should.equal('/reply-method')
      +})
      +.end(function(err, res){
      +  res.text.should.equal('method=put');
      +  done();
      +})
      +
      +
      +
      +

      on 308

      +
      +
      should redirect with same method
      +
      request
      +.put('http://localhost:3003/redirect-308')
      +.send({msg: "hello"})
      +.redirects(1)
      +.on('redirect', function(res) {
      +  res.headers.location.should.equal('/reply-method')
      +})
      +.end(function(err, res){
      +  res.text.should.equal('method=put');
      +  done();
      +})
      +
      +
      +
      +
      +
      +

      response

      +
      +
      should act as a readable stream
      +
      var req = request
      +  .get('http://localhost:3025')
      +  .buffer(false);
      +req.end(function(err,res){
      +  if (err) return done(err);
      +  var trackEndEvent = 0;
      +  var trackCloseEvent = 0;
      +  res.on('end',function(){
      +    trackEndEvent++;
      +    trackEndEvent.should.equal(1);
      +    trackCloseEvent.should.equal(0);  // close should not have been called
      +    done();
      +  });
      +  res.on('close',function(){
      +    trackCloseEvent++;
      +  });
      +
      +  (function(){ res.pause() }).should.not.throw();
      +  (function(){ res.resume() }).should.not.throw();
      +  (function(){ res.destroy() }).should.not.throw();
      +});
      +
      +
      +
      +

      .timeout(ms)

      +
      +
      +

      when timeout is exceeded

      +
      +
      should error
      +
      request
      +.get('http://localhost:3009/500')
      +.timeout(150)
      +.end(function(err, res){
      +  assert(err, 'expected an error');
      +  assert('number' == typeof err.timeout, 'expected an error with .timeout');
      +  assert('ECONNABORTED' == err.code, 'expected abort error code')
      +  done();
      +});
      +
      +
      +
      +
      +
      +

      res.toError()

      +
      +
      should return an Error
      +
      request
      +.get('http://localhost:' + server.address().port)
      +.end(function(err, res){
      +  var err = res.toError();
      +  assert(err.status == 400);
      +  assert(err.method == 'GET');
      +  assert(err.path == '/');
      +  assert(err.message == 'cannot GET / (400)');
      +  assert(err.text == 'invalid json');
      +  done();
      +});
      +
      +
      +
      +

      req.get()

      +
      +
      should set a default user-agent
      +
      request
      +.get('http://localhost:3345/ua')
      +.end(function(err, res){
      +  assert(res.headers);
      +  assert(res.headers['user-agent']);
      +  assert(/^node-superagent\/\d+\.\d+\.\d+$/.test(res.headers['user-agent']));
      +  done();
      +});
      +
      should be able to override user-agent
      +
      request
      +.get('http://localhost:3345/ua')
      +.set('User-Agent', 'foo/bar')
      +.end(function(err, res){
      +  assert(res.headers);
      +  assert(res.headers['user-agent'] == 'foo/bar');
      +  done();
      +});
      +
      should be able to wipe user-agent
      +
      request
      +.get('http://localhost:3345/ua')
      +.unset('User-Agent')
      +.end(function(err, res){
      +  assert(res.headers);
      +  assert(res.headers['user-agent'] == void 0);
      +  done();
      +});
      +
      +
      +
      +

      utils.type(str)

      +
      +
      should return the mime type
      +
      utils.type('application/json; charset=utf-8')
      +  .should.equal('application/json');
      +utils.type('application/json')
      +  .should.equal('application/json');
      +
      +
      +
      +

      utils.params(str)

      +
      +
      should return the field parameters
      +
      var str = 'application/json; charset=utf-8; foo  = bar';
      +var obj = utils.params(str);
      +obj.charset.should.equal('utf-8');
      +obj.foo.should.equal('bar');
      +var str = 'application/json';
      +utils.params(str).should.eql({});
      +
      +
      +
      +

      utils.parseLinks(str)

      +
      +
      should parse links
      +
      var str = '<https://api.github.com/repos/visionmedia/mocha/issues?page=2>; rel="next", <https://api.github.com/repos/visionmedia/mocha/issues?page=5>; rel="last"';
      +var ret = utils.parseLinks(str);
      +ret.next.should.equal('https://api.github.com/repos/visionmedia/mocha/issues?page=2');
      +ret.last.should.equal('https://api.github.com/repos/visionmedia/mocha/issues?page=5');
      +
      +
      +
      + Fork me on GitHub + + \ No newline at end of file diff --git a/public/node_modules/superagent/lib/client.js b/public/node_modules/superagent/lib/client.js new file mode 100644 index 00000000..e907af06 --- /dev/null +++ b/public/node_modules/superagent/lib/client.js @@ -0,0 +1,1191 @@ +/** + * Module dependencies. + */ + +var Emitter = require('emitter'); +var reduce = require('reduce'); + +/** + * Root reference for iframes. + */ + +var root; +if (typeof window !== 'undefined') { // Browser window + root = window; +} else if (typeof self !== 'undefined') { // Web Worker + root = self; +} else { // Other environments + root = this; +} + +/** + * Noop. + */ + +function noop(){}; + +/** + * Check if `obj` is a host object, + * we don't want to serialize these :) + * + * TODO: future proof, move to compoent land + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ + +function isHost(obj) { + var str = {}.toString.call(obj); + + switch (str) { + case '[object File]': + case '[object Blob]': + case '[object FormData]': + return true; + default: + return false; + } +} + +/** + * Determine XHR. + */ + +request.getXHR = function () { + if (root.XMLHttpRequest + && (!root.location || 'file:' != root.location.protocol + || !root.ActiveXObject)) { + return new XMLHttpRequest; + } else { + try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} + try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {} + try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {} + try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {} + } + return false; +}; + +/** + * Removes leading and trailing whitespace, added to support IE. + * + * @param {String} s + * @return {String} + * @api private + */ + +var trim = ''.trim + ? function(s) { return s.trim(); } + : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); }; + +/** + * Check if `obj` is an object. + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ + +function isObject(obj) { + return obj === Object(obj); +} + +/** + * Serialize the given `obj`. + * + * @param {Object} obj + * @return {String} + * @api private + */ + +function serialize(obj) { + if (!isObject(obj)) return obj; + var pairs = []; + for (var key in obj) { + if (null != obj[key]) { + pushEncodedKeyValuePair(pairs, key, obj[key]); + } + } + return pairs.join('&'); +} + +/** + * Helps 'serialize' with serializing arrays. + * Mutates the pairs array. + * + * @param {Array} pairs + * @param {String} key + * @param {Mixed} val + */ + +function pushEncodedKeyValuePair(pairs, key, val) { + if (Array.isArray(val)) { + return val.forEach(function(v) { + pushEncodedKeyValuePair(pairs, key, v); + }); + } + pairs.push(encodeURIComponent(key) + + '=' + encodeURIComponent(val)); +} + +/** + * Expose serialization method. + */ + + request.serializeObject = serialize; + + /** + * Parse the given x-www-form-urlencoded `str`. + * + * @param {String} str + * @return {Object} + * @api private + */ + +function parseString(str) { + var obj = {}; + var pairs = str.split('&'); + var parts; + var pair; + + for (var i = 0, len = pairs.length; i < len; ++i) { + pair = pairs[i]; + parts = pair.split('='); + obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]); + } + + return obj; +} + +/** + * Expose parser. + */ + +request.parseString = parseString; + +/** + * Default MIME type map. + * + * superagent.types.xml = 'application/xml'; + * + */ + +request.types = { + html: 'text/html', + json: 'application/json', + xml: 'application/xml', + urlencoded: 'application/x-www-form-urlencoded', + 'form': 'application/x-www-form-urlencoded', + 'form-data': 'application/x-www-form-urlencoded' +}; + +/** + * Default serialization map. + * + * superagent.serialize['application/xml'] = function(obj){ + * return 'generated xml here'; + * }; + * + */ + + request.serialize = { + 'application/x-www-form-urlencoded': serialize, + 'application/json': JSON.stringify + }; + + /** + * Default parsers. + * + * superagent.parse['application/xml'] = function(str){ + * return { object parsed from str }; + * }; + * + */ + +request.parse = { + 'application/x-www-form-urlencoded': parseString, + 'application/json': JSON.parse +}; + +/** + * Parse the given header `str` into + * an object containing the mapped fields. + * + * @param {String} str + * @return {Object} + * @api private + */ + +function parseHeader(str) { + var lines = str.split(/\r?\n/); + var fields = {}; + var index; + var line; + var field; + var val; + + lines.pop(); // trailing CRLF + + for (var i = 0, len = lines.length; i < len; ++i) { + line = lines[i]; + index = line.indexOf(':'); + field = line.slice(0, index).toLowerCase(); + val = trim(line.slice(index + 1)); + fields[field] = val; + } + + return fields; +} + +/** + * Check if `mime` is json or has +json structured syntax suffix. + * + * @param {String} mime + * @return {Boolean} + * @api private + */ + +function isJSON(mime) { + return /[\/+]json\b/.test(mime); +} + +/** + * Return the mime type for the given `str`. + * + * @param {String} str + * @return {String} + * @api private + */ + +function type(str){ + return str.split(/ *; */).shift(); +}; + +/** + * Return header field parameters. + * + * @param {String} str + * @return {Object} + * @api private + */ + +function params(str){ + return reduce(str.split(/ *; */), function(obj, str){ + var parts = str.split(/ *= */) + , key = parts.shift() + , val = parts.shift(); + + if (key && val) obj[key] = val; + return obj; + }, {}); +}; + +/** + * Initialize a new `Response` with the given `xhr`. + * + * - set flags (.ok, .error, etc) + * - parse header + * + * Examples: + * + * Aliasing `superagent` as `request` is nice: + * + * request = superagent; + * + * We can use the promise-like API, or pass callbacks: + * + * request.get('/').end(function(res){}); + * request.get('/', function(res){}); + * + * Sending data can be chained: + * + * request + * .post('/user') + * .send({ name: 'tj' }) + * .end(function(res){}); + * + * Or passed to `.send()`: + * + * request + * .post('/user') + * .send({ name: 'tj' }, function(res){}); + * + * Or passed to `.post()`: + * + * request + * .post('/user', { name: 'tj' }) + * .end(function(res){}); + * + * Or further reduced to a single call for simple cases: + * + * request + * .post('/user', { name: 'tj' }, function(res){}); + * + * @param {XMLHTTPRequest} xhr + * @param {Object} options + * @api private + */ + +function Response(req, options) { + options = options || {}; + this.req = req; + this.xhr = this.req.xhr; + // responseText is accessible only if responseType is '' or 'text' and on older browsers + this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined') + ? this.xhr.responseText + : null; + this.statusText = this.req.xhr.statusText; + this.setStatusProperties(this.xhr.status); + this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders()); + // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but + // getResponseHeader still works. so we get content-type even if getting + // other headers fails. + this.header['content-type'] = this.xhr.getResponseHeader('content-type'); + this.setHeaderProperties(this.header); + this.body = this.req.method != 'HEAD' + ? this.parseBody(this.text ? this.text : this.xhr.response) + : null; +} + +/** + * Get case-insensitive `field` value. + * + * @param {String} field + * @return {String} + * @api public + */ + +Response.prototype.get = function(field){ + return this.header[field.toLowerCase()]; +}; + +/** + * Set header related properties: + * + * - `.type` the content type without params + * + * A response of "Content-Type: text/plain; charset=utf-8" + * will provide you with a `.type` of "text/plain". + * + * @param {Object} header + * @api private + */ + +Response.prototype.setHeaderProperties = function(header){ + // content-type + var ct = this.header['content-type'] || ''; + this.type = type(ct); + + // params + var obj = params(ct); + for (var key in obj) this[key] = obj[key]; +}; + +/** + * Parse the given body `str`. + * + * Used for auto-parsing of bodies. Parsers + * are defined on the `superagent.parse` object. + * + * @param {String} str + * @return {Mixed} + * @api private + */ + +Response.prototype.parseBody = function(str){ + var parse = request.parse[this.type]; + return parse && str && (str.length || str instanceof Object) + ? parse(str) + : null; +}; + +/** + * Set flags such as `.ok` based on `status`. + * + * For example a 2xx response will give you a `.ok` of __true__ + * whereas 5xx will be __false__ and `.error` will be __true__. The + * `.clientError` and `.serverError` are also available to be more + * specific, and `.statusType` is the class of error ranging from 1..5 + * sometimes useful for mapping respond colors etc. + * + * "sugar" properties are also defined for common cases. Currently providing: + * + * - .noContent + * - .badRequest + * - .unauthorized + * - .notAcceptable + * - .notFound + * + * @param {Number} status + * @api private + */ + +Response.prototype.setStatusProperties = function(status){ + // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request + if (status === 1223) { + status = 204; + } + + var type = status / 100 | 0; + + // status / class + this.status = this.statusCode = status; + this.statusType = type; + + // basics + this.info = 1 == type; + this.ok = 2 == type; + this.clientError = 4 == type; + this.serverError = 5 == type; + this.error = (4 == type || 5 == type) + ? this.toError() + : false; + + // sugar + this.accepted = 202 == status; + this.noContent = 204 == status; + this.badRequest = 400 == status; + this.unauthorized = 401 == status; + this.notAcceptable = 406 == status; + this.notFound = 404 == status; + this.forbidden = 403 == status; +}; + +/** + * Return an `Error` representative of this response. + * + * @return {Error} + * @api public + */ + +Response.prototype.toError = function(){ + var req = this.req; + var method = req.method; + var url = req.url; + + var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')'; + var err = new Error(msg); + err.status = this.status; + err.method = method; + err.url = url; + + return err; +}; + +/** + * Expose `Response`. + */ + +request.Response = Response; + +/** + * Initialize a new `Request` with the given `method` and `url`. + * + * @param {String} method + * @param {String} url + * @api public + */ + +function Request(method, url) { + var self = this; + Emitter.call(this); + this._query = this._query || []; + this.method = method; + this.url = url; + this.header = {}; + this._header = {}; + this.on('end', function(){ + var err = null; + var res = null; + + try { + res = new Response(self); + } catch(e) { + err = new Error('Parser is unable to parse the response'); + err.parse = true; + err.original = e; + // issue #675: return the raw response if the response parsing fails + err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null; + return self.callback(err); + } + + self.emit('response', res); + + if (err) { + return self.callback(err, res); + } + + if (res.status >= 200 && res.status < 300) { + return self.callback(err, res); + } + + var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); + new_err.original = err; + new_err.response = res; + new_err.status = res.status; + + self.callback(new_err, res); + }); +} + +/** + * Mixin `Emitter`. + */ + +Emitter(Request.prototype); + +/** + * Allow for extension + */ + +Request.prototype.use = function(fn) { + fn(this); + return this; +} + +/** + * Set timeout to `ms`. + * + * @param {Number} ms + * @return {Request} for chaining + * @api public + */ + +Request.prototype.timeout = function(ms){ + this._timeout = ms; + return this; +}; + +/** + * Clear previous timeout. + * + * @return {Request} for chaining + * @api public + */ + +Request.prototype.clearTimeout = function(){ + this._timeout = 0; + clearTimeout(this._timer); + return this; +}; + +/** + * Abort the request, and clear potential timeout. + * + * @return {Request} + * @api public + */ + +Request.prototype.abort = function(){ + if (this.aborted) return; + this.aborted = true; + this.xhr.abort(); + this.clearTimeout(); + this.emit('abort'); + return this; +}; + +/** + * Set header `field` to `val`, or multiple fields with one object. + * + * Examples: + * + * req.get('/') + * .set('Accept', 'application/json') + * .set('X-API-Key', 'foobar') + * .end(callback); + * + * req.get('/') + * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) + * .end(callback); + * + * @param {String|Object} field + * @param {String} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.set = function(field, val){ + if (isObject(field)) { + for (var key in field) { + this.set(key, field[key]); + } + return this; + } + this._header[field.toLowerCase()] = val; + this.header[field] = val; + return this; +}; + +/** + * Remove header `field`. + * + * Example: + * + * req.get('/') + * .unset('User-Agent') + * .end(callback); + * + * @param {String} field + * @return {Request} for chaining + * @api public + */ + +Request.prototype.unset = function(field){ + delete this._header[field.toLowerCase()]; + delete this.header[field]; + return this; +}; + +/** + * Get case-insensitive header `field` value. + * + * @param {String} field + * @return {String} + * @api private + */ + +Request.prototype.getHeader = function(field){ + return this._header[field.toLowerCase()]; +}; + +/** + * Set Content-Type to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.xml = 'application/xml'; + * + * request.post('/') + * .type('xml') + * .send(xmlstring) + * .end(callback); + * + * request.post('/') + * .type('application/xml') + * .send(xmlstring) + * .end(callback); + * + * @param {String} type + * @return {Request} for chaining + * @api public + */ + +Request.prototype.type = function(type){ + this.set('Content-Type', request.types[type] || type); + return this; +}; + +/** + * Force given parser + * + * Sets the body parser no matter type. + * + * @param {Function} + * @api public + */ + +Request.prototype.parse = function(fn){ + this._parser = fn; + return this; +}; + +/** + * Set Accept to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.json = 'application/json'; + * + * request.get('/agent') + * .accept('json') + * .end(callback); + * + * request.get('/agent') + * .accept('application/json') + * .end(callback); + * + * @param {String} accept + * @return {Request} for chaining + * @api public + */ + +Request.prototype.accept = function(type){ + this.set('Accept', request.types[type] || type); + return this; +}; + +/** + * Set Authorization field value with `user` and `pass`. + * + * @param {String} user + * @param {String} pass + * @return {Request} for chaining + * @api public + */ + +Request.prototype.auth = function(user, pass){ + var str = btoa(user + ':' + pass); + this.set('Authorization', 'Basic ' + str); + return this; +}; + +/** +* Add query-string `val`. +* +* Examples: +* +* request.get('/shoes') +* .query('size=10') +* .query({ color: 'blue' }) +* +* @param {Object|String} val +* @return {Request} for chaining +* @api public +*/ + +Request.prototype.query = function(val){ + if ('string' != typeof val) val = serialize(val); + if (val) this._query.push(val); + return this; +}; + +/** + * Write the field `name` and `val` for "multipart/form-data" + * request bodies. + * + * ``` js + * request.post('/upload') + * .field('foo', 'bar') + * .end(callback); + * ``` + * + * @param {String} name + * @param {String|Blob|File} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.field = function(name, val){ + if (!this._formData) this._formData = new root.FormData(); + this._formData.append(name, val); + return this; +}; + +/** + * Queue the given `file` as an attachment to the specified `field`, + * with optional `filename`. + * + * ``` js + * request.post('/upload') + * .attach(new Blob(['hey!'], { type: "text/html"})) + * .end(callback); + * ``` + * + * @param {String} field + * @param {Blob|File} file + * @param {String} filename + * @return {Request} for chaining + * @api public + */ + +Request.prototype.attach = function(field, file, filename){ + if (!this._formData) this._formData = new root.FormData(); + this._formData.append(field, file, filename || file.name); + return this; +}; + +/** + * Send `data` as the request body, defaulting the `.type()` to "json" when + * an object is given. + * + * Examples: + * + * // manual json + * request.post('/user') + * .type('json') + * .send('{"name":"tj"}') + * .end(callback) + * + * // auto json + * request.post('/user') + * .send({ name: 'tj' }) + * .end(callback) + * + * // manual x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send('name=tj') + * .end(callback) + * + * // auto x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send({ name: 'tj' }) + * .end(callback) + * + * // defaults to x-www-form-urlencoded + * request.post('/user') + * .send('name=tobi') + * .send('species=ferret') + * .end(callback) + * + * @param {String|Object} data + * @return {Request} for chaining + * @api public + */ + +Request.prototype.send = function(data){ + var obj = isObject(data); + var type = this.getHeader('Content-Type'); + + // merge + if (obj && isObject(this._data)) { + for (var key in data) { + this._data[key] = data[key]; + } + } else if ('string' == typeof data) { + if (!type) this.type('form'); + type = this.getHeader('Content-Type'); + if ('application/x-www-form-urlencoded' == type) { + this._data = this._data + ? this._data + '&' + data + : data; + } else { + this._data = (this._data || '') + data; + } + } else { + this._data = data; + } + + if (!obj || isHost(data)) return this; + if (!type) this.type('json'); + return this; +}; + +/** + * Invoke the callback with `err` and `res` + * and handle arity check. + * + * @param {Error} err + * @param {Response} res + * @api private + */ + +Request.prototype.callback = function(err, res){ + var fn = this._callback; + this.clearTimeout(); + fn(err, res); +}; + +/** + * Invoke callback with x-domain error. + * + * @api private + */ + +Request.prototype.crossDomainError = function(){ + var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'); + err.crossDomain = true; + + err.status = this.status; + err.method = this.method; + err.url = this.url; + + this.callback(err); +}; + +/** + * Invoke callback with timeout error. + * + * @api private + */ + +Request.prototype.timeoutError = function(){ + var timeout = this._timeout; + var err = new Error('timeout of ' + timeout + 'ms exceeded'); + err.timeout = timeout; + this.callback(err); +}; + +/** + * Enable transmission of cookies with x-domain requests. + * + * Note that for this to work the origin must not be + * using "Access-Control-Allow-Origin" with a wildcard, + * and also must set "Access-Control-Allow-Credentials" + * to "true". + * + * @api public + */ + +Request.prototype.withCredentials = function(){ + this._withCredentials = true; + return this; +}; + +/** + * Initiate request, invoking callback `fn(res)` + * with an instanceof `Response`. + * + * @param {Function} fn + * @return {Request} for chaining + * @api public + */ + +Request.prototype.end = function(fn){ + var self = this; + var xhr = this.xhr = request.getXHR(); + var query = this._query.join('&'); + var timeout = this._timeout; + var data = this._formData || this._data; + + // store callback + this._callback = fn || noop; + + // state change + xhr.onreadystatechange = function(){ + if (4 != xhr.readyState) return; + + // In IE9, reads to any property (e.g. status) off of an aborted XHR will + // result in the error "Could not complete the operation due to error c00c023f" + var status; + try { status = xhr.status } catch(e) { status = 0; } + + if (0 == status) { + if (self.timedout) return self.timeoutError(); + if (self.aborted) return; + return self.crossDomainError(); + } + self.emit('end'); + }; + + // progress + var handleProgress = function(e){ + if (e.total > 0) { + e.percent = e.loaded / e.total * 100; + } + e.direction = 'download'; + self.emit('progress', e); + }; + if (this.hasListeners('progress')) { + xhr.onprogress = handleProgress; + } + try { + if (xhr.upload && this.hasListeners('progress')) { + xhr.upload.onprogress = handleProgress; + } + } catch(e) { + // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. + // Reported here: + // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context + } + + // timeout + if (timeout && !this._timer) { + this._timer = setTimeout(function(){ + self.timedout = true; + self.abort(); + }, timeout); + } + + // querystring + if (query) { + query = request.serializeObject(query); + this.url += ~this.url.indexOf('?') + ? '&' + query + : '?' + query; + } + + // initiate request + xhr.open(this.method, this.url, true); + + // CORS + if (this._withCredentials) xhr.withCredentials = true; + + // body + if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) { + // serialize stuff + var contentType = this.getHeader('Content-Type'); + var serialize = this._parser || request.serialize[contentType ? contentType.split(';')[0] : '']; + if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json']; + if (serialize) data = serialize(data); + } + + // set header fields + for (var field in this.header) { + if (null == this.header[field]) continue; + xhr.setRequestHeader(field, this.header[field]); + } + + // send stuff + this.emit('request', this); + + // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing) + // We need null here if data is undefined + xhr.send(typeof data !== 'undefined' ? data : null); + return this; +}; + +/** + * Faux promise support + * + * @param {Function} fulfill + * @param {Function} reject + * @return {Request} + */ + +Request.prototype.then = function (fulfill, reject) { + return this.end(function(err, res) { + err ? reject(err) : fulfill(res); + }); +} + +/** + * Expose `Request`. + */ + +request.Request = Request; + +/** + * Issue a request: + * + * Examples: + * + * request('GET', '/users').end(callback) + * request('/users').end(callback) + * request('/users', callback) + * + * @param {String} method + * @param {String|Function} url or callback + * @return {Request} + * @api public + */ + +function request(method, url) { + // callback + if ('function' == typeof url) { + return new Request('GET', method).end(url); + } + + // url first + if (1 == arguments.length) { + return new Request('GET', method); + } + + return new Request(method, url); +} + +/** + * GET `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.get = function(url, data, fn){ + var req = request('GET', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.query(data); + if (fn) req.end(fn); + return req; +}; + +/** + * HEAD `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.head = function(url, data, fn){ + var req = request('HEAD', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * DELETE `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Function} fn + * @return {Request} + * @api public + */ + +function del(url, fn){ + var req = request('DELETE', url); + if (fn) req.end(fn); + return req; +}; + +request['del'] = del; +request['delete'] = del; + +/** + * PATCH `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} data + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.patch = function(url, data, fn){ + var req = request('PATCH', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * POST `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} data + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.post = function(url, data, fn){ + var req = request('POST', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * PUT `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.put = function(url, data, fn){ + var req = request('PUT', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * Expose `request`. + */ + +module.exports = request; diff --git a/public/node_modules/superagent/lib/node/agent.js b/public/node_modules/superagent/lib/node/agent.js new file mode 100644 index 00000000..2b9d912e --- /dev/null +++ b/public/node_modules/superagent/lib/node/agent.js @@ -0,0 +1,76 @@ + +/** + * Module dependencies. + */ + +var CookieJar = require('cookiejar').CookieJar; +var CookieAccess = require('cookiejar').CookieAccessInfo; +var parse = require('url').parse; +var request = require('./index'); +var methods = require('methods'); + +/** + * Expose `Agent`. + */ + +module.exports = Agent; + +/** + * Initialize a new `Agent`. + * + * @api public + */ + +function Agent(options) { + if (!(this instanceof Agent)) return new Agent(options); + if (options) this._ca = options.ca; + this.jar = new CookieJar; +} + +/** + * Save the cookies in the given `res` to + * the agent's cookie jar for persistence. + * + * @param {Response} res + * @api private + */ + +Agent.prototype.saveCookies = function(res){ + var cookies = res.headers['set-cookie']; + if (cookies) this.jar.setCookies(cookies); +}; + +/** + * Attach cookies when available to the given `req`. + * + * @param {Request} req + * @api private + */ + +Agent.prototype.attachCookies = function(req){ + var url = parse(req.url); + var access = CookieAccess(url.hostname, url.pathname, 'https:' == url.protocol); + var cookies = this.jar.getCookies(access).toValueString(); + req.cookies = cookies; +}; + +// generate HTTP verb methods +methods.indexOf('del') == -1 && methods.push('del'); +methods.forEach(function(method){ + var name = method; + method = 'del' == method ? 'delete' : method; + + method = method.toUpperCase(); + Agent.prototype[name] = function(url, fn){ + var req = request(method, url); + req.ca(this._ca); + + req.on('response', this.saveCookies.bind(this)); + req.on('redirect', this.saveCookies.bind(this)); + req.on('redirect', this.attachCookies.bind(this, req)); + this.attachCookies(req); + + fn && req.end(fn); + return req; + }; +}); diff --git a/public/node_modules/superagent/lib/node/index.js b/public/node_modules/superagent/lib/node/index.js new file mode 100644 index 00000000..5b957489 --- /dev/null +++ b/public/node_modules/superagent/lib/node/index.js @@ -0,0 +1,1234 @@ + +/** + * Module dependencies. + */ + +var debug = require('debug')('superagent'); +var formidable = require('formidable'); +var FormData = require('form-data'); +var Response = require('./response'); +var parse = require('url').parse; +var format = require('url').format; +var resolve = require('url').resolve; +var methods = require('methods'); +var Stream = require('stream'); +var utils = require('./utils'); +var extend = require('extend'); +var Part = require('./part'); +var mime = require('mime'); +var https = require('https'); +var http = require('http'); +var fs = require('fs'); +var qs = require('qs'); +var zlib = require('zlib'); +var util = require('util'); +var pkg = require('../../package.json'); + +/** + * Expose the request function. + */ + +exports = module.exports = request; + +/** + * Expose the agent function + */ + +exports.agent = require('./agent'); + +/** + * Expose `Part`. + */ + +exports.Part = Part; + +/** + * Noop. + */ + +function noop(){}; + +/** + * Expose `Response`. + */ + +exports.Response = Response; + +/** + * Define "form" mime type. + */ + +mime.define({ + 'application/x-www-form-urlencoded': ['form', 'urlencoded', 'form-data'] +}); + +/** + * Protocol map. + */ + +exports.protocols = { + 'http:': http, + 'https:': https +}; + +/** + * Check if `obj` is an object. + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ + +function isObject(obj) { + return null != obj && 'object' == typeof obj; +} + +/** + * Default serialization map. + * + * superagent.serialize['application/xml'] = function(obj){ + * return 'generated xml here'; + * }; + * + */ + +exports.serialize = { + 'application/x-www-form-urlencoded': qs.stringify, + 'application/json': JSON.stringify +}; + +/** + * Default parsers. + * + * superagent.parse['application/xml'] = function(res, fn){ + * fn(null, res); + * }; + * + */ + +exports.parse = require('./parsers'); + +/** + * Initialize a new `Request` with the given `method` and `url`. + * + * @param {String} method + * @param {String|Object} url + * @api public + */ + +function Request(method, url) { + Stream.call(this); + var self = this; + if ('string' != typeof url) url = format(url); + this._agent = false; + this._formData = null; + this.method = method; + this.url = url; + this.header = { + 'User-Agent': 'node-superagent/' + pkg.version + }; + this.writable = true; + this._redirects = 0; + this.redirects(5); + this.cookies = ''; + this.qs = {}; + this.qsRaw = []; + this._redirectList = []; + this._streamRequest = false; + this.on('end', this.clearTimeout.bind(this)); +} + +/** + * Inherit from `Stream`. + */ + +util.inherits(Request, Stream); + +/** + * Write the field `name` and `val` for "multipart/form-data" + * request bodies. + * + * ``` js + * request.post('http://localhost/upload') + * .field('foo', 'bar') + * .end(callback); + * ``` + * + * @param {String} name + * @param {String|Buffer|fs.ReadStream} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.field = function(name, val){ + debug('field', name, val); + if (!this._formData) this._formData = new FormData(); + this._formData.append(name, val); + return this; +}; + +/** + * Queue the given `file` as an attachment to the specified `field`, + * with optional `filename`. + * + * ``` js + * request.post('http://localhost/upload') + * .attach(new Buffer('Hello world'), 'hello.html') + * .end(callback); + * ``` + * + * A filename may also be used: + * + * ``` js + * request.post('http://localhost/upload') + * .attach('files', 'image.jpg') + * .end(callback); + * ``` + * + * @param {String} field + * @param {String|fs.ReadStream|Buffer} file + * @param {String} filename + * @return {Request} for chaining + * @api public + */ + +Request.prototype.attach = function(field, file, filename){ + if (!this._formData) this._formData = new FormData(); + if ('string' == typeof file) { + if (!filename) filename = file; + debug('creating `fs.ReadStream` instance for file: %s', file); + file = fs.createReadStream(file); + } else if(!filename && file.path) { + filename = file.path; + } + this._formData.append(field, file, { filename: filename }); + return this; +}; + +/** + * Set the max redirects to `n`. + * + * @param {Number} n + * @return {Request} for chaining + * @api public + */ + +Request.prototype.redirects = function(n){ + debug('max redirects %s', n); + this._maxRedirects = n; + return this; +}; + +/** + * Return a new `Part` for this request. + * + * @return {Part} + * @api public + * @deprecated pass a readable stream in to `Request#attach()` instead + */ + +Request.prototype.part = util.deprecate(function(){ + return new Part(this); +}, '`Request#part()` is deprecated. ' + + 'Pass a readable stream in to `Request#attach()` instead.'); + +/** + * Gets/sets the `Agent` to use for this HTTP request. The default (if this + * function is not called) is to opt out of connection pooling (`agent: false`). + * + * @param {http.Agent} agent + * @return {http.Agent} + * @api public + */ + +Request.prototype.agent = function(agent){ + if (!arguments.length) return this._agent; + this._agent = agent; + return this; +}; + +/** + * Set header `field` to `val`, or multiple fields with one object. + * + * Examples: + * + * req.get('/') + * .set('Accept', 'application/json') + * .set('X-API-Key', 'foobar') + * .end(callback); + * + * req.get('/') + * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) + * .end(callback); + * + * @param {String|Object} field + * @param {String} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.set = function(field, val){ + if (isObject(field)) { + for (var key in field) { + this.set(key, field[key]); + } + return this; + } + + debug('set %s "%s"', field, val); + this.header[field] = val; + return this; +}; + +/** + * Remove header `field`. + * + * Example: + * + * req.get('/') + * .unset('User-Agent') + * .end(callback); + * + * @param {String} field + * @return {Request} for chaining + * @api public + */ + +Request.prototype.unset = function(field){ + debug('unset %s', field); + + delete this.header[field]; + return this; +}; + +/** + * Get request header `field`. + * + * @param {String} field + * @return {String} + * @api public + */ + +Request.prototype.get = function(field){ + return this.header[field]; +}; + +/** + * Set _Content-Type_ response header passed through `mime.lookup()`. + * + * Examples: + * + * request.post('/') + * .type('xml') + * .send(xmlstring) + * .end(callback); + * + * request.post('/') + * .type('json') + * .send(jsonstring) + * .end(callback); + * + * request.post('/') + * .type('application/json') + * .send(jsonstring) + * .end(callback); + * + * @param {String} type + * @return {Request} for chaining + * @api public + */ + +Request.prototype.type = function(type){ + return this.set('Content-Type', ~type.indexOf('/') + ? type + : mime.lookup(type)); +}; + +/** + * Set _Accept_ response header passed through `mime.lookup()`. + * + * Examples: + * + * superagent.types.json = 'application/json'; + * + * request.get('/agent') + * .accept('json') + * .end(callback); + * + * request.get('/agent') + * .accept('application/json') + * .end(callback); + * + * @param {String} accept + * @return {Request} for chaining + * @api public + */ + +Request.prototype.accept = function(type){ + return this.set('Accept', ~type.indexOf('/') + ? type + : mime.lookup(type)); +}; + +/** + * Add query-string `val`. + * + * Examples: + * + * request.get('/shoes') + * .query('size=10') + * .query({ color: 'blue' }) + * + * @param {Object|String} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.query = function(val){ + if ('string' == typeof val) { + this.qsRaw.push(val); + return this; + } + + extend(this.qs, val); + return this; +}; + +/** + * Send `data` as the request body, defaulting the `.type()` to "json" when + * an object is given. + * + * Examples: + * + * // manual json + * request.post('/user') + * .type('json') + * .send('{"name":"tj"}') + * .end(callback) + * + * // auto json + * request.post('/user') + * .send({ name: 'tj' }) + * .end(callback) + * + * // manual x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send('name=tj') + * .end(callback) + * + * // auto x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send({ name: 'tj' }) + * .end(callback) + * + * // string defaults to x-www-form-urlencoded + * request.post('/user') + * .send('name=tj') + * .send('foo=bar') + * .send('bar=baz') + * .end(callback) + * + * @param {String|Object} data + * @return {Request} for chaining + * @api public + */ + +Request.prototype.send = function(data){ + var obj = isObject(data); + var type = this.get('Content-Type'); + // merge + if (obj && isObject(this._data)) { + for (var key in data) { + this._data[key] = data[key]; + } + // string + } else if ('string' == typeof data) { + // default to x-www-form-urlencoded + if (!type) this.type('form'); + type = this.get('Content-Type'); + + // concat & + if ('application/x-www-form-urlencoded' == type) { + this._data = this._data + ? this._data + '&' + data + : data; + } else { + this._data = (this._data || '') + data; + } + } else { + this._data = data; + } + + if (!obj) return this; + + // default to json + if (!type) this.type('json'); + return this; +}; + +/** + * Write raw `data` / `encoding` to the socket. + * + * @param {Buffer|String} data + * @param {String} encoding + * @return {Boolean} + * @api public + */ + +Request.prototype.write = function(data, encoding){ + var req = this.request(); + if (!this._streamRequest) { + this._streamRequest = true; + try { + // ensure querystring is appended before headers are sent + this.appendQueryString(req); + } catch (e) { + return this.emit('error', e); + } + } + return req.write(data, encoding); +}; + +/** + * Pipe the request body to `stream`. + * + * @param {Stream} stream + * @param {Object} options + * @return {Stream} + * @api public + */ + +Request.prototype.pipe = function(stream, options){ + this.piped = true; // HACK... + this.buffer(false); + var self = this; + this.end().req.on('response', function(res){ + // redirect + var redirect = isRedirect(res.statusCode); + if (redirect && self._redirects++ != self._maxRedirects) { + return self.redirect(res).pipe(stream, options); + } + + if (/^(deflate|gzip)$/.test(res.headers['content-encoding'])) { + res.pipe(zlib.createUnzip()).pipe(stream, options); + } else { + res.pipe(stream, options); + } + res.on('end', function(){ + self.emit('end'); + }); + }); + return stream; +}; + +/** + * Enable / disable buffering. + * + * @return {Boolean} [val] + * @return {Request} for chaining + * @api public + */ + +Request.prototype.buffer = function(val){ + this._buffer = false === val + ? false + : true; + return this; +}; + +/** + * Set timeout to `ms`. + * + * @param {Number} ms + * @return {Request} for chaining + * @api public + */ + +Request.prototype.timeout = function(ms){ + this._timeout = ms; + return this; +}; + +/** + * Clear previous timeout. + * + * @return {Request} for chaining + * @api public + */ + +Request.prototype.clearTimeout = function(){ + debug('clear timeout %s %s', this.method, this.url); + this._timeout = 0; + clearTimeout(this._timer); + return this; +}; + +/** + * Abort and clear timeout. + * + * @api public + */ + +Request.prototype.abort = function(){ + debug('abort %s %s', this.method, this.url); + this._aborted = true; + this.clearTimeout(); + this.req.abort(); + this.emit('abort'); +}; + +/** + * Define the parser to be used for this response. + * + * @param {Function} fn + * @return {Request} for chaining + * @api public + */ + +Request.prototype.parse = function(fn){ + this._parser = fn; + return this; +}; + +/** + * Redirect to `url + * + * @param {IncomingMessage} res + * @return {Request} for chaining + * @api private + */ + +Request.prototype.redirect = function(res){ + var url = res.headers.location; + if (!url) { + return this.callback(new Error('No location header for redirect'), res); + } + + debug('redirect %s -> %s', this.url, url); + + // location + url = resolve(this.url, url); + + // ensure the response is being consumed + // this is required for Node v0.10+ + res.resume(); + + var headers = this.req._headers; + + var shouldStripCookie = parse(url).host !== parse(this.url).host; + + // implementation of 302 following defacto standard + if (res.statusCode == 301 || res.statusCode == 302){ + // strip Content-* related fields + // in case of POST etc + headers = utils.cleanHeader(this.req._headers, shouldStripCookie); + + // force GET + this.method = 'HEAD' == this.method + ? 'HEAD' + : 'GET'; + + // clear data + this._data = null; + } + // 303 is always GET + if (res.statusCode == 303) { + // strip Content-* related fields + // in case of POST etc + headers = utils.cleanHeader(this.req._headers, shouldStripCookie); + + // force method + this.method = 'GET'; + + // clear data + this._data = null; + } + // 307 preserves method + // 308 preserves method + delete headers.host; + + delete this.req; + + // remove all add header except User-Agent + for (var key in this.header) { + if (key !== 'User-Agent') { + delete this.header[key] + } + } + + // redirect + this.url = url; + this._redirectList.push(url); + this.emit('redirect', res); + this.qs = {}; + this.qsRaw = []; + this.set(headers); + this.end(this._callback); + return this; +}; + +/** + * Set Authorization field value with `user` and `pass`. + * + * Examples: + * + * .auth('tobi', 'learnboost') + * .auth('tobi:learnboost') + * .auth('tobi') + * + * @param {String} user + * @param {String} pass + * @return {Request} for chaining + * @api public + */ + +Request.prototype.auth = function(user, pass){ + if (1 === arguments.length) pass = ''; + if (!~user.indexOf(':')) user = user + ':'; + var str = new Buffer(user + pass).toString('base64'); + return this.set('Authorization', 'Basic ' + str); +}; + +/** + * Set the certificate authority option for https request. + * + * @param {Buffer | Array} cert + * @return {Request} for chaining + * @api public + */ + +Request.prototype.ca = function(cert){ + this._ca = cert; + return this; +}; + +/** + * Allow for extension + */ + +Request.prototype.use = function(fn) { + fn(this); + return this; +}; + +/** + * Return an http[s] request. + * + * @return {OutgoingMessage} + * @api private + */ + +Request.prototype.request = function(){ + if (this.req) return this.req; + + var self = this; + var options = {}; + var data = this._data; + var url = this.url; + + // default to http:// + if (0 != url.indexOf('http')) url = 'http://' + url; + url = parse(url); + + // options + options.method = this.method; + options.port = url.port; + options.path = url.pathname; + options.host = url.hostname; + options.ca = this._ca; + options.agent = this._agent; + + // initiate request + var mod = exports.protocols[url.protocol]; + + // request + var req = this.req = mod.request(options); + if ('HEAD' != options.method) req.setHeader('Accept-Encoding', 'gzip, deflate'); + this.protocol = url.protocol; + this.host = url.host; + + // expose events + req.on('drain', function(){ self.emit('drain'); }); + + req.on('error', function(err){ + // flag abortion here for out timeouts + // because node will emit a faux-error "socket hang up" + // when request is aborted before a connection is made + if (self._aborted) return; + // if we've recieved a response then we don't want to let + // an error in the request blow up the response + if (self.response) return; + self.callback(err); + }); + + // auth + if (url.auth) { + var auth = url.auth.split(':'); + this.auth(auth[0], auth[1]); + } + + // query + if (url.search) + this.query(url.search.substr(1)); + + // add cookies + if (this.cookies) req.setHeader('Cookie', this.cookies); + + for (var key in this.header) { + req.setHeader(key, this.header[key]); + } + + return req; +}; + +/** + * Invoke the callback with `err` and `res` + * and handle arity check. + * + * @param {Error} err + * @param {Response} res + * @api private + */ + +Request.prototype.callback = function(err, res){ + // Avoid the error which is emitted from 'socket hang up' to cause the fn undefined error on JS runtime. + var fn = this._callback || noop; + this.clearTimeout(); + if (this.called) return console.warn('double callback!'); + this.called = true; + + if (err) { + err.response = res; + } + + // only emit error event if there is a listener + // otherwise we assume the callback to `.end()` will get the error + if (err && this.listeners('error').length > 0) this.emit('error', err); + + if (err) { + return fn(err, res); + } + + if (res && res.status >= 200 && res.status < 300) { + return fn(err, res); + } + + var msg = 'Unsuccessful HTTP response'; + if (res) { + msg = http.STATUS_CODES[res.status] || msg; + } + var new_err = new Error(msg); + new_err.original = err; + new_err.response = res; + new_err.status = (res) ? res.status : undefined; + + fn(err || new_err, res); +}; + +/** + * Compose querystring to append to req.path + * + * @return {String} querystring + * @api private + */ + +Request.prototype.appendQueryString = function(req){ + var querystring = qs.stringify(this.qs, { indices: false }); + querystring += ((querystring.length && this.qsRaw.length) ? '&' : '') + this.qsRaw.join('&'); + req.path += querystring.length + ? (~req.path.indexOf('?') ? '&' : '?') + querystring + : ''; +}; + +/** + * Initiate request, invoking callback `fn(err, res)` + * with an instanceof `Response`. + * + * @param {Function} fn + * @return {Request} for chaining + * @api public + */ + +/** +* Client API parity, irrelevant in a Node context. +* +* @api public +*/ + +Request.prototype.withCredentials = function(){ + return this; +}; + +Request.prototype.end = function(fn){ + var self = this; + var data = this._data; + var req = this.request(); + var buffer = this._buffer; + var method = this.method; + var timeout = this._timeout; + debug('%s %s', this.method, this.url); + + // store callback + this._callback = fn || noop; + + // querystring + try { + this.appendQueryString(req); + } catch (e) { + return this.callback(e); + } + + // timeout + if (timeout && !this._timer) { + debug('timeout %sms %s %s', timeout, this.method, this.url); + this._timer = setTimeout(function(){ + var err = new Error('timeout of ' + timeout + 'ms exceeded'); + err.timeout = timeout; + err.code = 'ECONNABORTED'; + self.abort(); + self.callback(err); + }, timeout); + } + + // body + if ('HEAD' != method && !req._headerSent) { + // serialize stuff + if ('string' != typeof data) { + var contentType = req.getHeader('Content-Type') + // Parse out just the content type from the header (ignore the charset) + if (contentType) contentType = contentType.split(';')[0] + var serialize = exports.serialize[contentType]; + if (!serialize && isJSON(contentType)) serialize = exports.serialize['application/json']; + if (serialize) data = serialize(data); + } + + // content-length + if (data && !req.getHeader('Content-Length')) { + req.setHeader('Content-Length', Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data)); + } + } + + // response + req.on('response', function(res){ + debug('%s %s -> %s', self.method, self.url, res.statusCode); + var max = self._maxRedirects; + var mime = utils.type(res.headers['content-type'] || '') || 'text/plain'; + var len = res.headers['content-length']; + var type = mime.split('/'); + var subtype = type[1]; + var type = type[0]; + var multipart = 'multipart' == type; + var redirect = isRedirect(res.statusCode); + var parser = self._parser; + + self.res = res; + + if ('HEAD' == self.method) { + var response = new Response(self); + self.response = response; + response.redirects = self._redirectList; + self.emit('response', response); + self.callback(null, response); + self.emit('end'); + return; + } + + if (self.piped) { + return; + } + + // redirect + if (redirect && self._redirects++ != max) { + return self.redirect(res); + } + + // zlib support + if (/^(deflate|gzip)$/.test(res.headers['content-encoding'])) { + utils.unzip(req, res); + } + + // don't buffer multipart + if (multipart) buffer = false; + + // TODO: make all parsers take callbacks + if (!parser && multipart) { + var form = new formidable.IncomingForm; + + form.parse(res, function(err, fields, files){ + if (err) return self.callback(err); + var response = new Response(self); + self.response = response; + response.body = fields; + response.files = files; + response.redirects = self._redirectList; + self.emit('end'); + self.callback(null, response); + }); + return; + } + + // check for images, one more special treatment + if (!parser && isImage(mime)) { + exports.parse.image(res, function(err, obj){ + if (err) return self.callback(err); + var response = new Response(self); + self.response = response; + response.body = obj; + response.redirects = self._redirectList; + self.emit('end'); + self.callback(null, response); + }); + return; + } + + // by default only buffer text/*, json and messed up thing from hell + if (null == buffer && isText(mime) || isJSON(mime)) buffer = true; + + // parser + var parse = 'text' == type + ? exports.parse.text + : exports.parse[mime]; + + // everyone wants their own white-labeled json + if (!parse && isJSON(mime)) parse = exports.parse['application/json']; + + // buffered response + if (buffer) parse = parse || exports.parse.text; + + // explicit parser + if (parser) parse = parser; + + // parse + if (parse) { + try { + parse(res, function(err, obj){ + if (err && !self._aborted) self.callback(err); + res.body = obj; + }); + } catch (err) { + self.callback(err); + return; + } + } + + // unbuffered + if (!buffer) { + debug('unbuffered %s %s', self.method, self.url); + self.res = res; + var response = new Response(self); + self.response = response; + response.redirects = self._redirectList; + self.emit('response', response); + self.callback(null, response); + if (multipart) return // allow multipart to handle end event + res.on('end', function(){ + debug('end %s %s', self.method, self.url); + self.emit('end'); + }) + return; + } + + // terminating events + self.res = res; + res.on('error', function(err){ + self.callback(err, null); + }); + res.on('end', function(){ + debug('end %s %s', self.method, self.url); + // TODO: unless buffering emit earlier to stream + var response = new Response(self); + self.response = response; + response.redirects = self._redirectList; + self.emit('response', response); + self.callback(null, response); + self.emit('end'); + }); + }); + + this.emit('request', this); + + // if a FormData instance got created, then we send that as the request body + var formData = this._formData; + if (formData) { + + // set headers + var headers = formData.getHeaders(); + for (var i in headers) { + debug('setting FormData header: "%s: %s"', i, headers[i]); + req.setHeader(i, headers[i]); + } + + // attempt to get "Content-Length" header + formData.getLength(function(err, length) { + // TODO: Add chunked encoding when no length (if err) + + debug('got FormData Content-Length: %s', length); + if ('number' == typeof length) { + req.setHeader('Content-Length', length); + } + + var getProgressMonitor = function () { + var lengthComputable = true; + var total = req.getHeader('Content-Length'); + var loaded = 0; + + var progress = new Stream.Transform(); + progress._transform = function (chunk, encoding, cb) { + loaded += chunk.length; + self.emit('progress', { + direction: 'upload', + lengthComputable: lengthComputable, + loaded: loaded, + total: total + }); + cb(null, chunk); + }; + return progress; + }; + formData.pipe(getProgressMonitor()).pipe(req); + }); + } else { + req.end(data); + } + + return this; +}; + +/** + * Faux promise support + * + * @param {Function} fulfill + * @param {Function} reject + * @return {Request} + */ + +Request.prototype.then = function (fulfill, reject) { + return this.end(function(err, res) { + err ? reject(err) : fulfill(res); + }); +} + +/** + * To json. + * + * @return {Object} + * @api public + */ + +Request.prototype.toJSON = function(){ + return { + method: this.method, + url: this.url, + data: this._data + }; +}; + +/** + * Expose `Request`. + */ + +exports.Request = Request; + +/** + * Issue a request: + * + * Examples: + * + * request('GET', '/users').end(callback) + * request('/users').end(callback) + * request('/users', callback) + * + * @param {String} method + * @param {String|Function} url or callback + * @return {Request} + * @api public + */ + +function request(method, url) { + // callback + if ('function' == typeof url) { + return new Request('GET', method).end(url); + } + + // url first + if (1 == arguments.length) { + return new Request('GET', method); + } + + return new Request(method, url); +} + +// generate HTTP verb methods +methods.indexOf('del') == -1 && methods.push('del'); +methods.forEach(function(method){ + var name = method; + method = 'del' == method ? 'delete' : method; + + method = method.toUpperCase(); + request[name] = function(url, data, fn){ + var req = request(method, url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + fn && req.end(fn); + return req; + }; +}); + +/** + * Check if `mime` is text and should be buffered. + * + * @param {String} mime + * @return {Boolean} + * @api public + */ + +function isText(mime) { + var parts = mime.split('/'); + var type = parts[0]; + var subtype = parts[1]; + + return 'text' == type + || 'x-www-form-urlencoded' == subtype; +} + +/** + * Check if `mime` is image + * + * @param {String} mime + * @return {Boolean} + * @api public + */ + +function isImage(mime) { + var parts = mime.split('/'); + var type = parts[0]; + var subtype = parts[1]; + + return 'image' == type; +} + +/** + * Check if `mime` is json or has +json structured syntax suffix. + * + * @param {String} mime + * @return {Boolean} + * @api private + */ + +function isJSON(mime) { + return /[\/+]json\b/.test(mime); +} + +/** + * Check if we should follow the redirect `code`. + * + * @param {Number} code + * @return {Boolean} + * @api private + */ + +function isRedirect(code) { + return ~[301, 302, 303, 305, 307, 308].indexOf(code); +} diff --git a/public/node_modules/superagent/lib/node/parsers/image.js b/public/node_modules/superagent/lib/node/parsers/image.js new file mode 100644 index 00000000..b3e0ebc4 --- /dev/null +++ b/public/node_modules/superagent/lib/node/parsers/image.js @@ -0,0 +1,10 @@ +module.exports = function(res, fn){ + var data = []; // Binary data needs binary storage + + res.on('data', function(chunk){ + data.push(chunk); + }); + res.on('end', function () { + fn(null, Buffer.concat(data)); + }); +}; \ No newline at end of file diff --git a/public/node_modules/superagent/lib/node/parsers/index.js b/public/node_modules/superagent/lib/node/parsers/index.js new file mode 100644 index 00000000..61a98cd2 --- /dev/null +++ b/public/node_modules/superagent/lib/node/parsers/index.js @@ -0,0 +1,5 @@ + +exports['application/x-www-form-urlencoded'] = require('./urlencoded'); +exports['application/json'] = require('./json'); +exports.text = require('./text'); +exports.image = require('./image'); diff --git a/public/node_modules/superagent/lib/node/parsers/json.js b/public/node_modules/superagent/lib/node/parsers/json.js new file mode 100644 index 00000000..7eb60546 --- /dev/null +++ b/public/node_modules/superagent/lib/node/parsers/json.js @@ -0,0 +1,17 @@ + +module.exports = function parseJSON(res, fn){ + res.text = ''; + res.setEncoding('utf8'); + res.on('data', function(chunk){ res.text += chunk;}); + res.on('end', function(){ + try { + var body = res.text && JSON.parse(res.text); + } catch (e) { + var err = e; + // issue #675: return the raw response if the response parsing fails + err.rawResponse = res.text || null; + } finally { + fn(err, body); + } + }); +}; diff --git a/public/node_modules/superagent/lib/node/parsers/text.js b/public/node_modules/superagent/lib/node/parsers/text.js new file mode 100644 index 00000000..03575c69 --- /dev/null +++ b/public/node_modules/superagent/lib/node/parsers/text.js @@ -0,0 +1,7 @@ + +module.exports = function(res, fn){ + res.text = ''; + res.setEncoding('utf8'); + res.on('data', function(chunk){ res.text += chunk; }); + res.on('end', fn); +}; \ No newline at end of file diff --git a/public/node_modules/superagent/lib/node/parsers/urlencoded.js b/public/node_modules/superagent/lib/node/parsers/urlencoded.js new file mode 100644 index 00000000..245c665f --- /dev/null +++ b/public/node_modules/superagent/lib/node/parsers/urlencoded.js @@ -0,0 +1,19 @@ + +/** + * Module dependencies. + */ + +var qs = require('qs'); + +module.exports = function(res, fn){ + res.text = ''; + res.setEncoding('ascii'); + res.on('data', function(chunk){ res.text += chunk; }); + res.on('end', function(){ + try { + fn(null, qs.parse(res.text)); + } catch (err) { + fn(err); + } + }); +}; \ No newline at end of file diff --git a/public/node_modules/superagent/lib/node/part.js b/public/node_modules/superagent/lib/node/part.js new file mode 100644 index 00000000..82ed5653 --- /dev/null +++ b/public/node_modules/superagent/lib/node/part.js @@ -0,0 +1,150 @@ + +/** + * Module dependencies. + */ + +var util = require('util'); +var mime = require('mime'); +var FormData = require('form-data'); +var PassThrough = require('readable-stream/passthrough'); + +/** + * Initialize a new `Part` for the given `req`. + * + * @param {Request} req + * @api public + * @deprecated pass a readable stream in to `Request#attach()` instead + */ + +var Part = function (req) { + PassThrough.call(this); + this._req = req; + this._attached = false; + this._name = null; + this._type = null; + this._header = null; + this._filename = null; + + this.once('pipe', this._attach.bind(this)); +}; +Part = util.deprecate(Part, 'The `Part()` constructor is deprecated. ' + + 'Pass a readable stream in to `Request#attach()` instead.'); + +/** + * Inherit from `PassThrough`. + */ + +util.inherits(Part, PassThrough); + +/** + * Expose `Part`. + */ + +module.exports = Part; + +/** + * Set header `field` to `val`. + * + * @param {String} field + * @param {String} val + * @return {Part} for chaining + * @api public + */ + +Part.prototype.set = function(field, val){ + //if (!this._header) this._header = {}; + //this._header[field] = val; + //return this; + throw new TypeError('setting custom form-data part headers is unsupported'); +}; + +/** + * Set _Content-Type_ response header passed through `mime.lookup()`. + * + * Examples: + * + * res.type('html'); + * res.type('.html'); + * + * @param {String} type + * @return {Part} for chaining + * @api public + */ + +Part.prototype.type = function(type){ + var lookup = mime.lookup(type); + this._type = lookup; + //this.set('Content-Type', lookup); + return this; +}; + +/** + * Set the "name" portion for the _Content-Disposition_ header field. + * + * @param {String} name + * @return {Part} for chaining + * @api public + */ + +Part.prototype.name = function(name){ + this._name = name; + return this; +}; + +/** + * Set _Content-Disposition_ header field to _attachment_ with `filename` + * and field `name`. + * + * @param {String} name + * @param {String} filename + * @return {Part} for chaining + * @api public + */ + +Part.prototype.attachment = function(name, filename){ + this.name(name); + if (filename) { + this.type(filename); + this._filename = filename; + } + return this; +}; + +/** + * Calls `FormData#append()` on the Request instance's FormData object. + * + * Gets called implicitly upon the first `write()` call, or the "pipe" event. + * + * @api private + */ + +Part.prototype._attach = function(){ + if (this._attached) return; + this._attached = true; + + if (!this._name) throw new Error('must call `Part#name()` first!'); + + // add `this` Stream's readable side as a stream for this Part + if (!this._req._formData) this._req._formData = new FormData(); + this._req._formData.append(this._name, this, { + contentType: this._type, + filename: this._filename + }); + + // restore PassThrough's default `write()` function now that we're setup + this.write = PassThrough.prototype.write; +}; + +/** + * Write `data` with `encoding`. + * + * @param {Buffer|String} data + * @param {String} encoding + * @return {Boolean} + * @api public + */ + +Part.prototype.write = function(){ + this._attach(); + return this.write.apply(this, arguments); +}; diff --git a/public/node_modules/superagent/lib/node/response.js b/public/node_modules/superagent/lib/node/response.js new file mode 100644 index 00000000..b30c28b5 --- /dev/null +++ b/public/node_modules/superagent/lib/node/response.js @@ -0,0 +1,210 @@ + +/** + * Module dependencies. + */ + +var util = require('util'); +var utils = require('./utils'); +var Stream = require('stream'); + +/** + * Expose `Response`. + */ + +module.exports = Response; + +/** + * Initialize a new `Response` with the given `xhr`. + * + * - set flags (.ok, .error, etc) + * - parse header + * + * @param {Request} req + * @param {Object} options + * @constructor + * @extends {Stream} + * @implements {ReadableStream} + * @api private + */ + +function Response(req, options) { + Stream.call(this); + options = options || {}; + var res = this.res = req.res; + this.request = req; + this.req = req.req; + this.links = {}; + this.text = res.text; + this.body = res.body !== undefined ? res.body : {}; + this.files = res.files || {}; + this.buffered = 'string' == typeof this.text; + this.header = this.headers = res.headers; + this.setStatusProperties(res.statusCode); + this.setHeaderProperties(this.header); + this.setEncoding = res.setEncoding.bind(res); + res.on('data', this.emit.bind(this, 'data')); + res.on('end', this.emit.bind(this, 'end')); + res.on('close', this.emit.bind(this, 'close')); + res.on('error', this.emit.bind(this, 'error')); +} + +/** + * Inherit from `Stream`. + */ + +util.inherits(Response, Stream); + +/** + * Get case-insensitive `field` value. + * + * @param {String} field + * @return {String} + * @api public + */ + +Response.prototype.get = function(field){ + return this.header[field.toLowerCase()]; +}; + +/** + * Implements methods of a `ReadableStream` + */ + +Response.prototype.destroy = function(err){ + this.res.destroy(err); +}; + +/** + * Pause. + */ + +Response.prototype.pause = function(){ + this.res.pause(); +}; + +/** + * Resume. + */ + +Response.prototype.resume = function(){ + this.res.resume(); +}; + +/** + * Return an `Error` representative of this response. + * + * @return {Error} + * @api public + */ + +Response.prototype.toError = function(){ + var req = this.req; + var method = req.method; + var path = req.path; + + var msg = 'cannot ' + method + ' ' + path + ' (' + this.status + ')'; + var err = new Error(msg); + err.status = this.status; + err.text = this.text; + err.method = method; + err.path = path; + + return err; +}; + +/** + * Set header related properties: + * + * - `.type` the content type without params + * + * A response of "Content-Type: text/plain; charset=utf-8" + * will provide you with a `.type` of "text/plain". + * + * @param {Object} header + * @api private + */ + +Response.prototype.setHeaderProperties = function(header){ + // TODO: moar! + // TODO: make this a util + + // content-type + var ct = this.header['content-type'] || ''; + + // params + var params = utils.params(ct); + for (var key in params) this[key] = params[key]; + + this.type = utils.type(ct); + + // links + try { + if (header.link) this.links = utils.parseLinks(header.link); + } catch (err) { + // ignore + } +}; + +/** + * Set flags such as `.ok` based on `status`. + * + * For example a 2xx response will give you a `.ok` of __true__ + * whereas 5xx will be __false__ and `.error` will be __true__. The + * `.clientError` and `.serverError` are also available to be more + * specific, and `.statusType` is the class of error ranging from 1..5 + * sometimes useful for mapping respond colors etc. + * + * "sugar" properties are also defined for common cases. Currently providing: + * + * - .noContent + * - .badRequest + * - .unauthorized + * - .notAcceptable + * - .notFound + * + * @param {Number} status + * @api private + */ + +Response.prototype.setStatusProperties = function(status){ + var type = status / 100 | 0; + + // status / class + this.status = this.statusCode = status; + this.statusType = type; + + // basics + this.info = 1 == type; + this.ok = 2 == type; + this.redirect = 3 == type; + this.clientError = 4 == type; + this.serverError = 5 == type; + this.error = (4 == type || 5 == type) + ? this.toError() + : false; + + // sugar + this.accepted = 202 == status; + this.noContent = 204 == status; + this.badRequest = 400 == status; + this.unauthorized = 401 == status; + this.notAcceptable = 406 == status; + this.forbidden = 403 == status; + this.notFound = 404 == status; +}; + +/** + * To json. + * + * @return {Object} + * @api public + */ + +Response.prototype.toJSON = function(){ + return { + req: this.request.toJSON(), + header: this.header, + status: this.status, + text: this.text + }; +}; diff --git a/public/node_modules/superagent/lib/node/utils.js b/public/node_modules/superagent/lib/node/utils.js new file mode 100644 index 00000000..822929e4 --- /dev/null +++ b/public/node_modules/superagent/lib/node/utils.js @@ -0,0 +1,142 @@ + +/** + * Module dependencies. + */ + +var StringDecoder = require('string_decoder').StringDecoder; +var Stream = require('stream'); +var zlib; + +/** + * Require zlib module for Node 0.6+ + */ + +try { + zlib = require('zlib'); +} catch (e) { } + +/** + * Return the mime type for the given `str`. + * + * @param {String} str + * @return {String} + * @api private + */ + +exports.type = function(str){ + return str.split(/ *; */).shift(); +}; + +/** + * Return header field parameters. + * + * @param {String} str + * @return {Object} + * @api private + */ + +exports.params = function(str){ + return str.split(/ *; */).reduce(function(obj, str){ + var parts = str.split(/ *= */); + var key = parts.shift(); + var val = parts.shift(); + + if (key && val) obj[key] = val; + return obj; + }, {}); +}; + +/** + * Parse Link header fields. + * + * @param {String} str + * @return {Object} + * @api private + */ + +exports.parseLinks = function(str){ + return str.split(/ *, */).reduce(function(obj, str){ + var parts = str.split(/ *; */); + var url = parts[0].slice(1, -1); + var rel = parts[1].split(/ *= */)[1].slice(1, -1); + obj[rel] = url; + return obj; + }, {}); +}; + +/** + * Buffers response data events and re-emits when they're unzipped. + * + * @param {Request} req + * @param {Response} res + * @api private + */ + +exports.unzip = function(req, res){ + if (!zlib) return; + + var unzip = zlib.createUnzip(); + var stream = new Stream; + var decoder; + + // make node responseOnEnd() happy + stream.req = req; + + unzip.on('error', function(err){ + stream.emit('error', err); + }); + + // pipe to unzip + res.pipe(unzip); + + // override `setEncoding` to capture encoding + res.setEncoding = function(type){ + decoder = new StringDecoder(type); + }; + + // decode upon decompressing with captured encoding + unzip.on('data', function(buf){ + if (decoder) { + var str = decoder.write(buf); + if (str.length) stream.emit('data', str); + } else { + stream.emit('data', buf); + } + }); + + unzip.on('end', function(){ + stream.emit('end'); + }); + + // override `on` to capture data listeners + var _on = res.on; + res.on = function(type, fn){ + if ('data' == type || 'end' == type) { + stream.on(type, fn); + } else if ('error' == type) { + stream.on(type, fn); + _on.call(res, type, fn); + } else { + _on.call(res, type, fn); + } + }; +}; + +/** + * Strip content related fields from `header`. + * + * @param {Object} header + * @return {Object} header + * @api private + */ + +exports.cleanHeader = function(header, shouldStripCookie){ + delete header['content-type']; + delete header['content-length']; + delete header['transfer-encoding']; + delete header['host']; + if (shouldStripCookie) { + delete header['cookie']; + } + return header; +}; diff --git a/public/node_modules/superagent/package.json b/public/node_modules/superagent/package.json new file mode 100644 index 00000000..505a636a --- /dev/null +++ b/public/node_modules/superagent/package.json @@ -0,0 +1,160 @@ +{ + "_args": [ + [ + "superagent", + "/Users/jfrederick/repos/react-tutorial" + ] + ], + "_from": "superagent@*", + "_id": "superagent@1.7.0", + "_inCache": true, + "_installable": true, + "_location": "/superagent", + "_nodeVersion": "5.4.0", + "_npmUser": { + "email": "pornel@pornel.net", + "name": "kornel" + }, + "_npmVersion": "3.5.3", + "_phantomChildren": {}, + "_requested": { + "name": "superagent", + "raw": "superagent", + "rawSpec": "", + "scope": null, + "spec": "*", + "type": "range" + }, + "_requiredBy": [ + "#USER" + ], + "_resolved": "https://registry.npmjs.org/superagent/-/superagent-1.7.0.tgz", + "_shasum": "fa40411e78525b74fbf9cde8e4c0afc43af851e5", + "_shrinkwrap": null, + "_spec": "superagent", + "_where": "/Users/jfrederick/repos/react-tutorial", + "author": { + "email": "tj@vision-media.ca", + "name": "TJ Holowaychuk" + }, + "browser": { + "./lib/node/index.js": "./lib/client.js", + "./test/support/server.js": "./test/support/blank.js", + "emitter": "component-emitter", + "reduce": "reduce-component" + }, + "bugs": { + "url": "https://github.com/visionmedia/superagent/issues" + }, + "component": { + "scripts": { + "superagent": "lib/client.js" + } + }, + "contributors": [ + { + "name": "Hunter Loftis", + "email": "hunter@hunterloftis.com" + } + ], + "dependencies": { + "component-emitter": "~1.2.0", + "cookiejar": "2.0.6", + "debug": "2", + "extend": "1.2.1", + "form-data": "0.2.0", + "formidable": "~1.0.14", + "methods": "~1.1.1", + "mime": "1.3.4", + "qs": "2.3.3", + "readable-stream": "1.0.27-1", + "reduce-component": "1.0.1" + }, + "description": "elegant & feature rich browser / node HTTP with a fluent API", + "devDependencies": { + "Base64": "~0.3.0", + "basic-auth-connect": "~1.0.0", + "better-assert": "~1.0.1", + "body-parser": "~1.9.2", + "browserify": "~6.3.2", + "cookie-parser": "~1.3.3", + "express": "~4.9.8", + "express-session": "~1.9.1", + "marked": "0.3.5", + "mocha": "~2.0.1", + "should": "~3.1.3", + "zuul": "~1.19.0" + }, + "directories": {}, + "dist": { + "shasum": "fa40411e78525b74fbf9cde8e4c0afc43af851e5", + "tarball": "http://registry.npmjs.org/superagent/-/superagent-1.7.0.tgz" + }, + "engines": { + "node": ">= 0.8" + }, + "gitHead": "2a84525ddee5d3f43385c5273d1cd5f1de8dccdc", + "homepage": "https://github.com/visionmedia/superagent#readme", + "keywords": [ + "agent", + "ajax", + "http", + "request" + ], + "license": "MIT", + "main": "./lib/node/index.js", + "maintainers": [ + { + "name": "defunctzombie", + "email": "shtylman@gmail.com" + }, + { + "name": "kof", + "email": "oleg008@gmail.com" + }, + { + "name": "kornel", + "email": "pornel@pornel.net" + }, + { + "name": "naman34", + "email": "naman34@gmail.com" + }, + { + "name": "nw", + "email": "nw@nwhite.net" + }, + { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + { + "name": "superjoe", + "email": "superjoe30@gmail.com" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "travisjeffery", + "email": "tj@travisjeffery.com" + }, + { + "name": "yields", + "email": "yields@icloud.com" + } + ], + "name": "superagent", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/superagent.git" + }, + "scripts": { + "prepublish": "make all", + "test": "make test" + }, + "version": "1.7.0" +} diff --git a/public/node_modules/superagent/superagent.js b/public/node_modules/superagent/superagent.js new file mode 100644 index 00000000..140bc4d1 --- /dev/null +++ b/public/node_modules/superagent/superagent.js @@ -0,0 +1,1383 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.superagent=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 200 && res.status < 300) { + return self.callback(err, res); + } + + var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); + new_err.original = err; + new_err.response = res; + new_err.status = res.status; + + self.callback(new_err, res); + }); +} + +/** + * Mixin `Emitter`. + */ + +Emitter(Request.prototype); + +/** + * Allow for extension + */ + +Request.prototype.use = function(fn) { + fn(this); + return this; +} + +/** + * Set timeout to `ms`. + * + * @param {Number} ms + * @return {Request} for chaining + * @api public + */ + +Request.prototype.timeout = function(ms){ + this._timeout = ms; + return this; +}; + +/** + * Clear previous timeout. + * + * @return {Request} for chaining + * @api public + */ + +Request.prototype.clearTimeout = function(){ + this._timeout = 0; + clearTimeout(this._timer); + return this; +}; + +/** + * Abort the request, and clear potential timeout. + * + * @return {Request} + * @api public + */ + +Request.prototype.abort = function(){ + if (this.aborted) return; + this.aborted = true; + this.xhr.abort(); + this.clearTimeout(); + this.emit('abort'); + return this; +}; + +/** + * Set header `field` to `val`, or multiple fields with one object. + * + * Examples: + * + * req.get('/') + * .set('Accept', 'application/json') + * .set('X-API-Key', 'foobar') + * .end(callback); + * + * req.get('/') + * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) + * .end(callback); + * + * @param {String|Object} field + * @param {String} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.set = function(field, val){ + if (isObject(field)) { + for (var key in field) { + this.set(key, field[key]); + } + return this; + } + this._header[field.toLowerCase()] = val; + this.header[field] = val; + return this; +}; + +/** + * Remove header `field`. + * + * Example: + * + * req.get('/') + * .unset('User-Agent') + * .end(callback); + * + * @param {String} field + * @return {Request} for chaining + * @api public + */ + +Request.prototype.unset = function(field){ + delete this._header[field.toLowerCase()]; + delete this.header[field]; + return this; +}; + +/** + * Get case-insensitive header `field` value. + * + * @param {String} field + * @return {String} + * @api private + */ + +Request.prototype.getHeader = function(field){ + return this._header[field.toLowerCase()]; +}; + +/** + * Set Content-Type to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.xml = 'application/xml'; + * + * request.post('/') + * .type('xml') + * .send(xmlstring) + * .end(callback); + * + * request.post('/') + * .type('application/xml') + * .send(xmlstring) + * .end(callback); + * + * @param {String} type + * @return {Request} for chaining + * @api public + */ + +Request.prototype.type = function(type){ + this.set('Content-Type', request.types[type] || type); + return this; +}; + +/** + * Force given parser + * + * Sets the body parser no matter type. + * + * @param {Function} + * @api public + */ + +Request.prototype.parse = function(fn){ + this._parser = fn; + return this; +}; + +/** + * Set Accept to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.json = 'application/json'; + * + * request.get('/agent') + * .accept('json') + * .end(callback); + * + * request.get('/agent') + * .accept('application/json') + * .end(callback); + * + * @param {String} accept + * @return {Request} for chaining + * @api public + */ + +Request.prototype.accept = function(type){ + this.set('Accept', request.types[type] || type); + return this; +}; + +/** + * Set Authorization field value with `user` and `pass`. + * + * @param {String} user + * @param {String} pass + * @return {Request} for chaining + * @api public + */ + +Request.prototype.auth = function(user, pass){ + var str = btoa(user + ':' + pass); + this.set('Authorization', 'Basic ' + str); + return this; +}; + +/** +* Add query-string `val`. +* +* Examples: +* +* request.get('/shoes') +* .query('size=10') +* .query({ color: 'blue' }) +* +* @param {Object|String} val +* @return {Request} for chaining +* @api public +*/ + +Request.prototype.query = function(val){ + if ('string' != typeof val) val = serialize(val); + if (val) this._query.push(val); + return this; +}; + +/** + * Write the field `name` and `val` for "multipart/form-data" + * request bodies. + * + * ``` js + * request.post('/upload') + * .field('foo', 'bar') + * .end(callback); + * ``` + * + * @param {String} name + * @param {String|Blob|File} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.field = function(name, val){ + if (!this._formData) this._formData = new root.FormData(); + this._formData.append(name, val); + return this; +}; + +/** + * Queue the given `file` as an attachment to the specified `field`, + * with optional `filename`. + * + * ``` js + * request.post('/upload') + * .attach(new Blob(['hey!'], { type: "text/html"})) + * .end(callback); + * ``` + * + * @param {String} field + * @param {Blob|File} file + * @param {String} filename + * @return {Request} for chaining + * @api public + */ + +Request.prototype.attach = function(field, file, filename){ + if (!this._formData) this._formData = new root.FormData(); + this._formData.append(field, file, filename || file.name); + return this; +}; + +/** + * Send `data` as the request body, defaulting the `.type()` to "json" when + * an object is given. + * + * Examples: + * + * // manual json + * request.post('/user') + * .type('json') + * .send('{"name":"tj"}') + * .end(callback) + * + * // auto json + * request.post('/user') + * .send({ name: 'tj' }) + * .end(callback) + * + * // manual x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send('name=tj') + * .end(callback) + * + * // auto x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send({ name: 'tj' }) + * .end(callback) + * + * // defaults to x-www-form-urlencoded + * request.post('/user') + * .send('name=tobi') + * .send('species=ferret') + * .end(callback) + * + * @param {String|Object} data + * @return {Request} for chaining + * @api public + */ + +Request.prototype.send = function(data){ + var obj = isObject(data); + var type = this.getHeader('Content-Type'); + + // merge + if (obj && isObject(this._data)) { + for (var key in data) { + this._data[key] = data[key]; + } + } else if ('string' == typeof data) { + if (!type) this.type('form'); + type = this.getHeader('Content-Type'); + if ('application/x-www-form-urlencoded' == type) { + this._data = this._data + ? this._data + '&' + data + : data; + } else { + this._data = (this._data || '') + data; + } + } else { + this._data = data; + } + + if (!obj || isHost(data)) return this; + if (!type) this.type('json'); + return this; +}; + +/** + * Invoke the callback with `err` and `res` + * and handle arity check. + * + * @param {Error} err + * @param {Response} res + * @api private + */ + +Request.prototype.callback = function(err, res){ + var fn = this._callback; + this.clearTimeout(); + fn(err, res); +}; + +/** + * Invoke callback with x-domain error. + * + * @api private + */ + +Request.prototype.crossDomainError = function(){ + var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'); + err.crossDomain = true; + + err.status = this.status; + err.method = this.method; + err.url = this.url; + + this.callback(err); +}; + +/** + * Invoke callback with timeout error. + * + * @api private + */ + +Request.prototype.timeoutError = function(){ + var timeout = this._timeout; + var err = new Error('timeout of ' + timeout + 'ms exceeded'); + err.timeout = timeout; + this.callback(err); +}; + +/** + * Enable transmission of cookies with x-domain requests. + * + * Note that for this to work the origin must not be + * using "Access-Control-Allow-Origin" with a wildcard, + * and also must set "Access-Control-Allow-Credentials" + * to "true". + * + * @api public + */ + +Request.prototype.withCredentials = function(){ + this._withCredentials = true; + return this; +}; + +/** + * Initiate request, invoking callback `fn(res)` + * with an instanceof `Response`. + * + * @param {Function} fn + * @return {Request} for chaining + * @api public + */ + +Request.prototype.end = function(fn){ + var self = this; + var xhr = this.xhr = request.getXHR(); + var query = this._query.join('&'); + var timeout = this._timeout; + var data = this._formData || this._data; + + // store callback + this._callback = fn || noop; + + // state change + xhr.onreadystatechange = function(){ + if (4 != xhr.readyState) return; + + // In IE9, reads to any property (e.g. status) off of an aborted XHR will + // result in the error "Could not complete the operation due to error c00c023f" + var status; + try { status = xhr.status } catch(e) { status = 0; } + + if (0 == status) { + if (self.timedout) return self.timeoutError(); + if (self.aborted) return; + return self.crossDomainError(); + } + self.emit('end'); + }; + + // progress + var handleProgress = function(e){ + if (e.total > 0) { + e.percent = e.loaded / e.total * 100; + } + e.direction = 'download'; + self.emit('progress', e); + }; + if (this.hasListeners('progress')) { + xhr.onprogress = handleProgress; + } + try { + if (xhr.upload && this.hasListeners('progress')) { + xhr.upload.onprogress = handleProgress; + } + } catch(e) { + // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. + // Reported here: + // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context + } + + // timeout + if (timeout && !this._timer) { + this._timer = setTimeout(function(){ + self.timedout = true; + self.abort(); + }, timeout); + } + + // querystring + if (query) { + query = request.serializeObject(query); + this.url += ~this.url.indexOf('?') + ? '&' + query + : '?' + query; + } + + // initiate request + xhr.open(this.method, this.url, true); + + // CORS + if (this._withCredentials) xhr.withCredentials = true; + + // body + if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) { + // serialize stuff + var contentType = this.getHeader('Content-Type'); + var serialize = this._parser || request.serialize[contentType ? contentType.split(';')[0] : '']; + if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json']; + if (serialize) data = serialize(data); + } + + // set header fields + for (var field in this.header) { + if (null == this.header[field]) continue; + xhr.setRequestHeader(field, this.header[field]); + } + + // send stuff + this.emit('request', this); + + // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing) + // We need null here if data is undefined + xhr.send(typeof data !== 'undefined' ? data : null); + return this; +}; + +/** + * Faux promise support + * + * @param {Function} fulfill + * @param {Function} reject + * @return {Request} + */ + +Request.prototype.then = function (fulfill, reject) { + return this.end(function(err, res) { + err ? reject(err) : fulfill(res); + }); +} + +/** + * Expose `Request`. + */ + +request.Request = Request; + +/** + * Issue a request: + * + * Examples: + * + * request('GET', '/users').end(callback) + * request('/users').end(callback) + * request('/users', callback) + * + * @param {String} method + * @param {String|Function} url or callback + * @return {Request} + * @api public + */ + +function request(method, url) { + // callback + if ('function' == typeof url) { + return new Request('GET', method).end(url); + } + + // url first + if (1 == arguments.length) { + return new Request('GET', method); + } + + return new Request(method, url); +} + +/** + * GET `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.get = function(url, data, fn){ + var req = request('GET', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.query(data); + if (fn) req.end(fn); + return req; +}; + +/** + * HEAD `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.head = function(url, data, fn){ + var req = request('HEAD', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * DELETE `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Function} fn + * @return {Request} + * @api public + */ + +function del(url, fn){ + var req = request('DELETE', url); + if (fn) req.end(fn); + return req; +}; + +request['del'] = del; +request['delete'] = del; + +/** + * PATCH `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} data + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.patch = function(url, data, fn){ + var req = request('PATCH', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * POST `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} data + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.post = function(url, data, fn){ + var req = request('POST', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * PUT `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.put = function(url, data, fn){ + var req = request('PUT', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * Expose `request`. + */ + +module.exports = request; + +},{"emitter":1,"reduce":2}]},{},[3])(3) +}); \ No newline at end of file diff --git a/public/node_modules/superagent/test.js b/public/node_modules/superagent/test.js new file mode 100644 index 00000000..67637f08 --- /dev/null +++ b/public/node_modules/superagent/test.js @@ -0,0 +1,6 @@ + +var bla = require('.'); + +bla.get('http://localhost:8080/') + .then(function(){return 1;}) + .then(console.log.bind(console)); diff --git a/public/scripts/jim.js b/public/scripts/jim.js index a4d2d4d2..c9a33053 100644 --- a/public/scripts/jim.js +++ b/public/scripts/jim.js @@ -1,10 +1,55 @@ var CommentBox = React.createClass({ + loadCommentsFromServer: function() { + var request = window.superagent; + var response = request.get(this.props.url); + response.end(function(resp) { + console.log('Got response', resp.text); + }); + $.ajax({ + url: this.props.url, + dataType: 'json', + cache: false, + success: function(data) { + this.setState({data: data}); + }.bind(this), + error: function(xhr, status, err) { + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + handleCommentSubmit: function(comment) { + var comments = this.state.data; + comment.id = Date.now(); + var newComments = comments.concat([comment]); + this.setState({data: newComments}); + var myvar = 'hello'; + $.ajax({ + url: this.props.url, + dataType: 'json', + type: 'POST', + data: comment, + success: function(data) { + this.setState({data: data}); + }.bind(this), + error: function(xhr, status, err) { + this.setState({data: comments}); + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + getInitialState: function() { + return {data: []}; + }, + componentDidMount: function() { + this.loadCommentsFromServer(); + setInterval(this.loadCommentsFromServer, this.props.pollInterval); + }, render: function() { return (

      Comments

      - - + +
      ); } @@ -12,39 +57,85 @@ var CommentBox = React.createClass({ var CommentList = React.createClass({ render: function() { + var commentNodes = this.props.data.map(function(comment) { + return ( + + {comment.text} + + ); + }); return (
      - Meooowww - What?? + {commentNodes}
      ); } }); -var CommentForm = React.createClass({ +var Comment = React.createClass({ + rawMarkup: function() { + var rawMarkup = marked(this.props.children.toString(), {sanitize: true}); + return { __html: rawMarkup }; + }, render: function() { return ( -
      - Hello, world! I am a CommentForm. +
      +

      + {this.props.author} +

      +
      ); } }); -var Comment = React.createClass({ +var CommentForm = React.createClass({ + getInitialState: function() { + return {author: '', text: ''}; + }, + handleAuthorChange: function(e) { + this.setState({author: e.target.value}); + }, + handleTextChange: function(e) { + this.setState({text: e.target.value}); + }, + handleSubmit: function(e) { + e.preventDefault(); + var author = this.state.author.trim(); + var text = this.state.text.trim(); + if (!text || !author) { + return; + } + this.props.onCommentSubmit({author: author, text: text}); + this.setState({author: '', text: ''}); + }, render: function() { return ( -
      -

      - {this.props.author} -

      - {this.props.children} -
      +
      + + + + ); } }); +var data = [ + {id: 1, author: "Mr. Whiskers", text: "Meoooowww"}, + {id: 2, author: "Mrs. Whiskers", text: "What? _Speak English_, you silly cat!"} +]; + ReactDOM.render( - , + , document.getElementById('content') - ); \ No newline at end of file + );