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.
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,11 @@
1
+ .gitignore
2
+ .travis.ymp
3
+ .tmp
4
+ /bench
5
+ checklist.csv
6
+ collections.cat.js
7
+ collections.min.js
8
+ /coverage
9
+ /demo
10
+ /minify
11
+ /spec
@@ -0,0 +1,4 @@
1
+ language: node_js
2
+ node_js:
3
+ - "0.8"
4
+ - "0.10"
@@ -0,0 +1,78 @@
1
+
2
+ ## v0.2.2
3
+
4
+ - `one` now returns a consistent value between changes of a sorted
5
+ set.
6
+ - All collections can now be required using the MontageJS style, as
7
+ well as the Node.js style. I reserve the right to withdraw support
8
+ for the current MontageJS style if in a future,
9
+ backward-incompatible release of Montage migrated to the Node.js
10
+ style.
11
+
12
+ ## v0.2.1
13
+
14
+ - Identify Maps with `isMap` property instead of `keys`, as ES6
15
+ proposes `keys`, `values`, and `entries` methods for arrays.
16
+
17
+ ## v0.2.0
18
+
19
+ - Fixes the enumerability of dispatchesRangeChanges and
20
+ dispatchesMapChanges on observable arrays (and others,
21
+ incidentally).
22
+ - List and Set now dispatch valid range changes, at the penalty of
23
+ making updates linear when they are made observable.
24
+ - Adds `join` method to generic collections.
25
+ - Fixes a bug in `Object.has(object, value)`, where it would not
26
+ delegate polymorphically to `object.has(value)`
27
+ - Fixes `Object.addEach(object, undefined)`, such that it tolerates
28
+ the case without throwing an error, like `addEach` on other
29
+ collections.
30
+ - Fixes change dispatch on LruSet (Paul Koppen) such that a single
31
+ change event gets dispatched for both augmentation and truncation.
32
+ - Fixes change dispatch on Dict, such that the value gets sent on
33
+ addition.
34
+
35
+ ## v0.1.24
36
+
37
+ - Factored out WeakMap into separately maintained package.
38
+
39
+ ## v0.1.23
40
+
41
+ - Introduces `entries` and deprecates `items` on all map collections.
42
+ - Fixes Map clear change dispatch.
43
+
44
+ ## v0.1.22
45
+
46
+ - Fixes Set clear change dispatch.
47
+
48
+ ## v0.1.21
49
+
50
+ - Fixes a bug when the `plus` argument of swap is not an array.
51
+
52
+ ## v0.1.20
53
+
54
+ - Fixes generic map change dispatch on clear.
55
+ - Adds map change dispatch to Dict.
56
+
57
+ ## v0.1.18, v0.1.19
58
+
59
+ - Require total order on SortedSet
60
+ - Remove Node v0.6 from supported versions
61
+ - Add Node v0.10 to supported versions
62
+ - Fixes `hrtime` handling (Alexy Kupershtokh)
63
+
64
+ ## v0.1.17
65
+
66
+ ...
67
+
68
+ ## v0.0.5
69
+
70
+ - The `observable-array` and `observable-object` modules have been
71
+ moved to the Functional Reactive Bindings (`frb`) package as `array`
72
+ and `object`.
73
+ - `List`, `Set`, and `SortedSet` now support content change
74
+ notifications compatibly with `frb`.
75
+ - The `observable` module provides generics methods for observables.
76
+ New collections need only call the appropriate dispatch functions if
77
+ `isObservable` is true.
78
+
@@ -0,0 +1,21 @@
1
+
2
+ Copyright 2012 Kristopher Michael Kowal. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to
6
+ deal in the Software without restriction, including without limitation the
7
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
+ sell copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
+ IN THE SOFTWARE.
21
+
@@ -0,0 +1,1285 @@
1
+ [![Build Status](https://travis-ci.org/montagejs/collections.png?branch=master)](http://travis-ci.org/montagejs/collections)
2
+
3
+ # Collections
4
+
5
+ This package contains JavaScript implementations of common data
6
+ structures with idiomatic iterfaces, including extensions for Array and
7
+ Object.
8
+
9
+ You can use these Node Packaged Modules with Node.js, [Browserify][],
10
+ [Mr][], or any compatible CommonJS module loader. Using a module loader
11
+ or bundler when using Collections in web browsers has the advantage of
12
+ only incorporating the modules you need. However, you can just embed
13
+ `<script src="collections/collections.min.js">` and *all* of the
14
+ collections will be introduced as globals. :warning:
15
+ `require("collections")` is not supported.
16
+
17
+ ```
18
+ npm install collections --save
19
+ ```
20
+
21
+ [Browserify]: https://github.com/substack/node-browserify
22
+ [Mr]: https://github.com/montagejs/mr
23
+
24
+
25
+ ## Collections
26
+
27
+ ### List(values, equals, getDefault)
28
+
29
+ ```javascript
30
+ var List = require("collections/list");
31
+ ```
32
+
33
+ An ordered collection of values with fast insertion and deletion and
34
+ forward and backward traversal, backed by a cyclic doubly linked
35
+ list with a head node. Lists support most of the Array interface,
36
+ except that they use and return nodes instead of integer indicies in
37
+ analogous functions.
38
+
39
+ Lists have a `head` `Node`. The node type is available as `Node` on
40
+ the list prototype and can be overridden by inheritors. Each node
41
+ has `prev` and `next` properties.
42
+
43
+ ### Set(values, equals, hash, getDefault)
44
+
45
+ ```javascript
46
+ var Set = require("collections/set");
47
+ ```
48
+
49
+ A collection of unique values. The set can be iterated in the order
50
+ of insertion. With a good hash function for the stored values,
51
+ insertion and removal are fast regardless of the size of the
52
+ collection. Values may be objects. The `equals` and `hash`
53
+ functions can be overridden to provide alternate definitions of
54
+ "unique". `Set` is backed by `FastSet` and `List`.
55
+
56
+ ### Map(map, equals, hash, getDefault)
57
+
58
+ ```javascript
59
+ var Map = require("collections/map");
60
+ ```
61
+
62
+ A collection of key and value entries with unique keys. Keys may be
63
+ objects. The collection iterates in the order of insertion. `Map`
64
+ is backed by `Set`.
65
+
66
+ ### MultiMap(map, getDefault, equals, hash)
67
+
68
+ ```javascript
69
+ var MultiMap = require("collections/multi-map");
70
+ ```
71
+
72
+ A collection of keys mapped to collections of values. The default
73
+ `getDefault` collection is an `Array`, but it can be a `List` or any
74
+ other array-like object. `MultiMap` inherits `Map` but overrides
75
+ the `getDefault(key)` provider.
76
+
77
+ ### WeakMap()
78
+
79
+ ```javascript
80
+ var WeakMap = require("collections/weak-map");
81
+ ```
82
+
83
+ A non-iterable collection of key value pairs. Keys must objects and
84
+ do not benefit from `hash` functions. Some engines already
85
+ implement `WeakMap`. The non-iterable requirement makes it possible
86
+ for weak maps to collect garbage when the key is no longer
87
+ available, without betraying when the key is collected. The shimmed
88
+ implementation undetectably annotates the given key and thus does
89
+ not necessarily leak memory, but cannot collect certain reference
90
+ graphs. This WeakMap shim was implemented by Mark Miller of Google.
91
+
92
+ ### SortedSet(values, equals, compare, getDefault)
93
+
94
+ ```javascript
95
+ var SortedSet = require("collections/sorted-set");
96
+ ```
97
+
98
+ A collection of unique values stored in stored order, backed by a
99
+ splay tree. The `equals` and `compare` functions can be overridden
100
+ to provide alternate definitions of "unique".
101
+
102
+ The `compare` method *must* provide a total order of all unique
103
+ values. That is, if `compare(a, b) === 0`, it *must* follow that
104
+ `equals(a, b)`.
105
+
106
+ ### SortedMap(map, equals, compare, getDefault)
107
+
108
+ ```javascript
109
+ var SortedMap = require("collections/sorted-map");
110
+ ```
111
+
112
+ A collection of key value pairs stored in sorted order. `SortedMap`
113
+ is backed by `SortedSet` and the `GenericMap` mixin.
114
+
115
+ ### LruSet(values, maxLength, equals, hash, getDefault)
116
+
117
+ ```javascript
118
+ var LruSet = require("collections/lru-set");
119
+ ```
120
+
121
+ A cache with the Least-Recently-Used strategy for truncating its
122
+ content when it’s length exceeds `maxLength`. `LruSet` is backed by
123
+ a `Set` and takes advantage of the already tracked insertion order.
124
+ Both getting and setting a value constitute usage, but checking
125
+ whether the set has a value and iterating values do not.
126
+
127
+ ### LruMap(map, maxLength, equals, hash, getDefault)
128
+
129
+ ```javascript
130
+ var LruMap = require("collections/lru-map");
131
+ ```
132
+
133
+ A cache of entries backed by an `LruSet`.
134
+
135
+ ### SortedArray(values, equals, compare, getDefault)
136
+
137
+ ```javascript
138
+ var SortedArray = require("collections/sorted-array");
139
+ ```
140
+
141
+ A collection of values stored in a stable sorted order, backed by an
142
+ array.
143
+
144
+ ### SortedArraySet(values, equals, compare, getDefault)
145
+
146
+ ```javascript
147
+ var SortedArraySet = require("collections/sorted-array-set");
148
+ ```
149
+
150
+ A collection of unique values stored in sorted order, backed by a
151
+ plain array. If the given values are an actual array, the sorted
152
+ array set takes ownership of that array and retains its content. A
153
+ sorted array set performs better than a sorted set when it has
154
+ roughly less than 100 values.
155
+
156
+ ### SortedArrayMap(values, equals, compare, getDefault)
157
+
158
+ ```javascript
159
+ var SortedArrayMap = require("collections/sorted-array-map");
160
+ ```
161
+
162
+ A collection of key value pairs stored in sorted order, backed by a
163
+ sorted array set.
164
+
165
+ ### FastSet(values, equals, hash, getDefault)
166
+
167
+ ```javascript
168
+ var FastSet = require("collections/fast-set");
169
+ ```
170
+
171
+ A collection of unique values stored like a hash table. The
172
+ underlying storage is a `Dict` that maps hashes to lists of values
173
+ that share the same hash. Values may be objects. The `equals` and
174
+ `hash` functions can be overridden to provide alternate definitions
175
+ of "unique".
176
+
177
+ ### FastMap(map, equals, hash, getDefault)
178
+
179
+ ```javascript
180
+ var FastMap = require("collections/fast-map");
181
+ ```
182
+
183
+ A collection of key and value entries with unique keys, backed by a
184
+ set. Keys may be objects. `FastMap` is backed by `FastSet` and the
185
+ `GenericMap` mixin.
186
+
187
+ ### Dict(values, getDefault)
188
+
189
+ ```javascript
190
+ var Dict = require("collections/dict");
191
+ ```
192
+
193
+ A collection of string to value mappings backed by a plain
194
+ JavaScript object. The keys are mangled to prevent collisions with
195
+ JavaScript properties.
196
+
197
+ ### Heap(values, equals, compare)
198
+
199
+ ```javascript
200
+ var Heap = require("collections/heap");
201
+ ```
202
+
203
+ A collection that can always quickly (constant time) report its
204
+ largest value, with reasonable performance for incremental changes
205
+ (logarithmic), using a contiguous array as its backing storage.
206
+ However, it does not track the sorted order of its elements.
207
+
208
+ ### Iterator(iterable)
209
+
210
+ ```javascript
211
+ var Iterator = require("collections/iterator");
212
+ ```
213
+
214
+ A wrapper for any iterable that implements `iterate` or iterator the
215
+ implements `next`, providing a rich lazy traversal interface.
216
+
217
+ ### Array
218
+
219
+ ```javascript
220
+ require("collections/shim-array");
221
+ ```
222
+
223
+ An ordered collection of values with fast random access, push, and
224
+ pop, but slow splice. The `array` module provides extensions so it
225
+ hosts all the expressiveness of other collections. The `shim-array`
226
+ module shims EcmaScript 5 methods onto the array prototype if they
227
+ are not natively implemented.
228
+
229
+ ### Object
230
+
231
+ ```javascript
232
+ require("collections/shim-object");
233
+ ```
234
+
235
+ Can be used as a mapping of owned string keys to arbitrary values.
236
+ The `object` module provides extensions for the `Object` constructor
237
+ that support the map collection interface and can delegate to
238
+ methods of collections, allowing them to gracefully handle both
239
+ object literals and collections.
240
+
241
+ ## Constructor Arguments
242
+
243
+ For all of these constructors, the argument `values` is an optional
244
+ collection of initial values, and may be an array. If the `values` are
245
+ in a map collection, the the values are taken, but the keys are ignored.
246
+
247
+ ### map
248
+
249
+ The `map` argument is an optional collection to copy shallowly into
250
+ the new mapping. The `map` may be an object literal. If `map`
251
+ implements `keys`, it is treated as a mapping itself and copied.
252
+ Otherwise, if `map` implements `forEach`, it may be any collection
253
+ of `[key, value]` pairs.
254
+
255
+ `equals(x, y)`, `compare(x, y)`, and `hash(value)` are all optional
256
+ arguments overriding the meaning of equality, comparability, and
257
+ consistent hashing for the purposes of the collection. `equals` must
258
+ return a boolean. `compare` must return an integer with the same
259
+ relationship to zero as x to y. `hash` should consistently return the
260
+ same string for any given object.
261
+
262
+ ### equals(x, y)
263
+
264
+ The default `equals` operator is implemented in terms of `===`, but
265
+ treats `NaN` as equal to itself and `-0` as distinct from `+0`. It
266
+ also delegates to an `equals` method of either the left or right
267
+ argument if one exists. The default equality operator is shimmed as
268
+ `Object.equals`.
269
+
270
+ ### compare(x, y)
271
+
272
+ The default `compare` operator is implemented in terms of `<` and
273
+ `>`. It delegates to the `compare` method of either the left or
274
+ right argument if one exists. It inverts the result if it uses the
275
+ falls to the right argument. The default comparator is shimmed as
276
+ `Object.compare`.
277
+
278
+ ### hash(value)
279
+
280
+ The default `hash` operator uses `toString` for values and provides
281
+ a [Unique Label][] for arbitrary objects. The default hash is
282
+ shimmed as `Object.hash`.
283
+
284
+ [Unique Label]: (http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps#unique_labeler)
285
+
286
+ ### getDefault(key or value)
287
+
288
+ The default `getDefault` function is `Function.noop`, which returns
289
+ `undefined`. The fallback function is used when you `get` a
290
+ nonexistant value from any collection. The `getDefault` function
291
+ becomes a member of the collection object, so `getDefault` is called
292
+ with the collection as `this`, so you can also use it to guarantee
293
+ that default values in a collection are retained, as in `MultiMap`.
294
+
295
+
296
+ ## Collection Methods
297
+
298
+ Where these methods coincide with the specification of an existing
299
+ method of Array, Array is noted as an implementation. `Array+` refers
300
+ to shimmed arrays, as installed with the `array` module. `Object`
301
+ refers to methods implemented on the `Object` constructor function, as
302
+ opposed to the `Object.prototype`. `Object+` in turn refers to methods
303
+ shimmed on the object constructor by the `object` module. These
304
+ functions accept the object as the first argument instead of the `this`
305
+ implied argument. ~~Strikethrough~~ indicates an implementation that
306
+ should exist but has not yet been made (Send a pull request!).
307
+
308
+ These are all of the collections:
309
+
310
+ (Array, Array+, Object+, Iterator, List, Set, Map, MultiMap, WeakMap,
311
+ SortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
312
+ SortedArrayMap, FastSet, FastMap, Dict)
313
+
314
+ ### has
315
+
316
+ #### has(key)
317
+
318
+ Whether a value for the given key exists.
319
+
320
+ (Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,
321
+ Dict)
322
+
323
+ #### has(value, opt_equals)
324
+
325
+ Whether a value exists in this collection. This is slow for list
326
+ (linear), but fast (logarithmic) for SortedSet and SortedArraySet,
327
+ and very fast (constant) for Set.
328
+
329
+ (Array+, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,
330
+ FastSet)
331
+
332
+ ### get
333
+
334
+ #### get(key or index)
335
+
336
+ The value for a key. If a Map or SortedMap lacks a key, returns
337
+ `getDefault(key)`.
338
+
339
+ (Array+, Map, SortedMap, SortedArrayMap, WeakMap, Object+)
340
+
341
+ #### get(value)
342
+
343
+ Gets the equivalent value, or falls back to `getDefault(value)`.
344
+
345
+ (List, Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet)
346
+
347
+ ### set(key or index, value)
348
+
349
+ Sets the value for a key.
350
+
351
+ (Map, MultiMap, WeakMap, SortedMap, LruMap, SortedArrayMap, FastMap,
352
+ Dict)
353
+
354
+ ### add
355
+
356
+ #### add(value)
357
+
358
+ Adds a value. Ignores the operation and returns false if an
359
+ equivalent value already exists.
360
+
361
+ (Array+, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,
362
+ FastSet, Heap)
363
+
364
+ #### add(value, key)
365
+
366
+ Aliases `set(key, value)`, to assist generic methods used for maps,
367
+ sets, and other collections.
368
+
369
+ ### addEach
370
+
371
+ #### addEach(values)
372
+
373
+ Copies values from another collection to this one.
374
+
375
+ (Array+, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,
376
+ FastSet, Heap)
377
+
378
+ #### addEach(mapping)
379
+
380
+ Copies entries from another collection to this map. If the mapping
381
+ implements `keys` (indicating that it is a mapping) and `forEach`,
382
+ all of the key value pairs are copied. If the mapping only
383
+ implements `forEach`, it is assumed to contain `[key, value]` arrays
384
+ which are copied instead.
385
+
386
+ (Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,
387
+ Dict)
388
+
389
+ ### delete
390
+
391
+ #### delete(key)
392
+
393
+ Deletes the value for a given key. Returns whether the key was
394
+ found.
395
+
396
+ (Map, MultiMap, WeakMap, SortedMap, LruMap, SortedArrayMap, FastMap,
397
+ Dict)
398
+
399
+ #### delete(value)
400
+
401
+ Deletes a value. Returns whether the value was found.
402
+
403
+ (Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet, Heap)
404
+
405
+ #### delete(value, equals)
406
+
407
+ Deletes the equivalent value. Returns whether the value was found.
408
+
409
+ (Array+, List)
410
+
411
+ ### deleteEach(values or keys)
412
+
413
+ Deletes every value or every value for each key.
414
+
415
+ (Array+, List, Set, Map, MultiMap, SortedSet, SortedMap,
416
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
417
+ FastSet, FastMap, Dict, Heap)
418
+
419
+ ### indexOf(value)
420
+
421
+ Returns the position in the collection of a value, or `-1` if it is
422
+ not found. Returns the position of the first of equivalent values.
423
+ For an Array this takes linear time. For a SortedArray and
424
+ SortedArraySet, it takes logarithmic time to perform a binary
425
+ search. For a SortedSet, this takes ammortized logarithmic time
426
+ since it incrementally updates the number of nodes under each
427
+ subtree as it rotates.
428
+
429
+ (Array, ~~List~~, SortedSet, SortedArray, SortedArraySet)
430
+
431
+ ### lastIndexOf(value)
432
+
433
+ Returns the position in the collection of a value, or `-1` if it is
434
+ not found. Returns the position of the last of equivalent values.
435
+
436
+ (Array, ~~List~~, SortedArray, SortedArraySet)
437
+
438
+ ### find(value, opt_equals)
439
+
440
+ Finds a value. For List and SortedSet, returns the node at which
441
+ the value was found. For SortedSet, the optional `equals` argument
442
+ is ignored.
443
+
444
+ (Array+, List, SortedSet)
445
+
446
+ ### findLast(value, opt_equals)
447
+
448
+ Finds the last equivalent value, returning the node at which the
449
+ value was found.
450
+
451
+ (Array+, List, SortedArray, SortedArraySet)
452
+
453
+ ### findLeast()
454
+
455
+ Finds the smallest value, returning the node at which it was found,
456
+ or undefined. This is fast (logarithmic) and performs no rotations.
457
+
458
+ (SortedSet)
459
+
460
+ ### findLeastGreaterThan(value)
461
+
462
+ Finds the smallest value greater than the given value. This is fast
463
+ (logarithic) but does cause rotations.
464
+
465
+ (SortedSet)
466
+
467
+ ### findLeastGreaterThanOrEqual(value)
468
+
469
+ Finds the smallest value greater than or equal to the given value.
470
+ This is fast (logarithmic) but does cause rotations.
471
+
472
+ (SortedSet)
473
+
474
+ ### findGreatest()
475
+
476
+ (SortedSet)
477
+
478
+ ### findGreatestLessThan(value)
479
+
480
+ (SortedSet)
481
+
482
+ ### findGreatestLessThanOrEqual(value)
483
+
484
+ (SortedSet)
485
+
486
+ ### push
487
+
488
+ #### push(...values)
489
+
490
+ Adds values to the end of a collection.
491
+
492
+ (Array, List)
493
+
494
+ #### push(...values) for non-dequeues
495
+
496
+ Adds values to their proper places in a collection.
497
+ This method exists only to have the same interface as other
498
+ collections.
499
+
500
+ (Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet, Heap)
501
+
502
+ ### unshift
503
+
504
+ #### unshift(...values)
505
+
506
+ Adds values to the beginning of a collection.
507
+
508
+ (Array, List)
509
+
510
+ #### unshift(...values) for non-dequeues
511
+
512
+ Adds values to their proper places in a collection.
513
+ This method exists only to have the same interface as other
514
+ collections.
515
+
516
+ (Set, SortedSet, LruSet, SortedArray, SortedArraySet, FastSet)
517
+
518
+ ### pop()
519
+
520
+ Removes and returns the value at the end of a collection. For a
521
+ Heap, this means the greatest contained value, as defined by the
522
+ comparator.
523
+
524
+ (Array, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,
525
+ Heap)
526
+
527
+ ### shift()
528
+
529
+ Removes and returns the value at the beginning of a collection.
530
+
531
+ (Array, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet)
532
+
533
+ ### peek()
534
+
535
+ Returns the last value in an ordered collection.
536
+
537
+ (List)
538
+
539
+ ### poke(value)
540
+
541
+ Replaces the last value in an ordered collection.
542
+
543
+ (List)
544
+
545
+ ### slice(start, end)
546
+
547
+ Returns an array of the values contained in the
548
+ half-open interval [start, end), that is, including the start and
549
+ excluding the end. For lists and arrays, both terms may be numeric
550
+ positive or negative indicies. For a list, either term may be a
551
+ node.
552
+
553
+ (Array, List, SortedSet, SortedArray, SortedArraySet)
554
+
555
+ ### splice(start, length, ...values)
556
+
557
+ Works as with an array, but for a list, the start may be an index or
558
+ a node.
559
+
560
+ (Array, List, SortedArray, SortedSet, SortedArraySet)
561
+
562
+ ### swap(start, length, values)
563
+
564
+ Performs a splice without variadic arguments.
565
+
566
+ (Array+, List, SortedArray, SortedSet, SortedArraySet)
567
+
568
+ ### clear()
569
+
570
+ Deletes the all values.
571
+
572
+ (Array+, Object+, List, Set, Map, MultiMap, SortedSet,
573
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
574
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
575
+
576
+ ### sort(compare)
577
+
578
+ Sorts a collection in place. The comparator by only be a function.
579
+ The default comparator coerces unlike types rather than fail to
580
+ compare.
581
+
582
+ (Array)
583
+
584
+ ### sorted(compare, by, order)
585
+
586
+ Returns a collection as an array in sorted order. Accepts an
587
+ optional `compare(x, y)` function, `by(property(x))` function, and
588
+ `order` indicator, `-1` for descending, `1` for ascending, `0` for
589
+ stable.
590
+
591
+ Instead of a `compare` function, the comparator can be an object
592
+ with `compare` and `by` functions. The default `compare` value is
593
+ `Object.compare`.
594
+
595
+ The `by` function must be a function that accepts a value from the
596
+ collection and returns a representative value on which to sort.
597
+
598
+ (Array+, List, Set, Map, SortedSet, LruSet, SortedArray,
599
+ SortedArraySet, FastSet, Heap)
600
+
601
+ ### group(callback, thisp, equals)
602
+
603
+ Returns an array of [key, equivalence class] pairs where every
604
+ element from the collection is placed into an equivalence class
605
+ if they have the same corresponding return value from the given
606
+ callback.
607
+
608
+ (Array+, Object+, List, Set, Map, MultiMap, SortedSet,
609
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
610
+ SortedArrayMap, FastSet, FastMap, Dict, Heap, Iterator)
611
+
612
+ ### reverse()
613
+
614
+ Reverses a collection in place.
615
+
616
+ (Array, List)
617
+
618
+ ### reversed()
619
+
620
+ Returns a collection of the same type with this collection's
621
+ contents in reverse order.
622
+
623
+ (Array, List)
624
+
625
+ ### enumerate(start=0)
626
+
627
+ Returns an array of [index, value] pairs from the source collection,
628
+ starting with the given index.
629
+
630
+ ### join(delimiter="")
631
+
632
+ Returns a string of all the values in the collection joined.
633
+
634
+ (Array, List, Set, SortedSet, LruSet, SortedArray, SortedArraySet,
635
+ FastSet, Heap, Iterator)
636
+
637
+ ### concat(...iterables)
638
+
639
+ Produces a new collection of the same type containing all the values
640
+ of itself and the values of any number of other collections. Favors
641
+ the last of duplicate values. For map-like objects, the given
642
+ iterables are treated as map-like objects and each successively
643
+ updates the result. Array is like a map from index to value. List,
644
+ Set, and SortedSet are like maps from nodes to values.
645
+
646
+ (Array, ~~Object+~~, Iterator, List, Set, Map, MultiMap,
647
+ SortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
648
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
649
+
650
+ ### keys()
651
+
652
+ Returns an array of the keys.
653
+
654
+ (Object, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,
655
+ Dict)
656
+
657
+ ### values()
658
+
659
+ Returns an array of the values
660
+
661
+ (Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,
662
+ Dict)
663
+
664
+ ### entries()
665
+
666
+ Returns an array of `[key, value]` pairs for each entry.
667
+
668
+ (Object+, Map, MultiMap, SortedMap, LruMap, SortedArrayMap, FastMap,
669
+ Dict)
670
+
671
+ ### reduce(callback(result, value, key, object, depth), basis, thisp)
672
+
673
+ (Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
674
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
675
+ FastSet, FastMap, Dict, Heap)
676
+
677
+ ### reduceRight(callback(result, value, key, object, depth), basis, thisp)
678
+
679
+ (Array, List, SortedSet, ~~SortedMap~~, SortedArray, SortedArraySet,
680
+ ~~SortedArrayMap~~, Heap)
681
+
682
+ ### forEach(callback(value, key, object, depth), thisp)
683
+
684
+ Calls the callback for each value in the collection. The iteration
685
+ of lists is resilient to changes to the list. Particularly, nodes
686
+ added after the current node will be visited and nodes added before
687
+ the current node will be ignored, and no node will be visited twice.
688
+
689
+ (Array, Object+, Iterator, List, Set, Map, MultiMap, WeakMap,
690
+ SortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
691
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
692
+
693
+ ### map(callback(value, key, object, depth), thisp)
694
+
695
+ (Array, Object+, Iterator, List, Set, Map, MultiMap, WeakMap,
696
+ SortedSet, SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
697
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
698
+
699
+ ### toArray()
700
+
701
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
702
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
703
+ FastSet, FastMap, Dict, Heap)
704
+
705
+ ### toObject()
706
+
707
+ Converts any collection to an object, treating this collection as a
708
+ map-like object. Array is like a map from index to value.
709
+
710
+ (Array+ Iterator, List, Map, MultiMap, SortedMap, LruMap,
711
+ SortedArrayMap, FastMap, Dict, Heap)
712
+
713
+ ### filter(callback(value, key, object, depth), thisp)
714
+
715
+ (Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
716
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
717
+ FastSet, FastMap, Dict, Heap)
718
+
719
+ ### every(callback(value, key, object, depth), thisp)
720
+
721
+ Whether every value passes a given guard. Stops evaluating the
722
+ guard after the first failure. Iterators stop consuming after the
723
+ the first failure.
724
+
725
+ (Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
726
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
727
+ FastSet, FastMap, Dict, Heap)
728
+
729
+ ### some(callback(value, key, object, depth), thisp)
730
+
731
+ Whether there is a value that passes a given guard. Stops
732
+ evaluating the guard after the first success. Iterators stop
733
+ consuming after the first success.
734
+
735
+ (Array, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
736
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
737
+ FastSet, FastMap, Dict, Heap)
738
+
739
+ ### any()
740
+
741
+ Whether any value is truthy.
742
+
743
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
744
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
745
+ FastSet, FastMap, Dict, Heap)
746
+
747
+ ### all()
748
+
749
+ Whether all values are truthy.
750
+
751
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
752
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
753
+ FastSet, FastMap, Dict, Heap)
754
+
755
+ ### min()
756
+
757
+ The smallest value. This is fast for sorted collections (logarithic
758
+ for SortedSet, constant for SortedArray, SortedArraySet, and
759
+ SortedArrayMap), but slow for everything else (linear).
760
+
761
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
762
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
763
+ FastSet, FastMap, Dict)
764
+
765
+ ### max()
766
+
767
+ The largest value. This is fast for sorted collections (logarithic
768
+ for SortedSet, constant for SortedArray, SortedArraySet, and
769
+ SortedArrayMap), but slow for everything else (linear).
770
+
771
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
772
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
773
+ FastSet, FastMap, Dict, Heap)
774
+
775
+ ### one()
776
+
777
+ Any single value, or throws an exception if there are no values. This
778
+ is very fast (constant time) for most collections. For a sorted set,
779
+ `set.root.value` is always very fast to access, but changes whenever you
780
+ *access* a value, including using `has` or `find`. In the interest of
781
+ being consistent across accesses, and only changing in response to
782
+ mutation, `one` returns the `min` of the set in logarithmic time.
783
+
784
+ (Array+, List, Set, Map, MultiMap, SortedSet, SortedMap, LruSet,
785
+ LruMap, SortedArray, SortedArray, SortedArraySet, SortedArrayMap,
786
+ FastSet, FastMap, Dict, Heap)
787
+
788
+ ### only()
789
+
790
+ The one and only value, or throws an exception if there are no
791
+ values or more than one value.
792
+
793
+ (Array+, List, Set, Map, MultiMap, SortedSet, SortedMap, LruSet,
794
+ LruMap, SortedArray, SortedArray, SortedArraySet, SortedArrayMap,
795
+ FastSet, FastMap, Dict, Heap)
796
+
797
+ ### sum()
798
+
799
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet,
800
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
801
+ SortedArrayMap, FastSet, FastMap, Dict)
802
+
803
+ ### average()
804
+
805
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet,
806
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
807
+ SortedArrayMap, FastSet, FastMap, Dict)
808
+
809
+ ### flatten()
810
+
811
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet,
812
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
813
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
814
+
815
+ ### zip(...collections)
816
+
817
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet,
818
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
819
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
820
+
821
+ ### enumrate(zero)
822
+
823
+ (Array+, Iterator, List, Set, Map, MultiMap, SortedSet, SortedMap,
824
+ LruSet, LruMap, SortedArray, SortedArraySet, SortedArrayMap,
825
+ FastSet, FastMap, Dict, Heap)
826
+
827
+ ### clone(depth, memo)
828
+
829
+ Replicates the collection. Clones the values deeply, to the
830
+ specified depth, using the memo to resolve reference cycles. (which
831
+ must the `has` and `set` parts of the Map interface, allowing
832
+ objects for keys) The default depth is infinite and the default
833
+ memo is a WeakMap.
834
+
835
+ `Object.clone` can replicate object literals inheriting directly
836
+ from `Object.prototype` or `null`, or any object that implements
837
+ `clone` on its prototype. Any other object causes `clone` to throw
838
+ an exception.
839
+
840
+ The `clone` method on any other objects is not intended to be used
841
+ directly since they do not necessarily supply a default depth and
842
+ memo.
843
+
844
+ (Array+, Object+, List, Set, Map, MultiMap, SortedSet,
845
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
846
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
847
+
848
+ ### constructClone(values)
849
+
850
+ Replicates a collection shallowly. This is used by each `clone`
851
+ implementation to create a new collection of the same type, with the
852
+ same options (`equals`, `compare`, `hash` options), but it leaves
853
+ the job of deeply cloning the values to the more general `clone`
854
+ method.
855
+
856
+ (Array+, Object+, List, Set, Map, MultiMap, SortedSet,
857
+ SortedMap, LruSet, LruMap, SortedArray, SortedArraySet,
858
+ SortedArrayMap, FastSet, FastMap, Dict, Heap)
859
+
860
+ ### equals(that, equals)
861
+
862
+ (Array+, Object+, List, Set, Map, MultiMap, SortedSet, SortedMap,
863
+ LruSet, LruMap, ~~SortedArray~~, SortedArraySet, SortedArrayMap,
864
+ FastSet, FastMap, Dict)
865
+
866
+ ### compare(that)
867
+
868
+ (Array+, Object+, List, ~~SortedArray~~, ~~SortedArraySet~~)
869
+
870
+ ### iterate
871
+
872
+ #### iterate()
873
+
874
+ Produces an iterator with a `next` method. You may elect to get
875
+ richer iterators by wrapping this iterator with an `Iterator` from
876
+ the `iterator` module. Iteration order of lists is resilient to
877
+ changes to the list.
878
+
879
+ (Array+, Iterator, List, Set, SortedSet, LruSet, SortedArray,
880
+ SortedArraySet, FastSet)
881
+
882
+ #### iterate(start, end)
883
+
884
+ Returns an iterator for all values at indicies in the half-open
885
+ interval [start, end), that is, greater than start, and less than
886
+ end.
887
+
888
+ (Array+)
889
+
890
+ #### iterate(start, end)
891
+
892
+ Returns an iterator for all values in the half-open interval [start,
893
+ end), that is, greater than start, and less than end. The iterator
894
+ is resilient against changes to the data.
895
+
896
+ (SortedSet)
897
+
898
+ ### log(charmap, callback(node, write, writeAbove), log, logger)
899
+
900
+ Writes a tree describing the internal state of the data structure to
901
+ the console.
902
+
903
+ `charmap` is an object that notes which characters to use to draw
904
+ lines. By default, this is the `TreeLog.unicodeRound` property from the
905
+ `tree-log` module. `TreeLog.unicodeSharp` and `TreeLog.ascii` are
906
+ alternatives. The properties are:
907
+
908
+ - intersection: ╋
909
+ - through: ━
910
+ - branchUp: ┻
911
+ - branchDown: ┳
912
+ - fromBelow: ╭
913
+ - fromAbove: ╰
914
+ - fromBoth: ┣
915
+ - strafe: ┃
916
+
917
+ `callback` is a customizable function for rendering each node of the tree.
918
+ By default, it just writes the value of the node. It accepts the node and
919
+ a writer functions. The `write` function produces the line on which the
920
+ node joins the tree, and each subsequent line. The `writeAbove` function
921
+ can write lines before the branch.
922
+
923
+ `log` and `logger` default to `console.log` and `console`. To write
924
+ the representation to an array instead, they can be `array.push` and
925
+ `array`.
926
+
927
+ (SortedSet)
928
+
929
+
930
+ ### Iterator
931
+
932
+ #### dropWhile(callback(value, index, iterator), thisp)
933
+
934
+ #### takeWhile(callback(value, index, iterator), thisp)
935
+
936
+ #### mapIterator(callback(value, index, iterator))
937
+
938
+ Returns an iterator for a mapping on the source values. Values are
939
+ consumed on demand.
940
+
941
+ #### filterIterator(callback(value, index, iterator))
942
+
943
+ Returns an iterator for those values from the source that pass the
944
+ given guard. Values are consumed on demand.
945
+
946
+ #### zipIterator(...iterables)
947
+
948
+ Returns an iterator that incrementally combines the respective
949
+ values of the given iterations.
950
+
951
+ #### enumerateIterator(start = 0)
952
+
953
+ Returns an iterator that provides [index, value] pairs from the
954
+ source iteration.
955
+
956
+
957
+ ### Iterator utilities
958
+
959
+ #### cycle(iterable, times)
960
+
961
+ #### concat(iterables)
962
+
963
+ #### transpose(iterables)
964
+
965
+ #### zip(...iterables)
966
+
967
+ Variadic transpose.
968
+
969
+ #### chain(...iterables)
970
+
971
+ Variadic concat.
972
+
973
+ #### range(start, stop, step)
974
+
975
+ Iterates from start to stop by step.
976
+
977
+ #### count(start, step)
978
+
979
+ Iterates from start by step, indefinitely.
980
+
981
+ #### repeat(value, times)
982
+
983
+ Repeats the given value either finite times or indefinitely.
984
+
985
+
986
+ ## Change Listeners
987
+
988
+ All collections support change listeners. There are three types of
989
+ changes. Property changes, map changes, and range changes.
990
+
991
+ ### Property Changes
992
+
993
+ `PropertyChanges` from the `listen/property-changes` module can
994
+ configure listeners for property changes to specific keys of any object.
995
+
996
+ With the `listen/array-changes` module required, `PropertyChanges` can
997
+ also listen to changes to the length and indexed properties of an array.
998
+ The only caveat is that watched arrays can only modify their contents
999
+ with method calls like `array.push`. All methods of a watched array
1000
+ support change dispatch. In addition, arrays have a `set` method to
1001
+ make setting the value at a particular index observable.
1002
+
1003
+ - PropertyChanges.addOwnPropertyChangeListener(object, key, listener, before)
1004
+ - PropertyChanges.removeOwnPropertyChangeListener(object, key, listener, before)
1005
+ - PropertyChanges.dispatchOwnPropertyChange(object, key, value, before)
1006
+ - PropertyChanges.addBeforeOwnPropertyChangeListener(object, key, listener)
1007
+ - PropertyChanges.removeBeforeOwnPropertyChangeListener(object, key, listener)
1008
+ - PropertyChanges.dispatchBeforeOwnPropertyChange(object, key, value)
1009
+ - PropertyChanges.getOwnPropertyChangeDescriptor(object, key)
1010
+
1011
+ All of these functions delegate to methods of the same name if one
1012
+ exists on the object.
1013
+
1014
+ - object.addOwnPropertyChangeListener(key, listener, before)
1015
+ - object.removeOwnPropertyChangeListener(key, listener, before)
1016
+ - object.dispatchOwnPropertyChange(key, value, before)
1017
+ - object.addBeforeOwnPropertyChangeListener(key, listener)
1018
+ - object.removeBeforeOwnPropertyChangeListener(key, listener)
1019
+ - object.dispatchBeforeOwnPropertyChange(key, value)
1020
+ - object.getOwnPropertyChangeDescriptor(key)
1021
+
1022
+ Additionally, `PropertyChanges.prototype` can be **mixed into** other
1023
+ types of objects to support the property change dispatch interface. All
1024
+ collections support this interface.
1025
+
1026
+ The **listener** for a property change receives the arguments `value`,
1027
+ `key`, and `object`, just as a `forEach` or `map` callback. The
1028
+ listener may alternately be a delegate object that implements one of
1029
+ these methods:
1030
+
1031
+ - listener.handle + **key** + Change **or** WillChange
1032
+ - listener.handleProperty + Change **or** WillChange
1033
+ - listener.call
1034
+
1035
+ ### Map Changes
1036
+
1037
+ A map change listener receives notifications for the creation, removal,
1038
+ or updates for any entry in a map data structure.
1039
+
1040
+ With the `listen/array-changes` module required, `Array` can also
1041
+ dispatch map changes for the values at each index.
1042
+
1043
+ - collection.addMapChangeListener(listener, token, before)
1044
+ - collection.removeMapChangeListener(listener, token, before)
1045
+ - collection.dispatchMapChange(key, value, before)
1046
+ - collection.addBeforeMapChangeListener(listener)
1047
+ - collection.removeBeforeMapChangeListener(listener)
1048
+ - collection.dispatchBeforeMapChange(key, value)
1049
+ - collection.getMapChangeDescriptor()
1050
+
1051
+ The **listener** for a map change receives the `value`, `key`, and
1052
+ collection `object` as arguments, the same pattern as a `forEach` or
1053
+ `map` callback. In the after change phase, a value of `undefined` may
1054
+ indicate that the value was deleted or set to `undefined`. In the
1055
+ before change phase, a value of `undefined` may indicate the the value
1056
+ was added or was previously `undefined`.
1057
+
1058
+ The listener may be a delegate object with one of the following methods,
1059
+ in order of precedence:
1060
+
1061
+ - listener.handleMap + Change **or** WillChange
1062
+ - listener.handle + **token** + Map + Change **or** WillChange
1063
+ - listener.call
1064
+
1065
+ The `listen/map-changes` module exports a map changes **mixin**. The
1066
+ methods of `MaxChanges.prototype` can be copied to any collection that
1067
+ needs this interface. Its mutation methods will then need to dispatch
1068
+ map changes.
1069
+
1070
+ ### Range Changes
1071
+
1072
+ A range change listener receives notifications when a range of values at
1073
+ a particular position is added, removed, or replaced within an ordered
1074
+ collection.
1075
+
1076
+ - collection.**add**RangeChange**Listener**(listener, token, before)
1077
+ - collection.**remove**RangeChange**Listener**(listener, token, before)
1078
+ - collection.**dispatch**RangeChange(plus, minus, index, before)
1079
+ - collection.add**Before**RangeChange**Listener**(listener)
1080
+ - collection.remove**Before**RangeChange**Listener**(listener)
1081
+ - collection.dispatch**Before**RangeChange(plus, minus, index)
1082
+ - collection.**get**RangeChange**Descriptor**()
1083
+
1084
+ The **listener** for a range change is a function that accepts `plus`,
1085
+ `minus`, and `index` arguments. `plus` and `minus` are the values that
1086
+ were added or removed at the `index`. Whatever operation caused these
1087
+ changes is equivalent to:
1088
+
1089
+ ```javascript
1090
+ var minus = collection.splice(index, minus.length, ...plus)
1091
+ ```
1092
+
1093
+ The listener can alternately be a delegate object with one of the
1094
+ following methods in order of precedence:
1095
+
1096
+ - handle + **token** + Range + Change **or** WillChange
1097
+ - handleRange + Change **or** WillChange
1098
+ - call
1099
+
1100
+ The following support range change dispatch:
1101
+
1102
+ - `Array` with `require("collections/listen/array-changes")`
1103
+ - `SortedSet`
1104
+ - `SortedArray`
1105
+ - `SortedArraySet`
1106
+
1107
+ The `listen/range-changes` module exports a range changes **mixin**.
1108
+ The methods of `RangeChanges.prototype` can be copied to any collection
1109
+ that needs this interface. Its mutation methods will need to dispatch
1110
+ the range changes.
1111
+
1112
+ All **descriptors** are objects with the properties `changeListeners`
1113
+ and `willChangeListeners`. Both are arrays of listener functions or
1114
+ objects, in the order in which they were added.
1115
+
1116
+
1117
+ ## Miscellanea
1118
+
1119
+ ### Set and Map
1120
+
1121
+ Set and map are like hash tables, but not implemented with a block of
1122
+ memory as they would be in a lower-level language. Most of the work of
1123
+ providing fast insertion and lookup based on a hash is performed by the
1124
+ underlying plain JavaScript object. Each key of the object is a hash
1125
+ string and each value is a List of values with that hash. The inner
1126
+ list resolves collisions. With a good `hash` method, the use of the
1127
+ list can be avoided.
1128
+
1129
+ Sets and maps both have a `log` function that displays the internal
1130
+ structure of the bucket list in an NPM-style.
1131
+
1132
+ ```
1133
+ ┣━┳ 1
1134
+ ┃ ┗━━ {"key":1,"value":"a"}
1135
+ ┣━┳ 2
1136
+ ┃ ┣━━ {"key":2,"value":"c"}
1137
+ ┃ ┗━━ {"key":2,"value":"d"}
1138
+ ┗━┳ 3
1139
+ ┗━━ {"key":3,"value":"b"}
1140
+ ```
1141
+
1142
+
1143
+ ### Sorted Set and Sorted Map
1144
+
1145
+ A binary splay tree is a balanced binary tree that rotates the most
1146
+ frequently used entries toward the root such that they can be accessed the
1147
+ most quickly. `sorted-set` and `sorted-map` are backed by a splay tree.
1148
+
1149
+ All map implementations use an underlying set implementation. Any map
1150
+ can be implemented trivially atop a set by wrapping `compare`, `equals`,
1151
+ or `hash` to operate on the key of an entry.
1152
+
1153
+ The sorted set has a `root` node. Each node has a `left` and `right`
1154
+ property, which may be null. Nodes are returned by all of the "find"
1155
+ functions, and provided as the `key` argument to callbacks.
1156
+
1157
+ Both `sorted-set` and `sorted-map` implement a `log` function which can
1158
+ produce NPM-style visualizations of the internal state of the sorted
1159
+ tree.
1160
+
1161
+ ```
1162
+ > set.log(SortedSet.ascii)
1163
+ .-+ -3
1164
+ | '-- -2
1165
+ .-+ -1
1166
+ + 0
1167
+ | .-- 1
1168
+ '-+ 2
1169
+ '-- 3
1170
+ ```
1171
+
1172
+ ```
1173
+ > set.log(SortedSet.unicodeRound)
1174
+ ╭━┳ -3
1175
+ ┃ ╰━━ -2
1176
+ ╭━┻ -1
1177
+ ╋ 0
1178
+ ┃ ╭━┳ 1
1179
+ ┃ ┃ ╰━━ 2
1180
+ ╰━┻ 3
1181
+ ```
1182
+
1183
+
1184
+ ### Object and Function Shims
1185
+
1186
+ The collection methods on the `Object` constructor all polymorphically
1187
+ delegate to the corresponding method of any object that implements the
1188
+ method of the same name. So, `Object.has` can be used to check whether
1189
+ a key exists on an object, or in any collection that implements `has`.
1190
+ This permits the `Object` interface to be agnostic of the input type.
1191
+
1192
+ `Array.from` creates an array from any iterable.
1193
+
1194
+ `Array.unzip` transposes a collection of arrays, so rows become columns.
1195
+
1196
+ `Array.empty` is an empty array, frozen if possible. Do not modify it.
1197
+
1198
+ `Object.from` creates an object from any map or collection. For arrays
1199
+ and array-like collections, uses the index for the key.
1200
+
1201
+ `Object.empty` is an empty object literal.
1202
+
1203
+ `Object.isObject(value)` tests whether it is safe to attempt to access
1204
+ properties of a given value.
1205
+
1206
+ `Object.is(x, y)` compares objects for exact identity and is a good
1207
+ alternative to `Object.equals` in many collections.
1208
+
1209
+ `Object.getValueOf(value)` safely and idempotently returns the value of
1210
+ an object or value by only calling the `valueOf()` if the value
1211
+ implements that method.
1212
+
1213
+ `Object.owns` is a shorthand for `Object.prototype.hasOwnProperty.call`.
1214
+
1215
+ `Object.can(value, name)` checks whether an object implements a method
1216
+ on its prototype chain. An owned function property does not qualify as
1217
+ a method, to aid in distinguishing "static" functions.
1218
+
1219
+ `Object.concat(...maps)` and `Object.from(entries)` construct an object
1220
+ by adding the entries of other objects in order. The maps can be other
1221
+ objects, arrays of entries, or map alike collections.
1222
+
1223
+ `Function.noop` is returns undefined.
1224
+
1225
+ `Function.identity` returns its first argument.
1226
+
1227
+ `Function.by(relation)` creates a comparator from a relation function.
1228
+
1229
+ `Function.get(key)` creates a relation that returns the value for the
1230
+ property of a given object.
1231
+
1232
+
1233
+ ### References
1234
+
1235
+ - a SplayTree impementation buried in Fedor Indutny’s super-secret
1236
+ [Callgrind](https://github.com/indutny/callgrind.js). This
1237
+ implementation uses parent references.
1238
+ - a SplayTree implementation adapted by [Paolo
1239
+ Fragomeni](https://github.com/hij1nx/forest) from the V8 project and
1240
+ based on the top-down splaying algorithm from "Self-adjusting Binary
1241
+ Search Trees" by Sleator and Tarjan. This does not use or require
1242
+ parent references, so I favored it over Fedor Indutny’s style.
1243
+ - the interface of ECMAScript harmony [simple maps and
1244
+ sets](http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets)
1245
+ - a SplayTree implementation from [JavaScript data
1246
+ structures](derrickburns/Javascript-Data-Structures) mainted by
1247
+ Derrick Burns that supports change-resilient iterators and a
1248
+ comprehensive set of introspection functions.
1249
+
1250
+ ### Future work
1251
+
1252
+ Goals
1253
+
1254
+ - make array dispatch length property changes between range changes to
1255
+ be consistent with List.
1256
+ - automate the generation of the method support tables in readme and
1257
+ normalize declaration order
1258
+ - comprehensive specs and spec coverage tests
1259
+ - array set (a set, for fast lookup, backed by an array for meaningful
1260
+ range changes)
1261
+ - fast list splicing
1262
+ - dict map changes
1263
+ - revise map changes to use separate handlers for add/delete
1264
+ - revise tokens for range and map changes to specify complete alternate
1265
+ delegate methods, particularly for forwarding directly to dispatch
1266
+ - implement on/once/off listeners
1267
+ - Make it easier to created a SortedSet with a criterion like
1268
+ Function.by(Function.get('name'))
1269
+ - evaluate exposing observeProperty, observeRangeChange, and observeMapChange
1270
+ instead of the aEL/rEL inspired API FRB exposes today, to minimize
1271
+ book-keeping and garbage collection
1272
+
1273
+ More possible collections
1274
+
1275
+ - sorted-list (sorted, can contain duplicates, perhaps backed by splay
1276
+ tree with relaxation on the uniqueness invariant)
1277
+ - sorted-multi-map (sorted, can contain duplicate entries)
1278
+ - buffer (backed by a circular array, emits cull events)
1279
+ - emit cull events in LRU cache set and map
1280
+ - trie-set
1281
+ - trie-map
1282
+ - immutable-* (mutation functions return new objects that largely share
1283
+ the previous version's internal state, some perhaps backed by a hash
1284
+ trie)
1285
+