traceur-rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "weak-map",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "weak-map.js",
|
|
5
|
+
"readme": "ERROR: No README data found!",
|
|
6
|
+
"_id": "weak-map@1.0.0",
|
|
7
|
+
"dist": {
|
|
8
|
+
"shasum": "78b41fa948c0777ff8f41ad1cda10a37c22bad78"
|
|
9
|
+
},
|
|
10
|
+
"_from": "weak-map@1.0.0",
|
|
11
|
+
"_resolved": "https://registry.npmjs.org/weak-map/-/weak-map-1.0.0.tgz"
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
diff --git a/weak-map.js b/weak-map.js
|
|
2
|
+
index 9fa5d81..116ca05 100644
|
|
3
|
+
--- a/weak-map.js
|
|
4
|
+
+++ b/weak-map.js
|
|
5
|
+
@@ -77,7 +77,6 @@
|
|
6
|
+
* prevent access to this channel. (See
|
|
7
|
+
* PATCH_MUTABLE_FROZEN_WEAKMAP_PROTO in repairES5.js).
|
|
8
|
+
*/
|
|
9
|
+
-var WeakMap;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* If this is a full <a href=
|
|
13
|
+
@@ -127,8 +126,8 @@ var WeakMap;
|
|
14
|
+
|
|
15
|
+
// Check if there is already a good-enough WeakMap implementation, and if so
|
|
16
|
+
// exit without replacing it.
|
|
17
|
+
- var HostWeakMap = WeakMap;
|
|
18
|
+
- if (typeof HostWeakMap === 'function') {
|
|
19
|
+
+ if (typeof WeakMap === 'function') {
|
|
20
|
+
+ var HostWeakMap = WeakMap;
|
|
21
|
+
// There is a WeakMap -- is it good enough?
|
|
22
|
+
if (typeof navigator !== 'undefined' &&
|
|
23
|
+
/Firefox/.test(navigator.userAgent)) {
|
|
24
|
+
@@ -150,6 +149,7 @@ var WeakMap;
|
|
25
|
+
|
|
26
|
+
// Fall through to installing our WeakMap.
|
|
27
|
+
} else {
|
|
28
|
+
+ module.exports = WeakMap;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
@@ -565,7 +565,7 @@ var WeakMap;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
DoubleWeakMap.prototype = OurWeakMap.prototype;
|
|
36
|
+
- WeakMap = DoubleWeakMap;
|
|
37
|
+
+ module.exports = DoubleWeakMap;
|
|
38
|
+
|
|
39
|
+
// define .constructor to hide OurWeakMap ctor
|
|
40
|
+
Object.defineProperty(WeakMap.prototype, 'constructor', {
|
|
41
|
+
@@ -585,6 +585,6 @@ var WeakMap;
|
|
42
|
+
Proxy = undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
- WeakMap = OurWeakMap;
|
|
46
|
+
+ module.exports = OurWeakMap;
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
// Copyright (C) 2011 Google Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @fileoverview Install a leaky WeakMap emulation on platforms that
|
|
17
|
+
* don't provide a built-in one.
|
|
18
|
+
*
|
|
19
|
+
* <p>Assumes that an ES5 platform where, if {@code WeakMap} is
|
|
20
|
+
* already present, then it conforms to the anticipated ES6
|
|
21
|
+
* specification. To run this file on an ES5 or almost ES5
|
|
22
|
+
* implementation where the {@code WeakMap} specification does not
|
|
23
|
+
* quite conform, run <code>repairES5.js</code> first.
|
|
24
|
+
*
|
|
25
|
+
* <p> Even though WeakMapModule is not global, the linter thinks it
|
|
26
|
+
* is, which is why it is in the overrides list below.
|
|
27
|
+
*
|
|
28
|
+
* @author Mark S. Miller
|
|
29
|
+
* @requires crypto, ArrayBuffer, Uint8Array, navigator
|
|
30
|
+
* @overrides WeakMap, ses, Proxy
|
|
31
|
+
* @overrides WeakMapModule
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* This {@code WeakMap} emulation is observably equivalent to the
|
|
36
|
+
* ES-Harmony WeakMap, but with leakier garbage collection properties.
|
|
37
|
+
*
|
|
38
|
+
* <p>As with true WeakMaps, in this emulation, a key does not
|
|
39
|
+
* retain maps indexed by that key and (crucially) a map does not
|
|
40
|
+
* retain the keys it indexes. A map by itself also does not retain
|
|
41
|
+
* the values associated with that map.
|
|
42
|
+
*
|
|
43
|
+
* <p>However, the values associated with a key in some map are
|
|
44
|
+
* retained so long as that key is retained and those associations are
|
|
45
|
+
* not overridden. For example, when used to support membranes, all
|
|
46
|
+
* values exported from a given membrane will live for the lifetime
|
|
47
|
+
* they would have had in the absence of an interposed membrane. Even
|
|
48
|
+
* when the membrane is revoked, all objects that would have been
|
|
49
|
+
* reachable in the absence of revocation will still be reachable, as
|
|
50
|
+
* far as the GC can tell, even though they will no longer be relevant
|
|
51
|
+
* to ongoing computation.
|
|
52
|
+
*
|
|
53
|
+
* <p>The API implemented here is approximately the API as implemented
|
|
54
|
+
* in FF6.0a1 and agreed to by MarkM, Andreas Gal, and Dave Herman,
|
|
55
|
+
* rather than the offially approved proposal page. TODO(erights):
|
|
56
|
+
* upgrade the ecmascript WeakMap proposal page to explain this API
|
|
57
|
+
* change and present to EcmaScript committee for their approval.
|
|
58
|
+
*
|
|
59
|
+
* <p>The first difference between the emulation here and that in
|
|
60
|
+
* FF6.0a1 is the presence of non enumerable {@code get___, has___,
|
|
61
|
+
* set___, and delete___} methods on WeakMap instances to represent
|
|
62
|
+
* what would be the hidden internal properties of a primitive
|
|
63
|
+
* implementation. Whereas the FF6.0a1 WeakMap.prototype methods
|
|
64
|
+
* require their {@code this} to be a genuine WeakMap instance (i.e.,
|
|
65
|
+
* an object of {@code [[Class]]} "WeakMap}), since there is nothing
|
|
66
|
+
* unforgeable about the pseudo-internal method names used here,
|
|
67
|
+
* nothing prevents these emulated prototype methods from being
|
|
68
|
+
* applied to non-WeakMaps with pseudo-internal methods of the same
|
|
69
|
+
* names.
|
|
70
|
+
*
|
|
71
|
+
* <p>Another difference is that our emulated {@code
|
|
72
|
+
* WeakMap.prototype} is not itself a WeakMap. A problem with the
|
|
73
|
+
* current FF6.0a1 API is that WeakMap.prototype is itself a WeakMap
|
|
74
|
+
* providing ambient mutability and an ambient communications
|
|
75
|
+
* channel. Thus, if a WeakMap is already present and has this
|
|
76
|
+
* problem, repairES5.js wraps it in a safe wrappper in order to
|
|
77
|
+
* prevent access to this channel. (See
|
|
78
|
+
* PATCH_MUTABLE_FROZEN_WEAKMAP_PROTO in repairES5.js).
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* If this is a full <a href=
|
|
83
|
+
* "http://code.google.com/p/es-lab/wiki/SecureableES5"
|
|
84
|
+
* >secureable ES5</a> platform and the ES-Harmony {@code WeakMap} is
|
|
85
|
+
* absent, install an approximate emulation.
|
|
86
|
+
*
|
|
87
|
+
* <p>If WeakMap is present but cannot store some objects, use our approximate
|
|
88
|
+
* emulation as a wrapper.
|
|
89
|
+
*
|
|
90
|
+
* <p>If this is almost a secureable ES5 platform, then WeakMap.js
|
|
91
|
+
* should be run after repairES5.js.
|
|
92
|
+
*
|
|
93
|
+
* <p>See {@code WeakMap} for documentation of the garbage collection
|
|
94
|
+
* properties of this WeakMap emulation.
|
|
95
|
+
*/
|
|
96
|
+
(function WeakMapModule() {
|
|
97
|
+
"use strict";
|
|
98
|
+
|
|
99
|
+
if (typeof ses !== 'undefined' && ses.ok && !ses.ok()) {
|
|
100
|
+
// already too broken, so give up
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* In some cases (current Firefox), we must make a choice betweeen a
|
|
106
|
+
* WeakMap which is capable of using all varieties of host objects as
|
|
107
|
+
* keys and one which is capable of safely using proxies as keys. See
|
|
108
|
+
* comments below about HostWeakMap and DoubleWeakMap for details.
|
|
109
|
+
*
|
|
110
|
+
* This function (which is a global, not exposed to guests) marks a
|
|
111
|
+
* WeakMap as permitted to do what is necessary to index all host
|
|
112
|
+
* objects, at the cost of making it unsafe for proxies.
|
|
113
|
+
*
|
|
114
|
+
* Do not apply this function to anything which is not a genuine
|
|
115
|
+
* fresh WeakMap.
|
|
116
|
+
*/
|
|
117
|
+
function weakMapPermitHostObjects(map) {
|
|
118
|
+
// identity of function used as a secret -- good enough and cheap
|
|
119
|
+
if (map.permitHostObjects___) {
|
|
120
|
+
map.permitHostObjects___(weakMapPermitHostObjects);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (typeof ses !== 'undefined') {
|
|
124
|
+
ses.weakMapPermitHostObjects = weakMapPermitHostObjects;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Check if there is already a good-enough WeakMap implementation, and if so
|
|
128
|
+
// exit without replacing it.
|
|
129
|
+
if (typeof WeakMap === 'function') {
|
|
130
|
+
var HostWeakMap = WeakMap;
|
|
131
|
+
// There is a WeakMap -- is it good enough?
|
|
132
|
+
if (typeof navigator !== 'undefined' &&
|
|
133
|
+
/Firefox/.test(navigator.userAgent)) {
|
|
134
|
+
// We're now *assuming not*, because as of this writing (2013-05-06)
|
|
135
|
+
// Firefox's WeakMaps have a miscellany of objects they won't accept, and
|
|
136
|
+
// we don't want to make an exhaustive list, and testing for just one
|
|
137
|
+
// will be a problem if that one is fixed alone (as they did for Event).
|
|
138
|
+
|
|
139
|
+
// If there is a platform that we *can* reliably test on, here's how to
|
|
140
|
+
// do it:
|
|
141
|
+
// var problematic = ... ;
|
|
142
|
+
// var testHostMap = new HostWeakMap();
|
|
143
|
+
// try {
|
|
144
|
+
// testHostMap.set(problematic, 1); // Firefox 20 will throw here
|
|
145
|
+
// if (testHostMap.get(problematic) === 1) {
|
|
146
|
+
// return;
|
|
147
|
+
// }
|
|
148
|
+
// } catch (e) {}
|
|
149
|
+
|
|
150
|
+
// Fall through to installing our WeakMap.
|
|
151
|
+
} else {
|
|
152
|
+
module.exports = WeakMap;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var hop = Object.prototype.hasOwnProperty;
|
|
158
|
+
var gopn = Object.getOwnPropertyNames;
|
|
159
|
+
var defProp = Object.defineProperty;
|
|
160
|
+
var isExtensible = Object.isExtensible;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Security depends on HIDDEN_NAME being both <i>unguessable</i> and
|
|
164
|
+
* <i>undiscoverable</i> by untrusted code.
|
|
165
|
+
*
|
|
166
|
+
* <p>Given the known weaknesses of Math.random() on existing
|
|
167
|
+
* browsers, it does not generate unguessability we can be confident
|
|
168
|
+
* of.
|
|
169
|
+
*
|
|
170
|
+
* <p>It is the monkey patching logic in this file that is intended
|
|
171
|
+
* to ensure undiscoverability. The basic idea is that there are
|
|
172
|
+
* three fundamental means of discovering properties of an object:
|
|
173
|
+
* The for/in loop, Object.keys(), and Object.getOwnPropertyNames(),
|
|
174
|
+
* as well as some proposed ES6 extensions that appear on our
|
|
175
|
+
* whitelist. The first two only discover enumerable properties, and
|
|
176
|
+
* we only use HIDDEN_NAME to name a non-enumerable property, so the
|
|
177
|
+
* only remaining threat should be getOwnPropertyNames and some
|
|
178
|
+
* proposed ES6 extensions that appear on our whitelist. We monkey
|
|
179
|
+
* patch them to remove HIDDEN_NAME from the list of properties they
|
|
180
|
+
* returns.
|
|
181
|
+
*
|
|
182
|
+
* <p>TODO(erights): On a platform with built-in Proxies, proxies
|
|
183
|
+
* could be used to trap and thereby discover the HIDDEN_NAME, so we
|
|
184
|
+
* need to monkey patch Proxy.create, Proxy.createFunction, etc, in
|
|
185
|
+
* order to wrap the provided handler with the real handler which
|
|
186
|
+
* filters out all traps using HIDDEN_NAME.
|
|
187
|
+
*
|
|
188
|
+
* <p>TODO(erights): Revisit Mike Stay's suggestion that we use an
|
|
189
|
+
* encapsulated function at a not-necessarily-secret name, which
|
|
190
|
+
* uses the Stiegler shared-state rights amplification pattern to
|
|
191
|
+
* reveal the associated value only to the WeakMap in which this key
|
|
192
|
+
* is associated with that value. Since only the key retains the
|
|
193
|
+
* function, the function can also remember the key without causing
|
|
194
|
+
* leakage of the key, so this doesn't violate our general gc
|
|
195
|
+
* goals. In addition, because the name need not be a guarded
|
|
196
|
+
* secret, we could efficiently handle cross-frame frozen keys.
|
|
197
|
+
*/
|
|
198
|
+
var HIDDEN_NAME_PREFIX = 'weakmap:';
|
|
199
|
+
var HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'ident:' + Math.random() + '___';
|
|
200
|
+
|
|
201
|
+
if (typeof crypto !== 'undefined' &&
|
|
202
|
+
typeof crypto.getRandomValues === 'function' &&
|
|
203
|
+
typeof ArrayBuffer === 'function' &&
|
|
204
|
+
typeof Uint8Array === 'function') {
|
|
205
|
+
var ab = new ArrayBuffer(25);
|
|
206
|
+
var u8s = new Uint8Array(ab);
|
|
207
|
+
crypto.getRandomValues(u8s);
|
|
208
|
+
HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'rand:' +
|
|
209
|
+
Array.prototype.map.call(u8s, function(u8) {
|
|
210
|
+
return (u8 % 36).toString(36);
|
|
211
|
+
}).join('') + '___';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function isNotHiddenName(name) {
|
|
215
|
+
return !(
|
|
216
|
+
name.substr(0, HIDDEN_NAME_PREFIX.length) == HIDDEN_NAME_PREFIX &&
|
|
217
|
+
name.substr(name.length - 3) === '___');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Monkey patch getOwnPropertyNames to avoid revealing the
|
|
222
|
+
* HIDDEN_NAME.
|
|
223
|
+
*
|
|
224
|
+
* <p>The ES5.1 spec requires each name to appear only once, but as
|
|
225
|
+
* of this writing, this requirement is controversial for ES6, so we
|
|
226
|
+
* made this code robust against this case. If the resulting extra
|
|
227
|
+
* search turns out to be expensive, we can probably relax this once
|
|
228
|
+
* ES6 is adequately supported on all major browsers, iff no browser
|
|
229
|
+
* versions we support at that time have relaxed this constraint
|
|
230
|
+
* without providing built-in ES6 WeakMaps.
|
|
231
|
+
*/
|
|
232
|
+
defProp(Object, 'getOwnPropertyNames', {
|
|
233
|
+
value: function fakeGetOwnPropertyNames(obj) {
|
|
234
|
+
return gopn(obj).filter(isNotHiddenName);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* getPropertyNames is not in ES5 but it is proposed for ES6 and
|
|
240
|
+
* does appear in our whitelist, so we need to clean it too.
|
|
241
|
+
*/
|
|
242
|
+
if ('getPropertyNames' in Object) {
|
|
243
|
+
var originalGetPropertyNames = Object.getPropertyNames;
|
|
244
|
+
defProp(Object, 'getPropertyNames', {
|
|
245
|
+
value: function fakeGetPropertyNames(obj) {
|
|
246
|
+
return originalGetPropertyNames(obj).filter(isNotHiddenName);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* <p>To treat objects as identity-keys with reasonable efficiency
|
|
253
|
+
* on ES5 by itself (i.e., without any object-keyed collections), we
|
|
254
|
+
* need to add a hidden property to such key objects when we
|
|
255
|
+
* can. This raises several issues:
|
|
256
|
+
* <ul>
|
|
257
|
+
* <li>Arranging to add this property to objects before we lose the
|
|
258
|
+
* chance, and
|
|
259
|
+
* <li>Hiding the existence of this new property from most
|
|
260
|
+
* JavaScript code.
|
|
261
|
+
* <li>Preventing <i>certification theft</i>, where one object is
|
|
262
|
+
* created falsely claiming to be the key of an association
|
|
263
|
+
* actually keyed by another object.
|
|
264
|
+
* <li>Preventing <i>value theft</i>, where untrusted code with
|
|
265
|
+
* access to a key object but not a weak map nevertheless
|
|
266
|
+
* obtains access to the value associated with that key in that
|
|
267
|
+
* weak map.
|
|
268
|
+
* </ul>
|
|
269
|
+
* We do so by
|
|
270
|
+
* <ul>
|
|
271
|
+
* <li>Making the name of the hidden property unguessable, so "[]"
|
|
272
|
+
* indexing, which we cannot intercept, cannot be used to access
|
|
273
|
+
* a property without knowing the name.
|
|
274
|
+
* <li>Making the hidden property non-enumerable, so we need not
|
|
275
|
+
* worry about for-in loops or {@code Object.keys},
|
|
276
|
+
* <li>monkey patching those reflective methods that would
|
|
277
|
+
* prevent extensions, to add this hidden property first,
|
|
278
|
+
* <li>monkey patching those methods that would reveal this
|
|
279
|
+
* hidden property.
|
|
280
|
+
* </ul>
|
|
281
|
+
* Unfortunately, because of same-origin iframes, we cannot reliably
|
|
282
|
+
* add this hidden property before an object becomes
|
|
283
|
+
* non-extensible. Instead, if we encounter a non-extensible object
|
|
284
|
+
* without a hidden record that we can detect (whether or not it has
|
|
285
|
+
* a hidden record stored under a name secret to us), then we just
|
|
286
|
+
* use the key object itself to represent its identity in a brute
|
|
287
|
+
* force leaky map stored in the weak map, losing all the advantages
|
|
288
|
+
* of weakness for these.
|
|
289
|
+
*/
|
|
290
|
+
function getHiddenRecord(key) {
|
|
291
|
+
if (key !== Object(key)) {
|
|
292
|
+
throw new TypeError('Not an object: ' + key);
|
|
293
|
+
}
|
|
294
|
+
var hiddenRecord = key[HIDDEN_NAME];
|
|
295
|
+
if (hiddenRecord && hiddenRecord.key === key) { return hiddenRecord; }
|
|
296
|
+
if (!isExtensible(key)) {
|
|
297
|
+
// Weak map must brute force, as explained in doc-comment above.
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
var gets = [];
|
|
301
|
+
var vals = [];
|
|
302
|
+
hiddenRecord = {
|
|
303
|
+
key: key, // self pointer for quick own check above.
|
|
304
|
+
gets: gets, // get___ methods identifying weak maps
|
|
305
|
+
vals: vals // values associated with this key in each
|
|
306
|
+
// corresponding weak map.
|
|
307
|
+
};
|
|
308
|
+
defProp(key, HIDDEN_NAME, {
|
|
309
|
+
value: hiddenRecord,
|
|
310
|
+
writable: false,
|
|
311
|
+
enumerable: false,
|
|
312
|
+
configurable: false
|
|
313
|
+
});
|
|
314
|
+
return hiddenRecord;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Monkey patch operations that would make their argument
|
|
320
|
+
* non-extensible.
|
|
321
|
+
*
|
|
322
|
+
* <p>The monkey patched versions throw a TypeError if their
|
|
323
|
+
* argument is not an object, so it should only be done to functions
|
|
324
|
+
* that should throw a TypeError anyway if their argument is not an
|
|
325
|
+
* object.
|
|
326
|
+
*/
|
|
327
|
+
(function(){
|
|
328
|
+
var oldFreeze = Object.freeze;
|
|
329
|
+
defProp(Object, 'freeze', {
|
|
330
|
+
value: function identifyingFreeze(obj) {
|
|
331
|
+
getHiddenRecord(obj);
|
|
332
|
+
return oldFreeze(obj);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
var oldSeal = Object.seal;
|
|
336
|
+
defProp(Object, 'seal', {
|
|
337
|
+
value: function identifyingSeal(obj) {
|
|
338
|
+
getHiddenRecord(obj);
|
|
339
|
+
return oldSeal(obj);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
var oldPreventExtensions = Object.preventExtensions;
|
|
343
|
+
defProp(Object, 'preventExtensions', {
|
|
344
|
+
value: function identifyingPreventExtensions(obj) {
|
|
345
|
+
getHiddenRecord(obj);
|
|
346
|
+
return oldPreventExtensions(obj);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
})();
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
function constFunc(func) {
|
|
353
|
+
func.prototype = null;
|
|
354
|
+
return Object.freeze(func);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Right now (12/25/2012) the histogram supports the current
|
|
358
|
+
// representation. We should check this occasionally, as a true
|
|
359
|
+
// constant time representation is easy.
|
|
360
|
+
// var histogram = [];
|
|
361
|
+
|
|
362
|
+
var OurWeakMap = function() {
|
|
363
|
+
// We are currently (12/25/2012) never encountering any prematurely
|
|
364
|
+
// non-extensible keys.
|
|
365
|
+
var keys = []; // brute force for prematurely non-extensible keys.
|
|
366
|
+
var vals = []; // brute force for corresponding values.
|
|
367
|
+
|
|
368
|
+
function get___(key, opt_default) {
|
|
369
|
+
var hr = getHiddenRecord(key);
|
|
370
|
+
var i, vs;
|
|
371
|
+
if (hr) {
|
|
372
|
+
i = hr.gets.indexOf(get___);
|
|
373
|
+
vs = hr.vals;
|
|
374
|
+
} else {
|
|
375
|
+
i = keys.indexOf(key);
|
|
376
|
+
vs = vals;
|
|
377
|
+
}
|
|
378
|
+
return (i >= 0) ? vs[i] : opt_default;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function has___(key) {
|
|
382
|
+
var hr = getHiddenRecord(key);
|
|
383
|
+
var i;
|
|
384
|
+
if (hr) {
|
|
385
|
+
i = hr.gets.indexOf(get___);
|
|
386
|
+
} else {
|
|
387
|
+
i = keys.indexOf(key);
|
|
388
|
+
}
|
|
389
|
+
return i >= 0;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function set___(key, value) {
|
|
393
|
+
var hr = getHiddenRecord(key);
|
|
394
|
+
var i;
|
|
395
|
+
if (hr) {
|
|
396
|
+
i = hr.gets.indexOf(get___);
|
|
397
|
+
if (i >= 0) {
|
|
398
|
+
hr.vals[i] = value;
|
|
399
|
+
} else {
|
|
400
|
+
// i = hr.gets.length;
|
|
401
|
+
// histogram[i] = (histogram[i] || 0) + 1;
|
|
402
|
+
hr.gets.push(get___);
|
|
403
|
+
hr.vals.push(value);
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
i = keys.indexOf(key);
|
|
407
|
+
if (i >= 0) {
|
|
408
|
+
vals[i] = value;
|
|
409
|
+
} else {
|
|
410
|
+
keys.push(key);
|
|
411
|
+
vals.push(value);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function delete___(key) {
|
|
417
|
+
var hr = getHiddenRecord(key);
|
|
418
|
+
var i;
|
|
419
|
+
if (hr) {
|
|
420
|
+
i = hr.gets.indexOf(get___);
|
|
421
|
+
if (i >= 0) {
|
|
422
|
+
hr.gets.splice(i, 1);
|
|
423
|
+
hr.vals.splice(i, 1);
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
426
|
+
i = keys.indexOf(key);
|
|
427
|
+
if (i >= 0) {
|
|
428
|
+
keys.splice(i, 1);
|
|
429
|
+
vals.splice(i, 1);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return Object.create(OurWeakMap.prototype, {
|
|
436
|
+
get___: { value: constFunc(get___) },
|
|
437
|
+
has___: { value: constFunc(has___) },
|
|
438
|
+
set___: { value: constFunc(set___) },
|
|
439
|
+
delete___: { value: constFunc(delete___) }
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
OurWeakMap.prototype = Object.create(Object.prototype, {
|
|
443
|
+
get: {
|
|
444
|
+
/**
|
|
445
|
+
* Return the value most recently associated with key, or
|
|
446
|
+
* opt_default if none.
|
|
447
|
+
*/
|
|
448
|
+
value: function get(key, opt_default) {
|
|
449
|
+
return this.get___(key, opt_default);
|
|
450
|
+
},
|
|
451
|
+
writable: true,
|
|
452
|
+
configurable: true
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
has: {
|
|
456
|
+
/**
|
|
457
|
+
* Is there a value associated with key in this WeakMap?
|
|
458
|
+
*/
|
|
459
|
+
value: function has(key) {
|
|
460
|
+
return this.has___(key);
|
|
461
|
+
},
|
|
462
|
+
writable: true,
|
|
463
|
+
configurable: true
|
|
464
|
+
},
|
|
465
|
+
|
|
466
|
+
set: {
|
|
467
|
+
/**
|
|
468
|
+
* Associate value with key in this WeakMap, overwriting any
|
|
469
|
+
* previous association if present.
|
|
470
|
+
*/
|
|
471
|
+
value: function set(key, value) {
|
|
472
|
+
this.set___(key, value);
|
|
473
|
+
},
|
|
474
|
+
writable: true,
|
|
475
|
+
configurable: true
|
|
476
|
+
},
|
|
477
|
+
|
|
478
|
+
'delete': {
|
|
479
|
+
/**
|
|
480
|
+
* Remove any association for key in this WeakMap, returning
|
|
481
|
+
* whether there was one.
|
|
482
|
+
*
|
|
483
|
+
* <p>Note that the boolean return here does not work like the
|
|
484
|
+
* {@code delete} operator. The {@code delete} operator returns
|
|
485
|
+
* whether the deletion succeeds at bringing about a state in
|
|
486
|
+
* which the deleted property is absent. The {@code delete}
|
|
487
|
+
* operator therefore returns true if the property was already
|
|
488
|
+
* absent, whereas this {@code delete} method returns false if
|
|
489
|
+
* the association was already absent.
|
|
490
|
+
*/
|
|
491
|
+
value: function remove(key) {
|
|
492
|
+
return this.delete___(key);
|
|
493
|
+
},
|
|
494
|
+
writable: true,
|
|
495
|
+
configurable: true
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
if (typeof HostWeakMap === 'function') {
|
|
500
|
+
(function() {
|
|
501
|
+
// If we got here, then the platform has a WeakMap but we are concerned
|
|
502
|
+
// that it may refuse to store some key types. Therefore, make a map
|
|
503
|
+
// implementation which makes use of both as possible.
|
|
504
|
+
|
|
505
|
+
function DoubleWeakMap() {
|
|
506
|
+
// Preferable, truly weak map.
|
|
507
|
+
var hmap = new HostWeakMap();
|
|
508
|
+
|
|
509
|
+
// Our hidden-property-based pseudo-weak-map. Lazily initialized in the
|
|
510
|
+
// 'set' implementation; thus we can avoid performing extra lookups if
|
|
511
|
+
// we know all entries actually stored are entered in 'hmap'.
|
|
512
|
+
var omap = undefined;
|
|
513
|
+
|
|
514
|
+
// Hidden-property maps are not compatible with proxies because proxies
|
|
515
|
+
// can observe the hidden name and either accidentally expose it or fail
|
|
516
|
+
// to allow the hidden property to be set. Therefore, we do not allow
|
|
517
|
+
// arbitrary WeakMaps to switch to using hidden properties, but only
|
|
518
|
+
// those which need the ability, and unprivileged code is not allowed
|
|
519
|
+
// to set the flag.
|
|
520
|
+
var enableSwitching = false;
|
|
521
|
+
|
|
522
|
+
function dget(key, opt_default) {
|
|
523
|
+
if (omap) {
|
|
524
|
+
return hmap.has(key) ? hmap.get(key)
|
|
525
|
+
: omap.get___(key, opt_default);
|
|
526
|
+
} else {
|
|
527
|
+
return hmap.get(key, opt_default);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function dhas(key) {
|
|
532
|
+
return hmap.has(key) || (omap ? omap.has___(key) : false);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function dset(key, value) {
|
|
536
|
+
if (enableSwitching) {
|
|
537
|
+
try {
|
|
538
|
+
hmap.set(key, value);
|
|
539
|
+
} catch (e) {
|
|
540
|
+
if (!omap) { omap = new OurWeakMap(); }
|
|
541
|
+
omap.set___(key, value);
|
|
542
|
+
}
|
|
543
|
+
} else {
|
|
544
|
+
hmap.set(key, value);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function ddelete(key) {
|
|
549
|
+
hmap['delete'](key);
|
|
550
|
+
if (omap) { omap.delete___(key); }
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return Object.create(OurWeakMap.prototype, {
|
|
554
|
+
get___: { value: constFunc(dget) },
|
|
555
|
+
has___: { value: constFunc(dhas) },
|
|
556
|
+
set___: { value: constFunc(dset) },
|
|
557
|
+
delete___: { value: constFunc(ddelete) },
|
|
558
|
+
permitHostObjects___: { value: constFunc(function(token) {
|
|
559
|
+
if (token === weakMapPermitHostObjects) {
|
|
560
|
+
enableSwitching = true;
|
|
561
|
+
} else {
|
|
562
|
+
throw new Error('bogus call to permitHostObjects___');
|
|
563
|
+
}
|
|
564
|
+
})}
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
DoubleWeakMap.prototype = OurWeakMap.prototype;
|
|
568
|
+
module.exports = DoubleWeakMap;
|
|
569
|
+
|
|
570
|
+
// define .constructor to hide OurWeakMap ctor
|
|
571
|
+
Object.defineProperty(WeakMap.prototype, 'constructor', {
|
|
572
|
+
value: WeakMap,
|
|
573
|
+
enumerable: false, // as default .constructor is
|
|
574
|
+
configurable: true,
|
|
575
|
+
writable: true
|
|
576
|
+
});
|
|
577
|
+
})();
|
|
578
|
+
} else {
|
|
579
|
+
// There is no host WeakMap, so we must use the emulation.
|
|
580
|
+
|
|
581
|
+
// Emulated WeakMaps are incompatible with native proxies (because proxies
|
|
582
|
+
// can observe the hidden name), so we must disable Proxy usage (in
|
|
583
|
+
// ArrayLike and Domado, currently).
|
|
584
|
+
if (typeof Proxy !== 'undefined') {
|
|
585
|
+
Proxy = undefined;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
module.exports = OurWeakMap;
|
|
589
|
+
}
|
|
590
|
+
})();
|