traceur-rb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +2 -0
- data/lib/js/compile.js +31 -0
- data/lib/traceur-rb.rb +1 -0
- data/lib/traceur.rb +43 -0
- data/lib/traceur/compilation_options.rb +65 -0
- data/lib/traceur/compiler.rb +33 -0
- data/lib/traceur/configuration.rb +47 -0
- data/lib/traceur/node.rb +26 -0
- data/lib/traceur/node/command_result.rb +28 -0
- data/lib/traceur/node/runner.rb +40 -0
- data/lib/traceur/version.rb +3 -0
- data/spec/examples/classes.js +12 -0
- data/spec/integration/examples_spec.rb +28 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/traceur/compilation_options_spec.rb +31 -0
- data/spec/traceur/configuration_spec.rb +54 -0
- data/spec/traceur/node_spec.rb +15 -0
- data/traceur-rb.gemspec +25 -0
- data/vendor/node_modules/.bin/traceur +3 -0
- data/vendor/node_modules/traceur/README.md +40 -0
- data/vendor/node_modules/traceur/bin/traceur-runtime.js +2101 -0
- data/vendor/node_modules/traceur/bin/traceur.js +23034 -0
- data/vendor/node_modules/traceur/node_modules/.bin/semver +125 -0
- data/vendor/node_modules/traceur/node_modules/commander/Readme.md +208 -0
- data/vendor/node_modules/traceur/node_modules/commander/index.js +852 -0
- data/vendor/node_modules/traceur/node_modules/commander/package.json +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/.travis.yml +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +122 -0
- data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/README.md +928 -0
- data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +59 -0
- data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +44 -0
- data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +51 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +307 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +499 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +547 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +105 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs.js +355 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +65 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +152 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +24 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +93 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +154 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +178 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +417 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +58 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +78 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +120 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +27 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +209 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +125 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +175 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +75 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http.js +378 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +11 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.travis.yml +4 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +78 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +21 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +1285 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +22 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +142 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +57 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +183 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +261 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +186 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +55 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +59 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +236 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +371 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +435 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +247 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +147 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +448 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +139 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +79 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +142 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +60 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +41 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +12 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +7 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +48 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +590 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +49 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +173 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +274 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +59 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +538 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +14 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +6 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +49 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +51 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +269 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +61 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +736 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +66 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +114 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +35 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +84 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +1588 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +77 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +15 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +96 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +166 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +43 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +813 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +71 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +36 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +93 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +1937 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +35 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +6 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +36 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +7 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +38 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +32 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +39 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +2 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +123 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +128 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +53 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +61 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +856 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +1080 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +377 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +290 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +4 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +16 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +12 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +91 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +12 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +13 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +14 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +146 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +22 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +6 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +248 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +53 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +2 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +91 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +548 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +8 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +358 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +133 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.travis.yml +4 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +20 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +33 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +37 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +125 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +151 -0
- data/vendor/node_modules/traceur/node_modules/q-io/package.json +51 -0
- data/vendor/node_modules/traceur/node_modules/q-io/reader.js +133 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +47 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +11 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +33 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +92 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +41 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +57 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +70 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +109 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +67 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +219 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +20 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +26 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +37 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +39 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +32 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +26 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +86 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +31 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +73 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +23 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +22 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +25 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +45 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +38 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +52 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +86 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +49 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +47 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +186 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +82 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +110 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +96 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +96 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +42 -0
- data/vendor/node_modules/traceur/node_modules/q-io/writer.js +111 -0
- data/vendor/node_modules/traceur/node_modules/semver/.npmignore +1 -0
- data/vendor/node_modules/traceur/node_modules/semver/LICENSE +27 -0
- data/vendor/node_modules/traceur/node_modules/semver/Makefile +24 -0
- data/vendor/node_modules/traceur/node_modules/semver/README.md +158 -0
- data/vendor/node_modules/traceur/node_modules/semver/bin/semver +125 -0
- data/vendor/node_modules/traceur/node_modules/semver/foot.js +6 -0
- data/vendor/node_modules/traceur/node_modules/semver/head.js +2 -0
- data/vendor/node_modules/traceur/node_modules/semver/package.json +31 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +1039 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.js +1043 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/amd.js +15 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/gtr.js +173 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/index.js +584 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +174 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/no-module.js +19 -0
- data/vendor/node_modules/traceur/package.json +64 -0
- data/vendor/node_modules/traceur/src/node/System.js +31 -0
- data/vendor/node_modules/traceur/src/node/api.js +124 -0
- data/vendor/node_modules/traceur/src/node/command.js +141 -0
- data/vendor/node_modules/traceur/src/node/compile-single-file.js +69 -0
- data/vendor/node_modules/traceur/src/node/compiler.js +116 -0
- data/vendor/node_modules/traceur/src/node/deferred.js +110 -0
- data/vendor/node_modules/traceur/src/node/file-util.js +73 -0
- data/vendor/node_modules/traceur/src/node/getopt.js +147 -0
- data/vendor/node_modules/traceur/src/node/inline-module.js +149 -0
- data/vendor/node_modules/traceur/src/node/interpreter.js +33 -0
- data/vendor/node_modules/traceur/src/node/nodeLoader.js +41 -0
- data/vendor/node_modules/traceur/src/node/require.js +85 -0
- data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +33 -0
- data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +33 -0
- data/vendor/node_modules/traceur/src/node/traceur.js +32 -0
- data/vendor/node_modules/traceur/traceur +3 -0
- metadata +359 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "commander",
|
3
|
+
"version": "2.2.0",
|
4
|
+
"description": "the complete solution for node.js command-line programs",
|
5
|
+
"keywords": [
|
6
|
+
"command",
|
7
|
+
"option",
|
8
|
+
"parser",
|
9
|
+
"prompt",
|
10
|
+
"stdin"
|
11
|
+
],
|
12
|
+
"author": {
|
13
|
+
"name": "TJ Holowaychuk",
|
14
|
+
"email": "tj@vision-media.ca"
|
15
|
+
},
|
16
|
+
"repository": {
|
17
|
+
"type": "git",
|
18
|
+
"url": "https://github.com/visionmedia/commander.js.git"
|
19
|
+
},
|
20
|
+
"devDependencies": {
|
21
|
+
"should": ">= 0.0.1"
|
22
|
+
},
|
23
|
+
"scripts": {
|
24
|
+
"test": "make test"
|
25
|
+
},
|
26
|
+
"main": "index",
|
27
|
+
"engines": {
|
28
|
+
"node": ">= 0.6.x"
|
29
|
+
},
|
30
|
+
"files": [
|
31
|
+
"index.js"
|
32
|
+
],
|
33
|
+
"readme": "# Commander.js\n\n The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/visionmedia/commander).\n\n [![Build Status](https://secure.travis-ci.org/visionmedia/commander.js.png)](http://travis-ci.org/visionmedia/commander.js)\n\n## Installation\n\n $ npm install commander\n\n## Option parsing\n\n Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('commander');\n\nprogram\n .version('0.0.1')\n .option('-p, --peppers', 'Add peppers')\n .option('-P, --pineapple', 'Add pineapple')\n .option('-b, --bbq', 'Add bbq sauce')\n .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')\n .parse(process.argv);\n\nconsole.log('you ordered a pizza with:');\nif (program.peppers) console.log(' - peppers');\nif (program.pineapple) console.log(' - pineapple');\nif (program.bbq) console.log(' - bbq');\nconsole.log(' - %s cheese', program.cheese);\n```\n\n Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as \"--template-engine\" are camel-cased, becoming `program.templateEngine` etc.\n\n## Automated --help\n\n The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:\n\n``` \n $ ./examples/pizza --help\n\n Usage: pizza [options]\n\n Options:\n\n -V, --version output the version number\n -p, --peppers Add peppers\n -P, --pineapple Add pineapple\n -b, --bbq Add bbq sauce\n -c, --cheese <type> Add the specified type of cheese [marble]\n -h, --help output usage information\n\n```\n\n## Coercion\n\n```js\nfunction range(val) {\n return val.split('..').map(Number);\n}\n\nfunction list(val) {\n return val.split(',');\n}\n\nfunction collect(val, memo) {\n memo.push(val);\n return memo;\n}\n\nfunction increaseVerbosity(v, total) {\n return total + 1;\n}\n\nprogram\n .version('0.0.1')\n .usage('[options] <file ...>')\n .option('-i, --integer <n>', 'An integer argument', parseInt)\n .option('-f, --float <n>', 'A float argument', parseFloat)\n .option('-r, --range <a>..<b>', 'A range', range)\n .option('-l, --list <items>', 'A list', list)\n .option('-o, --optional [value]', 'An optional value')\n .option('-c, --collect [value]', 'A repeatable value', [])\n .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)\n .parse(process.argv);\n\nconsole.log(' int: %j', program.integer);\nconsole.log(' float: %j', program.float);\nconsole.log(' optional: %j', program.optional);\nprogram.range = program.range || [];\nconsole.log(' range: %j..%j', program.range[0], program.range[1]);\nconsole.log(' list: %j', program.list);\nconsole.log(' collect: %j', program.collect);\nconsole.log(' verbosity: %j', program.verbose);\nconsole.log(' args: %j', program.args);\n```\n\n## Custom help\n\n You can display arbitrary `-h, --help` information\n by listening for \"--help\". Commander will automatically\n exit once you are done so that the remainder of your program\n does not execute causing undesired behaviours, for example\n in the following executable \"stuff\" will not output when\n `--help` is used.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('../');\n\nfunction list(val) {\n return val.split(',').map(Number);\n}\n\nprogram\n .version('0.0.1')\n .option('-f, --foo', 'enable some foo')\n .option('-b, --bar', 'enable some bar')\n .option('-B, --baz', 'enable some baz');\n\n// must be before .parse() since\n// node's emit() is immediate\n\nprogram.on('--help', function(){\n console.log(' Examples:');\n console.log('');\n console.log(' $ custom-help --help');\n console.log(' $ custom-help -h');\n console.log('');\n});\n\nprogram.parse(process.argv);\n\nconsole.log('stuff');\n```\n\nyielding the following help output:\n\n```\n\nUsage: custom-help [options]\n\nOptions:\n\n -h, --help output usage information\n -V, --version output the version number\n -f, --foo enable some foo\n -b, --bar enable some bar\n -B, --baz enable some baz\n\nExamples:\n\n $ custom-help --help\n $ custom-help -h\n\n```\n\n## .outputHelp()\n\n Output help information without exiting.\n\n## .help()\n\n Output help information and exit immediately.\n\n## Links\n\n - [API documentation](http://visionmedia.github.com/commander.js/)\n - [ascii tables](https://github.com/LearnBoost/cli-table)\n - [progress bars](https://github.com/visionmedia/node-progress)\n - [more progress bars](https://github.com/substack/node-multimeter)\n - [examples](https://github.com/visionmedia/commander.js/tree/master/examples)\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
|
34
|
+
"readmeFilename": "Readme.md",
|
35
|
+
"bugs": {
|
36
|
+
"url": "https://github.com/visionmedia/commander.js/issues"
|
37
|
+
},
|
38
|
+
"_id": "commander@2.2.0",
|
39
|
+
"_from": "commander@>=1.1"
|
40
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
.tmp
|
@@ -0,0 +1,122 @@
|
|
1
|
+
<!-- vim:ts=4:sts=4:sw=4:et:tw=60 -->
|
2
|
+
|
3
|
+
## 1.10.9
|
4
|
+
|
5
|
+
- Fixes bug where the mock file system would not truncate before writing to an
|
6
|
+
existing file. #81
|
7
|
+
|
8
|
+
## 1.10.7-8
|
9
|
+
|
10
|
+
- Fixes support for range content requests, such that Q-IO based web serves can
|
11
|
+
host static audio and video content to the web. Further work needed for the
|
12
|
+
more escoteric non-contiguous multi-range requests.
|
13
|
+
- Allow `copyTree` to write over existing trees. (@nerfin)
|
14
|
+
|
15
|
+
## 1.10.6
|
16
|
+
|
17
|
+
- Restores the "request.terms.host" property to report which host pattern was
|
18
|
+
selected by a host negotiator.
|
19
|
+
|
20
|
+
## 1.10.5
|
21
|
+
|
22
|
+
- Fixes support for host negotiation.
|
23
|
+
|
24
|
+
## 1.10.4
|
25
|
+
|
26
|
+
- Fixes the `followInsecureSymbolicLinks` flag on the file tree HTTP
|
27
|
+
app. (@francoisfrisch)
|
28
|
+
- Fixes an error that gets missed when an HTTP request body is not
|
29
|
+
a proper forEachable. (@OliverJAsh)
|
30
|
+
|
31
|
+
## 1.10.3
|
32
|
+
|
33
|
+
- Fix support of Node 0.6 path separators (@Sevinf)
|
34
|
+
|
35
|
+
## 1.10.2
|
36
|
+
|
37
|
+
- Fix remoteTree for directories containing symbolic links.
|
38
|
+
- Tolerate "." in makeTree
|
39
|
+
- Stream writers now return reliable promises for finishing and flushing.
|
40
|
+
|
41
|
+
## 1.10.0
|
42
|
+
|
43
|
+
- Add support for HTTP agents (@yuxhuang)
|
44
|
+
|
45
|
+
## 1.9.4
|
46
|
+
|
47
|
+
- Updated dependencies
|
48
|
+
|
49
|
+
## 1.9.3
|
50
|
+
|
51
|
+
- Fixes a regression in supporting `FS.read(path, "b")`.
|
52
|
+
|
53
|
+
## 1.9.2
|
54
|
+
|
55
|
+
- Fixes `append` and aligns open flags with the underlying Node, except for
|
56
|
+
the default of UTF-8 if bytewise is not specified in the mode flag.
|
57
|
+
- Add `node` property to `Reader`, as advertised.
|
58
|
+
- Bug fixes
|
59
|
+
|
60
|
+
## 1.9.1
|
61
|
+
|
62
|
+
- Brings the mock file system API up to date with file system as of 1.9.0.
|
63
|
+
|
64
|
+
## 1.9.0
|
65
|
+
|
66
|
+
- Distinguishes `move` and `rename`. `move` will work across file system
|
67
|
+
boundaries.
|
68
|
+
|
69
|
+
## 1.8.0
|
70
|
+
|
71
|
+
- Allows `move` to overwrite the target, or overwrite a target directory if
|
72
|
+
empty.
|
73
|
+
|
74
|
+
## 1.7.2
|
75
|
+
|
76
|
+
- Fixes JSON content HTTP responses.
|
77
|
+
|
78
|
+
## 1.7.1
|
79
|
+
|
80
|
+
- Fixes a bug in the HTTP redirect trap.
|
81
|
+
|
82
|
+
## 1.7.0
|
83
|
+
|
84
|
+
- Added FileTree option followInsecureSymbolicLinks (@francoisfrisch)
|
85
|
+
|
86
|
+
## 0.0.12
|
87
|
+
|
88
|
+
- Addressed Node 0.7.* compatibility. (@strager)
|
89
|
+
- Synchronized Q to 0.8.2.
|
90
|
+
|
91
|
+
## 0.0.11
|
92
|
+
|
93
|
+
- Synchronized Q dependency.
|
94
|
+
|
95
|
+
## 0.0.10
|
96
|
+
|
97
|
+
- Removed spurious log message.
|
98
|
+
|
99
|
+
## 0.0.9
|
100
|
+
|
101
|
+
- Fixed a bug in observing the closing of files. (#1, @hornairs)
|
102
|
+
|
103
|
+
## 0.0.8
|
104
|
+
|
105
|
+
- Reorganized, moved q-io to the top level.
|
106
|
+
- Reved dependencies.
|
107
|
+
- Moved q-io-buffer to its own project.
|
108
|
+
|
109
|
+
## 0.0.3
|
110
|
+
|
111
|
+
- reved up Q to version 0.2 so duck-promises will work
|
112
|
+
|
113
|
+
## 0.0.2
|
114
|
+
|
115
|
+
- added buffer-io
|
116
|
+
- added buffer mode to readers and writers
|
117
|
+
|
118
|
+
## 0.0.1
|
119
|
+
|
120
|
+
- fixed dependency on broken q package
|
121
|
+
- restructured for overlay style packaging compatibility
|
122
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
Copyright 2009-2013 Kristopher Michael Kowal. All rights reserved.
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
19
|
+
IN THE SOFTWARE.
|
@@ -0,0 +1,928 @@
|
|
1
|
+
|
2
|
+
[![Build Status](https://secure.travis-ci.org/kriskowal/q-io.png)](http://travis-ci.org/kriskowal/q-io)
|
3
|
+
|
4
|
+
# Q-IO
|
5
|
+
|
6
|
+
Interfaces for IO that make use of promises.
|
7
|
+
|
8
|
+
Q-IO now subsumes all of [Q-HTTP][] and [Q-FS][].
|
9
|
+
|
10
|
+
[Q-HTTP]: https://github.com/kriskowal/q-http
|
11
|
+
[Q-FS]: https://github.com/kriskowal/q-fs
|
12
|
+
|
13
|
+
The Q-IO package does not export a main module. You must reach in
|
14
|
+
directly for `q-io/fs`, `q-io/http`, and `q-io/http-apps`.
|
15
|
+
|
16
|
+
## Filesystem
|
17
|
+
|
18
|
+
```javascript
|
19
|
+
var FS = require("q-io/fs");
|
20
|
+
```
|
21
|
+
|
22
|
+
File system API for Q promises with method signatures patterned after
|
23
|
+
[CommonJS/Fileystem/A](http://wiki.commonjs.org/wiki/Filesystem/A) but
|
24
|
+
returning promises and promise streams.
|
25
|
+
|
26
|
+
### open(path, options)
|
27
|
+
|
28
|
+
Open returns a promise for either a buffer or string Reader or a Writer
|
29
|
+
depending on the flags.
|
30
|
+
|
31
|
+
The options can be omitted, abbreviated to a `flags` string, or expanded
|
32
|
+
to an `options` object.
|
33
|
+
|
34
|
+
- ``flags``: ``r``, ``w``, ``a``, ``b``, default of `r`, not bytewise
|
35
|
+
- ``charset``: default of ``utf-8``
|
36
|
+
- ``bufferSize``: in bytes
|
37
|
+
- ``mode``: UNIX permissions
|
38
|
+
- ``begin`` first byte to read (defaults to zero)
|
39
|
+
- ``end`` one past the last byte to read. ``end - begin == length``
|
40
|
+
|
41
|
+
### read(path, options)
|
42
|
+
|
43
|
+
`read` is a shortcut for opening a file and reading the entire contents
|
44
|
+
into memory. It returns a promise for the whole file contents. By
|
45
|
+
default, `read` provides a string decoded from UTF-8. With the bytewise
|
46
|
+
mode flag, provides a `Buffer`.
|
47
|
+
|
48
|
+
The options argument is identical to that of `open`.
|
49
|
+
|
50
|
+
```javascript
|
51
|
+
return FS.read(__filename, "b")
|
52
|
+
.then(function (content) {
|
53
|
+
// ...
|
54
|
+
})
|
55
|
+
```
|
56
|
+
|
57
|
+
```javascript
|
58
|
+
return FS.read(__filename, {
|
59
|
+
flags: "b"
|
60
|
+
})
|
61
|
+
```
|
62
|
+
|
63
|
+
### write(path, content, options)
|
64
|
+
|
65
|
+
`write` is a shortcut for opening a file and writing its entire content
|
66
|
+
from a single string or buffer.
|
67
|
+
|
68
|
+
The options are identical to that of `open`, but the "w" flag is
|
69
|
+
implied, and the "b" flag is implied if the content is a buffer.
|
70
|
+
|
71
|
+
```javascript
|
72
|
+
return FS.write("hello.txt", "Hello, World!\n")
|
73
|
+
.then(function () {
|
74
|
+
return FS.read("hello.txt")
|
75
|
+
})
|
76
|
+
.then(function (hello) {
|
77
|
+
expect(hello).toBe("Hello, World!\n")
|
78
|
+
})
|
79
|
+
```
|
80
|
+
|
81
|
+
### append(path, content, options)
|
82
|
+
|
83
|
+
`append` is a shorthand for opening a file for writing from the end of
|
84
|
+
the existing content from a single string or buffer.
|
85
|
+
|
86
|
+
The options are identical to that of `open`, but the "w+" flags are
|
87
|
+
implied, and the "b" flag is implied if the content is a buffer.
|
88
|
+
|
89
|
+
### copy(source, target)
|
90
|
+
|
91
|
+
Copies a single file from one path to another. The target must be the
|
92
|
+
full path, including the file name. Unlike at the shell, the file name
|
93
|
+
is not inferred from the source path if the target turns out to be a
|
94
|
+
directory.
|
95
|
+
|
96
|
+
Returns a promise for the completion of the operation.
|
97
|
+
|
98
|
+
### copyTree(source, target)
|
99
|
+
|
100
|
+
Copies a file or tree of files from one path to another. Symbolic links
|
101
|
+
are copied but not followed.
|
102
|
+
|
103
|
+
Returns a promise for the completion of the operation.
|
104
|
+
|
105
|
+
### list(path)
|
106
|
+
|
107
|
+
Returns a promise for a list of file names in a directory. The file
|
108
|
+
names are relative to the given path.
|
109
|
+
|
110
|
+
### listTree(path, guard(path, stat))
|
111
|
+
|
112
|
+
Returns a promise for a list of files in a directory and all the
|
113
|
+
directories it contains. Does not follow symbolic links.
|
114
|
+
|
115
|
+
The second argument is an optional guard function that determines what
|
116
|
+
files to include and whether to traverse into another directory. It
|
117
|
+
receives the path of the file, relative to the starting path, and also
|
118
|
+
the stats object for that file. The guard must return a value like:
|
119
|
+
|
120
|
+
- `true` indicates that the entry should be included
|
121
|
+
- `false` indicates that the file should be excluded, but should still
|
122
|
+
be traversed if it is a directory.
|
123
|
+
- `null` indiciates that a directory should not be traversed.
|
124
|
+
|
125
|
+
### listDirectoryTree(path)
|
126
|
+
|
127
|
+
Returns a promise for a deep list of directories.
|
128
|
+
|
129
|
+
### makeDirectory(path, mode)
|
130
|
+
|
131
|
+
Makes a directory at a given path. Fails if the parent directory does
|
132
|
+
not exist. Returns a promise for the completion of the operation.
|
133
|
+
|
134
|
+
The mode is an optional Unix mode as an integer or string of octal
|
135
|
+
digits.
|
136
|
+
|
137
|
+
### makeTree(path, mode)
|
138
|
+
|
139
|
+
Finishes a path of directories. For any branch of the path that does
|
140
|
+
not exist, creates a directory. Fails if any branch of the path already
|
141
|
+
exists but is not a directory.
|
142
|
+
|
143
|
+
Makes any directories with the given Unix mode.
|
144
|
+
|
145
|
+
### remove(path)
|
146
|
+
|
147
|
+
Removes a file at the given path. Fails if a directory exists at the
|
148
|
+
given path or if no file exists at the path.
|
149
|
+
|
150
|
+
### removeTree(path)
|
151
|
+
|
152
|
+
Removes a file or directory at a given path, recursively removing any
|
153
|
+
contained files and directories, without following symbolic links.
|
154
|
+
|
155
|
+
### rename(source, target)
|
156
|
+
|
157
|
+
Moves a file or directory from one path to another using the underlying
|
158
|
+
`rename(2)` implementation, thus it cannot move a file across devices.
|
159
|
+
|
160
|
+
### move(source, target)
|
161
|
+
|
162
|
+
Moves a file or directory from one path to another. If the source and
|
163
|
+
target are on different devices, falls back to copying and removing,
|
164
|
+
using `copyTree(source, target)` and, if completely successful,
|
165
|
+
`removeTree(source)`.
|
166
|
+
|
167
|
+
### link(source, taget)
|
168
|
+
|
169
|
+
Creates a hard link from the source
|
170
|
+
|
171
|
+
### symbolicCopy(source, target, type)
|
172
|
+
|
173
|
+
Creates a relative symoblic link from the target to the source with an
|
174
|
+
effect that resembles copying a file.
|
175
|
+
|
176
|
+
The type is important for Windows. It is "file" by default, but may be
|
177
|
+
"directory" or "junction".
|
178
|
+
|
179
|
+
### symbolicLink(target, link, type)
|
180
|
+
|
181
|
+
Creates a symbolic link at the target path. The link may be absolute or
|
182
|
+
relative. The type *must* be "file", "directory", or "junction" and is
|
183
|
+
mandatory to encourage Windows portability.
|
184
|
+
|
185
|
+
### chown(path, uid, gid)
|
186
|
+
|
187
|
+
Changes the owner for a path using Unix user-id and group-id numbers.
|
188
|
+
|
189
|
+
### chmod(path, mode)
|
190
|
+
|
191
|
+
Changes the Unix mode for a path. Returns a promise.
|
192
|
+
|
193
|
+
### stat(path)
|
194
|
+
|
195
|
+
Follows all symoblic links along a path and returns a promise for the
|
196
|
+
metadata about a path as a `Stats` object. The Stats object implements:
|
197
|
+
|
198
|
+
- `size` the size of the file in bytes
|
199
|
+
- `isDirectory()`: returns whether the path refers to a directory with
|
200
|
+
entries for other paths.
|
201
|
+
- `isFile()`: returns whether the path refers to a file physically
|
202
|
+
stored by the file system.
|
203
|
+
- `isBlockDevice()`: returns whether the path refers to a Unix device
|
204
|
+
driver, in which case there is no actual data in storage but the
|
205
|
+
operating system may allow you to communicate with the driver as a
|
206
|
+
blocks of memory.
|
207
|
+
- `isCharacterDevice()`: returns whether the path refers to a Unix
|
208
|
+
device driver, in which case there is no actual data in storage but
|
209
|
+
the operating system may allow you to communicate with the driver as
|
210
|
+
a stream.
|
211
|
+
- `isSymbolicLink()`: returns whether the path refers to a symbolic
|
212
|
+
link or junction. Stats for symbolic links are only discoverable
|
213
|
+
through `statLink` since `stat` follows symbolic links.
|
214
|
+
- `isFIFO()`: returns whether the path refers to a Unix named pipe.
|
215
|
+
- `isSocket()`: returns whether the path refers to a Unix domain
|
216
|
+
socket.
|
217
|
+
- `lastModified()`: returns the last time the path was opened for
|
218
|
+
writing as a `Date`
|
219
|
+
- `lastAccessed()`: returns the last time the path was opened for
|
220
|
+
reading or writing as a `Date`
|
221
|
+
|
222
|
+
### statLink(path)
|
223
|
+
|
224
|
+
Returns a promise for the `Stats` for a path without following symbolic
|
225
|
+
links.
|
226
|
+
|
227
|
+
### statFd(fd)
|
228
|
+
|
229
|
+
Returns a promise for the `Stats` for a Unix file descriptor number.
|
230
|
+
|
231
|
+
### exists(path)
|
232
|
+
|
233
|
+
Follows symoblic links and returns a promise for whether an entry exists
|
234
|
+
at a given path.
|
235
|
+
|
236
|
+
### isFile(path)
|
237
|
+
|
238
|
+
Follows symbolic links and returns a promise for whether a file exists
|
239
|
+
at a given path and does not cause an exception if nothing exists at
|
240
|
+
that path.
|
241
|
+
|
242
|
+
### isDirectory(path)
|
243
|
+
|
244
|
+
Follows symbolic links and returns a promise for whether a directory
|
245
|
+
exists at a given path and does not cause an exception if nothing exists
|
246
|
+
at that path.
|
247
|
+
|
248
|
+
### isSymbolicLink(path)
|
249
|
+
|
250
|
+
Returns a promise for whether a symbolic link exists at a given path and
|
251
|
+
does not cause an exception if nothing exists at that path.
|
252
|
+
|
253
|
+
### lastModified(path)
|
254
|
+
|
255
|
+
Follows symbolic links and returns a promise for the `Date` when the
|
256
|
+
entry at the given path was last opened for writing, but causes an
|
257
|
+
exception if no file exists at that path.
|
258
|
+
|
259
|
+
### lastAccessed(path)
|
260
|
+
|
261
|
+
Follows symbolic links and returns a promise for the `Date` when the
|
262
|
+
entry at the given path was last opened for reading or writing, but
|
263
|
+
causes an exception if no file exists at that path.
|
264
|
+
|
265
|
+
### split(path)
|
266
|
+
|
267
|
+
Splits a path into the names of entries along the path. If the path is
|
268
|
+
absolute, the first component is either a drive (with a colon) on
|
269
|
+
Windows or an empty string for the root of a Unix file system.
|
270
|
+
|
271
|
+
### join(paths) or join(...paths)
|
272
|
+
|
273
|
+
Joins a sequence of paths into a single normalized path. All but the
|
274
|
+
last path are assumed to refer to directories.
|
275
|
+
|
276
|
+
### resolve(...paths)
|
277
|
+
|
278
|
+
Like join but treats each path like a relative URL, so a terminating
|
279
|
+
slash indicates that a path is to a directory and the next path begins
|
280
|
+
at that directory.
|
281
|
+
|
282
|
+
### normal(...paths)
|
283
|
+
|
284
|
+
Takes a single path or sequence of paths and joins them into a single
|
285
|
+
path, eliminating self `.` and parent `..` entries when possible.
|
286
|
+
|
287
|
+
### absolute(path)
|
288
|
+
|
289
|
+
Joins and normalizes a path from the current working directory,
|
290
|
+
returning a string.
|
291
|
+
|
292
|
+
### canonical(path)
|
293
|
+
|
294
|
+
Returns a promise for the absolute, canonical location of a given path,
|
295
|
+
following symbolic links and normalizing path components. An entry does
|
296
|
+
not need to exist at the end of the path.
|
297
|
+
|
298
|
+
### readLink(path)
|
299
|
+
|
300
|
+
Returns a promise for the path string of a symbolic link at a given
|
301
|
+
path.
|
302
|
+
|
303
|
+
### contains(parent, child)
|
304
|
+
|
305
|
+
For any two absolute or relative paths, computes whether the parent path
|
306
|
+
is an ancestor of the child path.
|
307
|
+
|
308
|
+
### relative(source, target)
|
309
|
+
|
310
|
+
Returns a promise for the relative path from one path to another using
|
311
|
+
`..` parent links where necessary. This operation is asynchronous
|
312
|
+
because it is necessary to determine whether the source path refers to a
|
313
|
+
directory or a file.
|
314
|
+
|
315
|
+
### relativeFromFile(source, target)
|
316
|
+
|
317
|
+
Assuming that the source path refers to a file, returns a string for the
|
318
|
+
relative path from the source to the target path.
|
319
|
+
|
320
|
+
### relativeFromDirectory(source, target)
|
321
|
+
|
322
|
+
Assuming that the source path refers to a directory, returns a string
|
323
|
+
for the relative path from the source to the target path.
|
324
|
+
|
325
|
+
### isAbsolute(path)
|
326
|
+
|
327
|
+
Returns whether a path begins at the root of a Unix file system or a
|
328
|
+
Windows drive.
|
329
|
+
|
330
|
+
### isRelative(path)
|
331
|
+
|
332
|
+
Returns whether a path does not begin at the root of a Unix file system
|
333
|
+
or Windows drive.
|
334
|
+
|
335
|
+
### isRoot(path)
|
336
|
+
|
337
|
+
Returns whether a path is to the root of a Unix file system or a Windows
|
338
|
+
drive.
|
339
|
+
|
340
|
+
### root(path)
|
341
|
+
|
342
|
+
Returns the Windows drive that contains a given path, or the root of a
|
343
|
+
Unix file system.
|
344
|
+
|
345
|
+
### directory(path)
|
346
|
+
|
347
|
+
Returns the path to the directory containing the given path.
|
348
|
+
|
349
|
+
### base(path, extension)
|
350
|
+
|
351
|
+
Returns the last entry of a path. If an extension is provided and
|
352
|
+
matches the extension of the path, removes that extension.
|
353
|
+
|
354
|
+
### extension(path)
|
355
|
+
|
356
|
+
Returns the extension for a path (everything following the last dot `.`
|
357
|
+
in a path, unless that dot is at the beginning of the entry).
|
358
|
+
|
359
|
+
### reroot(path)
|
360
|
+
|
361
|
+
Returns an attenuated file system that uses the given path as its root.
|
362
|
+
The resulting file system object is identical to the parent except that
|
363
|
+
the child cannot open any file that is not within the root. Hard links
|
364
|
+
are effectively inside the root regardless, but symbolic links cannot be
|
365
|
+
followed outside of the jail.
|
366
|
+
|
367
|
+
### toObject(path)
|
368
|
+
|
369
|
+
Reads every file in the file system under a given path and returns a
|
370
|
+
promise for an object that contains the absolute path and a Buffer for
|
371
|
+
each of those files.
|
372
|
+
|
373
|
+
### glob(pattern)
|
374
|
+
|
375
|
+
Not yet implemented
|
376
|
+
|
377
|
+
### match(pattern, path)
|
378
|
+
|
379
|
+
Not yet implemented
|
380
|
+
|
381
|
+
## Mock Filesystem
|
382
|
+
|
383
|
+
Q-IO provides a mock filesystem interface. The mock filesystem has the
|
384
|
+
same interface as the real one and has most of the same features, but
|
385
|
+
operates on a purely in-memory, in-process, in-javascript filesystem.
|
386
|
+
|
387
|
+
A mock filesystem can be created from a data structure. Objects are
|
388
|
+
directories. Keys are paths. A buffer is a file’s contents. Anything
|
389
|
+
else is coerced to a string, then to a buffer in the UTF-8 encoding.
|
390
|
+
|
391
|
+
```javascript
|
392
|
+
var MockFs = require("q-io/fs-mock");
|
393
|
+
var mockFs = MockFs({
|
394
|
+
"a": {
|
395
|
+
"b": {
|
396
|
+
"c.txt": "Content of a/b/c.txt"
|
397
|
+
}
|
398
|
+
},
|
399
|
+
"a/b/d.txt": new Buffer("Content of a/b/d.txt", "utf-8")
|
400
|
+
})
|
401
|
+
```
|
402
|
+
|
403
|
+
You can also instantiate a mock file system with the content of a
|
404
|
+
subtree of a real file system. You receive a promise for the mock
|
405
|
+
filesystem.
|
406
|
+
|
407
|
+
```javascript
|
408
|
+
var FS = require("q-io/fs");
|
409
|
+
FS.mock(__dirname)
|
410
|
+
.then(function (fs) {
|
411
|
+
//
|
412
|
+
})
|
413
|
+
.done();
|
414
|
+
```
|
415
|
+
|
416
|
+
## HTTP
|
417
|
+
|
418
|
+
The HTTP module resembles [CommonJS/JSGI][].
|
419
|
+
|
420
|
+
```javascript
|
421
|
+
var HTTP = require("q-io/http");
|
422
|
+
```
|
423
|
+
|
424
|
+
[CommonJS/JSGI]: http://wiki.commonjs.org/wiki/JSGI
|
425
|
+
|
426
|
+
### Server(app)
|
427
|
+
|
428
|
+
The `http` module exports a `Server` constructor.
|
429
|
+
|
430
|
+
- accepts an application, returns a server.
|
431
|
+
- calls the application function when requests are received.
|
432
|
+
- if the application returns a response object, sends that
|
433
|
+
response.
|
434
|
+
- ``listen(port)``
|
435
|
+
- accepts a port number.
|
436
|
+
- returns a promise for undefined when the server has begun
|
437
|
+
listening.
|
438
|
+
- ``stop()``
|
439
|
+
- returns a promise for undefined when the server has stopped.
|
440
|
+
|
441
|
+
### request(request object or url)
|
442
|
+
|
443
|
+
The `http` module exports a `request` function that returns a promise
|
444
|
+
for a response.
|
445
|
+
|
446
|
+
- accepts a request or a URL string.
|
447
|
+
- returns a promise for a response.
|
448
|
+
|
449
|
+
### read(request object or url)
|
450
|
+
|
451
|
+
The `http` module exports a `read` function, analogous to
|
452
|
+
`Fs.read(path)`, but returning a promise for the contento of an OK HTTP
|
453
|
+
response.
|
454
|
+
|
455
|
+
- accepts a request or a URL string.
|
456
|
+
- returns a promise for the response body as a string provided
|
457
|
+
that the request is successful with a 200 status.
|
458
|
+
- rejects the promise with the response as the reason for
|
459
|
+
failure if the request fails.
|
460
|
+
|
461
|
+
### normalizeRequest(request object or url)
|
462
|
+
|
463
|
+
- coerces URLs into request objects.
|
464
|
+
- completes an incomplete request object based on its `url`.
|
465
|
+
|
466
|
+
### normalizeResponse(response)
|
467
|
+
|
468
|
+
- coerces strings, arrays, and other objects supporting
|
469
|
+
``forEach`` into proper response objects.
|
470
|
+
- if it receives `undefined`, it returns `undefined`. This is used as
|
471
|
+
a singal to the requester that the responder has taken control of
|
472
|
+
the response stream.
|
473
|
+
|
474
|
+
### request
|
475
|
+
|
476
|
+
A complete request object has the following properties.
|
477
|
+
|
478
|
+
- ``url`` the full URL of the request as a string
|
479
|
+
- ``path`` the full path as a string
|
480
|
+
- ``scriptName`` the routed portion of the path, like ``""`` for
|
481
|
+
``http://example.com/`` if no routing has occurred.
|
482
|
+
- ``pathInfo`` the part of the path that remains to be routed,
|
483
|
+
like ``/`` for ``http://example.com`` or ``http://example.com/``
|
484
|
+
if no routing has occurred.
|
485
|
+
- ``version`` the requested HTTP version as an array of strings.
|
486
|
+
- ``method`` like ``"GET"``
|
487
|
+
- ``scheme`` like ``"http:"``
|
488
|
+
- ``host`` like ``"example.com"``
|
489
|
+
- ``port`` the port number, like ``80``
|
490
|
+
- ``remoteHost``
|
491
|
+
- ``remotePort``
|
492
|
+
- ``headers``
|
493
|
+
corresponding values, possibly an array for multiple headers
|
494
|
+
of the same name.
|
495
|
+
- ``agent``
|
496
|
+
a custom node [HTTP](http://nodejs.org/api/http.html#http_class_http_agent)
|
497
|
+
or [HTTPS](http://nodejs.org/api/https.html#https_class_https_agent)
|
498
|
+
agent. HTTP and HTTPS agents can implement custom socket pools,
|
499
|
+
allow use of SSL client certificates and self-signed certificates.
|
500
|
+
- ``body``
|
501
|
+
- ``node`` the wrapped Node request object
|
502
|
+
|
503
|
+
### response
|
504
|
+
|
505
|
+
A complete response object has the following properties.
|
506
|
+
|
507
|
+
- ``status`` the HTTP status code as a number, like ``200``.
|
508
|
+
- ``headers``
|
509
|
+
- ``body`` an IO reader
|
510
|
+
- ``onclose`` is an optional function that this library will call
|
511
|
+
when a response concludes.
|
512
|
+
- ``node`` the wrapped Node response object.
|
513
|
+
|
514
|
+
### headers
|
515
|
+
|
516
|
+
Headers are an object mapping lower-case header-names to corresponding
|
517
|
+
values, possibly an array for multiple headers of the same name, for
|
518
|
+
both requests and responses.
|
519
|
+
|
520
|
+
### body
|
521
|
+
|
522
|
+
body is a representation of a readable stream, either for the content of
|
523
|
+
a request or a response. It is implemented as a Q-IO reader.
|
524
|
+
|
525
|
+
- ``forEach(callback)``
|
526
|
+
- accepts a ``callback(chunk)`` function
|
527
|
+
- accepts a chunk as either a string or a ``Buffer``
|
528
|
+
- returns undefined or a promise for undefined when the
|
529
|
+
chunk has been flushed.
|
530
|
+
- returns undefined or a promise for undefined when the stream
|
531
|
+
is finished writing.
|
532
|
+
- the ``forEach`` function for arrays of strings or buffers is
|
533
|
+
sufficient for user-provided bodies
|
534
|
+
- the ``forEach`` function is the only necessary function for
|
535
|
+
bodies provided to this library.
|
536
|
+
- in addition to ``forEach``, bodies provided by this library
|
537
|
+
support the entire readable stream interface provided by
|
538
|
+
``q-io``.
|
539
|
+
- ``read()``
|
540
|
+
- returns a promise for the entire body as a string or a
|
541
|
+
buffer.
|
542
|
+
|
543
|
+
### application
|
544
|
+
|
545
|
+
An HTTP application is a function that accepts a request and returns a
|
546
|
+
response. The `request` function itself is an application.
|
547
|
+
Applications can be chained and combined to make advanced servers and
|
548
|
+
clients.
|
549
|
+
|
550
|
+
- accepts a request
|
551
|
+
- returns a response, a promise for a response, or nothing if no
|
552
|
+
response should be sent.
|
553
|
+
|
554
|
+
|
555
|
+
## Streams
|
556
|
+
|
557
|
+
### Reader
|
558
|
+
|
559
|
+
Reader instances have the following methods:
|
560
|
+
|
561
|
+
- `read()`
|
562
|
+
- `forEach(callback)`
|
563
|
+
- `close()`
|
564
|
+
- `node` the underlying node reader
|
565
|
+
|
566
|
+
Additionally, the `Reader` constructor has the following methods:
|
567
|
+
|
568
|
+
- `read(stream, charset)` accepts any foreachable and returns either a
|
569
|
+
buffer or a string if given a charset.
|
570
|
+
- `join(buffers)` consolidates an array of buffers into a single
|
571
|
+
buffer. The buffers array is collapsed in place and the new first
|
572
|
+
and only buffer is returned.
|
573
|
+
|
574
|
+
The `reader` module exports a function that accepts a Node reader and
|
575
|
+
returns a Q reader.
|
576
|
+
|
577
|
+
### Writer
|
578
|
+
|
579
|
+
Writer instances have the following methods:
|
580
|
+
|
581
|
+
- `write(content)` writes a chunk of content, either from a string or
|
582
|
+
a buffer.
|
583
|
+
- `flush()` returns a promise to drain the outbound content all the
|
584
|
+
way to its destination.
|
585
|
+
- `close()`
|
586
|
+
- `destroy()`
|
587
|
+
- `node` the underlying node writer
|
588
|
+
|
589
|
+
The `writer` module exports a function that accepts a Node writer and
|
590
|
+
returns a Q writer.
|
591
|
+
|
592
|
+
### Buffer
|
593
|
+
|
594
|
+
```javascript
|
595
|
+
var BufferStream = require("q-io/buffer-stream");
|
596
|
+
var stream = BufferStream(new Buffer("Hello, World!\n", "utf-8"), "utf-8")
|
597
|
+
```
|
598
|
+
|
599
|
+
## HTTP Applications
|
600
|
+
|
601
|
+
The HTTP applications module provides a comprehensive set of JSGI-alike
|
602
|
+
applications and application factories, suitable for use with the `http`
|
603
|
+
server and client.
|
604
|
+
|
605
|
+
```javascript
|
606
|
+
var Apps = require("q-io/http-apps");
|
607
|
+
```
|
608
|
+
|
609
|
+
### ok(content, contentType, status) : Response
|
610
|
+
|
611
|
+
Creates an `HTTP 200 Ok` response with the given content, content type,
|
612
|
+
and status.
|
613
|
+
|
614
|
+
The content may be a string, buffer, array of strings, array of buffers,
|
615
|
+
a readable stream of strings or buffers, or (generally) anything that
|
616
|
+
implements `forEach`.
|
617
|
+
|
618
|
+
The default content type is `text/plain`.
|
619
|
+
|
620
|
+
The default status is `200`.
|
621
|
+
|
622
|
+
### badRequest(request) : Response
|
623
|
+
|
624
|
+
An application that returns an `HTTP 400 Bad request` response for any
|
625
|
+
request.
|
626
|
+
|
627
|
+
### notFound(request) : Response
|
628
|
+
|
629
|
+
An application that returns an `HTTP 404 Not found` response for any
|
630
|
+
request.
|
631
|
+
|
632
|
+
### methodNotAllowed(request) : Response
|
633
|
+
|
634
|
+
An application that returns an `HTTP 405 Method not allowed` response
|
635
|
+
for any request. This is suitable for any endpoint where there is no
|
636
|
+
viable handler for the request method.
|
637
|
+
|
638
|
+
### notAcceptable(request) : Response
|
639
|
+
|
640
|
+
An application that returns an `HTTP 406 Not acceptable` response for
|
641
|
+
any request. This is suitable for any situation where content
|
642
|
+
negotiation has failed, for example, if you cannot response with any of
|
643
|
+
the accepted encoding, charset, or language.
|
644
|
+
|
645
|
+
### redirect(request, location, status, tree) : Response
|
646
|
+
|
647
|
+
Not to be confused with an HTTP application, this is a utility that
|
648
|
+
generates redirect responses.
|
649
|
+
|
650
|
+
The returns response issues a redirect to the given location. The
|
651
|
+
utility fully qualifies the location.
|
652
|
+
|
653
|
+
This particular method should be used directly to generate an `HTTP 301
|
654
|
+
Temporary redirect` response, but passing `307` in the status argument
|
655
|
+
turns it into an `HTTP 307 Permanent redirect` response.
|
656
|
+
|
657
|
+
This particular method should be used to send all requests to a specific
|
658
|
+
location, but setting the `tree` argument to `true` causes the redirect
|
659
|
+
to follow the remaining unrouted path from the redirect location, so if
|
660
|
+
you move an entire directory tree from one location to another, this
|
661
|
+
redirect can forward to all of them.
|
662
|
+
|
663
|
+
### redirectTree(request, location) : Response
|
664
|
+
|
665
|
+
Produces an `HTTP 301 Temporary redirect` from one directory tree to
|
666
|
+
another, using `redirect`.
|
667
|
+
|
668
|
+
### permanentRedirect(request, location) : Response
|
669
|
+
|
670
|
+
Produces an `HTTP 307 Permanent redirect` to a given location, using
|
671
|
+
`redirect`.
|
672
|
+
|
673
|
+
### permanentRedirectTree(request, location) : Response
|
674
|
+
|
675
|
+
Produces an `HTTP 307 Permanent redirect` from one directory tree to
|
676
|
+
another, using `redirect`.
|
677
|
+
|
678
|
+
### file(request, path, contentType) : Response
|
679
|
+
|
680
|
+
Produces an HTTP response with the file at a given path. By default, it
|
681
|
+
infers the content type from the extension of the path.
|
682
|
+
|
683
|
+
The file utility produces an `e-tag` header suitable for cache control,
|
684
|
+
and may produce an `HTTP 304 Not modified` if the requested resource has
|
685
|
+
the same entity tag.
|
686
|
+
|
687
|
+
The file utility may produce an `HTTP 206 Partial content` response with
|
688
|
+
a `content-range` header if the request has a `range` header. If the
|
689
|
+
partial range request cannot be satisified, it may respond `HTTP 416 Not
|
690
|
+
satisfiable`.
|
691
|
+
|
692
|
+
In all cases, the response body is streamed from the file system.
|
693
|
+
|
694
|
+
### etag(stat)
|
695
|
+
|
696
|
+
Computes an entity tag for a file system `Stats` object, using the
|
697
|
+
`node.ino`, `size`, and last modification time.
|
698
|
+
|
699
|
+
### directory(request, path)
|
700
|
+
|
701
|
+
This is not yet implemented.
|
702
|
+
|
703
|
+
### json(object, visitor, tabs) : Response
|
704
|
+
|
705
|
+
Returns an `HTTP 200 Ok` response from some JSON, using the same
|
706
|
+
argumensts as `JSON.stringify`.
|
707
|
+
|
708
|
+
### Content(body, contentType, status) : Application
|
709
|
+
|
710
|
+
A factory that produces an HTTP application that will always respond
|
711
|
+
with the given content, content type, and status. The default content
|
712
|
+
type is `text/plain` and the default status is `200`.
|
713
|
+
|
714
|
+
The body may be a string, array of strings or buffers, or a readable
|
715
|
+
stream of strings or buffers.
|
716
|
+
|
717
|
+
### File(path, contentType) : Application
|
718
|
+
|
719
|
+
A factory that produces an HTTP application that will always respond
|
720
|
+
with the file at the given path. The content type is inferred from the
|
721
|
+
path extension by default, but can be overridden with `contentType`.
|
722
|
+
|
723
|
+
### FileTree(path, options) : Application
|
724
|
+
|
725
|
+
A factory that produces an HTTP application that responds to all
|
726
|
+
requests with files within a branch of the file system starting at the
|
727
|
+
given path and using any unprocessed portion of the request location.
|
728
|
+
|
729
|
+
Options include:
|
730
|
+
|
731
|
+
- `notFound(request, response)`: alternate 404 responder, defaults to
|
732
|
+
`HttpApps.notFound`
|
733
|
+
- `file(request, path, contentType, fs)`: alternate file responder,
|
734
|
+
defaults to `HttpApps.file`
|
735
|
+
- `contentType`: forces the content type of file requests, forwarded
|
736
|
+
to the `file` handler.
|
737
|
+
- `directory(request, path, contentType, fs)`: alternate directory
|
738
|
+
responder, defaults to `HttpApps.directory`.
|
739
|
+
- `redirectSymbolicLinks`: directs the client to use a redirect
|
740
|
+
response for symbolic links instead of following links internally.
|
741
|
+
- `permanent`: symbolic links that are turned into HTTP redirects will
|
742
|
+
be permanent.
|
743
|
+
- `followInsecureSymbolicLinks`: directs `FileTree` to serve files
|
744
|
+
that are outside the root path of the file tree if a symbolic link
|
745
|
+
traverses there.
|
746
|
+
- `fs`: alternate file system, defaults to the `fs` module.
|
747
|
+
|
748
|
+
### Redirect(path) : Application
|
749
|
+
|
750
|
+
A factory that produces an HTTP application that temporarily redirects
|
751
|
+
to the given path.
|
752
|
+
|
753
|
+
### RedirectTree(path) : Application
|
754
|
+
|
755
|
+
A factory that produces an HTTP application that redirects all requests
|
756
|
+
under the requested path to parallel locations at the given path.
|
757
|
+
|
758
|
+
### PermanentRedirect(path) : Application
|
759
|
+
|
760
|
+
A factory that produces an HTTP application that redirects all requests
|
761
|
+
to an exact location and instructs the requester's cache never to ask
|
762
|
+
again.
|
763
|
+
|
764
|
+
### PermanentRedirectTree(path) : Application
|
765
|
+
|
766
|
+
A factory that produces an HTTP application that redirects all requests
|
767
|
+
under the request path to a parallel location under the given path and
|
768
|
+
instructs the requester's cache never to ask again.
|
769
|
+
|
770
|
+
### Cap(app, notFound) : Application
|
771
|
+
|
772
|
+
A factory that produces an HTTP application that will cause an `HTTP 404
|
773
|
+
Not found` response if the request has not reached the end of its route
|
774
|
+
(meaning `pathInfo` is not `""` or `"/"`), or will forward to the given
|
775
|
+
application.
|
776
|
+
|
777
|
+
### Routing
|
778
|
+
|
779
|
+
Several routing application factories have the same form. They all take
|
780
|
+
an object as their first argument and an optional fallback application
|
781
|
+
as their second. The object maps each of the supported options for keys
|
782
|
+
to an HTTP application for handling that option.
|
783
|
+
|
784
|
+
- Branch(paths, notFound) routes the next unprocessed path component
|
785
|
+
- Method(methods, notFound) routes the HTTP method. Methods are
|
786
|
+
upper-case.
|
787
|
+
- ContentType(contentTypes, notAcceptable) routes based on the
|
788
|
+
"accept" request header and produces a "content-type" response
|
789
|
+
header.
|
790
|
+
- Langauge(languages, notAcceptable) routes based on the
|
791
|
+
"accept-language" header and produces a "language" response header.
|
792
|
+
- Charaset(charsets, notAcceptable) routes based on the
|
793
|
+
"accept-charset" header and produces a "charset" response header.
|
794
|
+
- Encoding(encodings, notAcceptable) routes based on the
|
795
|
+
"accept-encoding" request header and produces an "encoding" response
|
796
|
+
header.
|
797
|
+
- Host(hosts, notFound) routes based on the host name of the request
|
798
|
+
"host" header, which defaults to "*". This is equivalent to virtual
|
799
|
+
host mapping.
|
800
|
+
|
801
|
+
### Select(selector) : Application
|
802
|
+
|
803
|
+
Produces an HTTP application that uses a function to determine the next
|
804
|
+
application to route. The `selector` is a function that accepts the
|
805
|
+
request and returns an HTTP application.
|
806
|
+
|
807
|
+
### FirstFound(apps)
|
808
|
+
|
809
|
+
Returns an HTTP application that attempts to respond with each of a
|
810
|
+
series of applications and returns the first response that does not have
|
811
|
+
a `404 Not found` status, or whatever response comes last.
|
812
|
+
|
813
|
+
### Error(application, debug) : Application
|
814
|
+
|
815
|
+
Wraps an application such that any exceptions get converted into `HTTP
|
816
|
+
500 Server error` responses. If `debug` is enabled, produces the
|
817
|
+
exception and stack traces in the body of the response.
|
818
|
+
|
819
|
+
### Log(application, log, stamp) : Application
|
820
|
+
|
821
|
+
Wraps an application such that request and response times are logged.
|
822
|
+
The `log` function reports to `console.log` by default. The
|
823
|
+
`stamp(message)` function prefixes an ISO time stamp by default.
|
824
|
+
|
825
|
+
### Time(application) : Application
|
826
|
+
|
827
|
+
Adds an `x-response-time` header to the response, with the time from receiving
|
828
|
+
starting the request to starting the response in miliseconds.
|
829
|
+
|
830
|
+
### Date(application) : Application
|
831
|
+
|
832
|
+
Adds a `date` header to the response with the current date for cache
|
833
|
+
control purposes.
|
834
|
+
|
835
|
+
### Tap(app, tap) : Application
|
836
|
+
|
837
|
+
Wraps an application such that the `tap` function receives the request
|
838
|
+
first. If the tap returns nothing, the request goes to the `app`. If
|
839
|
+
the `tap` returns a response, the `app` never gets called.
|
840
|
+
|
841
|
+
### Trap(app, trap) : Application
|
842
|
+
|
843
|
+
Wraps an application such that the `trap` function receives the
|
844
|
+
response. If it returns nothing, the response if forwarded. If the
|
845
|
+
`trap` returns a response, the original response is discarded.
|
846
|
+
|
847
|
+
### ParseQuery(application)
|
848
|
+
|
849
|
+
Wraps an application such that the query string is parsed and placed in
|
850
|
+
`request.parse`.
|
851
|
+
|
852
|
+
|
853
|
+
## Coverage
|
854
|
+
|
855
|
+
Use `npm run cover` to generate and view a coverage report of Q-IO.
|
856
|
+
|
857
|
+
<table>
|
858
|
+
<thead>
|
859
|
+
<tr>
|
860
|
+
<th>File</th>
|
861
|
+
<th>Percentage</th>
|
862
|
+
<th>Missing</th>
|
863
|
+
</tr>
|
864
|
+
</thead>
|
865
|
+
<tbody>
|
866
|
+
<tr>
|
867
|
+
<td><code>fs-boot.js</code></td>
|
868
|
+
<td>87%</td>
|
869
|
+
<td>41</td>
|
870
|
+
</tr>
|
871
|
+
<tr>
|
872
|
+
<td><code>fs.js</code></td>
|
873
|
+
<td>72%</td>
|
874
|
+
<td>100</td>
|
875
|
+
</tr>
|
876
|
+
<tr>
|
877
|
+
<td><code>reader.js</code></td>
|
878
|
+
<td>94%</td>
|
879
|
+
<td>8</td>
|
880
|
+
</tr>
|
881
|
+
<tr>
|
882
|
+
<td><code>writer.js</code></td>
|
883
|
+
<td>91%</td>
|
884
|
+
<td>8</td>
|
885
|
+
</tr>
|
886
|
+
<tr>
|
887
|
+
<td><code>fs-common.js</code></td>
|
888
|
+
<td>87%</td>
|
889
|
+
<td>52</td>
|
890
|
+
</tr>
|
891
|
+
<tr>
|
892
|
+
<td><code>fs-root.js</code></td>
|
893
|
+
<td>88%</td>
|
894
|
+
<td>11</td>
|
895
|
+
</tr>
|
896
|
+
<tr>
|
897
|
+
<td><code>fs-mock.js</code></td>
|
898
|
+
<td>91%</td>
|
899
|
+
<td>46</td>
|
900
|
+
</tr>
|
901
|
+
<tr>
|
902
|
+
<td><code>buffer-stream.js</code></td>
|
903
|
+
<td>89%</td>
|
904
|
+
<td>6</td>
|
905
|
+
</tr>
|
906
|
+
<tr>
|
907
|
+
<td><code>http.js</code></td>
|
908
|
+
<td>93%</td>
|
909
|
+
<td>25</td>
|
910
|
+
</tr>
|
911
|
+
<tr>
|
912
|
+
<td><code>http-apps.js</code></td>
|
913
|
+
<td>80%</td>
|
914
|
+
<td>286</td>
|
915
|
+
</tr>
|
916
|
+
<tr>
|
917
|
+
<td><code>http-cookie.js</code></td>
|
918
|
+
<td>79%</td>
|
919
|
+
<td>15</td>
|
920
|
+
</tr>
|
921
|
+
</tbody>
|
922
|
+
</table>
|
923
|
+
|
924
|
+
---
|
925
|
+
|
926
|
+
Copyright 2009–2013 Kristopher Michael Kowal
|
927
|
+
MIT License (enclosed)
|
928
|
+
|