traceur-rb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (410) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +2 -2
  3. data/lib/js/compile.js +7 -15
  4. data/lib/traceur.rb +2 -1
  5. data/lib/traceur/compilation_error.rb +27 -0
  6. data/lib/traceur/compiler.rb +4 -1
  7. data/lib/traceur/configuration.rb +1 -1
  8. data/lib/traceur/node/runner.rb +1 -1
  9. data/lib/traceur/version.rb +1 -1
  10. data/spec/examples/syntax_error.js +3 -0
  11. data/spec/integration/examples_spec.rb +6 -0
  12. data/vendor/node_modules/traceur/LICENSE +202 -0
  13. data/vendor/node_modules/traceur/README.md +5 -5
  14. data/vendor/node_modules/traceur/bin/traceur-runtime.js +1392 -623
  15. data/vendor/node_modules/traceur/bin/traceur.js +24749 -17990
  16. data/vendor/node_modules/traceur/node_modules/.bin/semver +2 -2
  17. data/vendor/node_modules/traceur/node_modules/commander/History.md +222 -0
  18. data/vendor/node_modules/traceur/node_modules/commander/Readme.md +127 -35
  19. data/vendor/node_modules/traceur/node_modules/commander/index.js +261 -93
  20. data/vendor/node_modules/traceur/node_modules/commander/package.json +41 -9
  21. data/vendor/node_modules/traceur/node_modules/glob/LICENSE +15 -0
  22. data/vendor/node_modules/traceur/node_modules/glob/README.md +357 -0
  23. data/vendor/node_modules/traceur/node_modules/glob/common.js +177 -0
  24. data/vendor/node_modules/traceur/node_modules/glob/glob.js +649 -0
  25. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/.eslintrc +17 -0
  26. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/LICENSE +15 -0
  27. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/README.md +37 -0
  28. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/inflight.js +44 -0
  29. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE +15 -0
  30. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md +36 -0
  31. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +34 -0
  32. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js +51 -0
  33. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js +33 -0
  34. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/package.json +61 -0
  35. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/test.js +97 -0
  36. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/LICENSE +16 -0
  37. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/README.md +42 -0
  38. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/inherits.js +1 -0
  39. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
  40. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/package.json +33 -0
  41. data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/test.js +25 -0
  42. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/.npmignore +1 -0
  43. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/.travis.yml +4 -0
  44. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/LICENSE +23 -0
  45. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/README.md +216 -0
  46. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/benchmark.js +15 -0
  47. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/browser.js +1181 -0
  48. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/minimatch.js +845 -0
  49. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +2 -0
  50. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml +3 -0
  51. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +121 -0
  52. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
  53. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
  54. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
  55. data/vendor/node_modules/traceur/node_modules/{q-io/node_modules/collections → glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.travis.yml +0 -0
  56. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
  57. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
  58. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
  59. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
  60. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +73 -0
  61. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
  62. data/vendor/node_modules/traceur/node_modules/{q-io/node_modules/url2 → glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/.travis.yml +1 -1
  63. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
  64. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
  65. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
  66. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
  67. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +83 -0
  68. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
  69. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +75 -0
  70. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js +32 -0
  71. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt +1075 -0
  72. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt +182 -0
  73. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js +9 -0
  74. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js +10 -0
  75. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh +24 -0
  76. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js +15 -0
  77. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js +16 -0
  78. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js +10 -0
  79. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js +13 -0
  80. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js +7 -0
  81. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js +50 -0
  82. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/package.json +60 -0
  83. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/basic.js +399 -0
  84. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/brace-expand.js +45 -0
  85. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/defaults.js +274 -0
  86. data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
  87. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/LICENSE +27 -0
  88. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/README.md +51 -0
  89. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +15 -0
  90. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
  91. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +34 -0
  92. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
  93. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
  94. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/once.js +21 -0
  95. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/package.json +42 -0
  96. data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/test/once.js +23 -0
  97. data/vendor/node_modules/traceur/node_modules/glob/package.json +72 -0
  98. data/vendor/node_modules/traceur/node_modules/glob/sync.js +409 -0
  99. data/vendor/node_modules/traceur/node_modules/rsvp/.release.json +17 -0
  100. data/vendor/node_modules/traceur/node_modules/rsvp/CHANGELOG.md +165 -0
  101. data/vendor/node_modules/traceur/node_modules/rsvp/LICENSE +19 -0
  102. data/vendor/node_modules/traceur/node_modules/rsvp/README.md +364 -0
  103. data/vendor/node_modules/traceur/node_modules/rsvp/dist/rsvp.js +1671 -0
  104. data/vendor/node_modules/traceur/node_modules/rsvp/dist/rsvp.min.js +9 -0
  105. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp.js +66 -0
  106. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp.umd.js +50 -0
  107. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/-internal.js +265 -0
  108. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/all-settled.js +71 -0
  109. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/all.js +15 -0
  110. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/asap.js +109 -0
  111. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/config.js +28 -0
  112. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/defer.js +45 -0
  113. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/enumerator.js +125 -0
  114. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/events.js +201 -0
  115. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/filter.js +120 -0
  116. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/hash-settled.js +124 -0
  117. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/hash.js +94 -0
  118. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/instrument.js +41 -0
  119. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/map.js +99 -0
  120. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/node.js +281 -0
  121. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise-hash.js +51 -0
  122. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise.js +496 -0
  123. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/all.js +52 -0
  124. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/race.js +105 -0
  125. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/reject.js +47 -0
  126. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/resolve.js +49 -0
  127. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/race.js +15 -0
  128. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/reject.js +16 -0
  129. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/resolve.js +17 -0
  130. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/rethrow.js +46 -0
  131. data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/utils.js +39 -0
  132. data/vendor/node_modules/traceur/node_modules/rsvp/package.json +100 -0
  133. data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/README.md +9 -0
  134. data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/bower.json +22 -0
  135. data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/composer.json +18 -0
  136. data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/package.json +52 -0
  137. data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/rsvp.amd.js +1607 -0
  138. data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/rsvp.js +1566 -0
  139. data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/rsvp.min.js +26 -0
  140. data/vendor/node_modules/traceur/node_modules/rsvp/vertx.js +1 -0
  141. data/vendor/node_modules/traceur/node_modules/semver/bin/semver +2 -2
  142. data/vendor/node_modules/traceur/node_modules/semver/package.json +4 -3
  143. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +7 -0
  144. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
  145. data/vendor/node_modules/traceur/node_modules/semver/semver.js +7 -0
  146. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -1
  147. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
  148. data/vendor/node_modules/traceur/node_modules/semver/test/index.js +8 -4
  149. data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +2 -1
  150. data/vendor/node_modules/traceur/node_modules/source-map-support/.npmignore +1 -0
  151. data/vendor/node_modules/traceur/node_modules/{q-io/node_modules/mime/LICENSE → source-map-support/LICENSE.md} +7 -5
  152. data/vendor/node_modules/traceur/node_modules/source-map-support/README.md +165 -0
  153. data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/browser-source-map-support.js +89 -0
  154. data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/index.html +6 -0
  155. data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/require.js +36 -0
  156. data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/script.coffee +13 -0
  157. data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/script.js +24 -0
  158. data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/script.map +10 -0
  159. data/vendor/node_modules/traceur/node_modules/source-map-support/browser-source-map-support.js +89 -0
  160. data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/index.html +6 -0
  161. data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/script.coffee +12 -0
  162. data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/script.js +25 -0
  163. data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/script.map +10 -0
  164. data/vendor/node_modules/traceur/node_modules/source-map-support/build.js +69 -0
  165. data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/index.html +6 -0
  166. data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/script.coffee +12 -0
  167. data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/script.js +25 -0
  168. data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/script.map +10 -0
  169. data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/server.js +45 -0
  170. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/.npmignore +2 -0
  171. data/vendor/node_modules/traceur/node_modules/{q-io → source-map-support/node_modules/source-map}/.travis.yml +1 -0
  172. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/CHANGELOG.md +121 -0
  173. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/LICENSE +28 -0
  174. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/Makefile.dryice.js +166 -0
  175. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/README.md +434 -0
  176. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/assert-shim.js +56 -0
  177. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/mini-require.js +152 -0
  178. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/prefix-source-map.jsm +20 -0
  179. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/prefix-utils.jsm +18 -0
  180. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-browser.js +8 -0
  181. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-source-map.jsm +6 -0
  182. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-utils.jsm +21 -0
  183. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/test-prefix.js +8 -0
  184. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/test-suffix.js +3 -0
  185. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map.js +8 -0
  186. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/array-set.js +97 -0
  187. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
  188. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js +42 -0
  189. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/binary-search.js +81 -0
  190. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-map-consumer.js +478 -0
  191. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-map-generator.js +380 -0
  192. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-node.js +371 -0
  193. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/util.js +205 -0
  194. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
  195. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/README.md +171 -0
  196. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
  197. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/intercept.js +36 -0
  198. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/package.json +37 -0
  199. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/package.json +142 -0
  200. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/run-tests.js +62 -0
  201. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-api.js +26 -0
  202. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-array-set.js +104 -0
  203. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
  204. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-base64.js +35 -0
  205. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
  206. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
  207. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-map-consumer.js +451 -0
  208. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-map-generator.js +417 -0
  209. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-node.js +365 -0
  210. data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/util.js +161 -0
  211. data/vendor/node_modules/traceur/node_modules/source-map-support/package.json +52 -0
  212. data/vendor/node_modules/traceur/node_modules/source-map-support/source-map-support.js +381 -0
  213. data/vendor/node_modules/traceur/node_modules/source-map-support/test.js +359 -0
  214. data/vendor/node_modules/traceur/package.json +234 -20
  215. data/vendor/node_modules/traceur/src/node/NodeCompiler.js +78 -0
  216. data/vendor/node_modules/traceur/src/node/System.js +32 -5
  217. data/vendor/node_modules/traceur/src/node/api.js +28 -93
  218. data/vendor/node_modules/traceur/src/node/command.js +84 -19
  219. data/vendor/node_modules/traceur/src/node/compileAllJsFilesInDir.js +40 -0
  220. data/vendor/node_modules/traceur/src/node/interpreter.js +11 -8
  221. data/vendor/node_modules/traceur/src/node/recursiveModuleCompile.js +171 -0
  222. data/vendor/node_modules/traceur/src/node/require.js +7 -21
  223. data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +2 -7
  224. data/vendor/node_modules/traceur/src/node/to-closure-compiler.js +28 -0
  225. data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +3 -7
  226. data/vendor/node_modules/traceur/src/node/traceur.js +1 -1
  227. metadata +196 -190
  228. data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +0 -1
  229. data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +0 -122
  230. data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +0 -19
  231. data/vendor/node_modules/traceur/node_modules/q-io/README.md +0 -928
  232. data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +0 -59
  233. data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +0 -44
  234. data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +0 -51
  235. data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +0 -307
  236. data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +0 -499
  237. data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +0 -547
  238. data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +0 -105
  239. data/vendor/node_modules/traceur/node_modules/q-io/fs.js +0 -355
  240. data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +0 -65
  241. data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +0 -152
  242. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +0 -24
  243. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +0 -93
  244. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +0 -154
  245. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +0 -178
  246. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +0 -417
  247. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +0 -58
  248. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +0 -78
  249. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +0 -120
  250. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +0 -27
  251. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +0 -209
  252. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +0 -125
  253. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +0 -175
  254. data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +0 -75
  255. data/vendor/node_modules/traceur/node_modules/q-io/http.js +0 -378
  256. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +0 -11
  257. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +0 -78
  258. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +0 -21
  259. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +0 -1285
  260. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +0 -22
  261. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +0 -142
  262. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +0 -57
  263. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +0 -183
  264. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +0 -261
  265. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +0 -186
  266. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +0 -55
  267. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +0 -59
  268. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +0 -236
  269. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +0 -371
  270. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +0 -435
  271. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +0 -247
  272. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +0 -147
  273. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +0 -448
  274. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +0 -139
  275. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +0 -79
  276. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +0 -142
  277. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +0 -60
  278. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +0 -41
  279. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +0 -12
  280. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +0 -7
  281. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +0 -48
  282. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +0 -590
  283. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +0 -49
  284. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +0 -173
  285. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +0 -274
  286. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +0 -59
  287. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +0 -538
  288. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +0 -14
  289. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +0 -6
  290. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +0 -49
  291. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +0 -51
  292. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +0 -269
  293. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +0 -61
  294. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +0 -736
  295. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +0 -40
  296. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +0 -1
  297. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +0 -66
  298. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +0 -114
  299. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +0 -35
  300. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +0 -84
  301. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +0 -1588
  302. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +0 -77
  303. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +0 -15
  304. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +0 -19
  305. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +0 -96
  306. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +0 -166
  307. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +0 -43
  308. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +0 -40
  309. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +0 -19
  310. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +0 -813
  311. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +0 -71
  312. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +0 -36
  313. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +0 -93
  314. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +0 -1937
  315. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +0 -35
  316. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +0 -6
  317. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +0 -36
  318. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +0 -7
  319. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +0 -38
  320. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +0 -32
  321. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +0 -39
  322. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +0 -2
  323. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +0 -123
  324. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +0 -19
  325. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +0 -3
  326. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +0 -3
  327. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +0 -128
  328. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +0 -53
  329. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +0 -61
  330. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +0 -856
  331. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +0 -1080
  332. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +0 -377
  333. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +0 -290
  334. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +0 -3
  335. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +0 -42
  336. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +0 -4
  337. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +0 -16
  338. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +0 -12
  339. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +0 -91
  340. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +0 -12
  341. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +0 -13
  342. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +0 -14
  343. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +0 -146
  344. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +0 -39
  345. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +0 -48
  346. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +0 -3
  347. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +0 -22
  348. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +0 -6
  349. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +0 -248
  350. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +0 -53
  351. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +0 -2
  352. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +0 -91
  353. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +0 -548
  354. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +0 -8
  355. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +0 -358
  356. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +0 -133
  357. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +0 -3
  358. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +0 -20
  359. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +0 -33
  360. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +0 -37
  361. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +0 -125
  362. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +0 -151
  363. data/vendor/node_modules/traceur/node_modules/q-io/package.json +0 -51
  364. data/vendor/node_modules/traceur/node_modules/q-io/reader.js +0 -133
  365. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +0 -47
  366. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +0 -11
  367. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +0 -1
  368. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +0 -33
  369. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +0 -92
  370. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +0 -41
  371. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +0 -57
  372. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +0 -1
  373. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +0 -70
  374. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +0 -109
  375. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +0 -67
  376. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +0 -219
  377. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +0 -20
  378. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +0 -26
  379. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +0 -40
  380. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +0 -37
  381. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +0 -39
  382. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +0 -32
  383. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +0 -26
  384. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +0 -86
  385. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +0 -31
  386. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +0 -73
  387. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +0 -23
  388. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +0 -1
  389. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +0 -22
  390. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +0 -25
  391. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +0 -45
  392. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +0 -38
  393. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +0 -52
  394. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +0 -86
  395. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +0 -1
  396. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +0 -1
  397. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
  398. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
  399. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +0 -49
  400. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +0 -47
  401. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +0 -186
  402. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +0 -82
  403. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +0 -110
  404. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +0 -96
  405. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +0 -96
  406. data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +0 -42
  407. data/vendor/node_modules/traceur/node_modules/q-io/writer.js +0 -111
  408. data/vendor/node_modules/traceur/src/node/compile-single-file.js +0 -69
  409. data/vendor/node_modules/traceur/src/node/compiler.js +0 -116
  410. data/vendor/node_modules/traceur/src/node/inline-module.js +0 -149
@@ -0,0 +1,281 @@
1
+ import Promise from './promise';
2
+ import {
3
+ noop,
4
+ resolve,
5
+ reject
6
+ } from './-internal';
7
+ import { isArray } from './utils';
8
+
9
+ function Result() {
10
+ this.value = undefined;
11
+ }
12
+
13
+ var ERROR = new Result();
14
+ var GET_THEN_ERROR = new Result();
15
+
16
+ function getThen(obj) {
17
+ try {
18
+ return obj.then;
19
+ } catch(error) {
20
+ ERROR.value= error;
21
+ return ERROR;
22
+ }
23
+ }
24
+
25
+
26
+ function tryApply(f, s, a) {
27
+ try {
28
+ f.apply(s, a);
29
+ } catch(error) {
30
+ ERROR.value = error;
31
+ return ERROR;
32
+ }
33
+ }
34
+
35
+ function makeObject(_, argumentNames) {
36
+ var obj = {};
37
+ var name;
38
+ var i;
39
+ var length = _.length;
40
+ var args = new Array(length);
41
+
42
+ for (var x = 0; x < length; x++) {
43
+ args[x] = _[x];
44
+ }
45
+
46
+ for (i = 0; i < argumentNames.length; i++) {
47
+ name = argumentNames[i];
48
+ obj[name] = args[i + 1];
49
+ }
50
+
51
+ return obj;
52
+ }
53
+
54
+ function arrayResult(_) {
55
+ var length = _.length;
56
+ var args = new Array(length - 1);
57
+
58
+ for (var i = 1; i < length; i++) {
59
+ args[i - 1] = _[i];
60
+ }
61
+
62
+ return args;
63
+ }
64
+
65
+ function wrapThenable(then, promise) {
66
+ return {
67
+ then: function(onFulFillment, onRejection) {
68
+ return then.call(promise, onFulFillment, onRejection);
69
+ }
70
+ };
71
+ }
72
+
73
+ /**
74
+ `RSVP.denodeify` takes a 'node-style' function and returns a function that
75
+ will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the
76
+ browser when you'd prefer to use promises over using callbacks. For example,
77
+ `denodeify` transforms the following:
78
+
79
+ ```javascript
80
+ var fs = require('fs');
81
+
82
+ fs.readFile('myfile.txt', function(err, data){
83
+ if (err) return handleError(err);
84
+ handleData(data);
85
+ });
86
+ ```
87
+
88
+ into:
89
+
90
+ ```javascript
91
+ var fs = require('fs');
92
+ var readFile = RSVP.denodeify(fs.readFile);
93
+
94
+ readFile('myfile.txt').then(handleData, handleError);
95
+ ```
96
+
97
+ If the node function has multiple success parameters, then `denodeify`
98
+ just returns the first one:
99
+
100
+ ```javascript
101
+ var request = RSVP.denodeify(require('request'));
102
+
103
+ request('http://example.com').then(function(res) {
104
+ // ...
105
+ });
106
+ ```
107
+
108
+ However, if you need all success parameters, setting `denodeify`'s
109
+ second parameter to `true` causes it to return all success parameters
110
+ as an array:
111
+
112
+ ```javascript
113
+ var request = RSVP.denodeify(require('request'), true);
114
+
115
+ request('http://example.com').then(function(result) {
116
+ // result[0] -> res
117
+ // result[1] -> body
118
+ });
119
+ ```
120
+
121
+ Or if you pass it an array with names it returns the parameters as a hash:
122
+
123
+ ```javascript
124
+ var request = RSVP.denodeify(require('request'), ['res', 'body']);
125
+
126
+ request('http://example.com').then(function(result) {
127
+ // result.res
128
+ // result.body
129
+ });
130
+ ```
131
+
132
+ Sometimes you need to retain the `this`:
133
+
134
+ ```javascript
135
+ var app = require('express')();
136
+ var render = RSVP.denodeify(app.render.bind(app));
137
+ ```
138
+
139
+ The denodified function inherits from the original function. It works in all
140
+ environments, except IE 10 and below. Consequently all properties of the original
141
+ function are available to you. However, any properties you change on the
142
+ denodeified function won't be changed on the original function. Example:
143
+
144
+ ```javascript
145
+ var request = RSVP.denodeify(require('request')),
146
+ cookieJar = request.jar(); // <- Inheritance is used here
147
+
148
+ request('http://example.com', {jar: cookieJar}).then(function(res) {
149
+ // cookieJar.cookies holds now the cookies returned by example.com
150
+ });
151
+ ```
152
+
153
+ Using `denodeify` makes it easier to compose asynchronous operations instead
154
+ of using callbacks. For example, instead of:
155
+
156
+ ```javascript
157
+ var fs = require('fs');
158
+
159
+ fs.readFile('myfile.txt', function(err, data){
160
+ if (err) { ... } // Handle error
161
+ fs.writeFile('myfile2.txt', data, function(err){
162
+ if (err) { ... } // Handle error
163
+ console.log('done')
164
+ });
165
+ });
166
+ ```
167
+
168
+ you can chain the operations together using `then` from the returned promise:
169
+
170
+ ```javascript
171
+ var fs = require('fs');
172
+ var readFile = RSVP.denodeify(fs.readFile);
173
+ var writeFile = RSVP.denodeify(fs.writeFile);
174
+
175
+ readFile('myfile.txt').then(function(data){
176
+ return writeFile('myfile2.txt', data);
177
+ }).then(function(){
178
+ console.log('done')
179
+ }).catch(function(error){
180
+ // Handle error
181
+ });
182
+ ```
183
+
184
+ @method denodeify
185
+ @static
186
+ @for RSVP
187
+ @param {Function} nodeFunc a 'node-style' function that takes a callback as
188
+ its last argument. The callback expects an error to be passed as its first
189
+ argument (if an error occurred, otherwise null), and the value from the
190
+ operation as its second argument ('function(err, value){ }').
191
+ @param {Boolean|Array} argumentNames An optional paramter that if set
192
+ to `true` causes the promise to fulfill with the callback's success arguments
193
+ as an array. This is useful if the node function has multiple success
194
+ paramters. If you set this paramter to an array with names, the promise will
195
+ fulfill with a hash with these names as keys and the success parameters as
196
+ values.
197
+ @return {Function} a function that wraps `nodeFunc` to return an
198
+ `RSVP.Promise`
199
+ @static
200
+ */
201
+ export default function denodeify(nodeFunc, options) {
202
+ var fn = function() {
203
+ var self = this;
204
+ var l = arguments.length;
205
+ var args = new Array(l + 1);
206
+ var arg;
207
+ var promiseInput = false;
208
+
209
+ for (var i = 0; i < l; ++i) {
210
+ arg = arguments[i];
211
+
212
+ if (!promiseInput) {
213
+ // TODO: clean this up
214
+ promiseInput = needsPromiseInput(arg);
215
+ if (promiseInput === GET_THEN_ERROR) {
216
+ var p = new Promise(noop);
217
+ reject(p, GET_THEN_ERROR.value);
218
+ return p;
219
+ } else if (promiseInput && promiseInput !== true) {
220
+ arg = wrapThenable(promiseInput, arg);
221
+ }
222
+ }
223
+ args[i] = arg;
224
+ }
225
+
226
+ var promise = new Promise(noop);
227
+
228
+ args[l] = function(err, val) {
229
+ if (err)
230
+ reject(promise, err);
231
+ else if (options === undefined)
232
+ resolve(promise, val);
233
+ else if (options === true)
234
+ resolve(promise, arrayResult(arguments));
235
+ else if (isArray(options))
236
+ resolve(promise, makeObject(arguments, options));
237
+ else
238
+ resolve(promise, val);
239
+ };
240
+
241
+ if (promiseInput) {
242
+ return handlePromiseInput(promise, args, nodeFunc, self);
243
+ } else {
244
+ return handleValueInput(promise, args, nodeFunc, self);
245
+ }
246
+ };
247
+
248
+ fn.__proto__ = nodeFunc;
249
+
250
+ return fn;
251
+ }
252
+
253
+ function handleValueInput(promise, args, nodeFunc, self) {
254
+ var result = tryApply(nodeFunc, self, args);
255
+ if (result === ERROR) {
256
+ reject(promise, result.value);
257
+ }
258
+ return promise;
259
+ }
260
+
261
+ function handlePromiseInput(promise, args, nodeFunc, self){
262
+ return Promise.all(args).then(function(args){
263
+ var result = tryApply(nodeFunc, self, args);
264
+ if (result === ERROR) {
265
+ reject(promise, result.value);
266
+ }
267
+ return promise;
268
+ });
269
+ }
270
+
271
+ function needsPromiseInput(arg) {
272
+ if (arg && typeof arg === 'object') {
273
+ if (arg.constructor === Promise) {
274
+ return true;
275
+ } else {
276
+ return getThen(arg);
277
+ }
278
+ } else {
279
+ return false;
280
+ }
281
+ }
@@ -0,0 +1,51 @@
1
+ import Enumerator from './enumerator';
2
+ import {
3
+ PENDING
4
+ } from './-internal';
5
+ import {
6
+ o_create
7
+ } from './utils';
8
+
9
+ function PromiseHash(Constructor, object, label) {
10
+ this._superConstructor(Constructor, object, true, label);
11
+ }
12
+
13
+ export default PromiseHash;
14
+
15
+ PromiseHash.prototype = o_create(Enumerator.prototype);
16
+ PromiseHash.prototype._superConstructor = Enumerator;
17
+ PromiseHash.prototype._init = function() {
18
+ this._result = {};
19
+ };
20
+
21
+ PromiseHash.prototype._validateInput = function(input) {
22
+ return input && typeof input === 'object';
23
+ };
24
+
25
+ PromiseHash.prototype._validationError = function() {
26
+ return new Error('Promise.hash must be called with an object');
27
+ };
28
+
29
+ PromiseHash.prototype._enumerate = function() {
30
+ var promise = this.promise;
31
+ var input = this._input;
32
+ var results = [];
33
+
34
+ for (var key in input) {
35
+ if (promise._state === PENDING && input.hasOwnProperty(key)) {
36
+ results.push({
37
+ position: key,
38
+ entry: input[key]
39
+ });
40
+ }
41
+ }
42
+
43
+ var length = results.length;
44
+ this._remaining = length;
45
+ var result;
46
+
47
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
48
+ result = results[i];
49
+ this._eachEntry(result.entry, result.position);
50
+ }
51
+ };
@@ -0,0 +1,496 @@
1
+ import { config } from './config';
2
+ import instrument from './instrument';
3
+
4
+ import {
5
+ isFunction,
6
+ now
7
+ } from './utils';
8
+
9
+ import {
10
+ noop,
11
+ subscribe,
12
+ initializePromise,
13
+ invokeCallback,
14
+ FULFILLED,
15
+ REJECTED
16
+ } from './-internal';
17
+
18
+ import all from './promise/all';
19
+ import race from './promise/race';
20
+ import Resolve from './promise/resolve';
21
+ import Reject from './promise/reject';
22
+
23
+ var guidKey = 'rsvp_' + now() + '-';
24
+ var counter = 0;
25
+
26
+ function needsResolver() {
27
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
28
+ }
29
+
30
+ function needsNew() {
31
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
32
+ }
33
+
34
+ /**
35
+ Promise objects represent the eventual result of an asynchronous operation. The
36
+ primary way of interacting with a promise is through its `then` method, which
37
+ registers callbacks to receive either a promise’s eventual value or the reason
38
+ why the promise cannot be fulfilled.
39
+
40
+ Terminology
41
+ -----------
42
+
43
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
44
+ - `thenable` is an object or function that defines a `then` method.
45
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
46
+ - `exception` is a value that is thrown using the throw statement.
47
+ - `reason` is a value that indicates why a promise was rejected.
48
+ - `settled` the final resting state of a promise, fulfilled or rejected.
49
+
50
+ A promise can be in one of three states: pending, fulfilled, or rejected.
51
+
52
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
53
+ state. Promises that are rejected have a rejection reason and are in the
54
+ rejected state. A fulfillment value is never a thenable.
55
+
56
+ Promises can also be said to *resolve* a value. If this value is also a
57
+ promise, then the original promise's settled state will match the value's
58
+ settled state. So a promise that *resolves* a promise that rejects will
59
+ itself reject, and a promise that *resolves* a promise that fulfills will
60
+ itself fulfill.
61
+
62
+
63
+ Basic Usage:
64
+ ------------
65
+
66
+ ```js
67
+ var promise = new Promise(function(resolve, reject) {
68
+ // on success
69
+ resolve(value);
70
+
71
+ // on failure
72
+ reject(reason);
73
+ });
74
+
75
+ promise.then(function(value) {
76
+ // on fulfillment
77
+ }, function(reason) {
78
+ // on rejection
79
+ });
80
+ ```
81
+
82
+ Advanced Usage:
83
+ ---------------
84
+
85
+ Promises shine when abstracting away asynchronous interactions such as
86
+ `XMLHttpRequest`s.
87
+
88
+ ```js
89
+ function getJSON(url) {
90
+ return new Promise(function(resolve, reject){
91
+ var xhr = new XMLHttpRequest();
92
+
93
+ xhr.open('GET', url);
94
+ xhr.onreadystatechange = handler;
95
+ xhr.responseType = 'json';
96
+ xhr.setRequestHeader('Accept', 'application/json');
97
+ xhr.send();
98
+
99
+ function handler() {
100
+ if (this.readyState === this.DONE) {
101
+ if (this.status === 200) {
102
+ resolve(this.response);
103
+ } else {
104
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
105
+ }
106
+ }
107
+ };
108
+ });
109
+ }
110
+
111
+ getJSON('/posts.json').then(function(json) {
112
+ // on fulfillment
113
+ }, function(reason) {
114
+ // on rejection
115
+ });
116
+ ```
117
+
118
+ Unlike callbacks, promises are great composable primitives.
119
+
120
+ ```js
121
+ Promise.all([
122
+ getJSON('/posts'),
123
+ getJSON('/comments')
124
+ ]).then(function(values){
125
+ values[0] // => postsJSON
126
+ values[1] // => commentsJSON
127
+
128
+ return values;
129
+ });
130
+ ```
131
+
132
+ @class RSVP.Promise
133
+ @param {function} resolver
134
+ @param {String} label optional string for labeling the promise.
135
+ Useful for tooling.
136
+ @constructor
137
+ */
138
+ function Promise(resolver, label) {
139
+ this._id = counter++;
140
+ this._label = label;
141
+ this._state = undefined;
142
+ this._result = undefined;
143
+ this._subscribers = [];
144
+
145
+ if (config.instrument) {
146
+ instrument('created', this);
147
+ }
148
+
149
+ if (noop !== resolver) {
150
+ if (!isFunction(resolver)) {
151
+ needsResolver();
152
+ }
153
+
154
+ if (!(this instanceof Promise)) {
155
+ needsNew();
156
+ }
157
+
158
+ initializePromise(this, resolver);
159
+ }
160
+ }
161
+
162
+ export default Promise;
163
+
164
+ Promise.cast = Resolve; // deprecated
165
+ Promise.all = all;
166
+ Promise.race = race;
167
+ Promise.resolve = Resolve;
168
+ Promise.reject = Reject;
169
+
170
+ Promise.prototype = {
171
+ constructor: Promise,
172
+
173
+ _guidKey: guidKey,
174
+
175
+ _onError: function (reason) {
176
+ config.async(function(promise) {
177
+ setTimeout(function() {
178
+ if (promise._onError) {
179
+ config['trigger']('error', reason);
180
+ }
181
+ }, 0);
182
+ }, this);
183
+ },
184
+
185
+ /**
186
+ The primary way of interacting with a promise is through its `then` method,
187
+ which registers callbacks to receive either a promise's eventual value or the
188
+ reason why the promise cannot be fulfilled.
189
+
190
+ ```js
191
+ findUser().then(function(user){
192
+ // user is available
193
+ }, function(reason){
194
+ // user is unavailable, and you are given the reason why
195
+ });
196
+ ```
197
+
198
+ Chaining
199
+ --------
200
+
201
+ The return value of `then` is itself a promise. This second, 'downstream'
202
+ promise is resolved with the return value of the first promise's fulfillment
203
+ or rejection handler, or rejected if the handler throws an exception.
204
+
205
+ ```js
206
+ findUser().then(function (user) {
207
+ return user.name;
208
+ }, function (reason) {
209
+ return 'default name';
210
+ }).then(function (userName) {
211
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
212
+ // will be `'default name'`
213
+ });
214
+
215
+ findUser().then(function (user) {
216
+ throw new Error('Found user, but still unhappy');
217
+ }, function (reason) {
218
+ throw new Error('`findUser` rejected and we're unhappy');
219
+ }).then(function (value) {
220
+ // never reached
221
+ }, function (reason) {
222
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
223
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
224
+ });
225
+ ```
226
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
227
+
228
+ ```js
229
+ findUser().then(function (user) {
230
+ throw new PedagogicalException('Upstream error');
231
+ }).then(function (value) {
232
+ // never reached
233
+ }).then(function (value) {
234
+ // never reached
235
+ }, function (reason) {
236
+ // The `PedgagocialException` is propagated all the way down to here
237
+ });
238
+ ```
239
+
240
+ Assimilation
241
+ ------------
242
+
243
+ Sometimes the value you want to propagate to a downstream promise can only be
244
+ retrieved asynchronously. This can be achieved by returning a promise in the
245
+ fulfillment or rejection handler. The downstream promise will then be pending
246
+ until the returned promise is settled. This is called *assimilation*.
247
+
248
+ ```js
249
+ findUser().then(function (user) {
250
+ return findCommentsByAuthor(user);
251
+ }).then(function (comments) {
252
+ // The user's comments are now available
253
+ });
254
+ ```
255
+
256
+ If the assimliated promise rejects, then the downstream promise will also reject.
257
+
258
+ ```js
259
+ findUser().then(function (user) {
260
+ return findCommentsByAuthor(user);
261
+ }).then(function (comments) {
262
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
263
+ }, function (reason) {
264
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
265
+ });
266
+ ```
267
+
268
+ Simple Example
269
+ --------------
270
+
271
+ Synchronous Example
272
+
273
+ ```javascript
274
+ var result;
275
+
276
+ try {
277
+ result = findResult();
278
+ // success
279
+ } catch(reason) {
280
+ // failure
281
+ }
282
+ ```
283
+
284
+ Errback Example
285
+
286
+ ```js
287
+ findResult(function(result, err){
288
+ if (err) {
289
+ // failure
290
+ } else {
291
+ // success
292
+ }
293
+ });
294
+ ```
295
+
296
+ Promise Example;
297
+
298
+ ```javascript
299
+ findResult().then(function(result){
300
+ // success
301
+ }, function(reason){
302
+ // failure
303
+ });
304
+ ```
305
+
306
+ Advanced Example
307
+ --------------
308
+
309
+ Synchronous Example
310
+
311
+ ```javascript
312
+ var author, books;
313
+
314
+ try {
315
+ author = findAuthor();
316
+ books = findBooksByAuthor(author);
317
+ // success
318
+ } catch(reason) {
319
+ // failure
320
+ }
321
+ ```
322
+
323
+ Errback Example
324
+
325
+ ```js
326
+
327
+ function foundBooks(books) {
328
+
329
+ }
330
+
331
+ function failure(reason) {
332
+
333
+ }
334
+
335
+ findAuthor(function(author, err){
336
+ if (err) {
337
+ failure(err);
338
+ // failure
339
+ } else {
340
+ try {
341
+ findBoooksByAuthor(author, function(books, err) {
342
+ if (err) {
343
+ failure(err);
344
+ } else {
345
+ try {
346
+ foundBooks(books);
347
+ } catch(reason) {
348
+ failure(reason);
349
+ }
350
+ }
351
+ });
352
+ } catch(error) {
353
+ failure(err);
354
+ }
355
+ // success
356
+ }
357
+ });
358
+ ```
359
+
360
+ Promise Example;
361
+
362
+ ```javascript
363
+ findAuthor().
364
+ then(findBooksByAuthor).
365
+ then(function(books){
366
+ // found books
367
+ }).catch(function(reason){
368
+ // something went wrong
369
+ });
370
+ ```
371
+
372
+ @method then
373
+ @param {Function} onFulfilled
374
+ @param {Function} onRejected
375
+ @param {String} label optional string for labeling the promise.
376
+ Useful for tooling.
377
+ @return {Promise}
378
+ */
379
+ then: function(onFulfillment, onRejection, label) {
380
+ var parent = this;
381
+ var state = parent._state;
382
+
383
+ if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
384
+ if (config.instrument) {
385
+ instrument('chained', this, this);
386
+ }
387
+ return this;
388
+ }
389
+
390
+ parent._onError = null;
391
+
392
+ var child = new this.constructor(noop, label);
393
+ var result = parent._result;
394
+
395
+ if (config.instrument) {
396
+ instrument('chained', parent, child);
397
+ }
398
+
399
+ if (state) {
400
+ var callback = arguments[state - 1];
401
+ config.async(function(){
402
+ invokeCallback(state, child, callback, result);
403
+ });
404
+ } else {
405
+ subscribe(parent, child, onFulfillment, onRejection);
406
+ }
407
+
408
+ return child;
409
+ },
410
+
411
+ /**
412
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
413
+ as the catch block of a try/catch statement.
414
+
415
+ ```js
416
+ function findAuthor(){
417
+ throw new Error('couldn't find that author');
418
+ }
419
+
420
+ // synchronous
421
+ try {
422
+ findAuthor();
423
+ } catch(reason) {
424
+ // something went wrong
425
+ }
426
+
427
+ // async with promises
428
+ findAuthor().catch(function(reason){
429
+ // something went wrong
430
+ });
431
+ ```
432
+
433
+ @method catch
434
+ @param {Function} onRejection
435
+ @param {String} label optional string for labeling the promise.
436
+ Useful for tooling.
437
+ @return {Promise}
438
+ */
439
+ 'catch': function(onRejection, label) {
440
+ return this.then(null, onRejection, label);
441
+ },
442
+
443
+ /**
444
+ `finally` will be invoked regardless of the promise's fate just as native
445
+ try/catch/finally behaves
446
+
447
+ Synchronous example:
448
+
449
+ ```js
450
+ findAuthor() {
451
+ if (Math.random() > 0.5) {
452
+ throw new Error();
453
+ }
454
+ return new Author();
455
+ }
456
+
457
+ try {
458
+ return findAuthor(); // succeed or fail
459
+ } catch(error) {
460
+ return findOtherAuther();
461
+ } finally {
462
+ // always runs
463
+ // doesn't affect the return value
464
+ }
465
+ ```
466
+
467
+ Asynchronous example:
468
+
469
+ ```js
470
+ findAuthor().catch(function(reason){
471
+ return findOtherAuther();
472
+ }).finally(function(){
473
+ // author was either found, or not
474
+ });
475
+ ```
476
+
477
+ @method finally
478
+ @param {Function} callback
479
+ @param {String} label optional string for labeling the promise.
480
+ Useful for tooling.
481
+ @return {Promise}
482
+ */
483
+ 'finally': function(callback, label) {
484
+ var constructor = this.constructor;
485
+
486
+ return this.then(function(value) {
487
+ return constructor.resolve(callback()).then(function(){
488
+ return value;
489
+ });
490
+ }, function(reason) {
491
+ return constructor.resolve(callback()).then(function(){
492
+ throw reason;
493
+ });
494
+ }, label);
495
+ }
496
+ };