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,22 @@
|
|
1
|
+
|
2
|
+
// used exclusively to generate collections.min.js for browsers
|
3
|
+
|
4
|
+
var Shim = require("./shim");
|
5
|
+
|
6
|
+
global.List = require("./list");
|
7
|
+
global.Set = require("./set");
|
8
|
+
global.Map = require("./map");
|
9
|
+
global.MultiMap = require("./multi-map");
|
10
|
+
global.WeakMap = require("weak-map");
|
11
|
+
global.SortedSet = require("./sorted-set");
|
12
|
+
global.SortedMap = require("./sorted-map");
|
13
|
+
global.LruSet = require("./lru-set");
|
14
|
+
global.LruMap = require("./lru-map");
|
15
|
+
global.SortedArray = require("./sorted-array");
|
16
|
+
global.SortedArraySet = require("./sorted-array-set");
|
17
|
+
global.SortedArrayMap = require("./sorted-array-map");
|
18
|
+
global.FastSet = require("./fast-set");
|
19
|
+
global.FastMap = require("./fast-map");
|
20
|
+
global.Dict = require("./dict");
|
21
|
+
global.Iterator = require("./iterator");
|
22
|
+
|
@@ -0,0 +1,142 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var Shim = require("./shim");
|
4
|
+
var GenericCollection = require("./generic-collection");
|
5
|
+
var GenericMap = require("./generic-map");
|
6
|
+
var PropertyChanges = require("./listen/property-changes");
|
7
|
+
|
8
|
+
// Burgled from https://github.com/domenic/dict
|
9
|
+
|
10
|
+
module.exports = Dict;
|
11
|
+
function Dict(values, getDefault) {
|
12
|
+
if (!(this instanceof Dict)) {
|
13
|
+
return new Dict(values, getDefault);
|
14
|
+
}
|
15
|
+
getDefault = getDefault || Function.noop;
|
16
|
+
this.getDefault = getDefault;
|
17
|
+
this.store = {};
|
18
|
+
this.length = 0;
|
19
|
+
this.addEach(values);
|
20
|
+
}
|
21
|
+
|
22
|
+
Dict.Dict = Dict; // hack so require("dict").Dict will work in MontageJS.
|
23
|
+
|
24
|
+
function mangle(key) {
|
25
|
+
return "~" + key;
|
26
|
+
}
|
27
|
+
|
28
|
+
function unmangle(mangled) {
|
29
|
+
return mangled.slice(1);
|
30
|
+
}
|
31
|
+
|
32
|
+
Object.addEach(Dict.prototype, GenericCollection.prototype);
|
33
|
+
Object.addEach(Dict.prototype, GenericMap.prototype);
|
34
|
+
Object.addEach(Dict.prototype, PropertyChanges.prototype);
|
35
|
+
|
36
|
+
Dict.prototype.constructClone = function (values) {
|
37
|
+
return new this.constructor(values, this.mangle, this.getDefault);
|
38
|
+
};
|
39
|
+
|
40
|
+
Dict.prototype.assertString = function (key) {
|
41
|
+
if (typeof key !== "string") {
|
42
|
+
throw new TypeError("key must be a string but Got " + key);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
Dict.prototype.get = function (key, defaultValue) {
|
47
|
+
this.assertString(key);
|
48
|
+
var mangled = mangle(key);
|
49
|
+
if (mangled in this.store) {
|
50
|
+
return this.store[mangled];
|
51
|
+
} else if (arguments.length > 1) {
|
52
|
+
return defaultValue;
|
53
|
+
} else {
|
54
|
+
return this.getDefault(key);
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
Dict.prototype.set = function (key, value) {
|
59
|
+
this.assertString(key);
|
60
|
+
var mangled = mangle(key);
|
61
|
+
if (mangled in this.store) { // update
|
62
|
+
if (this.dispatchesBeforeMapChanges) {
|
63
|
+
this.dispatchBeforeMapChange(key, this.store[mangled]);
|
64
|
+
}
|
65
|
+
this.store[mangled] = value;
|
66
|
+
if (this.dispatchesMapChanges) {
|
67
|
+
this.dispatchMapChange(key, value);
|
68
|
+
}
|
69
|
+
return false;
|
70
|
+
} else { // create
|
71
|
+
if (this.dispatchesMapChanges) {
|
72
|
+
this.dispatchBeforeMapChange(key, undefined);
|
73
|
+
}
|
74
|
+
this.length++;
|
75
|
+
this.store[mangled] = value;
|
76
|
+
if (this.dispatchesMapChanges) {
|
77
|
+
this.dispatchMapChange(key, value);
|
78
|
+
}
|
79
|
+
return true;
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
Dict.prototype.has = function (key) {
|
84
|
+
this.assertString(key);
|
85
|
+
var mangled = mangle(key);
|
86
|
+
return mangled in this.store;
|
87
|
+
};
|
88
|
+
|
89
|
+
Dict.prototype["delete"] = function (key) {
|
90
|
+
this.assertString(key);
|
91
|
+
var mangled = mangle(key);
|
92
|
+
if (mangled in this.store) {
|
93
|
+
if (this.dispatchesMapChanges) {
|
94
|
+
this.dispatchBeforeMapChange(key, this.store[mangled]);
|
95
|
+
}
|
96
|
+
delete this.store[mangle(key)];
|
97
|
+
this.length--;
|
98
|
+
if (this.dispatchesMapChanges) {
|
99
|
+
this.dispatchMapChange(key, undefined);
|
100
|
+
}
|
101
|
+
return true;
|
102
|
+
}
|
103
|
+
return false;
|
104
|
+
};
|
105
|
+
|
106
|
+
Dict.prototype.clear = function () {
|
107
|
+
var key, mangled;
|
108
|
+
for (mangled in this.store) {
|
109
|
+
key = unmangle(mangled);
|
110
|
+
if (this.dispatchesMapChanges) {
|
111
|
+
this.dispatchBeforeMapChange(key, this.store[mangled]);
|
112
|
+
}
|
113
|
+
delete this.store[mangled];
|
114
|
+
if (this.dispatchesMapChanges) {
|
115
|
+
this.dispatchMapChange(key, undefined);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
this.length = 0;
|
119
|
+
};
|
120
|
+
|
121
|
+
Dict.prototype.reduce = function (callback, basis, thisp) {
|
122
|
+
for (var mangled in this.store) {
|
123
|
+
basis = callback.call(thisp, basis, this.store[mangled], unmangle(mangled), this);
|
124
|
+
}
|
125
|
+
return basis;
|
126
|
+
};
|
127
|
+
|
128
|
+
Dict.prototype.reduceRight = function (callback, basis, thisp) {
|
129
|
+
var self = this;
|
130
|
+
var store = this.store;
|
131
|
+
return Object.keys(this.store).reduceRight(function (basis, mangled) {
|
132
|
+
return callback.call(thisp, basis, store[mangled], unmangle(mangled), self);
|
133
|
+
}, basis);
|
134
|
+
};
|
135
|
+
|
136
|
+
Dict.prototype.one = function () {
|
137
|
+
var key;
|
138
|
+
for (key in this.store) {
|
139
|
+
return this.store[key];
|
140
|
+
}
|
141
|
+
};
|
142
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var Shim = require("./shim");
|
4
|
+
var Set = require("./fast-set");
|
5
|
+
var GenericCollection = require("./generic-collection");
|
6
|
+
var GenericMap = require("./generic-map");
|
7
|
+
var PropertyChanges = require("./listen/property-changes");
|
8
|
+
|
9
|
+
module.exports = FastMap;
|
10
|
+
|
11
|
+
function FastMap(values, equals, hash, getDefault) {
|
12
|
+
if (!(this instanceof FastMap)) {
|
13
|
+
return new FastMap(values, equals, hash, getDefault);
|
14
|
+
}
|
15
|
+
equals = equals || Object.equals;
|
16
|
+
hash = hash || Object.hash;
|
17
|
+
getDefault = getDefault || Function.noop;
|
18
|
+
this.contentEquals = equals;
|
19
|
+
this.contentHash = hash;
|
20
|
+
this.getDefault = getDefault;
|
21
|
+
this.store = new Set(
|
22
|
+
undefined,
|
23
|
+
function keysEqual(a, b) {
|
24
|
+
return equals(a.key, b.key);
|
25
|
+
},
|
26
|
+
function keyHash(item) {
|
27
|
+
return hash(item.key);
|
28
|
+
}
|
29
|
+
);
|
30
|
+
this.length = 0;
|
31
|
+
this.addEach(values);
|
32
|
+
}
|
33
|
+
|
34
|
+
FastMap.FastMap = FastMap; // hack so require("fast-map").FastMap will work in MontageJS
|
35
|
+
|
36
|
+
Object.addEach(FastMap.prototype, GenericCollection.prototype);
|
37
|
+
Object.addEach(FastMap.prototype, GenericMap.prototype);
|
38
|
+
Object.addEach(FastMap.prototype, PropertyChanges.prototype);
|
39
|
+
|
40
|
+
FastMap.prototype.constructClone = function (values) {
|
41
|
+
return new this.constructor(
|
42
|
+
values,
|
43
|
+
this.contentEquals,
|
44
|
+
this.contentHash,
|
45
|
+
this.getDefault
|
46
|
+
);
|
47
|
+
};
|
48
|
+
|
49
|
+
FastMap.prototype.log = function (charmap, stringify) {
|
50
|
+
stringify = stringify || this.stringify;
|
51
|
+
this.store.log(charmap, stringify);
|
52
|
+
};
|
53
|
+
|
54
|
+
FastMap.prototype.stringify = function (item, leader) {
|
55
|
+
return leader + JSON.stringify(item.key) + ": " + JSON.stringify(item.value);
|
56
|
+
}
|
57
|
+
|
@@ -0,0 +1,183 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var Shim = require("./shim");
|
4
|
+
var Dict = require("./dict");
|
5
|
+
var List = require("./list");
|
6
|
+
var GenericCollection = require("./generic-collection");
|
7
|
+
var GenericSet = require("./generic-set");
|
8
|
+
var TreeLog = require("./tree-log");
|
9
|
+
var PropertyChanges = require("./listen/property-changes");
|
10
|
+
|
11
|
+
var object_has = Object.prototype.hasOwnProperty;
|
12
|
+
|
13
|
+
module.exports = FastSet;
|
14
|
+
|
15
|
+
function FastSet(values, equals, hash, getDefault) {
|
16
|
+
if (!(this instanceof FastSet)) {
|
17
|
+
return new FastSet(values, equals, hash, getDefault);
|
18
|
+
}
|
19
|
+
equals = equals || Object.equals;
|
20
|
+
hash = hash || Object.hash;
|
21
|
+
getDefault = getDefault || Function.noop;
|
22
|
+
this.contentEquals = equals;
|
23
|
+
this.contentHash = hash;
|
24
|
+
this.getDefault = getDefault;
|
25
|
+
this.buckets = new this.Buckets(null, this.Bucket);
|
26
|
+
this.length = 0;
|
27
|
+
this.addEach(values);
|
28
|
+
}
|
29
|
+
|
30
|
+
FastSet.FastSet = FastSet; // hack so require("fast-set").FastSet will work in MontageJS
|
31
|
+
|
32
|
+
Object.addEach(FastSet.prototype, GenericCollection.prototype);
|
33
|
+
Object.addEach(FastSet.prototype, GenericSet.prototype);
|
34
|
+
Object.addEach(FastSet.prototype, PropertyChanges.prototype);
|
35
|
+
|
36
|
+
FastSet.prototype.Buckets = Dict;
|
37
|
+
FastSet.prototype.Bucket = List;
|
38
|
+
|
39
|
+
FastSet.prototype.constructClone = function (values) {
|
40
|
+
return new this.constructor(
|
41
|
+
values,
|
42
|
+
this.contentEquals,
|
43
|
+
this.contentHash,
|
44
|
+
this.getDefault
|
45
|
+
);
|
46
|
+
};
|
47
|
+
|
48
|
+
FastSet.prototype.has = function (value) {
|
49
|
+
var hash = this.contentHash(value);
|
50
|
+
return this.buckets.get(hash).has(value);
|
51
|
+
};
|
52
|
+
|
53
|
+
FastSet.prototype.get = function (value) {
|
54
|
+
var hash = this.contentHash(value);
|
55
|
+
var buckets = this.buckets;
|
56
|
+
if (buckets.has(hash)) {
|
57
|
+
return buckets.get(hash).get(value);
|
58
|
+
} else {
|
59
|
+
return this.getDefault(value);
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
FastSet.prototype['delete'] = function (value) {
|
64
|
+
var hash = this.contentHash(value);
|
65
|
+
var buckets = this.buckets;
|
66
|
+
if (buckets.has(hash)) {
|
67
|
+
var bucket = buckets.get(hash);
|
68
|
+
if (bucket["delete"](value)) {
|
69
|
+
this.length--;
|
70
|
+
if (bucket.length === 0) {
|
71
|
+
buckets["delete"](hash);
|
72
|
+
}
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return false;
|
77
|
+
};
|
78
|
+
|
79
|
+
FastSet.prototype.clear = function () {
|
80
|
+
this.buckets.clear();
|
81
|
+
this.length = 0;
|
82
|
+
};
|
83
|
+
|
84
|
+
FastSet.prototype.add = function (value) {
|
85
|
+
var hash = this.contentHash(value);
|
86
|
+
var buckets = this.buckets;
|
87
|
+
if (!buckets.has(hash)) {
|
88
|
+
buckets.set(hash, new this.Bucket(null, this.contentEquals));
|
89
|
+
}
|
90
|
+
if (!buckets.get(hash).has(value)) {
|
91
|
+
buckets.get(hash).add(value);
|
92
|
+
this.length++;
|
93
|
+
return true;
|
94
|
+
}
|
95
|
+
return false;
|
96
|
+
};
|
97
|
+
|
98
|
+
FastSet.prototype.reduce = function (callback, basis /*, thisp*/) {
|
99
|
+
var thisp = arguments[2];
|
100
|
+
var buckets = this.buckets;
|
101
|
+
var index = 0;
|
102
|
+
return buckets.reduce(function (basis, bucket) {
|
103
|
+
return bucket.reduce(function (basis, value) {
|
104
|
+
return callback.call(thisp, basis, value, index++, this);
|
105
|
+
}, basis, this);
|
106
|
+
}, basis, this);
|
107
|
+
};
|
108
|
+
|
109
|
+
FastSet.prototype.one = function () {
|
110
|
+
if (this.length > 0) {
|
111
|
+
return this.buckets.one().one();
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
FastSet.prototype.iterate = function () {
|
116
|
+
return this.buckets.values().flatten().iterate();
|
117
|
+
};
|
118
|
+
|
119
|
+
FastSet.prototype.log = function (charmap, logNode, callback, thisp) {
|
120
|
+
charmap = charmap || TreeLog.unicodeSharp;
|
121
|
+
logNode = logNode || this.logNode;
|
122
|
+
if (!callback) {
|
123
|
+
callback = console.log;
|
124
|
+
thisp = console;
|
125
|
+
}
|
126
|
+
callback = callback.bind(thisp);
|
127
|
+
|
128
|
+
var buckets = this.buckets;
|
129
|
+
var hashes = buckets.keys();
|
130
|
+
hashes.forEach(function (hash, index) {
|
131
|
+
var branch;
|
132
|
+
var leader;
|
133
|
+
if (index === hashes.length - 1) {
|
134
|
+
branch = charmap.fromAbove;
|
135
|
+
leader = ' ';
|
136
|
+
} else if (index === 0) {
|
137
|
+
branch = charmap.branchDown;
|
138
|
+
leader = charmap.strafe;
|
139
|
+
} else {
|
140
|
+
branch = charmap.fromBoth;
|
141
|
+
leader = charmap.strafe;
|
142
|
+
}
|
143
|
+
var bucket = buckets.get(hash);
|
144
|
+
callback.call(thisp, branch + charmap.through + charmap.branchDown + ' ' + hash);
|
145
|
+
bucket.forEach(function (value, node) {
|
146
|
+
var branch, below;
|
147
|
+
if (node === bucket.head.prev) {
|
148
|
+
branch = charmap.fromAbove;
|
149
|
+
below = ' ';
|
150
|
+
} else {
|
151
|
+
branch = charmap.fromBoth;
|
152
|
+
below = charmap.strafe;
|
153
|
+
}
|
154
|
+
var written;
|
155
|
+
logNode(
|
156
|
+
node,
|
157
|
+
function (line) {
|
158
|
+
if (!written) {
|
159
|
+
callback.call(thisp, leader + ' ' + branch + charmap.through + charmap.through + line);
|
160
|
+
written = true;
|
161
|
+
} else {
|
162
|
+
callback.call(thisp, leader + ' ' + below + ' ' + line);
|
163
|
+
}
|
164
|
+
},
|
165
|
+
function (line) {
|
166
|
+
callback.call(thisp, leader + ' ' + charmap.strafe + ' ' + line);
|
167
|
+
}
|
168
|
+
);
|
169
|
+
});
|
170
|
+
});
|
171
|
+
};
|
172
|
+
|
173
|
+
FastSet.prototype.logNode = function (node, write) {
|
174
|
+
var value = node.value;
|
175
|
+
if (Object(value) === value) {
|
176
|
+
JSON.stringify(value, null, 4).split("\n").forEach(function (line) {
|
177
|
+
write(" " + line);
|
178
|
+
});
|
179
|
+
} else {
|
180
|
+
write(" " + value);
|
181
|
+
}
|
182
|
+
};
|
183
|
+
|
data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = GenericCollection;
|
4
|
+
function GenericCollection() {
|
5
|
+
throw new Error("Can't construct. GenericCollection is a mixin.");
|
6
|
+
}
|
7
|
+
|
8
|
+
GenericCollection.prototype.addEach = function (values) {
|
9
|
+
if (values && Object(values) === values) {
|
10
|
+
if (typeof values.forEach === "function") {
|
11
|
+
values.forEach(this.add, this);
|
12
|
+
} else if (typeof values.length === "number") {
|
13
|
+
// Array-like objects that do not implement forEach, ergo,
|
14
|
+
// Arguments
|
15
|
+
for (var i = 0; i < values.length; i++) {
|
16
|
+
this.add(values[i], i);
|
17
|
+
}
|
18
|
+
} else {
|
19
|
+
Object.keys(values).forEach(function (key) {
|
20
|
+
this.add(values[key], key);
|
21
|
+
}, this);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return this;
|
25
|
+
};
|
26
|
+
|
27
|
+
// This is sufficiently generic for Map (since the value may be a key)
|
28
|
+
// and ordered collections (since it forwards the equals argument)
|
29
|
+
GenericCollection.prototype.deleteEach = function (values, equals) {
|
30
|
+
values.forEach(function (value) {
|
31
|
+
this["delete"](value, equals);
|
32
|
+
}, this);
|
33
|
+
return this;
|
34
|
+
};
|
35
|
+
|
36
|
+
// all of the following functions are implemented in terms of "reduce".
|
37
|
+
// some need "constructClone".
|
38
|
+
|
39
|
+
GenericCollection.prototype.forEach = function (callback /*, thisp*/) {
|
40
|
+
var thisp = arguments[1];
|
41
|
+
return this.reduce(function (undefined, value, key, object, depth) {
|
42
|
+
callback.call(thisp, value, key, object, depth);
|
43
|
+
}, undefined);
|
44
|
+
};
|
45
|
+
|
46
|
+
GenericCollection.prototype.map = function (callback /*, thisp*/) {
|
47
|
+
var thisp = arguments[1];
|
48
|
+
var result = [];
|
49
|
+
this.reduce(function (undefined, value, key, object, depth) {
|
50
|
+
result.push(callback.call(thisp, value, key, object, depth));
|
51
|
+
}, undefined);
|
52
|
+
return result;
|
53
|
+
};
|
54
|
+
|
55
|
+
GenericCollection.prototype.enumerate = function (start) {
|
56
|
+
if (start == null) {
|
57
|
+
start = 0;
|
58
|
+
}
|
59
|
+
var result = [];
|
60
|
+
this.reduce(function (undefined, value) {
|
61
|
+
result.push([start++, value]);
|
62
|
+
}, undefined);
|
63
|
+
return result;
|
64
|
+
};
|
65
|
+
|
66
|
+
GenericCollection.prototype.group = function (callback, thisp, equals) {
|
67
|
+
equals = equals || Object.equals;
|
68
|
+
var groups = [];
|
69
|
+
var keys = [];
|
70
|
+
this.forEach(function (value, key, object) {
|
71
|
+
var key = callback.call(thisp, value, key, object);
|
72
|
+
var index = keys.indexOf(key, equals);
|
73
|
+
var group;
|
74
|
+
if (index === -1) {
|
75
|
+
group = [];
|
76
|
+
groups.push([key, group]);
|
77
|
+
keys.push(key);
|
78
|
+
} else {
|
79
|
+
group = groups[index][1];
|
80
|
+
}
|
81
|
+
group.push(value);
|
82
|
+
});
|
83
|
+
return groups;
|
84
|
+
};
|
85
|
+
|
86
|
+
GenericCollection.prototype.toArray = function () {
|
87
|
+
return this.map(Function.identity);
|
88
|
+
};
|
89
|
+
|
90
|
+
// this depends on stringable keys, which apply to Array and Iterator
|
91
|
+
// because they have numeric keys and all Maps since they may use
|
92
|
+
// strings as keys. List, Set, and SortedSet have nodes for keys, so
|
93
|
+
// toObject would not be meaningful.
|
94
|
+
GenericCollection.prototype.toObject = function () {
|
95
|
+
var object = {};
|
96
|
+
this.reduce(function (undefined, value, key) {
|
97
|
+
object[key] = value;
|
98
|
+
}, undefined);
|
99
|
+
return object;
|
100
|
+
};
|
101
|
+
|
102
|
+
GenericCollection.prototype.filter = function (callback /*, thisp*/) {
|
103
|
+
var thisp = arguments[1];
|
104
|
+
var result = this.constructClone();
|
105
|
+
this.reduce(function (undefined, value, key, object, depth) {
|
106
|
+
if (callback.call(thisp, value, key, object, depth)) {
|
107
|
+
result.add(value);
|
108
|
+
}
|
109
|
+
}, undefined);
|
110
|
+
return result;
|
111
|
+
};
|
112
|
+
|
113
|
+
GenericCollection.prototype.every = function (callback /*, thisp*/) {
|
114
|
+
var thisp = arguments[1];
|
115
|
+
return this.reduce(function (result, value, key, object, depth) {
|
116
|
+
return result && callback.call(thisp, value, key, object, depth);
|
117
|
+
}, true);
|
118
|
+
};
|
119
|
+
|
120
|
+
GenericCollection.prototype.some = function (callback /*, thisp*/) {
|
121
|
+
var thisp = arguments[1];
|
122
|
+
return this.reduce(function (result, value, key, object, depth) {
|
123
|
+
return result || callback.call(thisp, value, key, object, depth);
|
124
|
+
}, false);
|
125
|
+
};
|
126
|
+
|
127
|
+
GenericCollection.prototype.all = function () {
|
128
|
+
return this.every(Boolean);
|
129
|
+
};
|
130
|
+
|
131
|
+
GenericCollection.prototype.any = function () {
|
132
|
+
return this.some(Boolean);
|
133
|
+
};
|
134
|
+
|
135
|
+
GenericCollection.prototype.min = function (compare) {
|
136
|
+
compare = compare || this.contentCompare || Object.compare;
|
137
|
+
var first = true;
|
138
|
+
return this.reduce(function (result, value) {
|
139
|
+
if (first) {
|
140
|
+
first = false;
|
141
|
+
return value;
|
142
|
+
} else {
|
143
|
+
return compare(value, result) < 0 ? value : result;
|
144
|
+
}
|
145
|
+
}, undefined);
|
146
|
+
};
|
147
|
+
|
148
|
+
GenericCollection.prototype.max = function (compare) {
|
149
|
+
compare = compare || this.contentCompare || Object.compare;
|
150
|
+
var first = true;
|
151
|
+
return this.reduce(function (result, value) {
|
152
|
+
if (first) {
|
153
|
+
first = false;
|
154
|
+
return value;
|
155
|
+
} else {
|
156
|
+
return compare(value, result) > 0 ? value : result;
|
157
|
+
}
|
158
|
+
}, undefined);
|
159
|
+
};
|
160
|
+
|
161
|
+
GenericCollection.prototype.sum = function (zero) {
|
162
|
+
zero = zero === undefined ? 0 : zero;
|
163
|
+
return this.reduce(function (a, b) {
|
164
|
+
return a + b;
|
165
|
+
}, zero);
|
166
|
+
};
|
167
|
+
|
168
|
+
GenericCollection.prototype.average = function (zero) {
|
169
|
+
var sum = zero === undefined ? 0 : zero;
|
170
|
+
var count = zero === undefined ? 0 : zero;
|
171
|
+
this.reduce(function (undefined, value) {
|
172
|
+
sum += value;
|
173
|
+
count += 1;
|
174
|
+
}, undefined);
|
175
|
+
return sum / count;
|
176
|
+
};
|
177
|
+
|
178
|
+
GenericCollection.prototype.concat = function () {
|
179
|
+
var result = this.constructClone(this);
|
180
|
+
for (var i = 0; i < arguments.length; i++) {
|
181
|
+
result.addEach(arguments[i]);
|
182
|
+
}
|
183
|
+
return result;
|
184
|
+
};
|
185
|
+
|
186
|
+
GenericCollection.prototype.flatten = function () {
|
187
|
+
var self = this;
|
188
|
+
return this.reduce(function (result, array) {
|
189
|
+
array.forEach(function (value) {
|
190
|
+
this.push(value);
|
191
|
+
}, result, self);
|
192
|
+
return result;
|
193
|
+
}, []);
|
194
|
+
};
|
195
|
+
|
196
|
+
GenericCollection.prototype.zip = function () {
|
197
|
+
var table = Array.prototype.slice.call(arguments);
|
198
|
+
table.unshift(this);
|
199
|
+
return Array.unzip(table);
|
200
|
+
}
|
201
|
+
|
202
|
+
GenericCollection.prototype.join = function (delimiter) {
|
203
|
+
return this.reduce(function (result, string) {
|
204
|
+
return result + delimiter + string;
|
205
|
+
});
|
206
|
+
};
|
207
|
+
|
208
|
+
GenericCollection.prototype.sorted = function (compare, by, order) {
|
209
|
+
compare = compare || this.contentCompare || Object.compare;
|
210
|
+
// account for comparators generated by Function.by
|
211
|
+
if (compare.by) {
|
212
|
+
by = compare.by;
|
213
|
+
compare = compare.compare || this.contentCompare || Object.compare;
|
214
|
+
} else {
|
215
|
+
by = by || Function.identity;
|
216
|
+
}
|
217
|
+
if (order === undefined)
|
218
|
+
order = 1;
|
219
|
+
return this.map(function (item) {
|
220
|
+
return {
|
221
|
+
by: by(item),
|
222
|
+
value: item
|
223
|
+
};
|
224
|
+
})
|
225
|
+
.sort(function (a, b) {
|
226
|
+
return compare(a.by, b.by) * order;
|
227
|
+
})
|
228
|
+
.map(function (pair) {
|
229
|
+
return pair.value;
|
230
|
+
});
|
231
|
+
};
|
232
|
+
|
233
|
+
GenericCollection.prototype.reversed = function () {
|
234
|
+
return this.constructClone(this).reverse();
|
235
|
+
};
|
236
|
+
|
237
|
+
GenericCollection.prototype.clone = function (depth, memo) {
|
238
|
+
if (depth === undefined) {
|
239
|
+
depth = Infinity;
|
240
|
+
} else if (depth === 0) {
|
241
|
+
return this;
|
242
|
+
}
|
243
|
+
var clone = this.constructClone();
|
244
|
+
this.forEach(function (value, key) {
|
245
|
+
clone.add(Object.clone(value, depth - 1, memo), key);
|
246
|
+
}, this);
|
247
|
+
return clone;
|
248
|
+
};
|
249
|
+
|
250
|
+
GenericCollection.prototype.only = function () {
|
251
|
+
if (this.length === 1) {
|
252
|
+
return this.one();
|
253
|
+
}
|
254
|
+
};
|
255
|
+
|
256
|
+
GenericCollection.prototype.iterator = function () {
|
257
|
+
return this.iterate.apply(this, arguments);
|
258
|
+
};
|
259
|
+
|
260
|
+
require("./shim-array");
|
261
|
+
|