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,59 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = Function;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
A utility to reduce unnecessary allocations of <code>function () {}</code>
|
|
6
|
+
in its many colorful variations. It does nothing and returns
|
|
7
|
+
<code>undefined</code> thus makes a suitable default in some circumstances.
|
|
8
|
+
|
|
9
|
+
@function external:Function.noop
|
|
10
|
+
*/
|
|
11
|
+
Function.noop = function () {
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
A utility to reduce unnecessary allocations of <code>function (x) {return
|
|
16
|
+
x}</code> in its many colorful but ultimately wasteful parameter name
|
|
17
|
+
variations.
|
|
18
|
+
|
|
19
|
+
@function external:Function.identity
|
|
20
|
+
@param {Any} any value
|
|
21
|
+
@returns {Any} that value
|
|
22
|
+
*/
|
|
23
|
+
Function.identity = function (value) {
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
A utility for creating a comparator function for a particular aspect of a
|
|
29
|
+
figurative class of objects.
|
|
30
|
+
|
|
31
|
+
@function external:Function.by
|
|
32
|
+
@param {Function} relation A function that accepts a value and returns a
|
|
33
|
+
corresponding value to use as a representative when sorting that object.
|
|
34
|
+
@param {Function} compare an alternate comparator for comparing the
|
|
35
|
+
represented values. The default is <code>Object.compare</code>, which
|
|
36
|
+
does a deep, type-sensitive, polymorphic comparison.
|
|
37
|
+
@returns {Function} a comparator that has been annotated with
|
|
38
|
+
<code>by</code> and <code>compare</code> properties so
|
|
39
|
+
<code>sorted</code> can perform a transform that reduces the need to call
|
|
40
|
+
<code>by</code> on each sorted object to just once.
|
|
41
|
+
*/
|
|
42
|
+
Function.by = function (by , compare) {
|
|
43
|
+
compare = compare || Object.compare;
|
|
44
|
+
by = by || Function.identity;
|
|
45
|
+
var compareBy = function (a, b) {
|
|
46
|
+
return compare(by(a), by(b));
|
|
47
|
+
};
|
|
48
|
+
compareBy.compare = compare;
|
|
49
|
+
compareBy.by = by;
|
|
50
|
+
return compareBy;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// TODO document
|
|
54
|
+
Function.get = function (key) {
|
|
55
|
+
return function (object) {
|
|
56
|
+
return Object.get(object, key);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var WeakMap = require("weak-map");
|
|
4
|
+
|
|
5
|
+
module.exports = Object;
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Based in part on extras from Motorola Mobility’s Montage
|
|
9
|
+
Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.
|
|
10
|
+
3-Clause BSD License
|
|
11
|
+
https://github.com/motorola-mobility/montage/blob/master/LICENSE.md
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Defines extensions to intrinsic <code>Object</code>.
|
|
16
|
+
@see [Object class]{@link external:Object}
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
A utility object to avoid unnecessary allocations of an empty object
|
|
21
|
+
<code>{}</code>. This object is frozen so it is safe to share.
|
|
22
|
+
|
|
23
|
+
@object external:Object.empty
|
|
24
|
+
*/
|
|
25
|
+
Object.empty = Object.freeze(Object.create(null));
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
Returns whether the given value is an object, as opposed to a value.
|
|
29
|
+
Unboxed numbers, strings, true, false, undefined, and null are not
|
|
30
|
+
objects. Arrays are objects.
|
|
31
|
+
|
|
32
|
+
@function external:Object.isObject
|
|
33
|
+
@param {Any} value
|
|
34
|
+
@returns {Boolean} whether the given value is an object
|
|
35
|
+
*/
|
|
36
|
+
Object.isObject = function (object) {
|
|
37
|
+
return Object(object) === object;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
Returns the value of an any value, particularly objects that
|
|
42
|
+
implement <code>valueOf</code>.
|
|
43
|
+
|
|
44
|
+
<p>Note that, unlike the precedent of methods like
|
|
45
|
+
<code>Object.equals</code> and <code>Object.compare</code> would suggest,
|
|
46
|
+
this method is named <code>Object.getValueOf</code> instead of
|
|
47
|
+
<code>valueOf</code>. This is a delicate issue, but the basis of this
|
|
48
|
+
decision is that the JavaScript runtime would be far more likely to
|
|
49
|
+
accidentally call this method with no arguments, assuming that it would
|
|
50
|
+
return the value of <code>Object</code> itself in various situations,
|
|
51
|
+
whereas <code>Object.equals(Object, null)</code> protects against this case
|
|
52
|
+
by noting that <code>Object</code> owns the <code>equals</code> property
|
|
53
|
+
and therefore does not delegate to it.
|
|
54
|
+
|
|
55
|
+
@function external:Object.getValueOf
|
|
56
|
+
@param {Any} value a value or object wrapping a value
|
|
57
|
+
@returns {Any} the primitive value of that object, if one exists, or passes
|
|
58
|
+
the value through
|
|
59
|
+
*/
|
|
60
|
+
Object.getValueOf = function (value) {
|
|
61
|
+
if (Object.can(value, "valueOf")) {
|
|
62
|
+
value = value.valueOf();
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var hashMap = new WeakMap();
|
|
68
|
+
Object.hash = function (object) {
|
|
69
|
+
if (Object.can(object, "hash")) {
|
|
70
|
+
return "" + object.hash();
|
|
71
|
+
} else if (Object(object) === object) {
|
|
72
|
+
if (!hashMap.has(object)) {
|
|
73
|
+
hashMap.set(object, Math.random().toString(36).slice(2));
|
|
74
|
+
}
|
|
75
|
+
return hashMap.get(object);
|
|
76
|
+
} else {
|
|
77
|
+
return "" + object;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
A shorthand for <code>Object.prototype.hasOwnProperty.call(object,
|
|
83
|
+
key)</code>. Returns whether the object owns a property for the given key.
|
|
84
|
+
It does not consult the prototype chain and works for any string (including
|
|
85
|
+
"hasOwnProperty") except "__proto__".
|
|
86
|
+
|
|
87
|
+
@function external:Object.owns
|
|
88
|
+
@param {Object} object
|
|
89
|
+
@param {String} key
|
|
90
|
+
@returns {Boolean} whether the object owns a property wfor the given key.
|
|
91
|
+
*/
|
|
92
|
+
var owns = Object.prototype.hasOwnProperty;
|
|
93
|
+
Object.owns = function (object, key) {
|
|
94
|
+
return owns.call(object, key);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
Returns whether a value implements a particular duck-type method.
|
|
99
|
+
|
|
100
|
+
<p>To qualify as a duck-type method, the value in question must have a
|
|
101
|
+
method by the given name on the prototype chain. To distinguish it from
|
|
102
|
+
a property of an object literal, the property must not be owned by the
|
|
103
|
+
object directly.
|
|
104
|
+
|
|
105
|
+
<p>A value that implements a method is not necessarily an object, for
|
|
106
|
+
example, numbers implement <code>valueOf</code>, so this is function
|
|
107
|
+
does not imply <code>Object.isObject</code> of the same value.
|
|
108
|
+
|
|
109
|
+
@function external:Object.can
|
|
110
|
+
@param {Any} value a value
|
|
111
|
+
@param {String} name a method name
|
|
112
|
+
@returns {Boolean} whether the given value implements the given method
|
|
113
|
+
|
|
114
|
+
*/
|
|
115
|
+
Object.can = function (object, name) {
|
|
116
|
+
return (
|
|
117
|
+
object != null && // false only for null *and* undefined
|
|
118
|
+
typeof object[name] === "function" &&
|
|
119
|
+
!owns.call(object, name)
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
A utility that is like Object.owns but is also useful for finding
|
|
125
|
+
properties on the prototype chain, provided that they do not refer to
|
|
126
|
+
methods on the Object prototype. Works for all strings except "__proto__".
|
|
127
|
+
|
|
128
|
+
<p>Alternately, you could use the "in" operator as long as the object
|
|
129
|
+
descends from "null" instead of the Object.prototype, as with
|
|
130
|
+
<code>Object.create(null)</code>. However,
|
|
131
|
+
<code>Object.create(null)</code> only works in fully compliant EcmaScript 5
|
|
132
|
+
JavaScript engines and cannot be faithfully shimmed.
|
|
133
|
+
|
|
134
|
+
<p>If the given object is an instance of a type that implements a method
|
|
135
|
+
named "has", this function defers to the collection, so this method can be
|
|
136
|
+
used to generically handle objects, arrays, or other collections. In that
|
|
137
|
+
case, the domain of the key depends on the instance.
|
|
138
|
+
|
|
139
|
+
@param {Object} object
|
|
140
|
+
@param {String} key
|
|
141
|
+
@returns {Boolean} whether the object, or any of its prototypes except
|
|
142
|
+
<code>Object.prototype</code>
|
|
143
|
+
@function external:Object.has
|
|
144
|
+
*/
|
|
145
|
+
Object.has = function (object, key) {
|
|
146
|
+
if (typeof object !== "object") {
|
|
147
|
+
throw new Error("Object.has can't accept non-object: " + typeof object);
|
|
148
|
+
}
|
|
149
|
+
// forward to mapped collections that implement "has"
|
|
150
|
+
if (Object.can(object, "has")) {
|
|
151
|
+
return object.has(key);
|
|
152
|
+
// otherwise report whether the key is on the prototype chain,
|
|
153
|
+
// as long as it is not one of the methods on object.prototype
|
|
154
|
+
} else if (typeof key === "string") {
|
|
155
|
+
return key in object && object[key] !== Object.prototype[key];
|
|
156
|
+
} else {
|
|
157
|
+
throw new Error("Key must be a string for Object.has on plain objects");
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
Gets the value for a corresponding key from an object.
|
|
163
|
+
|
|
164
|
+
<p>Uses Object.has to determine whether there is a corresponding value for
|
|
165
|
+
the given key. As such, <code>Object.get</code> is capable of retriving
|
|
166
|
+
values from the prototype chain as long as they are not from the
|
|
167
|
+
<code>Object.prototype</code>.
|
|
168
|
+
|
|
169
|
+
<p>If there is no corresponding value, returns the given default, which may
|
|
170
|
+
be <code>undefined</code>.
|
|
171
|
+
|
|
172
|
+
<p>If the given object is an instance of a type that implements a method
|
|
173
|
+
named "get", this function defers to the collection, so this method can be
|
|
174
|
+
used to generically handle objects, arrays, or other collections. In that
|
|
175
|
+
case, the domain of the key depends on the implementation. For a `Map`,
|
|
176
|
+
for example, the key might be any object.
|
|
177
|
+
|
|
178
|
+
@param {Object} object
|
|
179
|
+
@param {String} key
|
|
180
|
+
@param {Any} value a default to return, <code>undefined</code> if omitted
|
|
181
|
+
@returns {Any} value for key, or default value
|
|
182
|
+
@function external:Object.get
|
|
183
|
+
*/
|
|
184
|
+
Object.get = function (object, key, value) {
|
|
185
|
+
if (typeof object !== "object") {
|
|
186
|
+
throw new Error("Object.get can't accept non-object: " + typeof object);
|
|
187
|
+
}
|
|
188
|
+
// forward to mapped collections that implement "get"
|
|
189
|
+
if (Object.can(object, "get")) {
|
|
190
|
+
return object.get(key, value);
|
|
191
|
+
} else if (Object.has(object, key)) {
|
|
192
|
+
return object[key];
|
|
193
|
+
} else {
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
Sets the value for a given key on an object.
|
|
200
|
+
|
|
201
|
+
<p>If the given object is an instance of a type that implements a method
|
|
202
|
+
named "set", this function defers to the collection, so this method can be
|
|
203
|
+
used to generically handle objects, arrays, or other collections. As such,
|
|
204
|
+
the key domain varies by the object type.
|
|
205
|
+
|
|
206
|
+
@param {Object} object
|
|
207
|
+
@param {String} key
|
|
208
|
+
@param {Any} value
|
|
209
|
+
@returns <code>undefined</code>
|
|
210
|
+
@function external:Object.set
|
|
211
|
+
*/
|
|
212
|
+
Object.set = function (object, key, value) {
|
|
213
|
+
if (Object.can(object, "set")) {
|
|
214
|
+
object.set(key, value);
|
|
215
|
+
} else {
|
|
216
|
+
object[key] = value;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
Object.addEach = function (target, source) {
|
|
221
|
+
if (!source) {
|
|
222
|
+
} else if (Object.can(source, "forEach")) {
|
|
223
|
+
// copy map-alikes
|
|
224
|
+
if (typeof source.keys === "function") {
|
|
225
|
+
source.forEach(function (value, key) {
|
|
226
|
+
target[key] = value;
|
|
227
|
+
});
|
|
228
|
+
// iterate key value pairs of other iterables
|
|
229
|
+
} else {
|
|
230
|
+
source.forEach(function (pair) {
|
|
231
|
+
target[pair[0]] = pair[1];
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
// copy other objects as map-alikes
|
|
236
|
+
Object.keys(source).forEach(function (key) {
|
|
237
|
+
target[key] = source[key];
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return target;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
Iterates over the owned properties of an object.
|
|
245
|
+
|
|
246
|
+
@function external:Object.forEach
|
|
247
|
+
@param {Object} object an object to iterate.
|
|
248
|
+
@param {Function} callback a function to call for every key and value
|
|
249
|
+
pair in the object. Receives <code>value</code>, <code>key</code>,
|
|
250
|
+
and <code>object</code> as arguments.
|
|
251
|
+
@param {Object} thisp the <code>this</code> to pass through to the
|
|
252
|
+
callback
|
|
253
|
+
*/
|
|
254
|
+
Object.forEach = function (object, callback, thisp) {
|
|
255
|
+
Object.keys(object).forEach(function (key) {
|
|
256
|
+
callback.call(thisp, object[key], key, object);
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
Iterates over the owned properties of a map, constructing a new array of
|
|
262
|
+
mapped values.
|
|
263
|
+
|
|
264
|
+
@function external:Object.map
|
|
265
|
+
@param {Object} object an object to iterate.
|
|
266
|
+
@param {Function} callback a function to call for every key and value
|
|
267
|
+
pair in the object. Receives <code>value</code>, <code>key</code>,
|
|
268
|
+
and <code>object</code> as arguments.
|
|
269
|
+
@param {Object} thisp the <code>this</code> to pass through to the
|
|
270
|
+
callback
|
|
271
|
+
@returns {Array} the respective values returned by the callback for each
|
|
272
|
+
item in the object.
|
|
273
|
+
*/
|
|
274
|
+
Object.map = function (object, callback, thisp) {
|
|
275
|
+
return Object.keys(object).map(function (key) {
|
|
276
|
+
return callback.call(thisp, object[key], key, object);
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
Returns the values for owned properties of an object.
|
|
282
|
+
|
|
283
|
+
@function external:Object.map
|
|
284
|
+
@param {Object} object
|
|
285
|
+
@returns {Array} the respective value for each owned property of the
|
|
286
|
+
object.
|
|
287
|
+
*/
|
|
288
|
+
Object.values = function (object) {
|
|
289
|
+
return Object.map(object, Function.identity);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// TODO inline document concat
|
|
293
|
+
Object.concat = function () {
|
|
294
|
+
var object = {};
|
|
295
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
296
|
+
Object.addEach(object, arguments[i]);
|
|
297
|
+
}
|
|
298
|
+
return object;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
Object.from = Object.concat;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
Returns whether two values are identical. Any value is identical to itself
|
|
305
|
+
and only itself. This is much more restictive than equivalence and subtly
|
|
306
|
+
different than strict equality, <code>===</code> because of edge cases
|
|
307
|
+
including negative zero and <code>NaN</code>. Identity is useful for
|
|
308
|
+
resolving collisions among keys in a mapping where the domain is any value.
|
|
309
|
+
This method does not delgate to any method on an object and cannot be
|
|
310
|
+
overridden.
|
|
311
|
+
@see http://wiki.ecmascript.org/doku.php?id=harmony:egal
|
|
312
|
+
@param {Any} this
|
|
313
|
+
@param {Any} that
|
|
314
|
+
@returns {Boolean} whether this and that are identical
|
|
315
|
+
@function external:Object.is
|
|
316
|
+
*/
|
|
317
|
+
Object.is = function (x, y) {
|
|
318
|
+
if (x === y) {
|
|
319
|
+
// 0 === -0, but they are not identical
|
|
320
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
321
|
+
}
|
|
322
|
+
// NaN !== NaN, but they are identical.
|
|
323
|
+
// NaNs are the only non-reflexive value, i.e., if x !== x,
|
|
324
|
+
// then x is a NaN.
|
|
325
|
+
// isNaN is broken: it converts its argument to number, so
|
|
326
|
+
// isNaN("foo") => true
|
|
327
|
+
return x !== x && y !== y;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
Performs a polymorphic, type-sensitive deep equivalence comparison of any
|
|
332
|
+
two values.
|
|
333
|
+
|
|
334
|
+
<p>As a basic principle, any value is equivalent to itself (as in
|
|
335
|
+
identity), any boxed version of itself (as a <code>new Number(10)</code> is
|
|
336
|
+
to 10), and any deep clone of itself.
|
|
337
|
+
|
|
338
|
+
<p>Equivalence has the following properties:
|
|
339
|
+
|
|
340
|
+
<ul>
|
|
341
|
+
<li><strong>polymorphic:</strong>
|
|
342
|
+
If the given object is an instance of a type that implements a
|
|
343
|
+
methods named "equals", this function defers to the method. So,
|
|
344
|
+
this function can safely compare any values regardless of type,
|
|
345
|
+
including undefined, null, numbers, strings, any pair of objects
|
|
346
|
+
where either implements "equals", or object literals that may even
|
|
347
|
+
contain an "equals" key.
|
|
348
|
+
<li><strong>type-sensitive:</strong>
|
|
349
|
+
Incomparable types are not equal. No object is equivalent to any
|
|
350
|
+
array. No string is equal to any other number.
|
|
351
|
+
<li><strong>deep:</strong>
|
|
352
|
+
Collections with equivalent content are equivalent, recursively.
|
|
353
|
+
<li><strong>equivalence:</strong>
|
|
354
|
+
Identical values and objects are equivalent, but so are collections
|
|
355
|
+
that contain equivalent content. Whether order is important varies
|
|
356
|
+
by type. For Arrays and lists, order is important. For Objects,
|
|
357
|
+
maps, and sets, order is not important. Boxed objects are mutally
|
|
358
|
+
equivalent with their unboxed values, by virtue of the standard
|
|
359
|
+
<code>valueOf</code> method.
|
|
360
|
+
</ul>
|
|
361
|
+
@param this
|
|
362
|
+
@param that
|
|
363
|
+
@returns {Boolean} whether the values are deeply equivalent
|
|
364
|
+
@function external:Object.equals
|
|
365
|
+
*/
|
|
366
|
+
Object.equals = function (a, b, equals) {
|
|
367
|
+
equals = equals || Object.equals;
|
|
368
|
+
// unbox objects, but do not confuse object literals
|
|
369
|
+
a = Object.getValueOf(a);
|
|
370
|
+
b = Object.getValueOf(b);
|
|
371
|
+
if (a === b)
|
|
372
|
+
// 0 === -0, but they are not equal
|
|
373
|
+
return a !== 0 || 1 / a === 1 / b;
|
|
374
|
+
if (a === null || b === null)
|
|
375
|
+
return a === b;
|
|
376
|
+
if (Object.can(a, "equals"))
|
|
377
|
+
return a.equals(b, equals);
|
|
378
|
+
// commutative
|
|
379
|
+
if (Object.can(b, "equals"))
|
|
380
|
+
return b.equals(a, equals);
|
|
381
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
382
|
+
var aPrototype = Object.getPrototypeOf(a);
|
|
383
|
+
var bPrototype = Object.getPrototypeOf(b);
|
|
384
|
+
if (
|
|
385
|
+
aPrototype === bPrototype && (
|
|
386
|
+
aPrototype === Object.prototype ||
|
|
387
|
+
aPrototype === null
|
|
388
|
+
)
|
|
389
|
+
) {
|
|
390
|
+
for (var key in a) {
|
|
391
|
+
if (!equals(a[key], b[key])) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
for (var key in b) {
|
|
396
|
+
if (!equals(a[key], b[key])) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// NaN !== NaN, but they are equal.
|
|
404
|
+
// NaNs are the only non-reflexive value, i.e., if x !== x,
|
|
405
|
+
// then x is a NaN.
|
|
406
|
+
// isNaN is broken: it converts its argument to number, so
|
|
407
|
+
// isNaN("foo") => true
|
|
408
|
+
return a !== a && b !== b;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// Because a return value of 0 from a `compare` function may mean either
|
|
412
|
+
// "equals" or "is incomparable", `equals` cannot be defined in terms of
|
|
413
|
+
// `compare`. However, `compare` *can* be defined in terms of `equals` and
|
|
414
|
+
// `lessThan`. Again however, more often it would be desirable to implement
|
|
415
|
+
// all of the comparison functions in terms of compare rather than the other
|
|
416
|
+
// way around.
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
Determines the order in which any two objects should be sorted by returning
|
|
420
|
+
a number that has an analogous relationship to zero as the left value to
|
|
421
|
+
the right. That is, if the left is "less than" the right, the returned
|
|
422
|
+
value will be "less than" zero, where "less than" may be any other
|
|
423
|
+
transitive relationship.
|
|
424
|
+
|
|
425
|
+
<p>Arrays are compared by the first diverging values, or by length.
|
|
426
|
+
|
|
427
|
+
<p>Any two values that are incomparable return zero. As such,
|
|
428
|
+
<code>equals</code> should not be implemented with <code>compare</code>
|
|
429
|
+
since incomparability is indistinguishable from equality.
|
|
430
|
+
|
|
431
|
+
<p>Sorts strings lexicographically. This is not suitable for any
|
|
432
|
+
particular international setting. Different locales sort their phone books
|
|
433
|
+
in very different ways, particularly regarding diacritics and ligatures.
|
|
434
|
+
|
|
435
|
+
<p>If the given object is an instance of a type that implements a method
|
|
436
|
+
named "compare", this function defers to the instance. The method does not
|
|
437
|
+
need to be an owned property to distinguish it from an object literal since
|
|
438
|
+
object literals are incomparable. Unlike <code>Object</code> however,
|
|
439
|
+
<code>Array</code> implements <code>compare</code>.
|
|
440
|
+
|
|
441
|
+
@param {Any} left
|
|
442
|
+
@param {Any} right
|
|
443
|
+
@returns {Number} a value having the same transitive relationship to zero
|
|
444
|
+
as the left and right values.
|
|
445
|
+
@function external:Object.compare
|
|
446
|
+
*/
|
|
447
|
+
Object.compare = function (a, b) {
|
|
448
|
+
// unbox objects, but do not confuse object literals
|
|
449
|
+
// mercifully handles the Date case
|
|
450
|
+
a = Object.getValueOf(a);
|
|
451
|
+
b = Object.getValueOf(b);
|
|
452
|
+
var aType = typeof a;
|
|
453
|
+
var bType = typeof b;
|
|
454
|
+
if (a === b)
|
|
455
|
+
return 0;
|
|
456
|
+
if (aType !== bType)
|
|
457
|
+
return 0;
|
|
458
|
+
if (aType === "number")
|
|
459
|
+
return a - b;
|
|
460
|
+
if (aType === "string")
|
|
461
|
+
return a < b ? -1 : 1;
|
|
462
|
+
// the possibility of equality elimiated above
|
|
463
|
+
if (Object.can(a, "compare"))
|
|
464
|
+
return a.compare(b);
|
|
465
|
+
// not commutative, the relationship is reversed
|
|
466
|
+
if (Object.can(b, "compare"))
|
|
467
|
+
return -b.compare(a);
|
|
468
|
+
return 0;
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
Creates a deep copy of any value. Values, being immutable, are
|
|
473
|
+
returned without alternation. Forwards to <code>clone</code> on
|
|
474
|
+
objects and arrays.
|
|
475
|
+
|
|
476
|
+
@function external:Object.clone
|
|
477
|
+
@param {Any} value a value to clone
|
|
478
|
+
@param {Number} depth an optional traversal depth, defaults to infinity.
|
|
479
|
+
A value of <code>0</code> means to make no clone and return the value
|
|
480
|
+
directly.
|
|
481
|
+
@param {Map} memo an optional memo of already visited objects to preserve
|
|
482
|
+
reference cycles. The cloned object will have the exact same shape as the
|
|
483
|
+
original, but no identical objects. Te map may be later used to associate
|
|
484
|
+
all objects in the original object graph with their corresponding member of
|
|
485
|
+
the cloned graph.
|
|
486
|
+
@returns a copy of the value
|
|
487
|
+
*/
|
|
488
|
+
Object.clone = function (value, depth, memo) {
|
|
489
|
+
value = Object.getValueOf(value);
|
|
490
|
+
memo = memo || new WeakMap();
|
|
491
|
+
if (depth === undefined) {
|
|
492
|
+
depth = Infinity;
|
|
493
|
+
} else if (depth === 0) {
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
496
|
+
if (Object.isObject(value)) {
|
|
497
|
+
if (!memo.has(value)) {
|
|
498
|
+
if (Object.can(value, "clone")) {
|
|
499
|
+
memo.set(value, value.clone(depth, memo));
|
|
500
|
+
} else {
|
|
501
|
+
var prototype = Object.getPrototypeOf(value);
|
|
502
|
+
if (prototype === null || prototype === Object.prototype) {
|
|
503
|
+
var clone = Object.create(prototype);
|
|
504
|
+
memo.set(value, clone);
|
|
505
|
+
for (var key in value) {
|
|
506
|
+
clone[key] = Object.clone(value[key], depth - 1, memo);
|
|
507
|
+
}
|
|
508
|
+
} else {
|
|
509
|
+
throw new Error("Can't clone " + value);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return memo.get(value);
|
|
514
|
+
}
|
|
515
|
+
return value;
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
Removes all properties owned by this object making the object suitable for
|
|
520
|
+
reuse.
|
|
521
|
+
|
|
522
|
+
@function external:Object.clear
|
|
523
|
+
@returns this
|
|
524
|
+
*/
|
|
525
|
+
Object.clear = function (object) {
|
|
526
|
+
if (Object.can(object, "clear")) {
|
|
527
|
+
object.clear();
|
|
528
|
+
} else {
|
|
529
|
+
var keys = Object.keys(object),
|
|
530
|
+
i = keys.length;
|
|
531
|
+
while (i) {
|
|
532
|
+
i--;
|
|
533
|
+
delete object[keys[i]];
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return object;
|
|
537
|
+
};
|
|
538
|
+
|