traceur-rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +87 -0
  10. data/Rakefile +2 -0
  11. data/lib/js/compile.js +31 -0
  12. data/lib/traceur-rb.rb +1 -0
  13. data/lib/traceur.rb +43 -0
  14. data/lib/traceur/compilation_options.rb +65 -0
  15. data/lib/traceur/compiler.rb +33 -0
  16. data/lib/traceur/configuration.rb +47 -0
  17. data/lib/traceur/node.rb +26 -0
  18. data/lib/traceur/node/command_result.rb +28 -0
  19. data/lib/traceur/node/runner.rb +40 -0
  20. data/lib/traceur/version.rb +3 -0
  21. data/spec/examples/classes.js +12 -0
  22. data/spec/integration/examples_spec.rb +28 -0
  23. data/spec/spec_helper.rb +1 -0
  24. data/spec/traceur/compilation_options_spec.rb +31 -0
  25. data/spec/traceur/configuration_spec.rb +54 -0
  26. data/spec/traceur/node_spec.rb +15 -0
  27. data/traceur-rb.gemspec +25 -0
  28. data/vendor/node_modules/.bin/traceur +3 -0
  29. data/vendor/node_modules/traceur/README.md +40 -0
  30. data/vendor/node_modules/traceur/bin/traceur-runtime.js +2101 -0
  31. data/vendor/node_modules/traceur/bin/traceur.js +23034 -0
  32. data/vendor/node_modules/traceur/node_modules/.bin/semver +125 -0
  33. data/vendor/node_modules/traceur/node_modules/commander/Readme.md +208 -0
  34. data/vendor/node_modules/traceur/node_modules/commander/index.js +852 -0
  35. data/vendor/node_modules/traceur/node_modules/commander/package.json +40 -0
  36. data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +1 -0
  37. data/vendor/node_modules/traceur/node_modules/q-io/.travis.yml +3 -0
  38. data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +122 -0
  39. data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +19 -0
  40. data/vendor/node_modules/traceur/node_modules/q-io/README.md +928 -0
  41. data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +59 -0
  42. data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +44 -0
  43. data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +51 -0
  44. data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +307 -0
  45. data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +499 -0
  46. data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +547 -0
  47. data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +105 -0
  48. data/vendor/node_modules/traceur/node_modules/q-io/fs.js +355 -0
  49. data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +65 -0
  50. data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +152 -0
  51. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +24 -0
  52. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +93 -0
  53. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +154 -0
  54. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +178 -0
  55. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +417 -0
  56. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +58 -0
  57. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +78 -0
  58. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +120 -0
  59. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +27 -0
  60. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +209 -0
  61. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +125 -0
  62. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +175 -0
  63. data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +75 -0
  64. data/vendor/node_modules/traceur/node_modules/q-io/http.js +378 -0
  65. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +11 -0
  66. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.travis.yml +4 -0
  67. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +78 -0
  68. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +21 -0
  69. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +1285 -0
  70. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +22 -0
  71. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +142 -0
  72. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +57 -0
  73. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +183 -0
  74. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +261 -0
  75. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +186 -0
  76. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +55 -0
  77. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +59 -0
  78. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +236 -0
  79. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +371 -0
  80. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +435 -0
  81. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +247 -0
  82. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +147 -0
  83. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +448 -0
  84. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +139 -0
  85. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +79 -0
  86. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +142 -0
  87. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +60 -0
  88. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +41 -0
  89. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +12 -0
  90. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +7 -0
  91. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +48 -0
  92. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +590 -0
  93. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +49 -0
  94. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +173 -0
  95. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +274 -0
  96. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +59 -0
  97. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +538 -0
  98. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +14 -0
  99. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +6 -0
  100. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +49 -0
  101. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +51 -0
  102. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +269 -0
  103. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +61 -0
  104. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +736 -0
  105. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +40 -0
  106. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +1 -0
  107. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/LICENSE +19 -0
  108. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +66 -0
  109. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +114 -0
  110. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +35 -0
  111. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +84 -0
  112. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +1588 -0
  113. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +77 -0
  114. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +15 -0
  115. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +19 -0
  116. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +96 -0
  117. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +166 -0
  118. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +43 -0
  119. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +40 -0
  120. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +19 -0
  121. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +813 -0
  122. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +71 -0
  123. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +36 -0
  124. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +93 -0
  125. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +1937 -0
  126. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +35 -0
  127. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +6 -0
  128. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +36 -0
  129. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +7 -0
  130. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +38 -0
  131. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +32 -0
  132. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +39 -0
  133. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +2 -0
  134. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +123 -0
  135. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +19 -0
  136. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +3 -0
  137. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +3 -0
  138. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +128 -0
  139. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +53 -0
  140. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +61 -0
  141. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +856 -0
  142. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +1080 -0
  143. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +377 -0
  144. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +290 -0
  145. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
  146. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
  147. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +4 -0
  148. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +16 -0
  149. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +12 -0
  150. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +91 -0
  151. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +12 -0
  152. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +13 -0
  153. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +14 -0
  154. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +146 -0
  155. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
  156. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
  157. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +3 -0
  158. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +22 -0
  159. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +6 -0
  160. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +248 -0
  161. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +53 -0
  162. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +2 -0
  163. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +91 -0
  164. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +548 -0
  165. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +8 -0
  166. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +358 -0
  167. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +133 -0
  168. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +3 -0
  169. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.travis.yml +4 -0
  170. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +20 -0
  171. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +33 -0
  172. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +37 -0
  173. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +125 -0
  174. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +151 -0
  175. data/vendor/node_modules/traceur/node_modules/q-io/package.json +51 -0
  176. data/vendor/node_modules/traceur/node_modules/q-io/reader.js +133 -0
  177. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +47 -0
  178. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +11 -0
  179. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +1 -0
  180. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +33 -0
  181. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +92 -0
  182. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +41 -0
  183. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +57 -0
  184. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +1 -0
  185. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +70 -0
  186. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +109 -0
  187. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +67 -0
  188. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +219 -0
  189. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +20 -0
  190. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +26 -0
  191. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +40 -0
  192. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +37 -0
  193. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +39 -0
  194. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +32 -0
  195. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +26 -0
  196. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +86 -0
  197. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +31 -0
  198. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +73 -0
  199. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +23 -0
  200. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +1 -0
  201. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +22 -0
  202. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +25 -0
  203. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +45 -0
  204. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +38 -0
  205. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +52 -0
  206. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +86 -0
  207. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +1 -0
  208. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +1 -0
  209. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
  210. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
  211. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +49 -0
  212. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +47 -0
  213. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +186 -0
  214. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +82 -0
  215. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +110 -0
  216. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +96 -0
  217. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +96 -0
  218. data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +42 -0
  219. data/vendor/node_modules/traceur/node_modules/q-io/writer.js +111 -0
  220. data/vendor/node_modules/traceur/node_modules/semver/.npmignore +1 -0
  221. data/vendor/node_modules/traceur/node_modules/semver/LICENSE +27 -0
  222. data/vendor/node_modules/traceur/node_modules/semver/Makefile +24 -0
  223. data/vendor/node_modules/traceur/node_modules/semver/README.md +158 -0
  224. data/vendor/node_modules/traceur/node_modules/semver/bin/semver +125 -0
  225. data/vendor/node_modules/traceur/node_modules/semver/foot.js +6 -0
  226. data/vendor/node_modules/traceur/node_modules/semver/head.js +2 -0
  227. data/vendor/node_modules/traceur/node_modules/semver/package.json +31 -0
  228. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +1039 -0
  229. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
  230. data/vendor/node_modules/traceur/node_modules/semver/semver.js +1043 -0
  231. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -0
  232. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
  233. data/vendor/node_modules/traceur/node_modules/semver/test/amd.js +15 -0
  234. data/vendor/node_modules/traceur/node_modules/semver/test/gtr.js +173 -0
  235. data/vendor/node_modules/traceur/node_modules/semver/test/index.js +584 -0
  236. data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +174 -0
  237. data/vendor/node_modules/traceur/node_modules/semver/test/no-module.js +19 -0
  238. data/vendor/node_modules/traceur/package.json +64 -0
  239. data/vendor/node_modules/traceur/src/node/System.js +31 -0
  240. data/vendor/node_modules/traceur/src/node/api.js +124 -0
  241. data/vendor/node_modules/traceur/src/node/command.js +141 -0
  242. data/vendor/node_modules/traceur/src/node/compile-single-file.js +69 -0
  243. data/vendor/node_modules/traceur/src/node/compiler.js +116 -0
  244. data/vendor/node_modules/traceur/src/node/deferred.js +110 -0
  245. data/vendor/node_modules/traceur/src/node/file-util.js +73 -0
  246. data/vendor/node_modules/traceur/src/node/getopt.js +147 -0
  247. data/vendor/node_modules/traceur/src/node/inline-module.js +149 -0
  248. data/vendor/node_modules/traceur/src/node/interpreter.js +33 -0
  249. data/vendor/node_modules/traceur/src/node/nodeLoader.js +41 -0
  250. data/vendor/node_modules/traceur/src/node/require.js +85 -0
  251. data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +33 -0
  252. data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +33 -0
  253. data/vendor/node_modules/traceur/src/node/traceur.js +32 -0
  254. data/vendor/node_modules/traceur/traceur +3 -0
  255. metadata +359 -0
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "collections",
3
+ "version": "0.2.2",
4
+ "description": "data structures with idiomatic JavaScript collection interfaces",
5
+ "homepage": "http://github.com/montagejs/collections",
6
+ "author": {
7
+ "name": "Kris Kowal",
8
+ "email": "kris@cixar.com",
9
+ "url": "http://github.com/kriskowal"
10
+ },
11
+ "keywords": [
12
+ "collections",
13
+ "data structures",
14
+ "observable",
15
+ "list",
16
+ "set",
17
+ "map",
18
+ "splay"
19
+ ],
20
+ "bugs": {
21
+ "url": "http://github.com/montagejs/collections/issues"
22
+ },
23
+ "licenses": [
24
+ {
25
+ "type": "MIT",
26
+ "url": "https://raw.github.com/montagejs/collections/master/LICENSE.md"
27
+ }
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "http://github.com/montagejs/collections.git"
32
+ },
33
+ "dependencies": {
34
+ "weak-map": "1.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "jasmine-node": "*",
38
+ "istanbul": "*",
39
+ "opener": "*"
40
+ },
41
+ "scripts": {
42
+ "test": "jasmine-node spec",
43
+ "cover": "istanbul cover node_modules/jasmine-node/bin/jasmine-node spec && istanbul report html && opener coverage/index.html"
44
+ },
45
+ "readme": "[![Build Status](https://travis-ci.org/montagejs/collections.png?branch=master)](http://travis-ci.org/montagejs/collections)\n\n# Collections\n\nThis package contains JavaScript implementations of common data\nstructures with idiomatic iterfaces, including extensions for Array and\nObject.\n\nYou can use these Node Packaged Modules with Node.js, [Browserify][],\n[Mr][], or any compatible CommonJS module loader. Using a module loader\nor bundler when using Collections in web browsers has the advantage of\nonly incorporating the modules you need. However, you can just embed\n`<script src=\"collections/collections.min.js\">` and *all* of the\ncollections will be introduced as globals. :warning:\n`require(\"collections\")` is not supported.\n\n```\nnpm install collections --save\n```\n\n[Browserify]: https://github.com/substack/node-browserify\n[Mr]: https://github.com/montagejs/mr\n\n\n## Collections\n\n### List(values, equals, getDefault)\n\n```javascript\nvar List = require(\"collections/list\");\n```\n\nAn ordered collection of values with fast insertion and deletion and\nforward and backward traversal, backed by a cyclic doubly linked\nlist with a head node. Lists support most of the Array interface,\nexcept that they use and return nodes instead of integer indicies in\nanalogous functions.\n\nLists have a `head` `Node`. The node type is available as `Node` on\nthe list prototype and can be overridden by inheritors. Each node\nhas `prev` and `next` properties.\n\n### Set(values, equals, hash, getDefault)\n\n```javascript\nvar Set = require(\"collections/set\");\n```\n\nA collection of unique values. The set can be iterated in the order\nof insertion. With a good hash function for the stored values,\ninsertion and removal are fast regardless of the size of the\ncollection. Values may be objects. The `equals` and `hash`\nfunctions can be overridden to provide alternate definitions of\n\"unique\". `Set` is backed by `FastSet` and `List`.\n\n### Map(map, equals, hash, getDefault)\n\n```javascript\nvar Map = require(\"collections/map\");\n```\n\nA collection of key and value entries with unique keys. Keys may be\nobjects. The collection iterates in the order of insertion. `Map`\nis backed by `Set`.\n\n### MultiMap(map, getDefault, equals, hash)\n\n```javascript\nvar MultiMap = require(\"collections/multi-map\");\n```\n\nA collection of keys mapped to collections of values. The default\n`getDefault` collection is an `Array`, but it can be a `List` or any\nother array-like object. `MultiMap` inherits `Map` but overrides\nthe `getDefault(key)` provider.\n\n### WeakMap()\n\n```javascript\nvar WeakMap = require(\"collections/weak-map\");\n```\n\nA non-iterable collection of key value pairs. Keys must objects and\ndo not benefit from `hash` functions. Some engines already\nimplement `WeakMap`. The non-iterable requirement makes it possible\nfor weak maps to collect garbage when the key is no longer\navailable, without betraying when the key is collected. The shimmed\nimplementation undetectably annotates the given key and thus does\nnot necessarily leak memory, but cannot collect certain reference\ngraphs. This WeakMap shim was implemented by Mark Miller of Google.\n\n### SortedSet(values, equals, compare, getDefault)\n\n```javascript\nvar SortedSet = require(\"collections/sorted-set\");\n```\n\nA collection of unique values stored in stored order, backed by a\nsplay tree. The `equals` and `compare` functions can be overridden\nto provide alternate definitions of \"unique\".\n\nThe `compare` method *must* provide a total order of all unique\nvalues. That is, if `compare(a, b) === 0`, it *must* follow that\n`equals(a, b)`.\n\n### SortedMap(map, equals, compare, getDefault)\n\n```javascript\nvar SortedMap = require(\"collections/sorted-map\");\n```\n\nA collection of key value pairs stored in sorted order. `SortedMap`\nis backed by `SortedSet` and the `GenericMap` mixin.\n\n### LruSet(values, maxLength, equals, hash, getDefault)\n\n```javascript\nvar LruSet = require(\"collections/lru-set\");\n```\n\nA cache with the Least-Recently-Used strategy for truncating its\ncontent when it’s length exceeds `maxLength`. `LruSet` is backed by\na `Set` and takes advantage of the already tracked insertion order.\nBoth getting and setting a value constitute usage, but checking\nwhether the set has a value and iterating values do not.\n\n### LruMap(map, maxLength, equals, hash, getDefault)\n\n```javascript\nvar LruMap = require(\"collections/lru-map\");\n```\n\nA cache of entries backed by an `LruSet`.\n\n### SortedArray(values, equals, compare, getDefault)\n\n```javascript\nvar SortedArray = require(\"collections/sorted-array\");\n```\n\nA collection of values stored in a stable sorted order, backed by an\narray.\n\n### SortedArraySet(values, equals, compare, getDefault)\n\n```javascript\nvar SortedArraySet = require(\"collections/sorted-array-set\");\n```\n\nA collection of unique values stored in sorted order, backed by a\nplain array. If the given values are an actual array, the sorted\narray set takes ownership of that array and retains its content. A\nsorted array set performs better than a sorted set when it has\nroughly less than 100 values.\n\n### SortedArrayMap(values, equals, compare, getDefault)\n\n```javascript\nvar SortedArrayMap = require(\"collections/sorted-array-map\");\n```\n\nA collection of key value pairs stored in sorted order, backed by a\nsorted array set.\n\n### FastSet(values, equals, hash, getDefault)\n\n```javascript\nvar FastSet = require(\"collections/fast-set\");\n```\n\nA collection of unique values stored like a hash table. The\nunderlying storage is a `Dict` that maps hashes to lists of values\nthat share the same hash. Values may be objects. The `equals` and\n`hash` functions can be overridden to provide alternate definitions\nof \"unique\".\n\n### FastMap(map, equals, hash, getDefault)\n\n```javascript\nvar FastMap = require(\"collections/fast-map\");\n```\n\nA collection of key and value entries with unique keys, backed by a\nset. Keys may be objects. `FastMap` is backed by `FastSet` and the\n`GenericMap` mixin.\n\n### Dict(values, getDefault)\n\n```javascript\nvar Dict = require(\"collections/dict\");\n```\n\nA collection of string to value mappings backed by a plain\nJavaScript object. The keys are mangled to prevent collisions with\nJavaScript properties.\n\n### Heap(values, equals, compare)\n\n```javascript\nvar Heap = require(\"collections/heap\");\n```\n\nA collection that can always quickly (constant time) report its\nlargest value, with reasonable performance for incremental changes\n(logarithmic), using a contiguous array as its backing storage.\nHowever, it does not track the sorted order of its elements.\n\n### Iterator(iterable)\n\n```javascript\nvar Iterator = require(\"collections/iterator\");\n```\n\nA wrapper for any iterable that implements `iterate` or iterator the\nimplements `next`, providing a rich lazy traversal interface.\n\n### Array\n\n```javascript\nrequire(\"collections/shim-array\");\n```\n\nAn ordered collection of values with fast random access, push, and\npop, but slow splice. The `array` module provides extensions so it\nhosts all the expressiveness of other collections. The `shim-array`\nmodule shims EcmaScript 5 methods onto the array prototype if they\nare not natively implemented.\n\n### Object\n\n```javascript\nrequire(\"collections/shim-object\");\n```\n\nCan be used as a mapping of owned string keys to arbitrary values.\nThe `object` module provides extensions for the `Object` constructor\nthat support the map collection interface and can delegate to\nmethods of collections, allowing them to gracefully handle both\nobject literals and collections.\n\n## Constructor Arguments\n\nFor all of these constructors, the argument `values` is an optional\ncollection of initial values, and may be an array. If the `values` are\nin a map collection, the the values are taken, but the keys are ignored.\n\n### map\n\nThe `map` argument is an optional collection to copy shallowly into\nthe new mapping. The `map` may be an object literal. If `map`\nimplements `keys`, it is treated as a mapping itself and copied.\nOtherwise, if `map` implements `forEach`, it may be any collection\nof `[key, value]` pairs.\n\n`equals(x, y)`, `compare(x, y)`, and `hash(value)` are all optional\narguments overriding the meaning of equality, comparability, and\nconsistent hashing for the purposes of the collection. `equals` must\nreturn a boolean. `compare` must return an integer with the same\nrelationship to zero as x to y. `hash` should consistently return the\nsame string for any given object.\n\n### equals(x, y)\n\nThe default `equals` operator is implemented in terms of `===`, but\ntreats `NaN` as equal to itself and `-0` as distinct from `+0`. It\nalso delegates to an `equals` method of either the left or right\nargument if one exists. The default equality operator is shimmed as\n`Object.equals`.\n\n### compare(x, y)\n\nThe default `compare` operator is implemented in terms of `<` and\n`>`. It delegates to the `compare` method of either the left or\nright argument if one exists. It inverts the result if it uses the\nfalls to the right argument. The default comparator is shimmed as\n`Object.compare`.\n\n### hash(value)\n\nThe default `hash` operator uses `toString` for values and provides\na [Unique Label][] for arbitrary objects. The default hash is\nshimmed as `Object.hash`.\n\n[Unique Label]: (http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps#unique_labeler)\n\n### getDefault(key or value)\n\nThe default `getDefault` function is `Function.noop`, which returns\n`undefined`. The fallback function is used when you `get` a\nnonexistant value from any collection. The `getDefault` function\nbecomes a member of the collection object, so `getDefault` is called\nwith the collection as `this`, so you can also use it to guarantee\nthat default values in a collection are retained, as in `MultiMap`.\n\n\n## Collection Methods\n\nWhere these methods coincide with the specification of an existing\nmethod of Array, Array is noted as an implementation. `Array+` refers\nto shimmed arrays, as installed with the `array` module. `Object`\nrefers to methods implemented on the `Object` constructor function, as\nopposed to the `Object.prototype`. `Object+` in turn refers to methods\nshimmed on the object constructor by the `object` module. These\nfunctions accept the object as the first argument instead of the `this`\nimplied argument. ~~Strikethrough~~ indicates an implementation that\nshould exist but has not yet been made (Send a pull request!).\n\nThese are all of the collections:\n\n(Array, Array+, Object+, Iterator, List, Set, Map, MultiMap, WeakMap,\nSortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict)\n\n### has\n\n#### has(key)\n\nWhether a value for the given key exists.\n\n(Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,\nDict)\n\n#### has(value, opt_equals)\n\nWhether a value exists in this collection. This is slow for list\n(linear), but fast (logarithmic) for SortedSet and SortedArraySet,\nand very fast (constant) for Set.\n\n(Array+, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,\nFastSet)\n\n### get\n\n#### get(key or index)\n\nThe value for a key. If a Map or SortedMap lacks a key, returns\n`getDefault(key)`.\n\n(Array+, Map, SortedMap, SortedArrayMap, WeakMap, Object+)\n\n#### get(value)\n\nGets the equivalent value, or falls back to `getDefault(value)`.\n\n(List, Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet)\n\n### set(key or index, value)\n\nSets the value for a key.\n\n(Map, MultiMap, WeakMap, SortedMap, LruMap, SortedArrayMap, FastMap,\nDict)\n\n### add\n\n#### add(value)\n\nAdds a value. Ignores the operation and returns false if an\nequivalent value already exists.\n\n(Array+, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,\nFastSet, Heap)\n\n#### add(value, key)\n\nAliases `set(key, value)`, to assist generic methods used for maps,\nsets, and other collections.\n\n### addEach\n\n#### addEach(values)\n\nCopies values from another collection to this one.\n\n(Array+, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,\nFastSet, Heap)\n\n#### addEach(mapping)\n\nCopies entries from another collection to this map. If the mapping\nimplements `keys` (indicating that it is a mapping) and `forEach`,\nall of the key value pairs are copied. If the mapping only\nimplements `forEach`, it is assumed to contain `[key, value]` arrays\nwhich are copied instead.\n\n(Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,\nDict)\n\n### delete\n\n#### delete(key)\n\nDeletes the value for a given key. Returns whether the key was\nfound.\n\n(Map, MultiMap, WeakMap, SortedMap, LruMap, SortedArrayMap, FastMap,\nDict)\n\n#### delete(value)\n\nDeletes a value. Returns whether the value was found.\n\n(Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet, Heap)\n\n#### delete(value, equals)\n\nDeletes the equivalent value. Returns whether the value was found.\n\n(Array+, List)\n\n### deleteEach(values or keys)\n\nDeletes every value or every value for each key.\n\n(Array+, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### indexOf(value)\n\nReturns the position in the collection of a value, or `-1` if it is\nnot found. Returns the position of the first of equivalent values.\nFor an Array this takes linear time. For a SortedArray and\nSortedArraySet, it takes logarithmic time to perform a binary\nsearch. For a SortedSet, this takes ammortized logarithmic time\nsince it incrementally updates the number of nodes under each\nsubtree as it rotates.\n\n(Array, ~~List~~, SortedSet, SortedArray, SortedArraySet)\n\n### lastIndexOf(value)\n\nReturns the position in the collection of a value, or `-1` if it is\nnot found. Returns the position of the last of equivalent values.\n\n(Array, ~~List~~, SortedArray, SortedArraySet)\n\n### find(value, opt_equals)\n\nFinds a value. For List and SortedSet, returns the node at which\nthe value was found. For SortedSet, the optional `equals` argument\nis ignored.\n\n(Array+, List, SortedSet)\n\n### findLast(value, opt_equals)\n\nFinds the last equivalent value, returning the node at which the\nvalue was found.\n\n(Array+, List, SortedArray, SortedArraySet)\n\n### findLeast()\n\nFinds the smallest value, returning the node at which it was found,\nor undefined. This is fast (logarithmic) and performs no rotations.\n\n(SortedSet)\n\n### findLeastGreaterThan(value)\n\nFinds the smallest value greater than the given value. This is fast\n(logarithic) but does cause rotations.\n\n(SortedSet)\n\n### findLeastGreaterThanOrEqual(value)\n\nFinds the smallest value greater than or equal to the given value.\nThis is fast (logarithmic) but does cause rotations.\n\n(SortedSet)\n\n### findGreatest()\n\n(SortedSet)\n\n### findGreatestLessThan(value)\n\n(SortedSet)\n\n### findGreatestLessThanOrEqual(value)\n\n(SortedSet)\n\n### push\n\n#### push(...values)\n\nAdds values to the end of a collection.\n\n(Array, List)\n\n#### push(...values) for non-dequeues\n\nAdds values to their proper places in a collection.\nThis method exists only to have the same interface as other\ncollections.\n\n(Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet, Heap)\n\n### unshift\n\n#### unshift(...values)\n\nAdds values to the beginning of a collection.\n\n(Array, List)\n\n#### unshift(...values) for non-dequeues\n\nAdds values to their proper places in a collection.\nThis method exists only to have the same interface as other\ncollections.\n\n(Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet)\n\n### pop()\n\nRemoves and returns the value at the end of a collection. For a\nHeap, this means the greatest contained value, as defined by the\ncomparator.\n\n(Array, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,\nHeap)\n\n### shift()\n\nRemoves and returns the value at the beginning of a collection.\n\n(Array, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet)\n\n### peek()\n\nReturns the last value in an ordered collection.\n\n(List)\n\n### poke(value)\n\nReplaces the last value in an ordered collection.\n\n(List)\n\n### slice(start, end)\n\nReturns an array of the values contained in the\nhalf-open interval [start, end), that is, including the start and\nexcluding the end. For lists and arrays, both terms may be numeric\npositive or negative indicies. For a list, either term may be a\nnode.\n\n(Array, List, SortedSet, SortedArray, SortedArraySet)\n\n### splice(start, length, ...values)\n\nWorks as with an array, but for a list, the start may be an index or\na node.\n\n(Array, List, SortedArray, SortedSet, SortedArraySet)\n\n### swap(start, length, values)\n\nPerforms a splice without variadic arguments.\n\n(Array+, List, SortedArray, SortedSet, SortedArraySet)\n\n### clear()\n\nDeletes the all values.\n\n(Array+, Object+, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### sort(compare)\n\nSorts a collection in place. The comparator by only be a function.\nThe default comparator coerces unlike types rather than fail to\ncompare.\n\n(Array)\n\n### sorted(compare, by, order)\n\nReturns a collection as an array in sorted order. Accepts an\noptional `compare(x, y)` function, `by(property(x))` function, and\n`order` indicator, `-1` for descending, `1` for ascending, `0` for\nstable.\n\nInstead of a `compare` function, the comparator can be an object\nwith `compare` and `by` functions. The default `compare` value is\n`Object.compare`.\n\nThe `by` function must be a function that accepts a value from the\ncollection and returns a representative value on which to sort.\n\n(Array+, List, Set, Map, SortedSet, LruSet, SortedArray,\nSortedArraySet, FastSet, Heap)\n\n### group(callback, thisp, equals)\n\nReturns an array of [key, equivalence class] pairs where every\nelement from the collection is placed into an equivalence class\nif they have the same corresponding return value from the given\ncallback.\n\n(Array+, Object+, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap, Iterator)\n\n### reverse()\n\nReverses a collection in place.\n\n(Array, List)\n\n### reversed()\n\nReturns a collection of the same type with this collection's\ncontents in reverse order.\n\n(Array, List)\n\n### enumerate(start=0)\n\nReturns an array of [index, value] pairs from the source collection,\nstarting with the given index.\n\n### join(delimiter=\"\")\n\nReturns a string of all the values in the collection joined.\n\n(Array, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,\nFastSet, Heap, Iterator)\n\n### concat(...iterables)\n\nProduces a new collection of the same type containing all the values\nof itself and the values of any number of other collections. Favors\nthe last of duplicate values. For map-like objects, the given\niterables are treated as map-like objects and each successively\nupdates the result. Array is like a map from index to value. List,\nSet, and SortedSet are like maps from nodes to values.\n\n(Array, ~~Object+~~, Iterator, List, Set, Map, MultiMap,\nSortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### keys()\n\nReturns an array of the keys.\n\n(Object, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,\nDict)\n\n### values()\n\nReturns an array of the values\n\n(Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,\nDict)\n\n### entries()\n\nReturns an array of `[key, value]` pairs for each entry.\n\n(Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,\nDict)\n\n### reduce(callback(result, value, key, object, depth), basis, thisp)\n\n(Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### reduceRight(callback(result, value, key, object, depth), basis, thisp)\n\n(Array, List, SortedSet, ~~SortedMap~~, SortedArray, SortedArraySet,\n~~SortedArrayMap~~, Heap)\n\n### forEach(callback(value, key, object, depth), thisp)\n\nCalls the callback for each value in the collection. The iteration\nof lists is resilient to changes to the list. Particularly, nodes\nadded after the current node will be visited and nodes added before\nthe current node will be ignored, and no node will be visited twice.\n\n(Array, Object+, Iterator, List, Set, Map, MultiMap, WeakMap,\nSortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### map(callback(value, key, object, depth), thisp)\n\n(Array, Object+, Iterator, List, Set, Map, MultiMap, WeakMap,\nSortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### toArray()\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### toObject()\n\nConverts any collection to an object, treating this collection as a\nmap-like object. Array is like a map from index to value.\n\n(Array+ Iterator, List, Map, MultiMap, SortedMap, LruMap,\nSortedArrayMap, FastMap, Dict, Heap)\n\n### filter(callback(value, key, object, depth), thisp)\n\n(Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### every(callback(value, key, object, depth), thisp)\n\nWhether every value passes a given guard. Stops evaluating the\nguard after the first failure. Iterators stop consuming after the\nthe first failure.\n\n(Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### some(callback(value, key, object, depth), thisp)\n\nWhether there is a value that passes a given guard. Stops\nevaluating the guard after the first success. Iterators stop\nconsuming after the first success.\n\n(Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### any()\n\nWhether any value is truthy.\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### all()\n\nWhether all values are truthy.\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### min()\n\nThe smallest value. This is fast for sorted collections (logarithic\nfor SortedSet, constant for SortedArray, SortedArraySet, and\nSortedArrayMap), but slow for everything else (linear).\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict)\n\n### max()\n\nThe largest value. This is fast for sorted collections (logarithic\nfor SortedSet, constant for SortedArray, SortedArraySet, and\nSortedArrayMap), but slow for everything else (linear).\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### one()\n\nAny single value, or throws an exception if there are no values. This\nis very fast (constant time) for most collections. For a sorted set,\n`set.root.value` is always very fast to access, but changes whenever you\n*access* a value, including using `has` or `find`. In the interest of\nbeing consistent across accesses, and only changing in response to\nmutation, `one` returns the `min` of the set in logarithmic time.\n\n(Array+, List, Set, Map, MultiMap, SortedSet, SortedMap, LruSet,\nLruMap, SortedArray, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### only()\n\nThe one and only value, or throws an exception if there are no\nvalues or more than one value.\n\n(Array+, List, Set, Map, MultiMap, SortedSet, SortedMap, LruSet,\nLruMap, SortedArray, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### sum()\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict)\n\n### average()\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict)\n\n### flatten()\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### zip(...collections)\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### enumrate(zero)\n\n(Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict, Heap)\n\n### clone(depth, memo)\n\nReplicates the collection. Clones the values deeply, to the\nspecified depth, using the memo to resolve reference cycles. (which\nmust the `has` and `set` parts of the Map interface, allowing\nobjects for keys) The default depth is infinite and the default\nmemo is a WeakMap.\n\n`Object.clone` can replicate object literals inheriting directly\nfrom `Object.prototype` or `null`, or any object that implements\n`clone` on its prototype. Any other object causes `clone` to throw\nan exception.\n\nThe `clone` method on any other objects is not intended to be used\ndirectly since they do not necessarily supply a default depth and\nmemo.\n\n(Array+, Object+, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### constructClone(values)\n\nReplicates a collection shallowly. This is used by each `clone`\nimplementation to create a new collection of the same type, with the\nsame options (`equals`, `compare`, `hash` options), but it leaves\nthe job of deeply cloning the values to the more general `clone`\nmethod.\n\n(Array+, Object+, List, Set, Map, MultiMap, SortedSet,\nSortedMap, LruSet, LruMap, SortedArray, SortedArraySet,\nSortedArrayMap, FastSet, FastMap, Dict, Heap)\n\n### equals(that, equals)\n\n(Array+, Object+, List, Set, Map, MultiMap, SortedSet, SortedMap,\nLruSet, LruMap, ~~SortedArray~~, SortedArraySet, SortedArrayMap,\nFastSet, FastMap, Dict)\n\n### compare(that)\n\n(Array+, Object+, List, ~~SortedArray~~, ~~SortedArraySet~~)\n\n### iterate\n\n#### iterate()\n\nProduces an iterator with a `next` method. You may elect to get\nricher iterators by wrapping this iterator with an `Iterator` from\nthe `iterator` module. Iteration order of lists is resilient to\nchanges to the list.\n\n(Array+, Iterator, List, Set, SortedSet, LruSet, SortedArray,\nSortedArraySet, FastSet)\n\n#### iterate(start, end)\n\nReturns an iterator for all values at indicies in the half-open\ninterval [start, end), that is, greater than start, and less than\nend.\n\n(Array+)\n\n#### iterate(start, end)\n\nReturns an iterator for all values in the half-open interval [start,\nend), that is, greater than start, and less than end. The iterator\nis resilient against changes to the data.\n\n(SortedSet)\n\n### log(charmap, callback(node, write, writeAbove), log, logger)\n\nWrites a tree describing the internal state of the data structure to\nthe console.\n\n`charmap` is an object that notes which characters to use to draw\nlines. By default, this is the `TreeLog.unicodeRound` property from the\n`tree-log` module. `TreeLog.unicodeSharp` and `TreeLog.ascii` are\nalternatives. The properties are:\n\n- intersection: ╋\n- through: ━\n- branchUp: ┻\n- branchDown: ┳\n- fromBelow: ╭\n- fromAbove: ╰\n- fromBoth: ┣\n- strafe: ┃\n\n`callback` is a customizable function for rendering each node of the tree.\nBy default, it just writes the value of the node. It accepts the node and\na writer functions. The `write` function produces the line on which the\nnode joins the tree, and each subsequent line. The `writeAbove` function\ncan write lines before the branch.\n\n`log` and `logger` default to `console.log` and `console`. To write\nthe representation to an array instead, they can be `array.push` and\n`array`.\n\n(SortedSet)\n\n\n### Iterator\n\n#### dropWhile(callback(value, index, iterator), thisp)\n\n#### takeWhile(callback(value, index, iterator), thisp)\n\n#### mapIterator(callback(value, index, iterator))\n\nReturns an iterator for a mapping on the source values. Values are\nconsumed on demand.\n\n#### filterIterator(callback(value, index, iterator))\n\nReturns an iterator for those values from the source that pass the\ngiven guard. Values are consumed on demand.\n\n#### zipIterator(...iterables)\n\nReturns an iterator that incrementally combines the respective\nvalues of the given iterations.\n\n#### enumerateIterator(start = 0)\n\nReturns an iterator that provides [index, value] pairs from the\nsource iteration.\n\n\n### Iterator utilities\n\n#### cycle(iterable, times)\n\n#### concat(iterables)\n\n#### transpose(iterables)\n\n#### zip(...iterables)\n\nVariadic transpose.\n\n#### chain(...iterables)\n\nVariadic concat.\n\n#### range(start, stop, step)\n\nIterates from start to stop by step.\n\n#### count(start, step)\n\nIterates from start by step, indefinitely.\n\n#### repeat(value, times)\n\nRepeats the given value either finite times or indefinitely.\n\n\n## Change Listeners\n\nAll collections support change listeners. There are three types of\nchanges. Property changes, map changes, and range changes.\n\n### Property Changes\n\n`PropertyChanges` from the `listen/property-changes` module can\nconfigure listeners for property changes to specific keys of any object.\n\nWith the `listen/array-changes` module required, `PropertyChanges` can\nalso listen to changes to the length and indexed properties of an array.\nThe only caveat is that watched arrays can only modify their contents\nwith method calls like `array.push`. All methods of a watched array\nsupport change dispatch. In addition, arrays have a `set` method to\nmake setting the value at a particular index observable.\n\n- PropertyChanges.addOwnPropertyChangeListener(object, key, listener, before)\n- PropertyChanges.removeOwnPropertyChangeListener(object, key, listener, before)\n- PropertyChanges.dispatchOwnPropertyChange(object, key, value, before)\n- PropertyChanges.addBeforeOwnPropertyChangeListener(object, key, listener)\n- PropertyChanges.removeBeforeOwnPropertyChangeListener(object, key, listener)\n- PropertyChanges.dispatchBeforeOwnPropertyChange(object, key, value)\n- PropertyChanges.getOwnPropertyChangeDescriptor(object, key)\n\nAll of these functions delegate to methods of the same name if one\nexists on the object.\n\n- object.addOwnPropertyChangeListener(key, listener, before)\n- object.removeOwnPropertyChangeListener(key, listener, before)\n- object.dispatchOwnPropertyChange(key, value, before)\n- object.addBeforeOwnPropertyChangeListener(key, listener)\n- object.removeBeforeOwnPropertyChangeListener(key, listener)\n- object.dispatchBeforeOwnPropertyChange(key, value)\n- object.getOwnPropertyChangeDescriptor(key)\n\nAdditionally, `PropertyChanges.prototype` can be **mixed into** other\ntypes of objects to support the property change dispatch interface. All\ncollections support this interface.\n\nThe **listener** for a property change receives the arguments `value`,\n`key`, and `object`, just as a `forEach` or `map` callback. The\nlistener may alternately be a delegate object that implements one of\nthese methods:\n\n- listener.handle + **key** + Change **or** WillChange\n- listener.handleProperty + Change **or** WillChange\n- listener.call\n\n### Map Changes\n\nA map change listener receives notifications for the creation, removal,\nor updates for any entry in a map data structure.\n\nWith the `listen/array-changes` module required, `Array` can also\ndispatch map changes for the values at each index.\n\n- collection.addMapChangeListener(listener, token, before)\n- collection.removeMapChangeListener(listener, token, before)\n- collection.dispatchMapChange(key, value, before)\n- collection.addBeforeMapChangeListener(listener)\n- collection.removeBeforeMapChangeListener(listener)\n- collection.dispatchBeforeMapChange(key, value)\n- collection.getMapChangeDescriptor()\n\nThe **listener** for a map change receives the `value`, `key`, and\ncollection `object` as arguments, the same pattern as a `forEach` or\n`map` callback. In the after change phase, a value of `undefined` may\nindicate that the value was deleted or set to `undefined`. In the\nbefore change phase, a value of `undefined` may indicate the the value\nwas added or was previously `undefined`.\n\nThe listener may be a delegate object with one of the following methods,\nin order of precedence:\n\n- listener.handleMap + Change **or** WillChange\n- listener.handle + **token** + Map + Change **or** WillChange\n- listener.call\n\nThe `listen/map-changes` module exports a map changes **mixin**. The\nmethods of `MaxChanges.prototype` can be copied to any collection that\nneeds this interface. Its mutation methods will then need to dispatch\nmap changes.\n\n### Range Changes\n\nA range change listener receives notifications when a range of values at\na particular position is added, removed, or replaced within an ordered\ncollection.\n\n- collection.**add**RangeChange**Listener**(listener, token, before)\n- collection.**remove**RangeChange**Listener**(listener, token, before)\n- collection.**dispatch**RangeChange(plus, minus, index, before)\n- collection.add**Before**RangeChange**Listener**(listener)\n- collection.remove**Before**RangeChange**Listener**(listener)\n- collection.dispatch**Before**RangeChange(plus, minus, index)\n- collection.**get**RangeChange**Descriptor**()\n\nThe **listener** for a range change is a function that accepts `plus`,\n`minus`, and `index` arguments. `plus` and `minus` are the values that\nwere added or removed at the `index`. Whatever operation caused these\nchanges is equivalent to:\n\n```javascript\nvar minus = collection.splice(index, minus.length, ...plus)\n```\n\nThe listener can alternately be a delegate object with one of the\nfollowing methods in order of precedence:\n\n- handle + **token** + Range + Change **or** WillChange\n- handleRange + Change **or** WillChange\n- call\n\nThe following support range change dispatch:\n\n- `Array` with `require(\"collections/listen/array-changes\")`\n- `SortedSet`\n- `SortedArray`\n- `SortedArraySet`\n\nThe `listen/range-changes` module exports a range changes **mixin**.\nThe methods of `RangeChanges.prototype` can be copied to any collection\nthat needs this interface. Its mutation methods will need to dispatch\nthe range changes.\n\nAll **descriptors** are objects with the properties `changeListeners`\nand `willChangeListeners`. Both are arrays of listener functions or\nobjects, in the order in which they were added.\n\n\n## Miscellanea\n\n### Set and Map\n\nSet and map are like hash tables, but not implemented with a block of\nmemory as they would be in a lower-level language. Most of the work of\nproviding fast insertion and lookup based on a hash is performed by the\nunderlying plain JavaScript object. Each key of the object is a hash\nstring and each value is a List of values with that hash. The inner\nlist resolves collisions. With a good `hash` method, the use of the\nlist can be avoided.\n\nSets and maps both have a `log` function that displays the internal\nstructure of the bucket list in an NPM-style.\n\n```\n┣━┳ 1\n┃ ┗━━ {\"key\":1,\"value\":\"a\"}\n┣━┳ 2\n┃ ┣━━ {\"key\":2,\"value\":\"c\"}\n┃ ┗━━ {\"key\":2,\"value\":\"d\"}\n┗━┳ 3\n ┗━━ {\"key\":3,\"value\":\"b\"}\n```\n\n\n### Sorted Set and Sorted Map\n\nA binary splay tree is a balanced binary tree that rotates the most\nfrequently used entries toward the root such that they can be accessed the\nmost quickly. `sorted-set` and `sorted-map` are backed by a splay tree.\n\nAll map implementations use an underlying set implementation. Any map\ncan be implemented trivially atop a set by wrapping `compare`, `equals`,\nor `hash` to operate on the key of an entry.\n\nThe sorted set has a `root` node. Each node has a `left` and `right`\nproperty, which may be null. Nodes are returned by all of the \"find\"\nfunctions, and provided as the `key` argument to callbacks.\n\nBoth `sorted-set` and `sorted-map` implement a `log` function which can\nproduce NPM-style visualizations of the internal state of the sorted\ntree.\n\n```\n> set.log(SortedSet.ascii)\n .-+ -3\n | '-- -2\n.-+ -1\n+ 0\n| .-- 1\n'-+ 2\n '-- 3\n```\n\n```\n> set.log(SortedSet.unicodeRound)\n ╭━┳ -3\n ┃ ╰━━ -2\n╭━┻ -1\n╋ 0\n┃ ╭━┳ 1\n┃ ┃ ╰━━ 2\n╰━┻ 3\n```\n\n\n### Object and Function Shims\n\nThe collection methods on the `Object` constructor all polymorphically\ndelegate to the corresponding method of any object that implements the\nmethod of the same name. So, `Object.has` can be used to check whether\na key exists on an object, or in any collection that implements `has`.\nThis permits the `Object` interface to be agnostic of the input type.\n\n`Array.from` creates an array from any iterable.\n\n`Array.unzip` transposes a collection of arrays, so rows become columns.\n\n`Array.empty` is an empty array, frozen if possible. Do not modify it.\n\n`Object.from` creates an object from any map or collection. For arrays\nand array-like collections, uses the index for the key.\n\n`Object.empty` is an empty object literal.\n\n`Object.isObject(value)` tests whether it is safe to attempt to access\nproperties of a given value.\n\n`Object.is(x, y)` compares objects for exact identity and is a good\nalternative to `Object.equals` in many collections.\n\n`Object.getValueOf(value)` safely and idempotently returns the value of\nan object or value by only calling the `valueOf()` if the value\nimplements that method.\n\n`Object.owns` is a shorthand for `Object.prototype.hasOwnProperty.call`.\n\n`Object.can(value, name)` checks whether an object implements a method\non its prototype chain. An owned function property does not qualify as\na method, to aid in distinguishing \"static\" functions.\n\n`Object.concat(...maps)` and `Object.from(entries)` construct an object\nby adding the entries of other objects in order. The maps can be other\nobjects, arrays of entries, or map alike collections.\n\n`Function.noop` is returns undefined.\n\n`Function.identity` returns its first argument.\n\n`Function.by(relation)` creates a comparator from a relation function.\n\n`Function.get(key)` creates a relation that returns the value for the\nproperty of a given object.\n\n\n### References\n\n- a SplayTree impementation buried in Fedor Indutny’s super-secret\n [Callgrind](https://github.com/indutny/callgrind.js). This\n implementation uses parent references.\n- a SplayTree implementation adapted by [Paolo\n Fragomeni](https://github.com/hij1nx/forest) from the V8 project and\n based on the top-down splaying algorithm from \"Self-adjusting Binary\n Search Trees\" by Sleator and Tarjan. This does not use or require\n parent references, so I favored it over Fedor Indutny’s style.\n- the interface of ECMAScript harmony [simple maps and\n sets](http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets)\n- a SplayTree implementation from [JavaScript data\n structures](derrickburns/Javascript-Data-Structures) mainted by\n Derrick Burns that supports change-resilient iterators and a\n comprehensive set of introspection functions.\n\n### Future work\n\nGoals\n\n- make array dispatch length property changes between range changes to\n be consistent with List.\n- automate the generation of the method support tables in readme and\n normalize declaration order\n- comprehensive specs and spec coverage tests\n- array set (a set, for fast lookup, backed by an array for meaningful\n range changes)\n- fast list splicing\n- dict map changes\n- revise map changes to use separate handlers for add/delete\n- revise tokens for range and map changes to specify complete alternate\n delegate methods, particularly for forwarding directly to dispatch\n- implement on/once/off listeners\n- Make it easier to created a SortedSet with a criterion like\n Function.by(Function.get('name'))\n- evaluate exposing observeProperty, observeRangeChange, and observeMapChange\n instead of the aEL/rEL inspired API FRB exposes today, to minimize\n book-keeping and garbage collection\n\nMore possible collections\n\n- sorted-list (sorted, can contain duplicates, perhaps backed by splay\n tree with relaxation on the uniqueness invariant)\n- sorted-multi-map (sorted, can contain duplicate entries)\n- buffer (backed by a circular array, emits cull events)\n- emit cull events in LRU cache set and map\n- trie-set\n- trie-map\n- immutable-* (mutation functions return new objects that largely share\n the previous version's internal state, some perhaps backed by a hash\n trie)\n\n",
46
+ "readmeFilename": "README.md",
47
+ "_id": "collections@0.2.2",
48
+ "_from": "collections@~0.2.0"
49
+ }
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+
3
+ var Shim = require("./shim");
4
+ var List = require("./list");
5
+ var FastSet = require("./fast-set");
6
+ var GenericCollection = require("./generic-collection");
7
+ var GenericSet = require("./generic-set");
8
+ var PropertyChanges = require("./listen/property-changes");
9
+ var RangeChanges = require("./listen/range-changes");
10
+
11
+ module.exports = Set;
12
+
13
+ function Set(values, equals, hash, getDefault) {
14
+ if (!(this instanceof Set)) {
15
+ return new Set(values, equals, hash, getDefault);
16
+ }
17
+ equals = equals || Object.equals;
18
+ hash = hash || Object.hash;
19
+ getDefault = getDefault || Function.noop;
20
+ this.contentEquals = equals;
21
+ this.contentHash = hash;
22
+ this.getDefault = getDefault;
23
+ // a list of values in insertion order, used for all operations that depend
24
+ // on iterating in insertion order
25
+ this.order = new this.Order(undefined, equals);
26
+ // a set of nodes from the order list, indexed by the corresponding value,
27
+ // used for all operations that need to quickly seek value in the list
28
+ this.store = new this.Store(
29
+ undefined,
30
+ function (a, b) {
31
+ return equals(a.value, b.value);
32
+ },
33
+ function (node) {
34
+ return hash(node.value);
35
+ }
36
+ );
37
+ this.length = 0;
38
+ this.addEach(values);
39
+ }
40
+
41
+ Set.Set = Set; // hack so require("set").Set will work in MontageJS
42
+
43
+ Object.addEach(Set.prototype, GenericCollection.prototype);
44
+ Object.addEach(Set.prototype, GenericSet.prototype);
45
+ Object.addEach(Set.prototype, PropertyChanges.prototype);
46
+ Object.addEach(Set.prototype, RangeChanges.prototype);
47
+
48
+ Set.prototype.Order = List;
49
+ Set.prototype.Store = FastSet;
50
+
51
+ Set.prototype.constructClone = function (values) {
52
+ return new this.constructor(values, this.contentEquals, this.contentHash, this.getDefault);
53
+ };
54
+
55
+ Set.prototype.has = function (value) {
56
+ var node = new this.order.Node(value);
57
+ return this.store.has(node);
58
+ };
59
+
60
+ Set.prototype.get = function (value) {
61
+ var node = new this.order.Node(value);
62
+ node = this.store.get(node);
63
+ if (node) {
64
+ return node.value;
65
+ } else {
66
+ return this.getDefault(value);
67
+ }
68
+ };
69
+
70
+ Set.prototype.add = function (value) {
71
+ var node = new this.order.Node(value);
72
+ if (!this.store.has(node)) {
73
+ var index = this.length;
74
+ if (this.dispatchesRangeChanges) {
75
+ this.dispatchBeforeRangeChange([value], [], index);
76
+ }
77
+ this.order.add(value);
78
+ node = this.order.head.prev;
79
+ this.store.add(node);
80
+ this.length++;
81
+ if (this.dispatchesRangeChanges) {
82
+ this.dispatchRangeChange([value], [], index);
83
+ }
84
+ return true;
85
+ }
86
+ return false;
87
+ };
88
+
89
+ Set.prototype["delete"] = function (value) {
90
+ var node = new this.order.Node(value);
91
+ if (this.store.has(node)) {
92
+ var node = this.store.get(node);
93
+ if (this.dispatchesRangeChanges) {
94
+ this.dispatchBeforeRangeChange([], [value], node.index);
95
+ }
96
+ this.store["delete"](node); // removes from the set
97
+ this.order.splice(node, 1); // removes the node from the list
98
+ this.length--;
99
+ if (this.dispatchesRangeChanges) {
100
+ this.dispatchRangeChange([], [value], node.index);
101
+ }
102
+ return true;
103
+ }
104
+ return false;
105
+ };
106
+
107
+ Set.prototype.pop = function () {
108
+ if (this.length) {
109
+ var result = this.order.head.prev.value;
110
+ this["delete"](result);
111
+ return result;
112
+ }
113
+ };
114
+
115
+ Set.prototype.shift = function () {
116
+ if (this.length) {
117
+ var result = this.order.head.next.value;
118
+ this["delete"](result);
119
+ return result;
120
+ }
121
+ };
122
+
123
+ Set.prototype.one = function () {
124
+ if (this.length > 0) {
125
+ return this.store.one().value;
126
+ }
127
+ };
128
+
129
+ Set.prototype.clear = function () {
130
+ var clearing;
131
+ if (this.dispatchesRangeChanges) {
132
+ clearing = this.toArray();
133
+ this.dispatchBeforeRangeChange([], clearing, 0);
134
+ }
135
+ this.store.clear();
136
+ this.order.clear();
137
+ this.length = 0;
138
+ if (this.dispatchesRangeChanges) {
139
+ this.dispatchRangeChange([], clearing, 0);
140
+ }
141
+ };
142
+
143
+ Set.prototype.reduce = function (callback, basis /*, thisp*/) {
144
+ var thisp = arguments[2];
145
+ var list = this.order;
146
+ var index = 0;
147
+ return list.reduce(function (basis, value) {
148
+ return callback.call(thisp, basis, value, index++, this);
149
+ }, basis, this);
150
+ };
151
+
152
+ Set.prototype.reduceRight = function (callback, basis /*, thisp*/) {
153
+ var thisp = arguments[2];
154
+ var list = this.order;
155
+ var index = this.length - 1;
156
+ return list.reduceRight(function (basis, value) {
157
+ return callback.call(thisp, basis, value, index--, this);
158
+ }, basis, this);
159
+ };
160
+
161
+ Set.prototype.iterate = function () {
162
+ return this.order.iterate();
163
+ };
164
+
165
+ Set.prototype.log = function () {
166
+ var set = this.store;
167
+ return set.log.apply(set, arguments);
168
+ };
169
+
170
+ Set.prototype.makeObservable = function () {
171
+ this.order.makeObservable();
172
+ };
173
+
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+
3
+ /*
4
+ Based in part on extras from Motorola Mobility’s Montage
5
+ Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.
6
+ 3-Clause BSD License
7
+ https://github.com/motorola-mobility/montage/blob/master/LICENSE.md
8
+ */
9
+
10
+ var Function = require("./shim-function");
11
+ var GenericCollection = require("./generic-collection");
12
+ var GenericOrder = require("./generic-order");
13
+ var WeakMap = require("weak-map");
14
+
15
+ module.exports = Array;
16
+
17
+ Array.empty = [];
18
+
19
+ if (Object.freeze) {
20
+ Object.freeze(Array.empty);
21
+ }
22
+
23
+ Array.from = function (values) {
24
+ var array = [];
25
+ array.addEach(values);
26
+ return array;
27
+ };
28
+
29
+ Array.unzip = function (table) {
30
+ var transpose = [];
31
+ var length = Infinity;
32
+ // compute shortest row
33
+ for (var i = 0; i < table.length; i++) {
34
+ var row = table[i];
35
+ table[i] = row.toArray();
36
+ if (row.length < length) {
37
+ length = row.length;
38
+ }
39
+ }
40
+ for (var i = 0; i < table.length; i++) {
41
+ var row = table[i];
42
+ for (var j = 0; j < row.length; j++) {
43
+ if (j < length && j in row) {
44
+ transpose[j] = transpose[j] || [];
45
+ transpose[j][i] = row[j];
46
+ }
47
+ }
48
+ }
49
+ return transpose;
50
+ };
51
+
52
+ function define(key, value) {
53
+ Object.defineProperty(Array.prototype, key, {
54
+ value: value,
55
+ writable: true,
56
+ configurable: true,
57
+ enumerable: false
58
+ });
59
+ }
60
+
61
+ define("addEach", GenericCollection.prototype.addEach);
62
+ define("deleteEach", GenericCollection.prototype.deleteEach);
63
+ define("toArray", GenericCollection.prototype.toArray);
64
+ define("toObject", GenericCollection.prototype.toObject);
65
+ define("all", GenericCollection.prototype.all);
66
+ define("any", GenericCollection.prototype.any);
67
+ define("min", GenericCollection.prototype.min);
68
+ define("max", GenericCollection.prototype.max);
69
+ define("sum", GenericCollection.prototype.sum);
70
+ define("average", GenericCollection.prototype.average);
71
+ define("only", GenericCollection.prototype.only);
72
+ define("flatten", GenericCollection.prototype.flatten);
73
+ define("zip", GenericCollection.prototype.zip);
74
+ define("enumerate", GenericCollection.prototype.enumerate);
75
+ define("group", GenericCollection.prototype.group);
76
+ define("sorted", GenericCollection.prototype.sorted);
77
+ define("reversed", GenericCollection.prototype.reversed);
78
+
79
+ define("constructClone", function (values) {
80
+ var clone = new this.constructor();
81
+ clone.addEach(values);
82
+ return clone;
83
+ });
84
+
85
+ define("has", function (value, equals) {
86
+ return this.find(value, equals) !== -1;
87
+ });
88
+
89
+ define("get", function (index, defaultValue) {
90
+ if (+index !== index)
91
+ throw new Error("Indicies must be numbers");
92
+ if (!index in this) {
93
+ return defaultValue;
94
+ } else {
95
+ return this[index];
96
+ }
97
+ });
98
+
99
+ define("set", function (index, value) {
100
+ this.splice(index, 1, value);
101
+ return true;
102
+ });
103
+
104
+ define("add", function (value) {
105
+ this.push(value);
106
+ return true;
107
+ });
108
+
109
+ define("delete", function (value, equals) {
110
+ var index = this.find(value, equals);
111
+ if (index !== -1) {
112
+ this.splice(index, 1);
113
+ return true;
114
+ }
115
+ return false;
116
+ });
117
+
118
+ define("find", function (value, equals) {
119
+ equals = equals || this.contentEquals || Object.equals;
120
+ for (var index = 0; index < this.length; index++) {
121
+ if (index in this && equals(this[index], value)) {
122
+ return index;
123
+ }
124
+ }
125
+ return -1;
126
+ });
127
+
128
+ define("findLast", function (value, equals) {
129
+ equals = equals || this.contentEquals || Object.equals;
130
+ var index = this.length;
131
+ do {
132
+ index--;
133
+ if (index in this && equals(this[index], value)) {
134
+ return index;
135
+ }
136
+ } while (index > 0);
137
+ return -1;
138
+ });
139
+
140
+ define("swap", function (index, length, plus) {
141
+ var args = Array.prototype.slice.call(arguments, 0, 2);
142
+ if (plus) {
143
+ if (!Array.isArray(plus)) {
144
+ plus = Array.prototype.slice.call(plus);
145
+ }
146
+ args.push.apply(args, plus);
147
+ }
148
+ return this.splice.apply(this, args);
149
+ });
150
+
151
+ define("one", function () {
152
+ for (var i in this) {
153
+ if (Object.owns(this, i)) {
154
+ return this[i];
155
+ }
156
+ }
157
+ });
158
+
159
+ define("clear", function () {
160
+ this.length = 0;
161
+ return this;
162
+ });
163
+
164
+ define("compare", function (that, compare) {
165
+ compare = compare || Object.compare;
166
+ var i;
167
+ var length;
168
+ var lhs;
169
+ var rhs;
170
+ var relative;
171
+
172
+ if (this === that) {
173
+ return 0;
174
+ }
175
+
176
+ if (!that || !Array.isArray(that)) {
177
+ return GenericOrder.prototype.compare.call(this, that, compare);
178
+ }
179
+
180
+ length = Math.min(this.length, that.length);
181
+
182
+ for (i = 0; i < length; i++) {
183
+ if (i in this) {
184
+ if (!(i in that)) {
185
+ return -1;
186
+ } else {
187
+ lhs = this[i];
188
+ rhs = that[i];
189
+ relative = compare(lhs, rhs);
190
+ if (relative) {
191
+ return relative;
192
+ }
193
+ }
194
+ } else if (i in that) {
195
+ return 1;
196
+ }
197
+ }
198
+
199
+ return this.length - that.length;
200
+ });
201
+
202
+ define("equals", function (that, equals) {
203
+ equals = equals || Object.equals;
204
+ var i = 0;
205
+ var length = this.length;
206
+ var left;
207
+ var right;
208
+
209
+ if (this === that) {
210
+ return true;
211
+ }
212
+ if (!that || !Array.isArray(that)) {
213
+ return GenericOrder.prototype.equals.call(this, that);
214
+ }
215
+
216
+ if (length !== that.length) {
217
+ return false;
218
+ } else {
219
+ for (; i < length; ++i) {
220
+ if (i in this) {
221
+ if (!(i in that)) {
222
+ return false;
223
+ }
224
+ left = this[i];
225
+ right = that[i];
226
+ if (!equals(left, right)) {
227
+ return false;
228
+ }
229
+ } else {
230
+ if (i in that) {
231
+ return false;
232
+ }
233
+ }
234
+ }
235
+ }
236
+ return true;
237
+ });
238
+
239
+ define("clone", function (depth, memo) {
240
+ if (depth === undefined) {
241
+ depth = Infinity;
242
+ } else if (depth === 0) {
243
+ return this;
244
+ }
245
+ memo = memo || new WeakMap();
246
+ var clone = [];
247
+ for (var i in this) {
248
+ if (Object.owns(this, i)) {
249
+ clone[i] = Object.clone(this[i], depth - 1, memo);
250
+ }
251
+ };
252
+ return clone;
253
+ });
254
+
255
+ define("iterate", function (start, end) {
256
+ return new ArrayIterator(this, start, end);
257
+ });
258
+
259
+ define("Iterator", ArrayIterator);
260
+
261
+ function ArrayIterator(array, start, end) {
262
+ this.array = array;
263
+ this.start = start == null ? 0 : start;
264
+ this.end = end;
265
+ };
266
+
267
+ ArrayIterator.prototype.next = function () {
268
+ if (this.start === (this.end == null ? this.array.length : this.end)) {
269
+ throw StopIteration;
270
+ } else {
271
+ return this.array[this.start++];
272
+ }
273
+ };
274
+